CpsG.thy
author zhangx
Tue, 09 Feb 2016 22:30:43 +0800
changeset 114 81c6ede5cd11
parent 112 b3795b1f030b
child 127 38c6acf03f68
permissions -rw-r--r--
More refinements in PIPBasics.thy.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
109
4e59c0ce1511 wq_in_inv and wq_out_inv are removed, a number of loop holes need to be filled.
zhangx
parents: 105
diff changeset
     1
theory CpsG
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
     2
imports PIPDefs
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
     3
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
     4
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
     5
section {* Generic aulxiliary lemmas *}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
     6
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
     7
lemma f_image_eq:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
     8
  assumes h: "\<And> a. a \<in> A \<Longrightarrow> f a = g a"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
     9
  shows "f ` A = g ` A"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    10
proof
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    11
  show "f ` A \<subseteq> g ` A"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    12
    by(rule image_subsetI, auto intro:h)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    13
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    14
  show "g ` A \<subseteq> f ` A"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    15
   by (rule image_subsetI, auto intro:h[symmetric])
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    16
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    17
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    18
lemma Max_fg_mono:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    19
  assumes "finite A"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    20
  and "\<forall> a \<in> A. f a \<le> g a"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    21
  shows "Max (f ` A) \<le> Max (g ` A)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    22
proof(cases "A = {}")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    23
  case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    24
  thus ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    25
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    26
  case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    27
  show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    28
  proof(rule Max.boundedI)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    29
    from assms show "finite (f ` A)" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    30
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    31
    from False show "f ` A \<noteq> {}" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    32
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    33
    fix fa
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    34
    assume "fa \<in> f ` A"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    35
    then obtain a where h_fa: "a \<in> A" "fa = f a" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    36
    show "fa \<le> Max (g ` A)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    37
    proof(rule Max_ge_iff[THEN iffD2])
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    38
      from assms show "finite (g ` A)" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    39
    next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    40
      from False show "g ` A \<noteq> {}" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    41
    next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    42
      from h_fa have "g a \<in> g ` A" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    43
      moreover have "fa \<le> g a" using h_fa assms(2) by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    44
      ultimately show "\<exists>a\<in>g ` A. fa \<le> a" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    45
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    46
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    47
qed 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    48
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    49
lemma Max_f_mono:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    50
  assumes seq: "A \<subseteq> B"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    51
  and np: "A \<noteq> {}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    52
  and fnt: "finite B"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    53
  shows "Max (f ` A) \<le> Max (f ` B)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    54
proof(rule Max_mono)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    55
  from seq show "f ` A \<subseteq> f ` B" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    56
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    57
  from np show "f ` A \<noteq> {}" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    58
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    59
  from fnt and seq show "finite (f ` B)" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    60
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    61
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    62
lemma Max_UNION: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    63
  assumes "finite A"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    64
  and "A \<noteq> {}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    65
  and "\<forall> M \<in> f ` A. finite M"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    66
  and "\<forall> M \<in> f ` A. M \<noteq> {}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    67
  shows "Max (\<Union>x\<in> A. f x) = Max (Max ` f ` A)" (is "?L = ?R")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    68
  using assms[simp]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    69
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    70
  have "?L = Max (\<Union>(f ` A))"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    71
    by (fold Union_image_eq, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    72
  also have "... = ?R"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    73
    by (subst Max_Union, simp+)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    74
  finally show ?thesis .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    75
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    76
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    77
lemma max_Max_eq:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    78
  assumes "finite A"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    79
    and "A \<noteq> {}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    80
    and "x = y"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    81
  shows "max x (Max A) = Max ({y} \<union> A)" (is "?L = ?R")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    82
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    83
  have "?R = Max (insert y A)" by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    84
  also from assms have "... = ?L"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    85
      by (subst Max.insert, simp+)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    86
  finally show ?thesis by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    87
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
    88
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
    89
lemma rel_eqI:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
    90
  assumes "\<And> x y. (x,y) \<in> A \<Longrightarrow> (x,y) \<in> B"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
    91
  and "\<And> x y. (x,y) \<in> B \<Longrightarrow> (x, y) \<in> A"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
    92
  shows "A = B"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
    93
  using assms by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
    94
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
    95
section {* Lemmas do not depend on trace validity *}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
    96
90
ed938e2246b9 Retrofiting of:
zhangx
parents: 84
diff changeset
    97
lemma birth_time_lt:  
ed938e2246b9 Retrofiting of:
zhangx
parents: 84
diff changeset
    98
  assumes "s \<noteq> []"
ed938e2246b9 Retrofiting of:
zhangx
parents: 84
diff changeset
    99
  shows "last_set th s < length s"
ed938e2246b9 Retrofiting of:
zhangx
parents: 84
diff changeset
   100
  using assms
ed938e2246b9 Retrofiting of:
zhangx
parents: 84
diff changeset
   101
proof(induct s)
ed938e2246b9 Retrofiting of:
zhangx
parents: 84
diff changeset
   102
  case (Cons a s)
ed938e2246b9 Retrofiting of:
zhangx
parents: 84
diff changeset
   103
  show ?case
ed938e2246b9 Retrofiting of:
zhangx
parents: 84
diff changeset
   104
  proof(cases "s \<noteq> []")
ed938e2246b9 Retrofiting of:
zhangx
parents: 84
diff changeset
   105
    case False
ed938e2246b9 Retrofiting of:
zhangx
parents: 84
diff changeset
   106
    thus ?thesis
ed938e2246b9 Retrofiting of:
zhangx
parents: 84
diff changeset
   107
      by (cases a, auto)
ed938e2246b9 Retrofiting of:
zhangx
parents: 84
diff changeset
   108
  next
ed938e2246b9 Retrofiting of:
zhangx
parents: 84
diff changeset
   109
    case True
ed938e2246b9 Retrofiting of:
zhangx
parents: 84
diff changeset
   110
    show ?thesis using Cons(1)[OF True]
ed938e2246b9 Retrofiting of:
zhangx
parents: 84
diff changeset
   111
      by (cases a, auto)
ed938e2246b9 Retrofiting of:
zhangx
parents: 84
diff changeset
   112
  qed
ed938e2246b9 Retrofiting of:
zhangx
parents: 84
diff changeset
   113
qed simp
ed938e2246b9 Retrofiting of:
zhangx
parents: 84
diff changeset
   114
ed938e2246b9 Retrofiting of:
zhangx
parents: 84
diff changeset
   115
lemma th_in_ne: "th \<in> threads s \<Longrightarrow> s \<noteq> []"
ed938e2246b9 Retrofiting of:
zhangx
parents: 84
diff changeset
   116
  by (induct s, auto)
ed938e2246b9 Retrofiting of:
zhangx
parents: 84
diff changeset
   117
ed938e2246b9 Retrofiting of:
zhangx
parents: 84
diff changeset
   118
lemma preced_tm_lt: "th \<in> threads s \<Longrightarrow> preced th s = Prc x y \<Longrightarrow> y < length s"
ed938e2246b9 Retrofiting of:
zhangx
parents: 84
diff changeset
   119
  by (drule_tac th_in_ne, unfold preced_def, auto intro: birth_time_lt)
ed938e2246b9 Retrofiting of:
zhangx
parents: 84
diff changeset
   120
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   121
lemma eq_RAG: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   122
  "RAG (wq s) = RAG s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   123
  by (unfold cs_RAG_def s_RAG_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   124
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   125
lemma waiting_holding:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   126
  assumes "waiting (s::state) th cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   127
  obtains th' where "holding s th' cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   128
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   129
  from assms[unfolded s_waiting_def, folded wq_def]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   130
  obtain th' where "th' \<in> set (wq s cs)" "th' = hd (wq s cs)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   131
    by (metis empty_iff hd_in_set list.set(1))
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   132
  hence "holding s th' cs" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   133
    by (unfold s_holding_def, fold wq_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   134
  from that[OF this] show ?thesis .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   135
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   136
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   137
lemma cp_eq_cpreced: "cp s th = cpreced (wq s) s th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   138
unfolding cp_def wq_def
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   139
apply(induct s rule: schs.induct)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   140
apply(simp add: Let_def cpreced_initial)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   141
apply(simp add: Let_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   142
apply(simp add: Let_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   143
apply(simp add: Let_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   144
apply(subst (2) schs.simps)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   145
apply(simp add: Let_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   146
apply(subst (2) schs.simps)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   147
apply(simp add: Let_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   148
done
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   149
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   150
lemma cp_alt_def:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   151
  "cp s th =  
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   152
           Max ((the_preced s) ` {th'. Th th' \<in> (subtree (RAG s) (Th th))})"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   153
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   154
  have "Max (the_preced s ` ({th} \<union> dependants (wq s) th)) =
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   155
        Max (the_preced s ` {th'. Th th' \<in> subtree (RAG s) (Th th)})" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   156
          (is "Max (_ ` ?L) = Max (_ ` ?R)")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   157
  proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   158
    have "?L = ?R" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   159
    by (auto dest:rtranclD simp:cs_dependants_def cs_RAG_def s_RAG_def subtree_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   160
    thus ?thesis by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   161
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   162
  thus ?thesis by (unfold cp_eq_cpreced cpreced_def, fold the_preced_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   163
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   164
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   165
lemma RAG_target_th: "(Th th, x) \<in> RAG (s::state) \<Longrightarrow> \<exists> cs. x = Cs cs"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   166
  by (unfold s_RAG_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   167
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   168
lemma waiting_eq: "waiting s th cs = waiting (wq s) th cs"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   169
  by  (unfold s_waiting_def cs_waiting_def wq_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   170
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   171
lemma holding_eq: "holding (s::state) th cs = holding (wq s) th cs"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   172
  by (unfold s_holding_def wq_def cs_holding_def, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   173
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   174
lemma children_RAG_alt_def:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   175
  "children (RAG (s::state)) (Th th) = Cs ` {cs. holding s th cs}"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   176
  by (unfold s_RAG_def, auto simp:children_def holding_eq)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   177
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   178
lemma holdents_alt_def:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   179
  "holdents s th = the_cs ` (children (RAG (s::state)) (Th th))"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   180
  by (unfold children_RAG_alt_def holdents_def, simp add: image_image)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   181
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   182
lemma cntCS_alt_def:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   183
  "cntCS s th = card (children (RAG s) (Th th))"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   184
  apply (unfold children_RAG_alt_def cntCS_def holdents_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   185
  by (rule card_image[symmetric], auto simp:inj_on_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   186
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   187
lemma runing_ready: 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   188
  shows "runing s \<subseteq> readys s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   189
  unfolding runing_def readys_def
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   190
  by auto 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   191
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   192
lemma readys_threads:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   193
  shows "readys s \<subseteq> threads s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   194
  unfolding readys_def
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   195
  by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   196
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   197
lemma wq_v_neq [simp]:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   198
   "cs \<noteq> cs' \<Longrightarrow> wq (V thread cs#s) cs' = wq s cs'"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   199
  by (auto simp:wq_def Let_def cp_def split:list.splits)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   200
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   201
lemma runing_head:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   202
  assumes "th \<in> runing s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   203
  and "th \<in> set (wq_fun (schs s) cs)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   204
  shows "th = hd (wq_fun (schs s) cs)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   205
  using assms
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   206
  by (simp add:runing_def readys_def s_waiting_def wq_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   207
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   208
lemma runing_wqE:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   209
  assumes "th \<in> runing s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   210
  and "th \<in> set (wq s cs)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   211
  obtains rest where "wq s cs = th#rest"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   212
proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   213
  from assms(2) obtain th' rest where eq_wq: "wq s cs = th'#rest"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   214
    by (meson list.set_cases)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   215
  have "th' = th"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   216
  proof(rule ccontr)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   217
    assume "th' \<noteq> th"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   218
    hence "th \<noteq> hd (wq s cs)" using eq_wq by auto 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   219
    with assms(2)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   220
    have "waiting s th cs" 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   221
      by (unfold s_waiting_def, fold wq_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   222
    with assms show False 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   223
      by (unfold runing_def readys_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   224
  qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   225
  with eq_wq that show ?thesis by metis
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   226
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   227
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   228
lemma isP_E:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   229
  assumes "isP e"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   230
  obtains cs where "e = P (actor e) cs"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   231
  using assms by (cases e, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   232
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   233
lemma isV_E:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   234
  assumes "isV e"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   235
  obtains cs where "e = V (actor e) cs"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   236
  using assms by (cases e, auto) 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   237
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   238
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   239
text {*
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   240
  Every thread can only be blocked on one critical resource, 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   241
  symmetrically, every critical resource can only be held by one thread. 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   242
  This fact is much more easier according to our definition. 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   243
*}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   244
lemma held_unique:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   245
  assumes "holding (s::event list) th1 cs"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   246
  and "holding s th2 cs"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   247
  shows "th1 = th2"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   248
 by (insert assms, unfold s_holding_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   249
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   250
lemma last_set_lt: "th \<in> threads s \<Longrightarrow> last_set th s < length s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   251
  apply (induct s, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   252
  by (case_tac a, auto split:if_splits)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   253
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   254
lemma last_set_unique: 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   255
  "\<lbrakk>last_set th1 s = last_set th2 s; th1 \<in> threads s; th2 \<in> threads s\<rbrakk>
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   256
          \<Longrightarrow> th1 = th2"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   257
  apply (induct s, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   258
  by (case_tac a, auto split:if_splits dest:last_set_lt)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   259
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   260
lemma preced_unique : 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   261
  assumes pcd_eq: "preced th1 s = preced th2 s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   262
  and th_in1: "th1 \<in> threads s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   263
  and th_in2: " th2 \<in> threads s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   264
  shows "th1 = th2"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   265
proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   266
  from pcd_eq have "last_set th1 s = last_set th2 s" by (simp add:preced_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   267
  from last_set_unique [OF this th_in1 th_in2]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   268
  show ?thesis .
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   269
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   270
                      
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   271
lemma preced_linorder: 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   272
  assumes neq_12: "th1 \<noteq> th2"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   273
  and th_in1: "th1 \<in> threads s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   274
  and th_in2: " th2 \<in> threads s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   275
  shows "preced th1 s < preced th2 s \<or> preced th1 s > preced th2 s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   276
proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   277
  from preced_unique [OF _ th_in1 th_in2] and neq_12 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   278
  have "preced th1 s \<noteq> preced th2 s" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   279
  thus ?thesis by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   280
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   281
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   282
lemma in_RAG_E:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   283
  assumes "(n1, n2) \<in> RAG (s::state)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   284
  obtains (waiting) th cs where "n1 = Th th" "n2 = Cs cs" "waiting s th cs"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   285
      | (holding) th cs where "n1 = Cs cs" "n2 = Th th" "holding s th cs"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   286
  using assms[unfolded s_RAG_def, folded waiting_eq holding_eq]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   287
  by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   288
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   289
lemma count_rec1 [simp]: 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   290
  assumes "Q e"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   291
  shows "count Q (e#es) = Suc (count Q es)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   292
  using assms
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   293
  by (unfold count_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   294
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   295
lemma count_rec2 [simp]: 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   296
  assumes "\<not>Q e"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   297
  shows "count Q (e#es) = (count Q es)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   298
  using assms
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   299
  by (unfold count_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   300
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   301
lemma count_rec3 [simp]: 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   302
  shows "count Q [] =  0"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   303
  by (unfold count_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   304
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   305
lemma cntP_simp1[simp]:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   306
  "cntP (P th cs'#s) th = cntP s th + 1"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   307
  by (unfold cntP_def, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   308
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   309
lemma cntP_simp2[simp]:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   310
  assumes "th' \<noteq> th"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   311
  shows "cntP (P th cs'#s) th' = cntP s th'"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   312
  using assms
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   313
  by (unfold cntP_def, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   314
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   315
lemma cntP_simp3[simp]:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   316
  assumes "\<not> isP e"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   317
  shows "cntP (e#s) th' = cntP s th'"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   318
  using assms
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   319
  by (unfold cntP_def, cases e, simp+)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   320
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   321
lemma cntV_simp1[simp]:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   322
  "cntV (V th cs'#s) th = cntV s th + 1"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   323
  by (unfold cntV_def, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   324
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   325
lemma cntV_simp2[simp]:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   326
  assumes "th' \<noteq> th"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   327
  shows "cntV (V th cs'#s) th' = cntV s th'"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   328
  using assms
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   329
  by (unfold cntV_def, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   330
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   331
lemma cntV_simp3[simp]:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   332
  assumes "\<not> isV e"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   333
  shows "cntV (e#s) th' = cntV s th'"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   334
  using assms
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   335
  by (unfold cntV_def, cases e, simp+)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   336
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   337
lemma cntP_diff_inv:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   338
  assumes "cntP (e#s) th \<noteq> cntP s th"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   339
  shows "isP e \<and> actor e = th"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   340
proof(cases e)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   341
  case (P th' pty)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   342
  show ?thesis
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   343
  by (cases "(\<lambda>e. \<exists>cs. e = P th cs) (P th' pty)", 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   344
        insert assms P, auto simp:cntP_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   345
qed (insert assms, auto simp:cntP_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   346
  
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   347
lemma cntV_diff_inv:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   348
  assumes "cntV (e#s) th \<noteq> cntV s th"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   349
  shows "isV e \<and> actor e = th"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   350
proof(cases e)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   351
  case (V th' pty)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   352
  show ?thesis
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   353
  by (cases "(\<lambda>e. \<exists>cs. e = V th cs) (V th' pty)", 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   354
        insert assms V, auto simp:cntV_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   355
qed (insert assms, auto simp:cntV_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   356
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   357
lemma eq_dependants: "dependants (wq s) = dependants s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   358
  by (simp add: s_dependants_abv wq_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   359
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   360
lemma inj_the_preced: 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   361
  "inj_on (the_preced s) (threads s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   362
  by (metis inj_onI preced_unique the_preced_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   363
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   364
lemma holding_next_thI:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   365
  assumes "holding s th cs"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   366
  and "length (wq s cs) > 1"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   367
  obtains th' where "next_th s th cs th'"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   368
proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   369
  from assms(1)[folded holding_eq, unfolded cs_holding_def]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   370
  have " th \<in> set (wq s cs) \<and> th = hd (wq s cs)" 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   371
    by (unfold s_holding_def, fold wq_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   372
  then obtain rest where h1: "wq s cs = th#rest" 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   373
    by (cases "wq s cs", auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   374
  with assms(2) have h2: "rest \<noteq> []" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   375
  let ?th' = "hd (SOME q. distinct q \<and> set q = set rest)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   376
  have "next_th s th cs ?th'" using  h1(1) h2 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   377
    by (unfold next_th_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   378
  from that[OF this] show ?thesis .
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   379
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   380
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   381
(* ccc *)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   382
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   383
section {* Locales used to investigate the execution of PIP *}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   384
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   385
text {* 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   386
  The following locale @{text valid_trace} is used to constrain the 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   387
  trace to be valid. All properties hold for valid traces are 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   388
  derived under this locale. 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   389
*}
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   390
locale valid_trace = 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   391
  fixes s
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   392
  assumes vt : "vt s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   393
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   394
text {* 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   395
  The following locale @{text valid_trace_e} describes 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   396
  the valid extension of a valid trace. The event @{text "e"}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   397
  represents an event in the system, which corresponds 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   398
  to a one step operation of the PIP protocol. 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   399
  It is required that @{text "e"} is an event eligible to happen
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   400
  under state @{text "s"}, which is already required to be valid
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   401
  by the parent locale @{text "valid_trace"}.
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   402
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   403
  This locale is used to investigate one step execution of PIP, 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   404
  properties concerning the effects of @{text "e"}'s execution, 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   405
  for example, how the values of observation functions are changed, 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   406
  or how desirable properties are kept invariant, are derived
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   407
  under this locale. The state before execution is @{text "s"}, while
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   408
  the state after execution is @{text "e#s"}. Therefore, the lemmas 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   409
  derived usually relate observations on @{text "e#s"} to those 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   410
  on @{text "s"}.
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   411
*}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   412
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   413
locale valid_trace_e = valid_trace +
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   414
  fixes e
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   415
  assumes vt_e: "vt (e#s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   416
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   417
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   418
text {*
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   419
  The following lemma shows that @{text "e"} must be a 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   420
  eligible event (or a valid step) to be taken under
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   421
  the state represented by @{text "s"}.
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   422
*}
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   423
lemma pip_e: "PIP s e"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   424
  using vt_e by (cases, simp)  
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   425
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   426
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   427
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   428
text {*
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   429
  Because @{term "e#s"} is also a valid trace, properties 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   430
  derived for valid trace @{term s} also hold on @{term "e#s"}.
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   431
*}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   432
sublocale valid_trace_e < vat_es!: valid_trace "e#s" 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   433
  using vt_e
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   434
  by (unfold_locales, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   435
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   436
text {*
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   437
  For each specific event (or operation), there is a sublocale
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   438
  further constraining that the event @{text e} to be that 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   439
  particular event. 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   440
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   441
  For example, the following 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   442
  locale @{text "valid_trace_create"} is the sublocale for 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   443
  event @{term "Create"}:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   444
*}
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   445
locale valid_trace_create = valid_trace_e + 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   446
  fixes th prio
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   447
  assumes is_create: "e = Create th prio"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   448
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   449
locale valid_trace_exit = valid_trace_e + 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   450
  fixes th
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   451
  assumes is_exit: "e = Exit th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   452
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   453
locale valid_trace_p = valid_trace_e + 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   454
  fixes th cs
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   455
  assumes is_p: "e = P th cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   456
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   457
text {*
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   458
  locale @{text "valid_trace_p"} is divided further into two 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   459
  sublocales, namely, @{text "valid_trace_p_h"} 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   460
  and @{text "valid_trace_p_w"}.
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   461
*}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   462
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   463
text {*
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   464
  The following two sublocales @{text "valid_trace_p_h"}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   465
  and @{text "valid_trace_p_w"} represent two complementary 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   466
  cases under @{text "valid_trace_p"}, where
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   467
  @{text "valid_trace_p_h"} further constraints that
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   468
  @{text "wq s cs = []"}, which means the waiting queue of 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   469
  the requested resource @{text "cs"} is empty, in which
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   470
  case,  the requesting thread @{text "th"} 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   471
  will take hold of @{text "cs"}. 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   472
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   473
  Opposite to @{text "valid_trace_p_h"},
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   474
  @{text "valid_trace_p_w"} constraints that
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   475
  @{text "wq s cs \<noteq> []"}, which means the waiting queue of 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   476
  the requested resource @{text "cs"} is nonempty, in which
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   477
  case,  the requesting thread @{text "th"} will be blocked
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   478
  on @{text "cs"}: 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   479
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   480
  Peculiar properties will be derived under respective 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   481
  locales.
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   482
*}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   483
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   484
locale valid_trace_p_h = valid_trace_p +
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   485
  assumes we: "wq s cs = []"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   486
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   487
locale valid_trace_p_w = valid_trace_p +
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   488
  assumes wne: "wq s cs \<noteq> []"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   489
begin
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   490
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   491
text {*
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   492
  The following @{text "holder"} designates
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   493
  the holder of @{text "cs"} before the @{text "P"}-operation.
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   494
*}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   495
definition "holder = hd (wq s cs)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   496
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   497
text {*
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   498
  The following @{text "waiters"} designates
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   499
  the list of threads waiting for @{text "cs"} 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   500
  before the @{text "P"}-operation.
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   501
*}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   502
definition "waiters = tl (wq s cs)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   503
end
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   504
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   505
text {* 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   506
  @{text "valid_trace_v"} is set for the @{term V}-operation.
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   507
*}
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   508
locale valid_trace_v = valid_trace_e + 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   509
  fixes th cs
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   510
  assumes is_v: "e = V th cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   511
begin
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   512
  -- {* The following @{text "rest"} is the tail of 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   513
        waiting queue of the resource @{text "cs"}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   514
        to be released by this @{text "V"}-operation.
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   515
     *}
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   516
  definition "rest = tl (wq s cs)"
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   517
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   518
  text {*
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   519
    The following @{text "wq'"} is the waiting
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   520
    queue of @{term "cs"}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   521
    after the @{text "V"}-operation, which
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   522
    is simply a reordering of @{term "rest"}. 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   523
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   524
    The effect of this reordering needs to be 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   525
    understood by two cases:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   526
    \begin{enumerate}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   527
    \item When @{text "rest = []"},
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   528
    the reordering gives rise to an empty list as well, 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   529
    which means there is no thread holding or waiting 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   530
    for resource @{term "cs"}, therefore, it is free.
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   531
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   532
    \item When @{text "rest \<noteq> []"}, the effect of 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   533
    this reordering is to arbitrarily 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   534
    switch one thread in @{term "rest"} to the 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   535
    head, which, by definition take over the hold
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   536
    of @{term "cs"} and is designated by @{text "taker"}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   537
    in the following sublocale @{text "valid_trace_v_n"}.
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   538
  *}
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   539
  definition "wq' = (SOME q. distinct q \<and> set q = set rest)"
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   540
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   541
  text {* 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   542
  The following @{text "rest'"} is the tail of the 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   543
  waiting queue after the @{text "V"}-operation. 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   544
  It plays only auxiliary role to ease reasoning. 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   545
  *}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   546
  definition "rest' = tl wq'"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   547
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   548
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   549
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   550
text {* 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   551
  In the following, @{text "valid_trace_v"} is also 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   552
  divided into two 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   553
  sublocales: when @{text "rest"} is empty (represented
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   554
  by @{text "valid_trace_v_e"}), which means, there is no thread waiting 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   555
  for @{text "cs"}, therefore, after the @{text "V"}-operation, 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   556
  it will become free; otherwise (represented 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   557
  by @{text "valid_trace_v_n"}), one thread 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   558
  will be picked from those in @{text "rest"} to take 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   559
  over @{text "cs"}.
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   560
*}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   561
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   562
locale valid_trace_v_e = valid_trace_v +
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   563
  assumes rest_nil: "rest = []"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   564
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   565
locale valid_trace_v_n = valid_trace_v +
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   566
  assumes rest_nnl: "rest \<noteq> []"
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   567
begin
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   568
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   569
text {* 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   570
  The following @{text "taker"} is the thread to 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   571
  take over @{text "cs"}. 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   572
*}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   573
  definition "taker = hd wq'"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   574
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   575
end
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   576
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   577
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   578
locale valid_trace_set = valid_trace_e + 
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   579
  fixes th prio
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   580
  assumes is_set: "e = Set th prio"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   581
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   582
context valid_trace
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   583
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   584
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   585
text {*
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   586
  Induction rule introduced to easy the 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   587
  derivation of properties for valid trace @{term "s"}.
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   588
  One more premises, namely @{term "valid_trace_e s e"}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   589
  is added, so that an interpretation of 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   590
  @{text "valid_trace_e"} can be instantiated 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   591
  so that all properties derived so far becomes 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   592
  available in the proof of induction step.
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   593
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   594
  You will see its use in the proofs that follows.
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   595
*}
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   596
lemma ind [consumes 0, case_names Nil Cons, induct type]:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   597
  assumes "PP []"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   598
     and "(\<And>s e. valid_trace_e s e \<Longrightarrow>
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   599
                   PP s \<Longrightarrow> PIP s e \<Longrightarrow> PP (e # s))"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   600
     shows "PP s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   601
proof(induct rule:vt.induct[OF vt, case_names Init Step])
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   602
  case Init
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   603
  from assms(1) show ?case .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   604
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   605
  case (Step s e)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   606
  show ?case
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   607
  proof(rule assms(2))
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   608
    show "valid_trace_e s e" using Step by (unfold_locales, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   609
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   610
    show "PP s" using Step by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   611
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   612
    show "PIP s e" using Step by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   613
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   614
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   615
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   616
text {*
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   617
  The following lemma says that if @{text "s"} is a valid state, so 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   618
  is its any postfix. Where @{term "monent t s"} is the postfix of 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   619
  @{term "s"} with length @{term "t"}.
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   620
*}
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   621
lemma  vt_moment: "\<And> t. vt (moment t s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   622
proof(induct rule:ind)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   623
  case Nil
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   624
  thus ?case by (simp add:vt_nil)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   625
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   626
  case (Cons s e t)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   627
  show ?case
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   628
  proof(cases "t \<ge> length (e#s)")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   629
    case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   630
    from True have "moment t (e#s) = e#s" by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   631
    thus ?thesis using Cons
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   632
      by (simp add:valid_trace_def valid_trace_e_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   633
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   634
    case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   635
    from Cons have "vt (moment t s)" by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   636
    moreover have "moment t (e#s) = moment t s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   637
    proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   638
      from False have "t \<le> length s" by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   639
      from moment_app [OF this, of "[e]"] 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   640
      show ?thesis by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   641
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   642
    ultimately show ?thesis by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   643
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   644
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   645
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   646
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   647
text {*
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   648
  The following locale @{text "valid_moment"} is to inherit the properties 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   649
  derived on any valid state to the prefix of it, with length @{text "i"}.
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   650
*}
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   651
locale valid_moment = valid_trace + 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   652
  fixes i :: nat
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   653
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   654
sublocale valid_moment < vat_moment!: valid_trace "(moment i s)"
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   655
  by (unfold_locales, insert vt_moment, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   656
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   657
locale valid_moment_e = valid_moment +
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   658
  assumes less_i: "i < length s"
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   659
begin
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   660
  definition "next_e  = hd (moment (Suc i) s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   661
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   662
  lemma trace_e: 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   663
    "moment (Suc i) s = next_e#moment i s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   664
   proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   665
    from less_i have "Suc i \<le> length s" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   666
    from moment_plus[OF this, folded next_e_def]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   667
    show ?thesis .
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   668
   qed
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   669
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   670
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   671
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   672
sublocale valid_moment_e < vat_moment_e!: valid_trace_e "moment i s" "next_e"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   673
  using vt_moment[of "Suc i", unfolded trace_e]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   674
  by (unfold_locales, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   675
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   676
section {* Distinctiveness of waiting queues *}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   677
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   678
context valid_trace_create
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   679
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   680
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   681
lemma wq_kept [simp]:
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   682
  shows "wq (e#s) cs' = wq s cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   683
    using assms unfolding is_create wq_def
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   684
  by (auto simp:Let_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   685
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   686
lemma wq_distinct_kept:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   687
  assumes "distinct (wq s cs')"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   688
  shows "distinct (wq (e#s) cs')"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   689
  using assms by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   690
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   691
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   692
context valid_trace_exit
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   693
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   694
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   695
lemma wq_kept [simp]:
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   696
  shows "wq (e#s) cs' = wq s cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   697
    using assms unfolding is_exit wq_def
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   698
  by (auto simp:Let_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   699
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   700
lemma wq_distinct_kept:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   701
  assumes "distinct (wq s cs')"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   702
  shows "distinct (wq (e#s) cs')"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   703
  using assms by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   704
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   705
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   706
context valid_trace_p 
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   707
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   708
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   709
lemma wq_neq_simp [simp]:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   710
  assumes "cs' \<noteq> cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   711
  shows "wq (e#s) cs' = wq s cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   712
    using assms unfolding is_p wq_def
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   713
  by (auto simp:Let_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   714
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   715
lemma runing_th_s:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   716
  shows "th \<in> runing s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   717
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   718
  from pip_e[unfolded is_p]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   719
  show ?thesis by (cases, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   720
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   721
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   722
lemma th_not_in_wq: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   723
  shows "th \<notin> set (wq s cs)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   724
proof
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   725
  assume otherwise: "th \<in> set (wq s cs)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   726
  from runing_wqE[OF runing_th_s this]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   727
  obtain rest where eq_wq: "wq s cs = th#rest" by blast
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   728
  with otherwise
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   729
  have "holding s th cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   730
    by (unfold s_holding_def, fold wq_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   731
  hence cs_th_RAG: "(Cs cs, Th th) \<in> RAG s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   732
    by (unfold s_RAG_def, fold holding_eq, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   733
  from pip_e[unfolded is_p]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   734
  show False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   735
  proof(cases)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   736
    case (thread_P)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   737
    with cs_th_RAG show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   738
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   739
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   740
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   741
lemma wq_es_cs: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   742
  "wq (e#s) cs =  wq s cs @ [th]"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   743
  by (unfold is_p wq_def, auto simp:Let_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   744
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   745
lemma wq_distinct_kept:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   746
  assumes "distinct (wq s cs')"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   747
  shows "distinct (wq (e#s) cs')"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   748
proof(cases "cs' = cs")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   749
  case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   750
  show ?thesis using True assms th_not_in_wq
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   751
    by (unfold True wq_es_cs, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   752
qed (insert assms, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   753
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   754
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   755
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   756
context valid_trace_v
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   757
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   758
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   759
lemma wq_neq_simp [simp]:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   760
  assumes "cs' \<noteq> cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   761
  shows "wq (e#s) cs' = wq s cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   762
    using assms unfolding is_v wq_def
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   763
  by (auto simp:Let_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   764
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   765
lemma wq_s_cs:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   766
  "wq s cs = th#rest"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   767
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   768
  from pip_e[unfolded is_v]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   769
  show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   770
  proof(cases)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   771
    case (thread_V)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   772
    from this(2) show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   773
      by (unfold rest_def s_holding_def, fold wq_def,
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   774
                 metis empty_iff list.collapse list.set(1))
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   775
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   776
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   777
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   778
lemma wq_es_cs:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   779
  "wq (e#s) cs = wq'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   780
 using wq_s_cs[unfolded wq_def]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   781
 by (auto simp:Let_def wq_def rest_def wq'_def is_v, simp) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   782
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   783
lemma wq_distinct_kept:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   784
  assumes "distinct (wq s cs')"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   785
  shows "distinct (wq (e#s) cs')"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   786
proof(cases "cs' = cs")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   787
  case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   788
  show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   789
  proof(unfold True wq_es_cs wq'_def, rule someI2)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   790
    show "distinct rest \<and> set rest = set rest"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   791
        using assms[unfolded True wq_s_cs] by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   792
  qed simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   793
qed (insert assms, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   794
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   795
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   796
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   797
context valid_trace_set
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   798
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   799
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   800
lemma wq_kept [simp]:
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   801
  shows "wq (e#s) cs' = wq s cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   802
    using assms unfolding is_set wq_def
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   803
  by (auto simp:Let_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   804
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   805
lemma wq_distinct_kept:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   806
  assumes "distinct (wq s cs')"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   807
  shows "distinct (wq (e#s) cs')"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   808
  using assms by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   809
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   810
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   811
context valid_trace
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   812
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   813
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   814
lemma  finite_threads:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   815
  shows "finite (threads s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   816
  using vt by (induct) (auto elim: step.cases)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   817
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   818
lemma finite_readys [simp]: "finite (readys s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   819
  using finite_threads readys_threads rev_finite_subset by blast
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   820
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   821
lemma wq_distinct: "distinct (wq s cs)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   822
proof(induct rule:ind)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   823
  case (Cons s e)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   824
  interpret vt_e: valid_trace_e s e using Cons by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   825
  show ?case 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   826
  proof(cases e)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   827
    case (Create th prio)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   828
    interpret vt_create: valid_trace_create s e th prio 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   829
      using Create by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   830
    show ?thesis using Cons by (simp add: vt_create.wq_distinct_kept) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   831
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   832
    case (Exit th)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   833
    interpret vt_exit: valid_trace_exit s e th  
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   834
        using Exit by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   835
    show ?thesis using Cons by (simp add: vt_exit.wq_distinct_kept) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   836
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   837
    case (P th cs)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   838
    interpret vt_p: valid_trace_p s e th cs using P by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   839
    show ?thesis using Cons by (simp add: vt_p.wq_distinct_kept) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   840
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   841
    case (V th cs)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   842
    interpret vt_v: valid_trace_v s e th cs using V by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   843
    show ?thesis using Cons by (simp add: vt_v.wq_distinct_kept) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   844
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   845
    case (Set th prio)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   846
    interpret vt_set: valid_trace_set s e th prio
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   847
        using Set by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   848
    show ?thesis using Cons by (simp add: vt_set.wq_distinct_kept) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   849
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   850
qed (unfold wq_def Let_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   851
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   852
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   853
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   854
section {* Waiting queues and threads *}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   855
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   856
context valid_trace_e
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   857
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   858
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   859
lemma wq_out_inv: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   860
  assumes s_in: "thread \<in> set (wq s cs)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   861
  and s_hd: "thread = hd (wq s cs)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   862
  and s_i: "thread \<noteq> hd (wq (e#s) cs)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   863
  shows "e = V thread cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   864
proof(cases e)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   865
-- {* There are only two non-trivial cases: *}
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   866
  case (V th cs1)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   867
  show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   868
  proof(cases "cs1 = cs")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   869
    case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   870
    have "PIP s (V th cs)" using pip_e[unfolded V[unfolded True]] .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   871
    thus ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   872
    proof(cases)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   873
      case (thread_V)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   874
      moreover have "th = thread" using thread_V(2) s_hd
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   875
          by (unfold s_holding_def wq_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   876
      ultimately show ?thesis using V True by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   877
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   878
  qed (insert assms V, auto simp:wq_def Let_def split:if_splits)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   879
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   880
  case (P th cs1)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   881
  show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   882
  proof(cases "cs1 = cs")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   883
    case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   884
    with P have "wq (e#s) cs = wq_fun (schs s) cs @ [th]"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   885
      by (auto simp:wq_def Let_def split:if_splits)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   886
    with s_i s_hd s_in have False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   887
      by (metis empty_iff hd_append2 list.set(1) wq_def) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   888
    thus ?thesis by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   889
  qed (insert assms P, auto simp:wq_def Let_def split:if_splits)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   890
qed (insert assms, auto simp:wq_def Let_def split:if_splits)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   891
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   892
lemma wq_in_inv: 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   893
  assumes s_ni: "thread \<notin> set (wq s cs)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   894
  and s_i: "thread \<in> set (wq (e#s) cs)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   895
  shows "e = P thread cs"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   896
proof(cases e)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   897
  -- {* This is the only non-trivial case: *}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   898
  case (V th cs1)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   899
  have False
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   900
  proof(cases "cs1 = cs")
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   901
    case True
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   902
    show ?thesis
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   903
    proof(cases "(wq s cs1)")
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   904
      case (Cons w_hd w_tl)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   905
      have "set (wq (e#s) cs) \<subseteq> set (wq s cs)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   906
      proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   907
        have "(wq (e#s) cs) = (SOME q. distinct q \<and> set q = set w_tl)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   908
          using  Cons V by (auto simp:wq_def Let_def True split:if_splits)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   909
        moreover have "set ... \<subseteq> set (wq s cs)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   910
        proof(rule someI2)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   911
          show "distinct w_tl \<and> set w_tl = set w_tl"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   912
            by (metis distinct.simps(2) local.Cons wq_distinct)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   913
        qed (insert Cons True, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   914
        ultimately show ?thesis by simp
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   915
      qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   916
      with assms show ?thesis by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   917
    qed (insert assms V True, auto simp:wq_def Let_def split:if_splits)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   918
  qed (insert assms V, auto simp:wq_def Let_def split:if_splits)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   919
  thus ?thesis by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   920
qed (insert assms, auto simp:wq_def Let_def split:if_splits)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   921
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   922
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
   923
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   924
lemma (in valid_trace_create)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   925
  th_not_in_threads: "th \<notin> threads s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   926
proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   927
  from pip_e[unfolded is_create]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   928
  show ?thesis by (cases, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   929
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   930
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   931
lemma (in valid_trace_create)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   932
  threads_es [simp]: "threads (e#s) = threads s \<union> {th}"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   933
  by (unfold is_create, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   934
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   935
lemma (in valid_trace_exit)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   936
  threads_es [simp]: "threads (e#s) = threads s - {th}"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   937
  by (unfold is_exit, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   938
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   939
lemma (in valid_trace_p)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   940
  threads_es [simp]: "threads (e#s) = threads s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   941
  by (unfold is_p, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   942
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   943
lemma (in valid_trace_v)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   944
  threads_es [simp]: "threads (e#s) = threads s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   945
  by (unfold is_v, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   946
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   947
lemma (in valid_trace_v)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   948
  th_not_in_rest[simp]: "th \<notin> set rest"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   949
proof
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   950
  assume otherwise: "th \<in> set rest"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   951
  have "distinct (wq s cs)" by (simp add: wq_distinct)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   952
  from this[unfolded wq_s_cs] and otherwise
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   953
  show False by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   954
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   955
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   956
lemma (in valid_trace_v) distinct_rest: "distinct rest"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   957
  by (simp add: distinct_tl rest_def wq_distinct)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   958
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   959
lemma (in valid_trace_v)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   960
  set_wq_es_cs [simp]: "set (wq (e#s) cs) = set (wq s cs) - {th}"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   961
proof(unfold wq_es_cs wq'_def, rule someI2)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   962
  show "distinct rest \<and> set rest = set rest"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   963
    by (simp add: distinct_rest) 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   964
next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   965
  fix x
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   966
  assume "distinct x \<and> set x = set rest"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   967
  thus "set x = set (wq s cs) - {th}" 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   968
      by (unfold wq_s_cs, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   969
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   970
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   971
lemma (in valid_trace_exit)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   972
  th_not_in_wq: "th \<notin> set (wq s cs)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   973
proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   974
  from pip_e[unfolded is_exit]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   975
  show ?thesis
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   976
  by (cases, unfold holdents_def s_holding_def, fold wq_def, 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   977
             auto elim!:runing_wqE)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   978
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   979
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   980
lemma (in valid_trace) wq_threads: 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   981
  assumes "th \<in> set (wq s cs)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   982
  shows "th \<in> threads s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   983
  using assms
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   984
proof(induct rule:ind)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   985
  case (Nil)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   986
  thus ?case by (auto simp:wq_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   987
next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   988
  case (Cons s e)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   989
  interpret vt_e: valid_trace_e s e using Cons by simp
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   990
  show ?case
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   991
  proof(cases e)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   992
    case (Create th' prio')
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   993
    interpret vt: valid_trace_create s e th' prio'
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   994
      using Create by (unfold_locales, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   995
    show ?thesis
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   996
      using Cons.hyps(2) Cons.prems by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   997
  next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   998
    case (Exit th')
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
   999
    interpret vt: valid_trace_exit s e th'
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1000
      using Exit by (unfold_locales, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1001
    show ?thesis
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1002
      using Cons.hyps(2) Cons.prems vt.th_not_in_wq by auto 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1003
  next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1004
    case (P th' cs')
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1005
    interpret vt: valid_trace_p s e th' cs'
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1006
      using P by (unfold_locales, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1007
    show ?thesis
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1008
      using Cons.hyps(2) Cons.prems readys_threads 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1009
        runing_ready vt.is_p vt.runing_th_s vt_e.wq_in_inv 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1010
        by fastforce 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1011
  next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1012
    case (V th' cs')
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1013
    interpret vt: valid_trace_v s e th' cs'
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1014
      using V by (unfold_locales, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1015
    show ?thesis using Cons
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1016
      using vt.is_v vt.threads_es vt_e.wq_in_inv by blast
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1017
  next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1018
    case (Set th' prio)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1019
    interpret vt: valid_trace_set s e th' prio
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1020
      using Set by (unfold_locales, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1021
    show ?thesis using Cons.hyps(2) Cons.prems vt.is_set 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1022
        by (auto simp:wq_def Let_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1023
  qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1024
qed 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1025
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1026
section {* RAG and threads *}
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1027
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1028
context valid_trace
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1029
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1030
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1031
lemma  dm_RAG_threads:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1032
  assumes in_dom: "(Th th) \<in> Domain (RAG s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1033
  shows "th \<in> threads s"
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1034
proof -
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1035
  from in_dom obtain n where "(Th th, n) \<in> RAG s" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1036
  moreover from RAG_target_th[OF this] obtain cs where "n = Cs cs" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1037
  ultimately have "(Th th, Cs cs) \<in> RAG s" by simp
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1038
  hence "th \<in> set (wq s cs)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1039
    by (unfold s_RAG_def, auto simp:cs_waiting_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1040
  from wq_threads [OF this] show ?thesis .
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1041
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1042
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1043
lemma rg_RAG_threads: 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1044
  assumes "(Th th) \<in> Range (RAG s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1045
  shows "th \<in> threads s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1046
  using assms
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1047
  by (unfold s_RAG_def cs_waiting_def cs_holding_def, 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1048
       auto intro:wq_threads)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1049
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1050
lemma RAG_threads:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1051
  assumes "(Th th) \<in> Field (RAG s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1052
  shows "th \<in> threads s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1053
  using assms
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1054
  by (metis Field_def UnE dm_RAG_threads rg_RAG_threads)
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1055
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1056
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1057
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1058
section {* The change of @{term RAG} *}
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1059
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1060
text {*
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1061
  The following three lemmas show that @{text "RAG"} does not change
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1062
  by the happening of @{text "Set"}, @{text "Create"} and @{text "Exit"}
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1063
  events, respectively.
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1064
*}
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1065
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1066
lemma (in valid_trace_set) RAG_unchanged [simp]: "(RAG (e # s)) = RAG s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1067
   by (unfold is_set s_RAG_def s_waiting_def wq_def, simp add:Let_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1068
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1069
lemma (in valid_trace_create) RAG_unchanged [simp]: "(RAG (e # s)) = RAG s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1070
 by (unfold is_create s_RAG_def s_waiting_def wq_def, simp add:Let_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1071
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1072
lemma (in valid_trace_exit) RAG_unchanged[simp]: "(RAG (e # s)) = RAG s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1073
  by (unfold is_exit s_RAG_def s_waiting_def wq_def, simp add:Let_def)
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1074
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1075
context valid_trace_v
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1076
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1077
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1078
lemma holding_cs_eq_th:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1079
  assumes "holding s t cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1080
  shows "t = th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1081
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1082
  from pip_e[unfolded is_v]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1083
  show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1084
  proof(cases)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1085
    case (thread_V)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1086
    from held_unique[OF this(2) assms]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1087
    show ?thesis by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1088
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1089
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1090
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1091
lemma distinct_wq': "distinct wq'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1092
  by (metis (mono_tags, lifting) distinct_rest  some_eq_ex wq'_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1093
  
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1094
lemma set_wq': "set wq' = set rest"
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1095
  by (metis (mono_tags, lifting) distinct_rest some_eq_ex wq'_def)
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1096
    
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1097
lemma th'_in_inv:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1098
  assumes "th' \<in> set wq'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1099
  shows "th' \<in> set rest"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1100
  using assms set_wq' by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1101
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1102
lemma runing_th_s:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1103
  shows "th \<in> runing s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1104
proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1105
  from pip_e[unfolded is_v]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1106
  show ?thesis by (cases, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1107
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1108
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1109
lemma neq_t_th: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1110
  assumes "waiting (e#s) t c"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1111
  shows "t \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1112
proof
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1113
  assume otherwise: "t = th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1114
  show False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1115
  proof(cases "c = cs")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1116
    case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1117
    have "t \<in> set wq'" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1118
     using assms[unfolded True s_waiting_def, folded wq_def, unfolded wq_es_cs]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1119
     by simp 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1120
    from th'_in_inv[OF this] have "t \<in> set rest" .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1121
    with wq_s_cs[folded otherwise] wq_distinct[of cs]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1122
    show ?thesis by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1123
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1124
    case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1125
    have "wq (e#s) c = wq s c" using False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1126
        by (unfold is_v, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1127
    hence "waiting s t c" using assms 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1128
        by (simp add: cs_waiting_def waiting_eq)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1129
    hence "t \<notin> readys s" by (unfold readys_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1130
    hence "t \<notin> runing s" using runing_ready by auto 
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1131
    with runing_th_s[folded otherwise] show ?thesis by auto 
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1132
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1133
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1134
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1135
lemma waiting_esI1:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1136
  assumes "waiting s t c"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1137
      and "c \<noteq> cs" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1138
  shows "waiting (e#s) t c" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1139
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1140
  have "wq (e#s) c = wq s c" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1141
    using assms(2) is_v by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1142
  with assms(1) show ?thesis 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1143
    using cs_waiting_def waiting_eq by auto 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1144
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1145
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1146
lemma holding_esI2:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1147
  assumes "c \<noteq> cs" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1148
  and "holding s t c"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1149
  shows "holding (e#s) t c"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1150
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1151
  from assms(1) have "wq (e#s) c = wq s c" using is_v by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1152
  from assms(2)[unfolded s_holding_def, folded wq_def, 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1153
                folded this, unfolded wq_def, folded s_holding_def]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1154
  show ?thesis .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1155
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1156
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1157
lemma holding_esI1:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1158
  assumes "holding s t c"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1159
  and "t \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1160
  shows "holding (e#s) t c"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1161
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1162
  have "c \<noteq> cs" using assms using holding_cs_eq_th by blast 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1163
  from holding_esI2[OF this assms(1)]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1164
  show ?thesis .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1165
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1166
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1167
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1168
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1169
context valid_trace_v_n
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1170
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1171
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1172
lemma neq_wq': "wq' \<noteq> []" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1173
proof (unfold wq'_def, rule someI2)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1174
  show "distinct rest \<and> set rest = set rest"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1175
    by (simp add: distinct_rest) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1176
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1177
  fix x
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1178
  assume " distinct x \<and> set x = set rest" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1179
  thus "x \<noteq> []" using rest_nnl by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1180
qed 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1181
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1182
lemma eq_wq': "wq' = taker # rest'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1183
  by (simp add: neq_wq' rest'_def taker_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1184
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1185
lemma next_th_taker: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1186
  shows "next_th s th cs taker"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1187
  using rest_nnl taker_def wq'_def wq_s_cs 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1188
  by (auto simp:next_th_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1189
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1190
lemma taker_unique: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1191
  assumes "next_th s th cs taker'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1192
  shows "taker' = taker"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1193
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1194
  from assms
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1195
  obtain rest' where 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1196
    h: "wq s cs = th # rest'" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1197
       "taker' = hd (SOME q. distinct q \<and> set q = set rest')"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1198
          by (unfold next_th_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1199
  with wq_s_cs have "rest' = rest" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1200
  thus ?thesis using h(2) taker_def wq'_def by auto 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1201
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1202
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1203
lemma waiting_set_eq:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1204
  "{(Th th', Cs cs) |th'. next_th s th cs th'} = {(Th taker, Cs cs)}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1205
  by (smt all_not_in_conv bot.extremum insertI1 insert_subset 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1206
      mem_Collect_eq next_th_taker subsetI subset_antisym taker_def taker_unique)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1207
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1208
lemma holding_set_eq:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1209
  "{(Cs cs, Th th') |th'.  next_th s th cs th'} = {(Cs cs, Th taker)}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1210
  using next_th_taker taker_def waiting_set_eq 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1211
  by fastforce
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1212
   
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1213
lemma holding_taker:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1214
  shows "holding (e#s) taker cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1215
    by (unfold s_holding_def, fold wq_def, unfold wq_es_cs, 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1216
        auto simp:neq_wq' taker_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1217
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1218
lemma waiting_esI2:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1219
  assumes "waiting s t cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1220
      and "t \<noteq> taker"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1221
  shows "waiting (e#s) t cs" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1222
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1223
  have "t \<in> set wq'" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1224
  proof(unfold wq'_def, rule someI2)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1225
    show "distinct rest \<and> set rest = set rest"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1226
          by (simp add: distinct_rest)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1227
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1228
    fix x
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1229
    assume "distinct x \<and> set x = set rest"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1230
    moreover have "t \<in> set rest"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1231
        using assms(1) cs_waiting_def waiting_eq wq_s_cs by auto 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1232
    ultimately show "t \<in> set x" by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1233
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1234
  moreover have "t \<noteq> hd wq'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1235
    using assms(2) taker_def by auto 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1236
  ultimately show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1237
    by (unfold s_waiting_def, fold wq_def, unfold wq_es_cs, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1238
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1239
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1240
lemma waiting_esE:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1241
  assumes "waiting (e#s) t c" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1242
  obtains "c \<noteq> cs" "waiting s t c"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1243
     |    "c = cs" "t \<noteq> taker" "waiting s t cs" "t \<in> set rest'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1244
proof(cases "c = cs")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1245
  case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1246
  hence "wq (e#s) c = wq s c" using is_v by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1247
  with assms have "waiting s t c" using cs_waiting_def waiting_eq by auto 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1248
  from that(1)[OF False this] show ?thesis .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1249
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1250
  case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1251
  from assms[unfolded s_waiting_def True, folded wq_def, unfolded wq_es_cs]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1252
  have "t \<noteq> hd wq'" "t \<in> set wq'" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1253
  hence "t \<noteq> taker" by (simp add: taker_def) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1254
  moreover hence "t \<noteq> th" using assms neq_t_th by blast 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1255
  moreover have "t \<in> set rest" by (simp add: `t \<in> set wq'` th'_in_inv) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1256
  ultimately have "waiting s t cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1257
    by (metis cs_waiting_def list.distinct(2) list.sel(1) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1258
                list.set_sel(2) rest_def waiting_eq wq_s_cs)  
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1259
  show ?thesis using that(2)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1260
  using True `t \<in> set wq'` `t \<noteq> taker` `waiting s t cs` eq_wq' by auto   
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1261
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1262
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1263
lemma holding_esI1:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1264
  assumes "c = cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1265
  and "t = taker"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1266
  shows "holding (e#s) t c"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1267
  by (unfold assms, simp add: holding_taker)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1268
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1269
lemma holding_esE:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1270
  assumes "holding (e#s) t c" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1271
  obtains "c = cs" "t = taker"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1272
      | "c \<noteq> cs" "holding s t c"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1273
proof(cases "c = cs")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1274
  case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1275
  from assms[unfolded True, unfolded s_holding_def, 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1276
             folded wq_def, unfolded wq_es_cs]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1277
  have "t = taker" by (simp add: taker_def) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1278
  from that(1)[OF True this] show ?thesis .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1279
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1280
  case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1281
  hence "wq (e#s) c = wq s c" using is_v by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1282
  from assms[unfolded s_holding_def, folded wq_def, 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1283
             unfolded this, unfolded wq_def, folded s_holding_def]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1284
  have "holding s t c"  .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1285
  from that(2)[OF False this] show ?thesis .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1286
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1287
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1288
end 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1289
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1290
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1291
context valid_trace_v_e
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1292
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1293
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1294
lemma nil_wq': "wq' = []" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1295
proof (unfold wq'_def, rule someI2)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1296
  show "distinct rest \<and> set rest = set rest"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1297
    by (simp add: distinct_rest) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1298
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1299
  fix x
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1300
  assume " distinct x \<and> set x = set rest" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1301
  thus "x = []" using rest_nil by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1302
qed 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1303
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1304
lemma no_taker: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1305
  assumes "next_th s th cs taker"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1306
  shows "False"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1307
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1308
  from assms[unfolded next_th_def]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1309
  obtain rest' where "wq s cs = th # rest'" "rest' \<noteq> []"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1310
    by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1311
  thus ?thesis using rest_def rest_nil by auto 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1312
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1313
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1314
lemma waiting_set_eq:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1315
  "{(Th th', Cs cs) |th'. next_th s th cs th'} = {}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1316
  using no_taker by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1317
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1318
lemma holding_set_eq:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1319
  "{(Cs cs, Th th') |th'.  next_th s th cs th'} = {}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1320
  using no_taker by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1321
   
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1322
lemma no_holding:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1323
  assumes "holding (e#s) taker cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1324
  shows False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1325
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1326
  from wq_es_cs[unfolded nil_wq']
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1327
  have " wq (e # s) cs = []" .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1328
  from assms[unfolded s_holding_def, folded wq_def, unfolded this]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1329
  show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1330
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1331
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1332
lemma no_waiting:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1333
  assumes "waiting (e#s) t cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1334
  shows False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1335
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1336
  from wq_es_cs[unfolded nil_wq']
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1337
  have " wq (e # s) cs = []" .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1338
  from assms[unfolded s_waiting_def, folded wq_def, unfolded this]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1339
  show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1340
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1341
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1342
lemma waiting_esI2:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1343
  assumes "waiting s t c"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1344
  shows "waiting (e#s) t c"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1345
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1346
  have "c \<noteq> cs" using assms
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1347
    using cs_waiting_def rest_nil waiting_eq wq_s_cs by auto 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1348
  from waiting_esI1[OF assms this]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1349
  show ?thesis .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1350
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1351
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1352
lemma waiting_esE:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1353
  assumes "waiting (e#s) t c" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1354
  obtains "c \<noteq> cs" "waiting s t c"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1355
proof(cases "c = cs")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1356
  case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1357
  hence "wq (e#s) c = wq s c" using is_v by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1358
  with assms have "waiting s t c" using cs_waiting_def waiting_eq by auto 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1359
  from that(1)[OF False this] show ?thesis .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1360
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1361
  case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1362
  from no_waiting[OF assms[unfolded True]]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1363
  show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1364
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1365
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1366
lemma holding_esE:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1367
  assumes "holding (e#s) t c" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1368
  obtains "c \<noteq> cs" "holding s t c"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1369
proof(cases "c = cs")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1370
  case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1371
  from no_holding[OF assms[unfolded True]] 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1372
  show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1373
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1374
  case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1375
  hence "wq (e#s) c = wq s c" using is_v by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1376
  from assms[unfolded s_holding_def, folded wq_def, 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1377
             unfolded this, unfolded wq_def, folded s_holding_def]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1378
  have "holding s t c"  .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1379
  from that[OF False this] show ?thesis .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1380
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1381
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1382
end 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1383
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1384
  
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1385
context valid_trace_v
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1386
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1387
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1388
lemma RAG_es:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1389
  "RAG (e # s) =
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1390
   RAG s - {(Cs cs, Th th)} -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1391
     {(Th th', Cs cs) |th'. next_th s th cs th'} \<union>
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1392
     {(Cs cs, Th th') |th'.  next_th s th cs th'}" (is "?L = ?R")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1393
proof(rule rel_eqI)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1394
  fix n1 n2
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1395
  assume "(n1, n2) \<in> ?L"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1396
  thus "(n1, n2) \<in> ?R"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1397
  proof(cases rule:in_RAG_E)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1398
    case (waiting th' cs')
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1399
    show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1400
    proof(cases "rest = []")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1401
      case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1402
      interpret h_n: valid_trace_v_n s e th cs
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1403
        by (unfold_locales, insert False, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1404
      from waiting(3)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1405
      show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1406
      proof(cases rule:h_n.waiting_esE)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1407
        case 1
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1408
        with waiting(1,2)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1409
        show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1410
        by (unfold h_n.waiting_set_eq h_n.holding_set_eq s_RAG_def, 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1411
             fold waiting_eq, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1412
      next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1413
        case 2
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1414
        with waiting(1,2)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1415
        show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1416
         by (unfold h_n.waiting_set_eq h_n.holding_set_eq s_RAG_def, 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1417
             fold waiting_eq, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1418
      qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1419
    next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1420
      case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1421
      interpret h_e: valid_trace_v_e s e th cs
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1422
        by (unfold_locales, insert True, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1423
      from waiting(3)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1424
      show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1425
      proof(cases rule:h_e.waiting_esE)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1426
        case 1
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1427
        with waiting(1,2)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1428
        show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1429
        by (unfold h_e.waiting_set_eq h_e.holding_set_eq s_RAG_def, 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1430
             fold waiting_eq, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1431
      qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1432
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1433
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1434
    case (holding th' cs')
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1435
    show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1436
    proof(cases "rest = []")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1437
      case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1438
      interpret h_n: valid_trace_v_n s e th cs
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1439
        by (unfold_locales, insert False, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1440
      from holding(3)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1441
      show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1442
      proof(cases rule:h_n.holding_esE)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1443
        case 1
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1444
        with holding(1,2)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1445
        show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1446
        by (unfold h_n.waiting_set_eq h_n.holding_set_eq s_RAG_def, 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1447
             fold waiting_eq, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1448
      next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1449
        case 2
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1450
        with holding(1,2)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1451
        show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1452
         by (unfold h_n.waiting_set_eq h_n.holding_set_eq s_RAG_def, 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1453
             fold holding_eq, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1454
      qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1455
    next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1456
      case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1457
      interpret h_e: valid_trace_v_e s e th cs
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1458
        by (unfold_locales, insert True, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1459
      from holding(3)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1460
      show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1461
      proof(cases rule:h_e.holding_esE)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1462
        case 1
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1463
        with holding(1,2)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1464
        show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1465
        by (unfold h_e.waiting_set_eq h_e.holding_set_eq s_RAG_def, 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1466
             fold holding_eq, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1467
      qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1468
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1469
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1470
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1471
  fix n1 n2
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1472
  assume h: "(n1, n2) \<in> ?R"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1473
  show "(n1, n2) \<in> ?L"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1474
  proof(cases "rest = []")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1475
    case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1476
    interpret h_n: valid_trace_v_n s e th cs
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1477
        by (unfold_locales, insert False, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1478
    from h[unfolded h_n.waiting_set_eq h_n.holding_set_eq]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1479
    have "((n1, n2) \<in> RAG s \<and> (n1 \<noteq> Cs cs \<or> n2 \<noteq> Th th)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1480
                            \<and> (n1 \<noteq> Th h_n.taker \<or> n2 \<noteq> Cs cs)) \<or> 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1481
          (n2 = Th h_n.taker \<and> n1 = Cs cs)" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1482
      by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1483
   thus ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1484
   proof
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1485
      assume "n2 = Th h_n.taker \<and> n1 = Cs cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1486
      with h_n.holding_taker
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1487
      show ?thesis 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1488
        by (unfold s_RAG_def, fold holding_eq, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1489
   next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1490
    assume h: "(n1, n2) \<in> RAG s \<and>
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1491
        (n1 \<noteq> Cs cs \<or> n2 \<noteq> Th th) \<and> (n1 \<noteq> Th h_n.taker \<or> n2 \<noteq> Cs cs)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1492
    hence "(n1, n2) \<in> RAG s" by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1493
    thus ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1494
    proof(cases rule:in_RAG_E)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1495
      case (waiting th' cs')
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1496
      from h and this(1,2)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1497
      have "th' \<noteq> h_n.taker \<or> cs' \<noteq> cs" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1498
      hence "waiting (e#s) th' cs'" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1499
      proof
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1500
        assume "cs' \<noteq> cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1501
        from waiting_esI1[OF waiting(3) this] 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1502
        show ?thesis .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1503
      next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1504
        assume neq_th': "th' \<noteq> h_n.taker"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1505
        show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1506
        proof(cases "cs' = cs")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1507
          case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1508
          from waiting_esI1[OF waiting(3) this] 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1509
          show ?thesis .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1510
        next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1511
          case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1512
          from h_n.waiting_esI2[OF waiting(3)[unfolded True] neq_th', folded True]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1513
          show ?thesis .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1514
        qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1515
      qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1516
      thus ?thesis using waiting(1,2)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1517
        by (unfold s_RAG_def, fold waiting_eq, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1518
    next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1519
      case (holding th' cs')
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1520
      from h this(1,2)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1521
      have "cs' \<noteq> cs \<or> th' \<noteq> th" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1522
      hence "holding (e#s) th' cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1523
      proof
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1524
        assume "cs' \<noteq> cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1525
        from holding_esI2[OF this holding(3)] 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1526
        show ?thesis .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1527
      next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1528
        assume "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1529
        from holding_esI1[OF holding(3) this]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1530
        show ?thesis .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1531
      qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1532
      thus ?thesis using holding(1,2)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1533
        by (unfold s_RAG_def, fold holding_eq, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1534
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1535
   qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1536
 next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1537
   case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1538
   interpret h_e: valid_trace_v_e s e th cs
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1539
        by (unfold_locales, insert True, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1540
   from h[unfolded h_e.waiting_set_eq h_e.holding_set_eq]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1541
   have h_s: "(n1, n2) \<in> RAG s" "(n1, n2) \<noteq> (Cs cs, Th th)" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1542
      by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1543
   from h_s(1)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1544
   show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1545
   proof(cases rule:in_RAG_E)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1546
    case (waiting th' cs')
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1547
    from h_e.waiting_esI2[OF this(3)]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1548
    show ?thesis using waiting(1,2)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1549
      by (unfold s_RAG_def, fold waiting_eq, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1550
   next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1551
    case (holding th' cs')
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1552
    with h_s(2)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1553
    have "cs' \<noteq> cs \<or> th' \<noteq> th" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1554
    thus ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1555
    proof
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1556
      assume neq_cs: "cs' \<noteq> cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1557
      from holding_esI2[OF this holding(3)]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1558
      show ?thesis using holding(1,2)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1559
        by (unfold s_RAG_def, fold holding_eq, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1560
    next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1561
      assume "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1562
      from holding_esI1[OF holding(3) this]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1563
      show ?thesis using holding(1,2)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1564
        by (unfold s_RAG_def, fold holding_eq, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1565
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1566
   qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1567
 qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1568
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1569
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1570
lemma 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1571
  finite_RAG_kept:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1572
  assumes "finite (RAG s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1573
  shows "finite (RAG (e#s))"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1574
proof(cases "rest = []")
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1575
  case True
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1576
  interpret vt: valid_trace_v_e using True
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1577
    by (unfold_locales, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1578
  show ?thesis using assms
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1579
    by  (unfold RAG_es vt.waiting_set_eq vt.holding_set_eq, simp)
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1580
next
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1581
  case False
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1582
  interpret vt: valid_trace_v_n using False
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1583
    by (unfold_locales, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1584
  show ?thesis using assms
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1585
    by  (unfold RAG_es vt.waiting_set_eq vt.holding_set_eq, simp)
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1586
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1587
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1588
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1589
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1590
context valid_trace_p
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1591
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1592
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1593
lemma waiting_kept:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1594
  assumes "waiting s th' cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1595
  shows "waiting (e#s) th' cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1596
  using assms
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1597
  by (metis cs_waiting_def hd_append2 list.sel(1) list.set_intros(2) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1598
      rotate1.simps(2) self_append_conv2 set_rotate1 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1599
        th_not_in_wq waiting_eq wq_es_cs wq_neq_simp)
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1600
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1601
lemma holding_kept:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1602
  assumes "holding s th' cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1603
  shows "holding (e#s) th' cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1604
proof(cases "cs' = cs")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1605
  case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1606
  hence "wq (e#s) cs' = wq s cs'" by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1607
  with assms show ?thesis using cs_holding_def holding_eq by auto 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1608
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1609
  case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1610
  from assms[unfolded s_holding_def, folded wq_def]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1611
  obtain rest where eq_wq: "wq s cs' = th'#rest"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1612
    by (metis empty_iff list.collapse list.set(1)) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1613
  hence "wq (e#s) cs' = th'#(rest@[th])"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1614
    by (simp add: True wq_es_cs) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1615
  thus ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1616
    by (simp add: cs_holding_def holding_eq) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1617
qed
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1618
end 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1619
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1620
lemma (in valid_trace_p) th_not_waiting: "\<not> waiting s th c"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1621
proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1622
  have "th \<in> readys s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1623
    using runing_ready runing_th_s by blast 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1624
  thus ?thesis
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1625
    by (unfold readys_def, auto)
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1626
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1627
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1628
context valid_trace_p_h
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1629
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1630
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1631
lemma wq_es_cs': "wq (e#s) cs = [th]"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1632
  using wq_es_cs[unfolded we] by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1633
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1634
lemma holding_es_th_cs: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1635
  shows "holding (e#s) th cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1636
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1637
  from wq_es_cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1638
  have "th \<in> set (wq (e#s) cs)" "th = hd (wq (e#s) cs)" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1639
  thus ?thesis using cs_holding_def holding_eq by blast 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1640
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1641
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1642
lemma RAG_edge: "(Cs cs, Th th) \<in> RAG (e#s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1643
  by (unfold s_RAG_def, fold holding_eq, insert holding_es_th_cs, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1644
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1645
lemma waiting_esE:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1646
  assumes "waiting (e#s) th' cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1647
  obtains "waiting s th' cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1648
  using assms
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1649
  by (metis cs_waiting_def event.distinct(15) is_p list.sel(1) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1650
        set_ConsD waiting_eq we wq_es_cs' wq_neq_simp wq_out_inv)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1651
  
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1652
lemma holding_esE:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1653
  assumes "holding (e#s) th' cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1654
  obtains "cs' \<noteq> cs" "holding s th' cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1655
    | "cs' = cs" "th' = th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1656
proof(cases "cs' = cs")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1657
  case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1658
  from held_unique[OF holding_es_th_cs assms[unfolded True]]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1659
  have "th' = th" by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1660
  from that(2)[OF True this] show ?thesis .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1661
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1662
  case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1663
  have "holding s th' cs'" using assms
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1664
    using False cs_holding_def holding_eq by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1665
  from that(1)[OF False this] show ?thesis .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1666
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1667
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1668
lemma RAG_es: "RAG (e # s) =  RAG s \<union> {(Cs cs, Th th)}" (is "?L = ?R")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1669
proof(rule rel_eqI)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1670
  fix n1 n2
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1671
  assume "(n1, n2) \<in> ?L"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1672
  thus "(n1, n2) \<in> ?R" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1673
  proof(cases rule:in_RAG_E)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1674
    case (waiting th' cs')
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1675
    from this(3)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1676
    show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1677
    proof(cases rule:waiting_esE)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1678
      case 1
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1679
      thus ?thesis using waiting(1,2)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1680
        by (unfold s_RAG_def, fold waiting_eq, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1681
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1682
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1683
    case (holding th' cs')
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1684
    from this(3)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1685
    show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1686
    proof(cases rule:holding_esE)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1687
      case 1
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1688
      with holding(1,2)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1689
      show ?thesis by (unfold s_RAG_def, fold holding_eq, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1690
    next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1691
      case 2
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1692
      with holding(1,2) show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1693
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1694
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1695
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1696
  fix n1 n2
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1697
  assume "(n1, n2) \<in> ?R"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1698
  hence "(n1, n2) \<in> RAG s \<or> (n1 = Cs cs \<and> n2 = Th th)" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1699
  thus "(n1, n2) \<in> ?L"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1700
  proof
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1701
    assume "(n1, n2) \<in> RAG s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1702
    thus ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1703
    proof(cases rule:in_RAG_E)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1704
      case (waiting th' cs')
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1705
      from waiting_kept[OF this(3)]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1706
      show ?thesis using waiting(1,2)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1707
         by (unfold s_RAG_def, fold waiting_eq, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1708
    next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1709
      case (holding th' cs')
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1710
      from holding_kept[OF this(3)]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1711
      show ?thesis using holding(1,2)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1712
         by (unfold s_RAG_def, fold holding_eq, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1713
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1714
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1715
    assume "n1 = Cs cs \<and> n2 = Th th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1716
    with holding_es_th_cs
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1717
    show ?thesis 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1718
      by (unfold s_RAG_def, fold holding_eq, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1719
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1720
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1721
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1722
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1723
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1724
context valid_trace_p_w
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1725
begin
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1726
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1727
lemma wq_s_cs: "wq s cs = holder#waiters"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1728
    by (simp add: holder_def waiters_def wne)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1729
    
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1730
lemma wq_es_cs': "wq (e#s) cs = holder#waiters@[th]"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1731
  by (simp add: wq_es_cs wq_s_cs)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1732
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1733
lemma waiting_es_th_cs: "waiting (e#s) th cs"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1734
  using cs_waiting_def th_not_in_wq waiting_eq wq_es_cs' wq_s_cs by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1735
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1736
lemma RAG_edge: "(Th th, Cs cs) \<in> RAG (e#s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1737
   by (unfold s_RAG_def, fold waiting_eq, insert waiting_es_th_cs, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1738
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1739
lemma holding_esE:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1740
  assumes "holding (e#s) th' cs'"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1741
  obtains "holding s th' cs'"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1742
  using assms 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1743
proof(cases "cs' = cs")
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1744
  case False
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1745
  hence "wq (e#s) cs' = wq s cs'" by simp
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1746
  with assms show ?thesis
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1747
    using cs_holding_def holding_eq that by auto 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1748
next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1749
  case True
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1750
  with assms show ?thesis
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1751
  by (metis cs_holding_def holding_eq list.sel(1) list.set_intros(1) that 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1752
        wq_es_cs' wq_s_cs) 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1753
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1754
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1755
lemma waiting_esE:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1756
  assumes "waiting (e#s) th' cs'"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1757
  obtains "th' \<noteq> th" "waiting s th' cs'"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1758
     |  "th' = th" "cs' = cs"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1759
proof(cases "waiting s th' cs'")
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1760
  case True
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1761
  have "th' \<noteq> th"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1762
  proof
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1763
    assume otherwise: "th' = th"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1764
    from True[unfolded this]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1765
    show False by (simp add: th_not_waiting)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1766
  qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1767
  from that(1)[OF this True] show ?thesis .
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1768
next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1769
  case False
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1770
  hence "th' = th \<and> cs' = cs"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1771
      by (metis assms cs_waiting_def holder_def list.sel(1) rotate1.simps(2) 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1772
        set_ConsD set_rotate1 waiting_eq wq_es_cs wq_es_cs' wq_neq_simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1773
  with that(2) show ?thesis by metis
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1774
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1775
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1776
lemma RAG_es: "RAG (e # s) =  RAG s \<union> {(Th th, Cs cs)}" (is "?L = ?R")
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1777
proof(rule rel_eqI)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1778
  fix n1 n2
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1779
  assume "(n1, n2) \<in> ?L"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1780
  thus "(n1, n2) \<in> ?R" 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1781
  proof(cases rule:in_RAG_E)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1782
    case (waiting th' cs')
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1783
    from this(3)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1784
    show ?thesis
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1785
    proof(cases rule:waiting_esE)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1786
      case 1
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1787
      thus ?thesis using waiting(1,2)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1788
        by (unfold s_RAG_def, fold waiting_eq, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1789
    next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1790
      case 2
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1791
      thus ?thesis using waiting(1,2) by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1792
    qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1793
  next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1794
    case (holding th' cs')
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1795
    from this(3)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1796
    show ?thesis
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1797
    proof(cases rule:holding_esE)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1798
      case 1
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1799
      with holding(1,2)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1800
      show ?thesis by (unfold s_RAG_def, fold holding_eq, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1801
    qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1802
  qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1803
next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1804
  fix n1 n2
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1805
  assume "(n1, n2) \<in> ?R"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1806
  hence "(n1, n2) \<in> RAG s \<or> (n1 = Th th \<and> n2 = Cs cs)" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1807
  thus "(n1, n2) \<in> ?L"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1808
  proof
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1809
    assume "(n1, n2) \<in> RAG s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1810
    thus ?thesis
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1811
    proof(cases rule:in_RAG_E)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1812
      case (waiting th' cs')
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1813
      from waiting_kept[OF this(3)]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1814
      show ?thesis using waiting(1,2)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1815
         by (unfold s_RAG_def, fold waiting_eq, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1816
    next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1817
      case (holding th' cs')
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1818
      from holding_kept[OF this(3)]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1819
      show ?thesis using holding(1,2)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1820
         by (unfold s_RAG_def, fold holding_eq, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1821
    qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1822
  next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1823
    assume "n1 = Th th \<and> n2 = Cs cs"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1824
    thus ?thesis using RAG_edge by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1825
  qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1826
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1827
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1828
end
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1829
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1830
context valid_trace_p
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1831
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1832
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1833
lemma RAG_es: "RAG (e # s) =  (if (wq s cs = []) then RAG s \<union> {(Cs cs, Th th)}
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1834
                                                  else RAG s \<union> {(Th th, Cs cs)})"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1835
proof(cases "wq s cs = []")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1836
  case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1837
  interpret vt_p: valid_trace_p_h using True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1838
    by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1839
  show ?thesis by (simp add: vt_p.RAG_es vt_p.we) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1840
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1841
  case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1842
  interpret vt_p: valid_trace_p_w using False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1843
    by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1844
  show ?thesis by (simp add: vt_p.RAG_es vt_p.wne) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1845
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1846
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1847
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  1848
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1849
section {* Finiteness of RAG *}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1850
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1851
context valid_trace
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1852
begin
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1853
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1854
lemma finite_RAG:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1855
  shows "finite (RAG s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1856
proof(induct rule:ind)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1857
  case Nil
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1858
  show ?case 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1859
  by (auto simp: s_RAG_def cs_waiting_def 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1860
                   cs_holding_def wq_def acyclic_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1861
next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1862
  case (Cons s e)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1863
  interpret vt_e: valid_trace_e s e using Cons by simp
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1864
  show ?case
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1865
  proof(cases e)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1866
    case (Create th prio)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1867
    interpret vt: valid_trace_create s e th prio using Create
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1868
      by (unfold_locales, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1869
    show ?thesis using Cons by simp
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1870
  next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1871
    case (Exit th)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1872
    interpret vt: valid_trace_exit s e th using Exit
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1873
      by (unfold_locales, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1874
    show ?thesis using Cons by simp
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1875
  next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1876
    case (P th cs)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1877
    interpret vt: valid_trace_p s e th cs using P
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1878
      by (unfold_locales, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1879
    show ?thesis using Cons using vt.RAG_es by auto 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1880
  next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1881
    case (V th cs)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1882
    interpret vt: valid_trace_v s e th cs using V
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1883
      by (unfold_locales, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1884
    show ?thesis using Cons by (simp add: vt.finite_RAG_kept) 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1885
  next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1886
    case (Set th prio)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1887
    interpret vt: valid_trace_set s e th prio using Set
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1888
      by (unfold_locales, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1889
    show ?thesis using Cons by simp
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1890
  qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1891
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1892
end
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1893
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1894
section {* RAG is acyclic *}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1895
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1896
text {* (* ddd *)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1897
  The nature of the work is like this: since it starts from a very simple and basic 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1898
  model, even intuitively very `basic` and `obvious` properties need to derived from scratch.
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1899
  For instance, the fact 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1900
  that one thread can not be blocked by two critical resources at the same time
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1901
  is obvious, because only running threads can make new requests, if one is waiting for 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1902
  a critical resource and get blocked, it can not make another resource request and get 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1903
  blocked the second time (because it is not running). 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1904
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1905
  To derive this fact, one needs to prove by contraction and 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1906
  reason about time (or @{text "moement"}). The reasoning is based on a generic theorem
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1907
  named @{text "p_split"}, which is about status changing along the time axis. It says if 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1908
  a condition @{text "Q"} is @{text "True"} at a state @{text "s"},
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1909
  but it was @{text "False"} at the very beginning, then there must exits a moment @{text "t"} 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1910
  in the history of @{text "s"} (notice that @{text "s"} itself is essentially the history 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1911
  of events leading to it), such that @{text "Q"} switched 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1912
  from being @{text "False"} to @{text "True"} and kept being @{text "True"}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1913
  till the last moment of @{text "s"}.
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1914
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1915
  Suppose a thread @{text "th"} is blocked
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1916
  on @{text "cs1"} and @{text "cs2"} in some state @{text "s"}, 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1917
  since no thread is blocked at the very beginning, by applying 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1918
  @{text "p_split"} to these two blocking facts, there exist 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1919
  two moments @{text "t1"} and @{text "t2"}  in @{text "s"}, such that 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1920
  @{text "th"} got blocked on @{text "cs1"} and @{text "cs2"} 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1921
  and kept on blocked on them respectively ever since.
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1922
 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1923
  Without lost of generality, we assume @{text "t1"} is earlier than @{text "t2"}.
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1924
  However, since @{text "th"} was blocked ever since memonent @{text "t1"}, so it was still
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1925
  in blocked state at moment @{text "t2"} and could not
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1926
  make any request and get blocked the second time: Contradiction.
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1927
*}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1928
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1929
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1930
context valid_trace
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1931
begin
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1932
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1933
lemma waiting_unique_pre: (* ddd *)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1934
  assumes h11: "thread \<in> set (wq s cs1)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1935
  and h12: "thread \<noteq> hd (wq s cs1)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1936
  assumes h21: "thread \<in> set (wq s cs2)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1937
  and h22: "thread \<noteq> hd (wq s cs2)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1938
  and neq12: "cs1 \<noteq> cs2"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1939
  shows "False"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1940
proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1941
  let "?Q" = "\<lambda> cs s. thread \<in> set (wq s cs) \<and> thread \<noteq> hd (wq s cs)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1942
  from h11 and h12 have q1: "?Q cs1 s" by simp
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1943
  from h21 and h22 have q2: "?Q cs2 s" by simp
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1944
  have nq1: "\<not> ?Q cs1 []" by (simp add:wq_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1945
  have nq2: "\<not> ?Q cs2 []" by (simp add:wq_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1946
  from p_split [of "?Q cs1", OF q1 nq1]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1947
  obtain t1 where lt1: "t1 < length s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1948
    and np1: "\<not> ?Q cs1 (moment t1 s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1949
    and nn1: "(\<forall>i'>t1. ?Q cs1 (moment i' s))" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1950
  from p_split [of "?Q cs2", OF q2 nq2]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1951
  obtain t2 where lt2: "t2 < length s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1952
    and np2: "\<not> ?Q cs2 (moment t2 s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1953
    and nn2: "(\<forall>i'>t2. ?Q cs2 (moment i' s))" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1954
  { fix s cs
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1955
    assume q: "?Q cs s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1956
    have "thread \<notin> runing s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1957
    proof
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1958
      assume "thread \<in> runing s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1959
      hence " \<forall>cs. \<not> (thread \<in> set (wq_fun (schs s) cs) \<and> 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1960
                 thread \<noteq> hd (wq_fun (schs s) cs))"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1961
        by (unfold runing_def s_waiting_def readys_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1962
      from this[rule_format, of cs] q 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1963
      show False by (simp add: wq_def) 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1964
    qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1965
  } note q_not_runing = this
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1966
  { fix t1 t2 cs1 cs2
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1967
    assume  lt1: "t1 < length s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1968
    and np1: "\<not> ?Q cs1 (moment t1 s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1969
    and nn1: "(\<forall>i'>t1. ?Q cs1 (moment i' s))"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1970
    and lt2: "t2 < length s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1971
    and np2: "\<not> ?Q cs2 (moment t2 s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1972
    and nn2: "(\<forall>i'>t2. ?Q cs2 (moment i' s))"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1973
    and lt12: "t1 < t2"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1974
    let ?t3 = "Suc t2" 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1975
    interpret ve2: valid_moment_e _ t2 using lt2
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1976
     by (unfold_locales, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1977
    let ?e = ve2.next_e
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1978
    have "t2 < ?t3" by simp
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1979
    from nn2 [rule_format, OF this] and ve2.trace_e
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1980
    have h1: "thread \<in> set (wq (?e#moment t2 s) cs2)" and
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1981
         h2: "thread \<noteq> hd (wq (?e#moment t2 s) cs2)" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1982
    have ?thesis
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1983
    proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1984
      have "thread \<in> runing (moment t2 s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1985
      proof(cases "thread \<in> set (wq (moment t2 s) cs2)")
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1986
        case True
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1987
        have "?e = V thread cs2"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1988
        proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1989
          have eq_th: "thread = hd (wq (moment t2 s) cs2)" 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1990
              using True and np2  by auto 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1991
          thus ?thesis
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1992
            using True h2 ve2.vat_moment_e.wq_out_inv by blast 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1993
        qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1994
        thus ?thesis
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1995
          using step.cases ve2.vat_moment_e.pip_e by auto 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1996
      next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1997
        case False
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1998
        hence "?e = P thread cs2"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  1999
          using h1 ve2.vat_moment_e.wq_in_inv by blast 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2000
        thus ?thesis
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2001
          using step.cases ve2.vat_moment_e.pip_e by auto 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2002
      qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2003
      moreover have "thread \<notin> runing (moment t2 s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2004
        by (rule q_not_runing[OF nn1[rule_format, OF lt12]])
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2005
      ultimately show ?thesis by simp
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2006
    qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2007
  } note lt_case = this
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2008
  show ?thesis
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2009
  proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2010
    { assume "t1 < t2"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2011
      from lt_case[OF lt1 np1 nn1 lt2 np2 nn2 this]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2012
      have ?thesis .
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2013
    } moreover {
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2014
      assume "t2 < t1"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2015
      from lt_case[OF lt2 np2 nn2 lt1 np1 nn1 this]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2016
      have ?thesis .
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2017
    } moreover { 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2018
      assume eq_12: "t1 = t2"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2019
      let ?t3 = "Suc t2"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2020
      interpret ve2: valid_moment_e _ t2 using lt2
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2021
        by (unfold_locales, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2022
      let ?e = ve2.next_e
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2023
      have "t2 < ?t3" by simp
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2024
      from nn2 [rule_format, OF this] and ve2.trace_e
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2025
      have h1: "thread \<in> set (wq (?e#moment t2 s) cs2)" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2026
      have lt_2: "t2 < ?t3" by simp
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2027
      from nn2 [rule_format, OF this] and ve2.trace_e
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2028
      have h1: "thread \<in> set (wq (?e#moment t2 s) cs2)" and
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2029
           h2: "thread \<noteq> hd (wq (?e#moment t2 s) cs2)" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2030
      from nn1[rule_format, OF lt_2[folded eq_12], unfolded ve2.trace_e[folded eq_12]] 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2031
           eq_12[symmetric]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2032
      have g1: "thread \<in> set (wq (?e#moment t1 s) cs1)" and
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2033
           g2: "thread \<noteq> hd (wq (?e#moment t1 s) cs1)" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2034
      have "?e = V thread cs2 \<or> ?e = P thread cs2"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2035
        using h1 h2 np2 ve2.vat_moment_e.wq_in_inv 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2036
              ve2.vat_moment_e.wq_out_inv by blast
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2037
      moreover have "?e = V thread cs1 \<or> ?e = P thread cs1"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2038
        using eq_12 g1 g2 np1 ve2.vat_moment_e.wq_in_inv 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2039
              ve2.vat_moment_e.wq_out_inv by blast
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2040
      ultimately have ?thesis using neq12 by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2041
    } ultimately show ?thesis using nat_neq_iff by blast 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2042
  qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2043
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2044
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2045
text {*
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2046
  This lemma is a simple corrolary of @{text "waiting_unique_pre"}.
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2047
*}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2048
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2049
lemma waiting_unique:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2050
  assumes "waiting s th cs1"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2051
  and "waiting s th cs2"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2052
  shows "cs1 = cs2"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2053
  using waiting_unique_pre assms
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2054
  unfolding wq_def s_waiting_def
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2055
  by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2056
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2057
end
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2058
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2059
lemma (in valid_trace_v)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2060
  preced_es [simp]: "preced th (e#s) = preced th s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2061
  by (unfold is_v preced_def, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2062
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2063
lemma the_preced_v[simp]: "the_preced (V th cs#s) = the_preced s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2064
proof
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2065
  fix th'
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2066
  show "the_preced (V th cs # s) th' = the_preced s th'"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2067
    by (unfold the_preced_def preced_def, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2068
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2069
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2070
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2071
lemma (in valid_trace_v)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2072
  the_preced_es: "the_preced (e#s) = the_preced s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2073
  by (unfold is_v preced_def, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2074
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2075
context valid_trace_p
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2076
begin
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2077
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2078
lemma not_holding_s_th_cs: "\<not> holding s th cs"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2079
proof
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2080
  assume otherwise: "holding s th cs"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2081
  from pip_e[unfolded is_p]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2082
  show False
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2083
  proof(cases)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2084
    case (thread_P)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2085
    moreover have "(Cs cs, Th th) \<in> RAG s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2086
      using otherwise cs_holding_def 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2087
            holding_eq th_not_in_wq by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2088
    ultimately show ?thesis by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2089
  qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2090
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2091
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2092
end
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2093
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2094
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2095
lemma (in valid_trace_v_n) finite_waiting_set:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2096
  "finite {(Th th', Cs cs) |th'. next_th s th cs th'}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2097
    by (simp add: waiting_set_eq)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2098
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2099
lemma (in valid_trace_v_n) finite_holding_set:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2100
  "finite {(Cs cs, Th th') |th'. next_th s th cs th'}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2101
    by (simp add: holding_set_eq)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2102
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2103
lemma (in valid_trace_v_e) finite_waiting_set:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2104
  "finite {(Th th', Cs cs) |th'. next_th s th cs th'}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2105
    by (simp add: waiting_set_eq)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2106
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2107
lemma (in valid_trace_v_e) finite_holding_set:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2108
  "finite {(Cs cs, Th th') |th'. next_th s th cs th'}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2109
    by (simp add: holding_set_eq)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2110
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2111
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2112
context valid_trace_v_e
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2113
begin 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2114
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2115
lemma 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2116
  acylic_RAG_kept:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2117
  assumes "acyclic (RAG s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2118
  shows "acyclic (RAG (e#s))"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2119
proof(rule acyclic_subset[OF assms])
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2120
  show "RAG (e # s) \<subseteq> RAG s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2121
      by (unfold RAG_es waiting_set_eq holding_set_eq, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2122
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2123
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2124
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2125
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2126
context valid_trace_v_n
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2127
begin 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2128
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2129
lemma waiting_taker: "waiting s taker cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2130
  apply (unfold s_waiting_def, fold wq_def, unfold wq_s_cs taker_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2131
  using eq_wq' th'_in_inv wq'_def by fastforce
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2132
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2133
lemma 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2134
  acylic_RAG_kept:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2135
  assumes "acyclic (RAG s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2136
  shows "acyclic (RAG (e#s))"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2137
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2138
  have "acyclic ((RAG s - {(Cs cs, Th th)} - {(Th taker, Cs cs)}) \<union> 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2139
                 {(Cs cs, Th taker)})" (is "acyclic (?A \<union> _)")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2140
  proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2141
    from assms
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2142
    have "acyclic ?A"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2143
       by (rule acyclic_subset, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2144
    moreover have "(Th taker, Cs cs) \<notin> ?A^*"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2145
    proof
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2146
      assume otherwise: "(Th taker, Cs cs) \<in> ?A^*"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2147
      hence "(Th taker, Cs cs) \<in> ?A^+"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2148
        by (unfold rtrancl_eq_or_trancl, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2149
      from tranclD[OF this]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2150
      obtain cs' where h: "(Th taker, Cs cs') \<in> ?A" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2151
                          "(Th taker, Cs cs') \<in> RAG s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2152
        by (unfold s_RAG_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2153
      from this(2) have "waiting s taker cs'" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2154
        by (unfold s_RAG_def, fold waiting_eq, auto)
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2155
      from waiting_unique[OF this waiting_taker] 
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2156
      have "cs' = cs" .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2157
      from h(1)[unfolded this] show False by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2158
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2159
    ultimately show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2160
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2161
  thus ?thesis 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2162
    by (unfold RAG_es waiting_set_eq holding_set_eq, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2163
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2164
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2165
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2166
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2167
context valid_trace_p_h
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2168
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2169
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2170
lemma 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2171
  acylic_RAG_kept:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2172
  assumes "acyclic (RAG s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2173
  shows "acyclic (RAG (e#s))"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2174
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2175
  have "acyclic (RAG s \<union> {(Cs cs, Th th)})" (is "acyclic (?A \<union> _)") 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2176
  proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2177
    from assms
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2178
    have "acyclic ?A"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2179
       by (rule acyclic_subset, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2180
    moreover have "(Th th, Cs cs) \<notin> ?A^*"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2181
    proof
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2182
      assume otherwise: "(Th th, Cs cs) \<in> ?A^*"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2183
      hence "(Th th, Cs cs) \<in> ?A^+"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2184
        by (unfold rtrancl_eq_or_trancl, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2185
      from tranclD[OF this]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2186
      obtain cs' where h: "(Th th, Cs cs') \<in> RAG s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2187
        by (unfold s_RAG_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2188
      hence "waiting s th cs'" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2189
        by (unfold s_RAG_def, fold waiting_eq, auto)
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2190
      with th_not_waiting show False by auto 
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2191
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2192
    ultimately show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2193
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2194
  thus ?thesis by (unfold RAG_es, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2195
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2196
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2197
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2198
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2199
context valid_trace_p_w
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2200
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2201
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2202
lemma 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2203
  acylic_RAG_kept:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2204
  assumes "acyclic (RAG s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2205
  shows "acyclic (RAG (e#s))"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2206
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2207
  have "acyclic (RAG s \<union> {(Th th, Cs cs)})" (is "acyclic (?A \<union> _)") 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2208
  proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2209
    from assms
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2210
    have "acyclic ?A"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2211
       by (rule acyclic_subset, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2212
    moreover have "(Cs cs, Th th) \<notin> ?A^*"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2213
    proof
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2214
      assume otherwise: "(Cs cs, Th th) \<in> ?A^*"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2215
      from pip_e[unfolded is_p]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2216
      show False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2217
      proof(cases)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2218
        case (thread_P)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2219
        moreover from otherwise have "(Cs cs, Th th) \<in> ?A^+"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2220
            by (unfold rtrancl_eq_or_trancl, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2221
        ultimately show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2222
      qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2223
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2224
    ultimately show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2225
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2226
  thus ?thesis by (unfold RAG_es, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2227
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2228
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2229
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2230
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2231
context valid_trace
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2232
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2233
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2234
lemma acyclic_RAG:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2235
  shows "acyclic (RAG s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2236
proof(induct rule:ind)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2237
  case Nil
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2238
  show ?case 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2239
  by (auto simp: s_RAG_def cs_waiting_def 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2240
                   cs_holding_def wq_def acyclic_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2241
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2242
  case (Cons s e)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2243
  interpret vt_e: valid_trace_e s e using Cons by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2244
  show ?case
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2245
  proof(cases e)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2246
    case (Create th prio)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2247
    interpret vt: valid_trace_create s e th prio using Create
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2248
      by (unfold_locales, simp)
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2249
    show ?thesis using Cons by simp 
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2250
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2251
    case (Exit th)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2252
    interpret vt: valid_trace_exit s e th using Exit
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2253
      by (unfold_locales, simp)
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2254
    show ?thesis using Cons by simp
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2255
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2256
    case (P th cs)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2257
    interpret vt: valid_trace_p s e th cs using P
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2258
      by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2259
    show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2260
    proof(cases "wq s cs = []")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2261
      case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2262
      then interpret vt_h: valid_trace_p_h s e th cs
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2263
        by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2264
      show ?thesis using Cons by (simp add: vt_h.acylic_RAG_kept) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2265
    next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2266
      case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2267
      then interpret vt_w: valid_trace_p_w s e th cs
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2268
        by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2269
      show ?thesis using Cons by (simp add: vt_w.acylic_RAG_kept) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2270
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2271
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2272
    case (V th cs)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2273
    interpret vt: valid_trace_v s e th cs using V
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2274
      by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2275
    show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2276
    proof(cases "vt.rest = []")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2277
      case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2278
      then interpret vt_e: valid_trace_v_e s e th cs
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2279
        by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2280
      show ?thesis by (simp add: Cons.hyps(2) vt_e.acylic_RAG_kept) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2281
    next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2282
      case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2283
      then interpret vt_n: valid_trace_v_n s e th cs
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2284
        by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2285
      show ?thesis by (simp add: Cons.hyps(2) vt_n.acylic_RAG_kept) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2286
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2287
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2288
    case (Set th prio)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2289
    interpret vt: valid_trace_set s e th prio using Set
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2290
      by (unfold_locales, simp)
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2291
    show ?thesis using Cons by simp 
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2292
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2293
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2294
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2295
end
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2296
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2297
section {* RAG is single-valued *}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2298
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2299
context valid_trace
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2300
begin
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2301
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2302
lemma unique_RAG: "\<lbrakk>(n, n1) \<in> RAG s; (n, n2) \<in> RAG s\<rbrakk> \<Longrightarrow> n1 = n2"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2303
  apply(unfold s_RAG_def, auto, fold waiting_eq holding_eq)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2304
  by(auto elim:waiting_unique held_unique)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2305
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2306
lemma sgv_RAG: "single_valued (RAG s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2307
  using unique_RAG by (auto simp:single_valued_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2308
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2309
end
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2310
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2311
section {* RAG is well-founded *}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2312
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2313
context valid_trace
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2314
begin
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2315
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2316
lemma wf_RAG: "wf (RAG s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2317
proof(rule finite_acyclic_wf)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2318
  from finite_RAG show "finite (RAG s)" .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2319
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2320
  from acyclic_RAG show "acyclic (RAG s)" .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2321
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2322
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2323
lemma wf_RAG_converse: 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2324
  shows "wf ((RAG s)^-1)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2325
proof(rule finite_acyclic_wf_converse)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2326
  from finite_RAG 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2327
  show "finite (RAG s)" .
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2328
next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2329
  from acyclic_RAG
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2330
  show "acyclic (RAG s)" .
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2331
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2332
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2333
end
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2334
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2335
section {* RAG forms a forest (or tree) *}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2336
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2337
context valid_trace
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2338
begin
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2339
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2340
lemma rtree_RAG: "rtree (RAG s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2341
  using sgv_RAG acyclic_RAG
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2342
  by (unfold rtree_def rtree_axioms_def sgv_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2343
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2344
end
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2345
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2346
sublocale valid_trace < rtree_RAG: rtree "RAG s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2347
  using rtree_RAG .
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2348
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2349
sublocale valid_trace < fsbtRAGs : fsubtree "RAG s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2350
proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2351
  show "fsubtree (RAG s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2352
  proof(intro_locales)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2353
    show "fbranch (RAG s)" using finite_fbranchI[OF finite_RAG] .
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2354
  next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2355
    show "fsubtree_axioms (RAG s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2356
    proof(unfold fsubtree_axioms_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2357
      from wf_RAG show "wf (RAG s)" .
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2358
    qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2359
  qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2360
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2361
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2362
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2363
section {* Derived properties for parts of RAG *}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2364
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2365
context valid_trace
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2366
begin
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2367
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2368
lemma acyclic_tRAG: "acyclic (tRAG s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2369
proof(unfold tRAG_def, rule acyclic_compose)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2370
  show "acyclic (RAG s)" using acyclic_RAG .
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2371
next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2372
  show "wRAG s \<subseteq> RAG s" unfolding RAG_split by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2373
next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2374
  show "hRAG s \<subseteq> RAG s" unfolding RAG_split by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2375
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2376
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2377
lemma sgv_wRAG: "single_valued (wRAG s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2378
  using waiting_unique
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2379
  by (unfold single_valued_def wRAG_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2380
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2381
lemma sgv_hRAG: "single_valued (hRAG s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2382
  using held_unique 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2383
  by (unfold single_valued_def hRAG_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2384
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2385
lemma sgv_tRAG: "single_valued (tRAG s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2386
  by (unfold tRAG_def, rule single_valued_relcomp, 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2387
              insert sgv_wRAG sgv_hRAG, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2388
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2389
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2390
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2391
sublocale valid_trace < rtree_s: rtree "tRAG s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2392
proof(unfold_locales)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2393
  from sgv_tRAG show "single_valued (tRAG s)" .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2394
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2395
  from acyclic_tRAG show "acyclic (tRAG s)" .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2396
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2397
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2398
sublocale valid_trace < fsbttRAGs: fsubtree "tRAG s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2399
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2400
  have "fsubtree (tRAG s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2401
  proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2402
    have "fbranch (tRAG s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2403
    proof(unfold tRAG_def, rule fbranch_compose)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2404
        show "fbranch (wRAG s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2405
        proof(rule finite_fbranchI)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2406
           from finite_RAG show "finite (wRAG s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2407
           by (unfold RAG_split, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2408
        qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2409
    next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2410
        show "fbranch (hRAG s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2411
        proof(rule finite_fbranchI)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2412
           from finite_RAG 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2413
           show "finite (hRAG s)" by (unfold RAG_split, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2414
        qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2415
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2416
    moreover have "wf (tRAG s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2417
    proof(rule wf_subset)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2418
      show "wf (RAG s O RAG s)" using wf_RAG
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2419
        by (fold wf_comp_self, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2420
    next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2421
      show "tRAG s \<subseteq> (RAG s O RAG s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2422
        by (unfold tRAG_alt_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2423
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2424
    ultimately show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2425
      by (unfold fsubtree_def fsubtree_axioms_def,auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2426
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2427
  from this[folded tRAG_def] show "fsubtree (tRAG s)" .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2428
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2429
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2430
lemma tRAG_nodeE:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2431
  assumes "(n1, n2) \<in> tRAG s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2432
  obtains th1 th2 where "n1 = Th th1" "n2 = Th th2"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2433
  using assms
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2434
  by (auto simp: tRAG_def wRAG_def hRAG_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2435
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2436
lemma tRAG_ancestorsE:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2437
  assumes "x \<in> ancestors (tRAG s) u"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2438
  obtains th where "x = Th th"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2439
proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2440
  from assms have "(u, x) \<in> (tRAG s)^+" 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2441
      by (unfold ancestors_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2442
  from tranclE[OF this] obtain c where "(c, x) \<in> tRAG s" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2443
  then obtain th where "x = Th th"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2444
    by (unfold tRAG_alt_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2445
  from that[OF this] show ?thesis .
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2446
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2447
                   
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2448
lemma subtree_nodeE:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2449
  assumes "n \<in> subtree (tRAG s) (Th th)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2450
  obtains th1 where "n = Th th1"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2451
proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2452
  show ?thesis
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2453
  proof(rule subtreeE[OF assms])
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2454
    assume "n = Th th"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2455
    from that[OF this] show ?thesis .
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2456
  next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2457
    assume "Th th \<in> ancestors (tRAG s) n"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2458
    hence "(n, Th th) \<in> (tRAG s)^+" by (auto simp:ancestors_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2459
    hence "\<exists> th1. n = Th th1"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2460
    proof(induct)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2461
      case (base y)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2462
      from tRAG_nodeE[OF this] show ?case by metis
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2463
    next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2464
      case (step y z)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2465
      thus ?case by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2466
    qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2467
    with that show ?thesis by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2468
  qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2469
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2470
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2471
lemma tRAG_star_RAG: "(tRAG s)^* \<subseteq> (RAG s)^*"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2472
proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2473
  have "(wRAG s O hRAG s)^* \<subseteq> (RAG s O RAG s)^*" 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2474
    by (rule rtrancl_mono, auto simp:RAG_split)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2475
  also have "... \<subseteq> ((RAG s)^*)^*"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2476
    by (rule rtrancl_mono, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2477
  also have "... = (RAG s)^*" by simp
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2478
  finally show ?thesis by (unfold tRAG_def, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2479
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2480
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2481
lemma tRAG_subtree_RAG: "subtree (tRAG s) x \<subseteq> subtree (RAG s) x"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2482
proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2483
  { fix a
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2484
    assume "a \<in> subtree (tRAG s) x"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2485
    hence "(a, x) \<in> (tRAG s)^*" by (auto simp:subtree_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2486
    with tRAG_star_RAG
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2487
    have "(a, x) \<in> (RAG s)^*" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2488
    hence "a \<in> subtree (RAG s) x" by (auto simp:subtree_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2489
  } thus ?thesis by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2490
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2491
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2492
lemma tRAG_trancl_eq:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2493
   "{th'. (Th th', Th th)  \<in> (tRAG s)^+} = 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2494
    {th'. (Th th', Th th)  \<in> (RAG s)^+}"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2495
   (is "?L = ?R")
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2496
proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2497
  { fix th'
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2498
    assume "th' \<in> ?L"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2499
    hence "(Th th', Th th) \<in> (tRAG s)^+" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2500
    from tranclD[OF this]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2501
    obtain z where h: "(Th th', z) \<in> tRAG s" "(z, Th th) \<in> (tRAG s)\<^sup>*" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2502
    from tRAG_subtree_RAG and this(2)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2503
    have "(z, Th th) \<in> (RAG s)^*" by (meson subsetCE tRAG_star_RAG) 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2504
    moreover from h(1) have "(Th th', z) \<in> (RAG s)^+" using tRAG_alt_def by auto 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2505
    ultimately have "th' \<in> ?R"  by auto 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2506
  } moreover 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2507
  { fix th'
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2508
    assume "th' \<in> ?R"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2509
    hence "(Th th', Th th) \<in> (RAG s)^+" by (auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2510
    from plus_rpath[OF this]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2511
    obtain xs where rp: "rpath (RAG s) (Th th') xs (Th th)" "xs \<noteq> []" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2512
    hence "(Th th', Th th) \<in> (tRAG s)^+"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2513
    proof(induct xs arbitrary:th' th rule:length_induct)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2514
      case (1 xs th' th)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2515
      then obtain x1 xs1 where Cons1: "xs = x1#xs1" by (cases xs, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2516
      show ?case
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2517
      proof(cases "xs1")
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2518
        case Nil
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2519
        from 1(2)[unfolded Cons1 Nil]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2520
        have rp: "rpath (RAG s) (Th th') [x1] (Th th)" .
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2521
        hence "(Th th', x1) \<in> (RAG s)" 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2522
          by (cases, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2523
        then obtain cs where "x1 = Cs cs" 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2524
              by (unfold s_RAG_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2525
        from rpath_nnl_lastE[OF rp[unfolded this]]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2526
        show ?thesis by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2527
      next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2528
        case (Cons x2 xs2)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2529
        from 1(2)[unfolded Cons1[unfolded this]]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2530
        have rp: "rpath (RAG s) (Th th') (x1 # x2 # xs2) (Th th)" .
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2531
        from rpath_edges_on[OF this]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2532
        have eds: "edges_on (Th th' # x1 # x2 # xs2) \<subseteq> RAG s" .
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2533
        have "(Th th', x1) \<in> edges_on (Th th' # x1 # x2 # xs2)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2534
            by (simp add: edges_on_unfold)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2535
        with eds have rg1: "(Th th', x1) \<in> RAG s" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2536
        then obtain cs1 where eq_x1: "x1 = Cs cs1" by (unfold s_RAG_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2537
        have "(x1, x2) \<in> edges_on (Th th' # x1 # x2 # xs2)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2538
            by (simp add: edges_on_unfold)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2539
        from this eds
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2540
        have rg2: "(x1, x2) \<in> RAG s" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2541
        from this[unfolded eq_x1] 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2542
        obtain th1 where eq_x2: "x2 = Th th1" by (unfold s_RAG_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2543
        from rg1[unfolded eq_x1] rg2[unfolded eq_x1 eq_x2]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2544
        have rt1: "(Th th', Th th1) \<in> tRAG s" by (unfold tRAG_alt_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2545
        from rp have "rpath (RAG s) x2 xs2 (Th th)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2546
           by  (elim rpath_ConsE, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2547
        from this[unfolded eq_x2] have rp': "rpath (RAG s) (Th th1) xs2 (Th th)" .
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2548
        show ?thesis
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2549
        proof(cases "xs2 = []")
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2550
          case True
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2551
          from rpath_nilE[OF rp'[unfolded this]]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2552
          have "th1 = th" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2553
          from rt1[unfolded this] show ?thesis by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2554
        next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2555
          case False
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2556
          from 1(1)[rule_format, OF _ rp' this, unfolded Cons1 Cons]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2557
          have "(Th th1, Th th) \<in> (tRAG s)\<^sup>+" by simp
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2558
          with rt1 show ?thesis by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2559
        qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2560
      qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2561
    qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2562
    hence "th' \<in> ?L" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2563
  } ultimately show ?thesis by blast
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2564
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2565
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2566
lemma tRAG_trancl_eq_Th:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2567
   "{Th th' | th'. (Th th', Th th)  \<in> (tRAG s)^+} = 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2568
    {Th th' | th'. (Th th', Th th)  \<in> (RAG s)^+}"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2569
    using tRAG_trancl_eq by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2570
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2571
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2572
lemma tRAG_Field:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2573
  "Field (tRAG s) \<subseteq> Field (RAG s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2574
  by (unfold tRAG_alt_def Field_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2575
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2576
lemma tRAG_mono:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2577
  assumes "RAG s' \<subseteq> RAG s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2578
  shows "tRAG s' \<subseteq> tRAG s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2579
  using assms 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2580
  by (unfold tRAG_alt_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2581
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2582
lemma tRAG_subtree_eq: 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2583
   "(subtree (tRAG s) (Th th)) = {Th th' | th'. Th th'  \<in> (subtree (RAG s) (Th th))}"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2584
   (is "?L = ?R")
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2585
proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2586
  { fix n 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2587
    assume h: "n \<in> ?L"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2588
    hence "n \<in> ?R"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2589
    by (smt mem_Collect_eq subsetCE subtree_def subtree_nodeE tRAG_subtree_RAG) 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2590
  } moreover {
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2591
    fix n
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2592
    assume "n \<in> ?R"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2593
    then obtain th' where h: "n = Th th'" "(Th th', Th th) \<in> (RAG s)^*"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2594
      by (auto simp:subtree_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2595
    from rtranclD[OF this(2)]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2596
    have "n \<in> ?L"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2597
    proof
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2598
      assume "Th th' \<noteq> Th th \<and> (Th th', Th th) \<in> (RAG s)\<^sup>+"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2599
      with h have "n \<in> {Th th' | th'. (Th th', Th th)  \<in> (RAG s)^+}" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2600
      thus ?thesis using subtree_def tRAG_trancl_eq by fastforce
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2601
    qed (insert h, auto simp:subtree_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2602
  } ultimately show ?thesis by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2603
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2604
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2605
lemma threads_set_eq: 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2606
   "the_thread ` (subtree (tRAG s) (Th th)) = 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2607
                  {th'. Th th' \<in> (subtree (RAG s) (Th th))}" (is "?L = ?R")
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2608
   by (auto intro:rev_image_eqI simp:tRAG_subtree_eq)
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2609
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2610
context valid_trace
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2611
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2612
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2613
lemma RAG_tRAG_transfer:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2614
  assumes  "RAG s' = RAG s \<union> {(Th th, Cs cs)}"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2615
  and "(Cs cs, Th th'') \<in> RAG s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2616
  shows "tRAG s' = tRAG s \<union> {(Th th, Th th'')}" (is "?L = ?R")
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2617
proof -
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2618
  { fix n1 n2
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2619
    assume "(n1, n2) \<in> ?L"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2620
    from this[unfolded tRAG_alt_def]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2621
    obtain th1 th2 cs' where 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2622
      h: "n1 = Th th1" "n2 = Th th2" 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2623
         "(Th th1, Cs cs') \<in> RAG s'"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2624
         "(Cs cs', Th th2) \<in> RAG s'" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2625
    from h(4) and assms(1) have cs_in: "(Cs cs', Th th2) \<in> RAG s" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2626
    from h(3) and assms(1) 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2627
    have "(Th th1, Cs cs') = (Th th, Cs cs) \<or> 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2628
          (Th th1, Cs cs') \<in> RAG s" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2629
    hence "(n1, n2) \<in> ?R"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2630
    proof
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2631
      assume h1: "(Th th1, Cs cs') = (Th th, Cs cs)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2632
      hence eq_th1: "th1 = th" by simp
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2633
      moreover have "th2 = th''"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2634
      proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2635
        from h1 have "cs' = cs" by simp
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2636
        from assms(2) cs_in[unfolded this]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2637
        show ?thesis using unique_RAG by auto 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2638
      qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2639
      ultimately show ?thesis using h(1,2) by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2640
    next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2641
      assume "(Th th1, Cs cs') \<in> RAG s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2642
      with cs_in have "(Th th1, Th th2) \<in> tRAG s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2643
        by (unfold tRAG_alt_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2644
      from this[folded h(1, 2)] show ?thesis by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2645
    qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2646
  } moreover {
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2647
    fix n1 n2
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2648
    assume "(n1, n2) \<in> ?R"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2649
    hence "(n1, n2) \<in>tRAG s \<or> (n1, n2) = (Th th, Th th'')" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2650
    hence "(n1, n2) \<in> ?L" 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2651
    proof
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2652
      assume "(n1, n2) \<in> tRAG s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2653
      moreover have "... \<subseteq> ?L"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2654
      proof(rule tRAG_mono)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2655
        show "RAG s \<subseteq> RAG s'" by (unfold assms(1), auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2656
      qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2657
      ultimately show ?thesis by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2658
    next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2659
      assume eq_n: "(n1, n2) = (Th th, Th th'')"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2660
      from assms(1, 2) have "(Cs cs, Th th'') \<in> RAG s'" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2661
      moreover have "(Th th, Cs cs) \<in> RAG s'" using assms(1) by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2662
      ultimately show ?thesis 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2663
        by (unfold eq_n tRAG_alt_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2664
    qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2665
  } ultimately show ?thesis by auto
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2666
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2667
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2668
lemma subtree_tRAG_thread:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2669
  assumes "th \<in> threads s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2670
  shows "subtree (tRAG s) (Th th) \<subseteq> Th ` threads s" (is "?L \<subseteq> ?R")
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2671
proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2672
  have "?L = {Th th' |th'. Th th' \<in> subtree (RAG s) (Th th)}"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2673
    by (unfold tRAG_subtree_eq, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2674
  also have "... \<subseteq> ?R"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2675
  proof
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2676
    fix x
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2677
    assume "x \<in> {Th th' |th'. Th th' \<in> subtree (RAG s) (Th th)}"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2678
    then obtain th' where h: "x = Th th'" "Th th' \<in> subtree (RAG s) (Th th)" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2679
    from this(2)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2680
    show "x \<in> ?R"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2681
    proof(cases rule:subtreeE)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2682
      case 1
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2683
      thus ?thesis by (simp add: assms h(1)) 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2684
    next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2685
      case 2
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2686
      thus ?thesis by (metis ancestors_Field dm_RAG_threads h(1) image_eqI) 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2687
    qed
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2688
  qed
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2689
  finally show ?thesis .
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2690
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2691
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2692
lemma dependants_alt_def:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2693
  "dependants s th = {th'. (Th th', Th th) \<in> (tRAG s)^+}"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2694
  by (metis eq_RAG s_dependants_def tRAG_trancl_eq)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2695
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2696
lemma dependants_alt_def1:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2697
  "dependants (s::state) th = {th'. (Th th', Th th) \<in> (RAG s)^+}"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2698
  using dependants_alt_def tRAG_trancl_eq by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2699
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2700
end
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2701
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2702
section {* Chain to readys *}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2703
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2704
context valid_trace
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2705
begin
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2706
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2707
lemma chain_building:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2708
  assumes "node \<in> Domain (RAG s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2709
  obtains th' where "th' \<in> readys s" "(node, Th th') \<in> (RAG s)^+"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2710
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2711
  from assms have "node \<in> Range ((RAG s)^-1)" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2712
  from wf_base[OF wf_RAG_converse this]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2713
  obtain b where h_b: "(b, node) \<in> ((RAG s)\<inverse>)\<^sup>+" "\<forall>c. (c, b) \<notin> (RAG s)\<inverse>" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2714
  obtain th' where eq_b: "b = Th th'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2715
  proof(cases b)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2716
    case (Cs cs)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2717
    from h_b(1)[unfolded trancl_converse] 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2718
    have "(node, b) \<in> ((RAG s)\<^sup>+)" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2719
    from tranclE[OF this]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2720
    obtain n where "(n, b) \<in> RAG s" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2721
    from this[unfolded Cs]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2722
    obtain th1 where "waiting s th1 cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2723
      by (unfold s_RAG_def, fold waiting_eq, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2724
    from waiting_holding[OF this]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2725
    obtain th2 where "holding s th2 cs" .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2726
    hence "(Cs cs, Th th2) \<in> RAG s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2727
      by (unfold s_RAG_def, fold holding_eq, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2728
    with h_b(2)[unfolded Cs, rule_format]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2729
    have False by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2730
    thus ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2731
  qed auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2732
  have "th' \<in> readys s" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2733
  proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2734
    from h_b(2)[unfolded eq_b]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2735
    have "\<forall>cs. \<not> waiting s th' cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2736
      by (unfold s_RAG_def, fold waiting_eq, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2737
    moreover have "th' \<in> threads s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2738
    proof(rule rg_RAG_threads)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2739
      from tranclD[OF h_b(1), unfolded eq_b]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2740
      obtain z where "(z, Th th') \<in> (RAG s)" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2741
      thus "Th th' \<in> Range (RAG s)" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2742
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2743
    ultimately show ?thesis by (auto simp:readys_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2744
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2745
  moreover have "(node, Th th') \<in> (RAG s)^+" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2746
    using h_b(1)[unfolded trancl_converse] eq_b by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2747
  ultimately show ?thesis using that by metis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2748
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2749
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2750
text {* \noindent
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2751
  The following is just an instance of @{text "chain_building"}.
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2752
*}                    
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2753
lemma th_chain_to_ready:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2754
  assumes th_in: "th \<in> threads s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2755
  shows "th \<in> readys s \<or> (\<exists> th'. th' \<in> readys s \<and> (Th th, Th th') \<in> (RAG s)^+)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2756
proof(cases "th \<in> readys s")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2757
  case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2758
  thus ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2759
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2760
  case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2761
  from False and th_in have "Th th \<in> Domain (RAG s)" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2762
    by (auto simp:readys_def s_waiting_def s_RAG_def wq_def cs_waiting_def Domain_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2763
  from chain_building [rule_format, OF this]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2764
  show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2765
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2766
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2767
lemma finite_subtree_threads:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2768
    "finite {th'. Th th' \<in> subtree (RAG s) (Th th)}" (is "finite ?A")
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2769
proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2770
  have "?A = the_thread ` {Th th' | th' . Th th' \<in> subtree (RAG s) (Th th)}"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2771
        by (auto, insert image_iff, fastforce)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2772
  moreover have "finite {Th th' | th' . Th th' \<in> subtree (RAG s) (Th th)}"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2773
        (is "finite ?B")
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2774
  proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2775
     have "?B = (subtree (RAG s) (Th th)) \<inter> {Th th' | th'. True}"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2776
      by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2777
     moreover have "... \<subseteq> (subtree (RAG s) (Th th))" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2778
     moreover have "finite ..." by (simp add: fsbtRAGs.finite_subtree) 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2779
     ultimately show ?thesis by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2780
  qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2781
  ultimately show ?thesis by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2782
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2783
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2784
lemma runing_unique:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2785
  assumes runing_1: "th1 \<in> runing s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2786
  and runing_2: "th2 \<in> runing s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2787
  shows "th1 = th2"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2788
proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2789
  from runing_1 and runing_2 have "cp s th1 = cp s th2"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2790
    unfolding runing_def by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2791
  from this[unfolded cp_alt_def]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2792
  have eq_max: 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2793
    "Max (the_preced s ` {th'. Th th' \<in> subtree (RAG s) (Th th1)}) =
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2794
     Max (the_preced s ` {th'. Th th' \<in> subtree (RAG s) (Th th2)})" 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2795
        (is "Max ?L = Max ?R") .
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2796
  have "Max ?L \<in> ?L"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2797
  proof(rule Max_in)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2798
    show "finite ?L" by (simp add: finite_subtree_threads) 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2799
  next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2800
    show "?L \<noteq> {}" using subtree_def by fastforce 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2801
  qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2802
  then obtain th1' where 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2803
    h_1: "Th th1' \<in> subtree (RAG s) (Th th1)" "the_preced s th1' = Max ?L"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2804
    by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2805
  have "Max ?R \<in> ?R"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2806
  proof(rule Max_in)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2807
    show "finite ?R" by (simp add: finite_subtree_threads)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2808
  next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2809
    show "?R \<noteq> {}" using subtree_def by fastforce 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2810
  qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2811
  then obtain th2' where 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2812
    h_2: "Th th2' \<in> subtree (RAG s) (Th th2)" "the_preced s th2' = Max ?R"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2813
    by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2814
  have "th1' = th2'"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2815
  proof(rule preced_unique)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2816
    from h_1(1)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2817
    show "th1' \<in> threads s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2818
    proof(cases rule:subtreeE)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2819
      case 1
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2820
      hence "th1' = th1" by simp
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2821
      with runing_1 show ?thesis by (auto simp:runing_def readys_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2822
    next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2823
      case 2
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2824
      from this(2)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2825
      have "(Th th1', Th th1) \<in> (RAG s)^+" by (auto simp:ancestors_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2826
      from tranclD[OF this]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2827
      have "(Th th1') \<in> Domain (RAG s)" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2828
      from dm_RAG_threads[OF this] show ?thesis .
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2829
    qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2830
  next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2831
    from h_2(1)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2832
    show "th2' \<in> threads s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2833
    proof(cases rule:subtreeE)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2834
      case 1
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2835
      hence "th2' = th2" by simp
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2836
      with runing_2 show ?thesis by (auto simp:runing_def readys_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2837
    next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2838
      case 2
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2839
      from this(2)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2840
      have "(Th th2', Th th2) \<in> (RAG s)^+" by (auto simp:ancestors_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2841
      from tranclD[OF this]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2842
      have "(Th th2') \<in> Domain (RAG s)" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2843
      from dm_RAG_threads[OF this] show ?thesis .
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2844
    qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2845
  next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2846
    have "the_preced s th1' = the_preced s th2'" 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2847
     using eq_max h_1(2) h_2(2) by metis
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2848
    thus "preced th1' s = preced th2' s" by (simp add:the_preced_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2849
  qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2850
  from h_1(1)[unfolded this]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2851
  have star1: "(Th th2', Th th1) \<in> (RAG s)^*" by (auto simp:subtree_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2852
  from h_2(1)[unfolded this]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2853
  have star2: "(Th th2', Th th2) \<in> (RAG s)^*" by (auto simp:subtree_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2854
  from star_rpath[OF star1] obtain xs1 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2855
    where rp1: "rpath (RAG s) (Th th2') xs1 (Th th1)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2856
    by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2857
  from star_rpath[OF star2] obtain xs2 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2858
    where rp2: "rpath (RAG s) (Th th2') xs2 (Th th2)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2859
    by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2860
  from rp1 rp2
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2861
  show ?thesis
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2862
  proof(cases)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2863
    case (less_1 xs')
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2864
    moreover have "xs' = []"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2865
    proof(rule ccontr)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2866
      assume otherwise: "xs' \<noteq> []"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2867
      from rpath_plus[OF less_1(3) this]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2868
      have "(Th th1, Th th2) \<in> (RAG s)\<^sup>+" .
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2869
      from tranclD[OF this]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2870
      obtain cs where "waiting s th1 cs"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2871
        by (unfold s_RAG_def, fold waiting_eq, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2872
      with runing_1 show False
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2873
        by (unfold runing_def readys_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2874
    qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2875
    ultimately have "xs2 = xs1" by simp
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2876
    from rpath_dest_eq[OF rp1 rp2[unfolded this]]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2877
    show ?thesis by simp
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2878
  next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2879
    case (less_2 xs')
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2880
    moreover have "xs' = []"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2881
    proof(rule ccontr)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2882
      assume otherwise: "xs' \<noteq> []"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2883
      from rpath_plus[OF less_2(3) this]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2884
      have "(Th th2, Th th1) \<in> (RAG s)\<^sup>+" .
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2885
      from tranclD[OF this]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2886
      obtain cs where "waiting s th2 cs"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2887
        by (unfold s_RAG_def, fold waiting_eq, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2888
      with runing_2 show False
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2889
        by (unfold runing_def readys_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2890
    qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2891
    ultimately have "xs2 = xs1" by simp
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2892
    from rpath_dest_eq[OF rp1 rp2[unfolded this]]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2893
    show ?thesis by simp
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2894
  qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2895
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2896
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2897
lemma card_runing: "card (runing s) \<le> 1"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2898
proof(cases "runing s = {}")
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2899
  case True
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2900
  thus ?thesis by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2901
next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2902
  case False
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2903
  then obtain th where [simp]: "th \<in> runing s" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2904
  from runing_unique[OF this]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2905
  have "runing s = {th}" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2906
  thus ?thesis by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2907
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2908
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2909
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2910
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2911
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2912
section {* Relating @{term cp} and @{term the_preced} and @{term preced} *}
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2913
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2914
context valid_trace
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2915
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  2916
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2917
lemma le_cp:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2918
  shows "preced th s \<le> cp s th"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2919
  proof(unfold cp_alt_def, rule Max_ge)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2920
    show "finite (the_preced s ` {th'. Th th' \<in> subtree (RAG s) (Th th)})"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2921
      by (simp add: finite_subtree_threads)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2922
  next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2923
    show "preced th s \<in> the_preced s ` {th'. Th th' \<in> subtree (RAG s) (Th th)}"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2924
      by (simp add: subtree_def the_preced_def)   
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2925
  qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2926
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2927
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2928
lemma cp_le:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2929
  assumes th_in: "th \<in> threads s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2930
  shows "cp s th \<le> Max (the_preced s ` threads s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2931
proof(unfold cp_alt_def, rule Max_f_mono)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2932
  show "finite (threads s)" by (simp add: finite_threads) 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2933
next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2934
  show " {th'. Th th' \<in> subtree (RAG s) (Th th)} \<noteq> {}"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2935
    using subtree_def by fastforce
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2936
next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2937
  show "{th'. Th th' \<in> subtree (RAG s) (Th th)} \<subseteq> threads s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2938
    using assms
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2939
    by (smt Domain.DomainI dm_RAG_threads mem_Collect_eq 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2940
        node.inject(1) rtranclD subsetI subtree_def trancl_domain) 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2941
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2942
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2943
lemma max_cp_eq: 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2944
  shows "Max ((cp s) ` threads s) = Max (the_preced s ` threads s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2945
  (is "?L = ?R")
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2946
proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2947
  have "?L \<le> ?R" 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2948
  proof(cases "threads s = {}")
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2949
    case False
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2950
    show ?thesis 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2951
      by (rule Max.boundedI, 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2952
          insert cp_le, 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2953
          auto simp:finite_threads False)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2954
  qed auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2955
  moreover have "?R \<le> ?L"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2956
    by (rule Max_fg_mono, 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2957
        simp add: finite_threads,
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2958
        simp add: le_cp the_preced_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2959
  ultimately show ?thesis by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2960
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2961
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2962
lemma threads_alt_def:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2963
  "(threads s) = (\<Union> th \<in> readys s. {th'. Th th' \<in> subtree (RAG s) (Th th)})"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2964
    (is "?L = ?R")
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2965
proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2966
  { fix th1
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2967
    assume "th1 \<in> ?L"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2968
    from th_chain_to_ready[OF this]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2969
    have "th1 \<in> readys s \<or> (\<exists>th'. th' \<in> readys s \<and> (Th th1, Th th') \<in> (RAG s)\<^sup>+)" .
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2970
    hence "th1 \<in> ?R" by (auto simp:subtree_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2971
  } moreover 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2972
  { fix th'
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2973
    assume "th' \<in> ?R"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2974
    then obtain th where h: "th \<in> readys s" " Th th' \<in> subtree (RAG s) (Th th)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2975
      by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2976
    from this(2)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2977
    have "th' \<in> ?L" 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2978
    proof(cases rule:subtreeE)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2979
      case 1
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2980
      with h(1) show ?thesis by (auto simp:readys_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2981
    next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2982
      case 2
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2983
      from tranclD[OF this(2)[unfolded ancestors_def, simplified]]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2984
      have "Th th' \<in> Domain (RAG s)" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2985
      from dm_RAG_threads[OF this]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2986
      show ?thesis .
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2987
    qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2988
  } ultimately show ?thesis by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2989
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2990
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2991
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2992
text {* (* ccc *) \noindent
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2993
  Since the current precedence of the threads in ready queue will always be boosted,
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2994
  there must be one inside it has the maximum precedence of the whole system. 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2995
*}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2996
lemma max_cp_readys_threads:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2997
  shows "Max (cp s ` readys s) = Max (cp s ` threads s)" (is "?L = ?R")
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2998
proof(cases "readys s = {}")
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  2999
  case False
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3000
  have "?R = Max (the_preced s ` threads s)" by (unfold max_cp_eq, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3001
  also have "... = 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3002
    Max (the_preced s ` (\<Union>th\<in>readys s. {th'. Th th' \<in> subtree (RAG s) (Th th)}))" 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3003
         by (unfold threads_alt_def, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3004
  also have "... = 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3005
    Max ((\<Union>th\<in>readys s. the_preced s ` {th'. Th th' \<in> subtree (RAG s) (Th th)}))"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3006
          by (unfold image_UN, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3007
  also have "... = 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3008
    Max (Max ` (\<lambda>th. the_preced s ` {th'. Th th' \<in> subtree (RAG s) (Th th)}) ` readys s)" 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3009
  proof(rule Max_UNION)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3010
    show "\<forall>M\<in>(\<lambda>x. the_preced s ` 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3011
                    {th'. Th th' \<in> subtree (RAG s) (Th x)}) ` readys s. finite M"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3012
                        using finite_subtree_threads by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3013
  qed (auto simp:False subtree_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3014
  also have "... =  
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3015
    Max ((Max \<circ> (\<lambda>th. the_preced s ` {th'. Th th' \<in> subtree (RAG s) (Th th)})) ` readys s)" 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3016
      by (unfold image_comp, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3017
  also have "... = ?L" (is "Max (?f ` ?A) = Max (?g ` ?A)")
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3018
  proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3019
    have "(?f ` ?A) = (?g ` ?A)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3020
    proof(rule f_image_eq)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3021
      fix th1 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3022
      assume "th1 \<in> ?A"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3023
      thus "?f th1 = ?g th1"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3024
        by (unfold cp_alt_def, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3025
    qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3026
    thus ?thesis by simp
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3027
  qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3028
  finally show ?thesis by simp
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3029
qed (auto simp:threads_alt_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3030
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3031
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3032
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3033
section {* Relating @{term cntP}, @{term cntV}, @{term cntCS} and @{term pvD} *}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3034
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3035
context valid_trace_p_w
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3036
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3037
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3038
lemma holding_s_holder: "holding s holder cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3039
  by (unfold s_holding_def, fold wq_def, unfold wq_s_cs, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3040
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3041
lemma holding_es_holder: "holding (e#s) holder cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3042
  by (unfold s_holding_def, fold wq_def, unfold wq_es_cs wq_s_cs, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3043
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3044
lemma holdents_es:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3045
  shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R") 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3046
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3047
  { fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3048
    assume "cs' \<in> ?L"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3049
    hence h: "holding (e#s) th' cs'" by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3050
    have "holding s th' cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3051
    proof(cases "cs' = cs")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3052
      case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3053
      from held_unique[OF h[unfolded True] holding_es_holder]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3054
      have "th' = holder" .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3055
      thus ?thesis 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3056
        by (unfold True holdents_def, insert holding_s_holder, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3057
    next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3058
      case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3059
      hence "wq (e#s) cs' = wq s cs'" by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3060
      from h[unfolded s_holding_def, folded wq_def, unfolded this]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3061
      show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3062
       by (unfold s_holding_def, fold wq_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3063
    qed 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3064
    hence "cs' \<in> ?R" by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3065
  } moreover {
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3066
    fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3067
    assume "cs' \<in> ?R"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3068
    hence h: "holding s th' cs'" by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3069
    have "holding (e#s) th' cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3070
    proof(cases "cs' = cs")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3071
      case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3072
      from held_unique[OF h[unfolded True] holding_s_holder]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3073
      have "th' = holder" .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3074
      thus ?thesis 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3075
        by (unfold True holdents_def, insert holding_es_holder, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3076
    next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3077
      case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3078
      hence "wq s cs' = wq (e#s) cs'" by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3079
      from h[unfolded s_holding_def, folded wq_def, unfolded this]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3080
      show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3081
       by (unfold s_holding_def, fold wq_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3082
    qed 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3083
    hence "cs' \<in> ?L" by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3084
  } ultimately show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3085
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3086
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3087
lemma cntCS_es_th[simp]: "cntCS (e#s) th' = cntCS s th'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3088
 by (unfold cntCS_def holdents_es, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3089
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3090
lemma th_not_ready_es: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3091
  shows "th \<notin> readys (e#s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3092
  using waiting_es_th_cs 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3093
  by (unfold readys_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3094
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3095
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3096
  
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3097
lemma (in valid_trace) finite_holdents: "finite (holdents s th)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3098
  by (unfold holdents_alt_def, insert fsbtRAGs.finite_children, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3099
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3100
context valid_trace_p 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3101
begin
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3102
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3103
lemma ready_th_s: "th \<in> readys s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3104
  using runing_th_s
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3105
  by (unfold runing_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3106
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3107
lemma live_th_s: "th \<in> threads s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3108
  using readys_threads ready_th_s by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3109
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3110
lemma live_th_es: "th \<in> threads (e#s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3111
  using live_th_s 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3112
  by (unfold is_p, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3113
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3114
lemma waiting_neq_th: 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3115
  assumes "waiting s t c"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3116
  shows "t \<noteq> th"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3117
  using assms using th_not_waiting by blast 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3118
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3119
end
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3120
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3121
context valid_trace_p_h
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3122
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3123
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3124
lemma th_not_waiting':
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3125
  "\<not> waiting (e#s) th cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3126
proof(cases "cs' = cs")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3127
  case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3128
  show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3129
    by (unfold True s_waiting_def, fold wq_def, unfold wq_es_cs', auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3130
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3131
  case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3132
  from th_not_waiting[of cs', unfolded s_waiting_def, folded wq_def]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3133
  show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3134
    by (unfold s_waiting_def, fold wq_def, insert False, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3135
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3136
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3137
lemma ready_th_es: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3138
  shows "th \<in> readys (e#s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3139
  using th_not_waiting'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3140
  by (unfold readys_def, insert live_th_es, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3141
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3142
lemma holdents_es_th:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3143
  "holdents (e#s) th = (holdents s th) \<union> {cs}" (is "?L = ?R")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3144
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3145
  { fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3146
    assume "cs' \<in> ?L" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3147
    hence "holding (e#s) th cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3148
      by (unfold holdents_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3149
    hence "cs' \<in> ?R"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3150
     by (cases rule:holding_esE, auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3151
  } moreover {
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3152
    fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3153
    assume "cs' \<in> ?R"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3154
    hence "holding s th cs' \<or> cs' = cs" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3155
      by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3156
    hence "cs' \<in> ?L"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3157
    proof
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3158
      assume "holding s th cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3159
      from holding_kept[OF this]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3160
      show ?thesis by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3161
    next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3162
      assume "cs' = cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3163
      thus ?thesis using holding_es_th_cs
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3164
        by (unfold holdents_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3165
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3166
  } ultimately show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3167
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3168
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3169
lemma cntCS_es_th: "cntCS (e#s) th = cntCS s th + 1"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3170
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3171
  have "card (holdents s th \<union> {cs}) = card (holdents s th) + 1"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3172
  proof(subst card_Un_disjoint)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3173
    show "holdents s th \<inter> {cs} = {}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3174
      using not_holding_s_th_cs by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3175
  qed (auto simp:finite_holdents)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3176
  thus ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3177
   by (unfold cntCS_def holdents_es_th, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3178
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3179
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3180
lemma no_holder: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3181
  "\<not> holding s th' cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3182
proof
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3183
  assume otherwise: "holding s th' cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3184
  from this[unfolded s_holding_def, folded wq_def, unfolded we]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3185
  show False by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3186
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3187
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3188
lemma holdents_es_th':
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3189
  assumes "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3190
  shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3191
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3192
  { fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3193
    assume "cs' \<in> ?L"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3194
    hence h_e: "holding (e#s) th' cs'" by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3195
    have "cs' \<noteq> cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3196
    proof
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3197
      assume "cs' = cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3198
      from held_unique[OF h_e[unfolded this] holding_es_th_cs]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3199
      have "th' = th" .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3200
      with assms show False by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3201
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3202
    from h_e[unfolded s_holding_def, folded wq_def, unfolded wq_neq_simp[OF this]]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3203
    have "th' \<in> set (wq s cs') \<and> th' = hd (wq s cs')" .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3204
    hence "cs' \<in> ?R" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3205
      by (unfold holdents_def s_holding_def, fold wq_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3206
  } moreover {
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3207
    fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3208
    assume "cs' \<in> ?R"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3209
    hence "holding s th' cs'" by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3210
    from holding_kept[OF this]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3211
    have "holding (e # s) th' cs'" .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3212
    hence "cs' \<in> ?L"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3213
      by (unfold holdents_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3214
  } ultimately show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3215
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3216
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3217
lemma cntCS_es_th'[simp]: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3218
  assumes "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3219
  shows "cntCS (e#s) th' = cntCS s th'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3220
  by (unfold cntCS_def holdents_es_th'[OF assms], simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3221
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3222
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3223
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3224
context valid_trace_p
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3225
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3226
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3227
lemma readys_kept1: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3228
  assumes "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3229
  and "th' \<in> readys (e#s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3230
  shows "th' \<in> readys s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3231
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3232
  { fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3233
    assume wait: "waiting s th' cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3234
    have n_wait: "\<not> waiting (e#s) th' cs'" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3235
        using assms(2)[unfolded readys_def] by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3236
    have False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3237
    proof(cases "cs' = cs")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3238
      case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3239
      with n_wait wait
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3240
      show ?thesis 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3241
        by (unfold s_waiting_def, fold wq_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3242
    next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3243
      case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3244
      show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3245
      proof(cases "wq s cs = []")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3246
        case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3247
        then interpret vt: valid_trace_p_h
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3248
          by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3249
        show ?thesis using n_wait wait waiting_kept by auto 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3250
      next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3251
        case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3252
        then interpret vt: valid_trace_p_w by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3253
        show ?thesis using n_wait wait waiting_kept by blast 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3254
      qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3255
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3256
  } with assms(2) show ?thesis  
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3257
    by (unfold readys_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3258
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3259
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3260
lemma readys_kept2: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3261
  assumes "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3262
  and "th' \<in> readys s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3263
  shows "th' \<in> readys (e#s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3264
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3265
  { fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3266
    assume wait: "waiting (e#s) th' cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3267
    have n_wait: "\<not> waiting s th' cs'" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3268
        using assms(2)[unfolded readys_def] by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3269
    have False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3270
    proof(cases "cs' = cs")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3271
      case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3272
      with n_wait wait
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3273
      show ?thesis 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3274
        by (unfold s_waiting_def, fold wq_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3275
    next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3276
      case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3277
      show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3278
      proof(cases "wq s cs = []")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3279
        case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3280
        then interpret vt: valid_trace_p_h
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3281
          by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3282
        show ?thesis using n_wait vt.waiting_esE wait by blast 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3283
      next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3284
        case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3285
        then interpret vt: valid_trace_p_w by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3286
        show ?thesis using assms(1) n_wait vt.waiting_esE wait by auto 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3287
      qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3288
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3289
  } with assms(2) show ?thesis  
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3290
    by (unfold readys_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3291
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3292
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3293
lemma readys_simp [simp]:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3294
  assumes "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3295
  shows "(th' \<in> readys (e#s)) = (th' \<in> readys s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3296
  using readys_kept1[OF assms] readys_kept2[OF assms]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3297
  by metis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3298
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3299
lemma cnp_cnv_cncs_kept: (* ddd *)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3300
  assumes "cntP s th' = cntV s th' + cntCS s th' + pvD s th'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3301
  shows "cntP (e#s) th' = cntV (e#s) th' +  cntCS (e#s) th' + pvD (e#s) th'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3302
proof(cases "th' = th")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3303
  case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3304
  note eq_th' = this
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3305
  show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3306
  proof(cases "wq s cs = []")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3307
    case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3308
    then interpret vt: valid_trace_p_h by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3309
    show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3310
      using assms eq_th' is_p ready_th_s vt.cntCS_es_th vt.ready_th_es pvD_def by auto 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3311
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3312
    case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3313
    then interpret vt: valid_trace_p_w by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3314
    show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3315
      using add.commute add.left_commute assms eq_th' is_p live_th_s 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3316
            ready_th_s vt.th_not_ready_es pvD_def
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3317
      apply (auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3318
      by (fold is_p, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3319
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3320
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3321
  case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3322
  note h_False = False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3323
  thus ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3324
  proof(cases "wq s cs = []")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3325
    case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3326
    then interpret vt: valid_trace_p_h by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3327
    show ?thesis using assms
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3328
      by (insert True h_False pvD_def, auto split:if_splits,unfold is_p, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3329
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3330
    case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3331
    then interpret vt: valid_trace_p_w by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3332
    show ?thesis using assms
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3333
      by (insert False h_False pvD_def, auto split:if_splits,unfold is_p, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3334
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3335
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3336
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3337
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3338
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3339
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3340
context valid_trace_v 
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3341
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3342
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3343
lemma holding_th_cs_s: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3344
  "holding s th cs" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3345
 by  (unfold s_holding_def, fold wq_def, unfold wq_s_cs, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3346
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3347
lemma th_ready_s [simp]: "th \<in> readys s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3348
  using runing_th_s
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3349
  by (unfold runing_def readys_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3350
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3351
lemma th_live_s [simp]: "th \<in> threads s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3352
  using th_ready_s by (unfold readys_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3353
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3354
lemma th_ready_es [simp]: "th \<in> readys (e#s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3355
  using runing_th_s neq_t_th
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3356
  by (unfold is_v runing_def readys_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3357
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3358
lemma th_live_es [simp]: "th \<in> threads (e#s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3359
  using th_ready_es by (unfold readys_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3360
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3361
lemma pvD_th_s[simp]: "pvD s th = 0"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3362
  by (unfold pvD_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3363
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3364
lemma pvD_th_es[simp]: "pvD (e#s) th = 0"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3365
  by (unfold pvD_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3366
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3367
lemma cntCS_s_th [simp]: "cntCS s th > 0"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3368
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3369
  have "cs \<in> holdents s th" using holding_th_cs_s
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3370
    by (unfold holdents_def, simp)
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3371
  moreover have "finite (holdents s th)" using finite_holdents 
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3372
    by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3373
  ultimately show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3374
    by (unfold cntCS_def, 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3375
        auto intro!:card_gt_0_iff[symmetric, THEN iffD1])
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3376
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3377
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3378
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3379
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3380
context valid_trace_v
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3381
begin
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3382
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3383
lemma th_not_waiting: 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3384
  "\<not> waiting s th c"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3385
proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3386
  have "th \<in> readys s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3387
    using runing_ready runing_th_s by blast 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3388
  thus ?thesis
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3389
    by (unfold readys_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3390
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3391
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3392
lemma waiting_neq_th: 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3393
  assumes "waiting s t c"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3394
  shows "t \<noteq> th"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3395
  using assms using th_not_waiting by blast 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3396
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3397
end
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3398
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3399
context valid_trace_v_n
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3400
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3401
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3402
lemma not_ready_taker_s[simp]: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3403
  "taker \<notin> readys s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3404
  using waiting_taker
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3405
  by (unfold readys_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3406
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3407
lemma taker_live_s [simp]: "taker \<in> threads s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3408
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3409
  have "taker \<in> set wq'" by (simp add: eq_wq') 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3410
  from th'_in_inv[OF this]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3411
  have "taker \<in> set rest" .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3412
  hence "taker \<in> set (wq s cs)" by (simp add: wq_s_cs) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3413
  thus ?thesis using wq_threads by auto 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3414
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3415
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3416
lemma taker_live_es [simp]: "taker \<in> threads (e#s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3417
  using taker_live_s threads_es by blast
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3418
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3419
lemma taker_ready_es [simp]:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3420
  shows "taker \<in> readys (e#s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3421
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3422
  { fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3423
    assume "waiting (e#s) taker cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3424
    hence False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3425
    proof(cases rule:waiting_esE)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3426
      case 1
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3427
      thus ?thesis using waiting_taker waiting_unique by auto 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3428
    qed simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3429
  } thus ?thesis by (unfold readys_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3430
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3431
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3432
lemma neq_taker_th: "taker \<noteq> th"
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3433
  using th_not_waiting waiting_taker by blast 
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3434
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3435
lemma not_holding_taker_s_cs:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3436
  shows "\<not> holding s taker cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3437
  using holding_cs_eq_th neq_taker_th by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3438
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3439
lemma holdents_es_taker:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3440
  "holdents (e#s) taker = holdents s taker \<union> {cs}" (is "?L = ?R")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3441
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3442
  { fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3443
    assume "cs' \<in> ?L"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3444
    hence "holding (e#s) taker cs'" by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3445
    hence "cs' \<in> ?R"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3446
    proof(cases rule:holding_esE)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3447
      case 2
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3448
      thus ?thesis by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3449
    qed auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3450
  } moreover {
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3451
    fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3452
    assume "cs' \<in> ?R"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3453
    hence "holding s taker cs' \<or> cs' = cs" by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3454
    hence "cs' \<in> ?L" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3455
    proof
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3456
      assume "holding s taker cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3457
      hence "holding (e#s) taker cs'" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3458
          using holding_esI2 holding_taker by fastforce 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3459
      thus ?thesis by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3460
    next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3461
      assume "cs' = cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3462
      with holding_taker
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3463
      show ?thesis by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3464
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3465
  } ultimately show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3466
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3467
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3468
lemma cntCS_es_taker [simp]: "cntCS (e#s) taker = cntCS s taker + 1"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3469
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3470
  have "card (holdents s taker \<union> {cs}) = card (holdents s taker) + 1"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3471
  proof(subst card_Un_disjoint)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3472
    show "holdents s taker \<inter> {cs} = {}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3473
      using not_holding_taker_s_cs by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3474
  qed (auto simp:finite_holdents)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3475
  thus ?thesis 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3476
    by (unfold cntCS_def, insert holdents_es_taker, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3477
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3478
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3479
lemma pvD_taker_s[simp]: "pvD s taker = 1"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3480
  by (unfold pvD_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3481
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3482
lemma pvD_taker_es[simp]: "pvD (e#s) taker = 0"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3483
  by (unfold pvD_def, simp)  
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3484
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3485
lemma pvD_th_s[simp]: "pvD s th = 0"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3486
  by (unfold pvD_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3487
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3488
lemma pvD_th_es[simp]: "pvD (e#s) th = 0"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3489
  by (unfold pvD_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3490
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3491
lemma holdents_es_th:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3492
  "holdents (e#s) th = holdents s th - {cs}" (is "?L = ?R")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3493
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3494
  { fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3495
    assume "cs' \<in> ?L"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3496
    hence "holding (e#s) th cs'" by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3497
    hence "cs' \<in> ?R"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3498
    proof(cases rule:holding_esE)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3499
      case 2
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3500
      thus ?thesis by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3501
    qed (insert neq_taker_th, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3502
  } moreover {
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3503
    fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3504
    assume "cs' \<in> ?R"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3505
    hence "cs' \<noteq> cs" "holding s th cs'" by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3506
    from holding_esI2[OF this]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3507
    have "cs' \<in> ?L" by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3508
  } ultimately show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3509
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3510
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3511
lemma cntCS_es_th [simp]: "cntCS (e#s) th = cntCS s th - 1"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3512
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3513
  have "card (holdents s th - {cs}) = card (holdents s th) - 1"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3514
  proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3515
    have "cs \<in> holdents s th" using holding_th_cs_s
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3516
      by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3517
    moreover have "finite (holdents s th)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3518
        by (simp add: finite_holdents) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3519
    ultimately show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3520
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3521
  thus ?thesis by (unfold cntCS_def holdents_es_th)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3522
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3523
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3524
lemma holdents_kept:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3525
  assumes "th' \<noteq> taker"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3526
  and "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3527
  shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3528
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3529
  { fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3530
    assume h: "cs' \<in> ?L"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3531
    have "cs' \<in> ?R"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3532
    proof(cases "cs' = cs")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3533
      case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3534
      hence eq_wq: "wq (e#s) cs' = wq s cs'" by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3535
      from h have "holding (e#s) th' cs'" by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3536
      from this[unfolded s_holding_def, folded wq_def, unfolded eq_wq]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3537
      show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3538
        by (unfold holdents_def s_holding_def, fold wq_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3539
    next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3540
      case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3541
      from h[unfolded this]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3542
      have "holding (e#s) th' cs" by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3543
      from held_unique[OF this holding_taker]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3544
      have "th' = taker" .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3545
      with assms show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3546
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3547
  } moreover {
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3548
    fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3549
    assume h: "cs' \<in> ?R"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3550
    have "cs' \<in> ?L"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3551
    proof(cases "cs' = cs")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3552
      case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3553
      hence eq_wq: "wq (e#s) cs' = wq s cs'" by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3554
      from h have "holding s th' cs'" by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3555
      from this[unfolded s_holding_def, folded wq_def, unfolded eq_wq]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3556
      show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3557
        by (unfold holdents_def s_holding_def, fold wq_def, insert eq_wq, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3558
    next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3559
      case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3560
      from h[unfolded this]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3561
      have "holding s th' cs" by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3562
      from held_unique[OF this holding_th_cs_s]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3563
      have "th' = th" .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3564
      with assms show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3565
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3566
  } ultimately show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3567
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3568
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3569
lemma cntCS_kept [simp]:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3570
  assumes "th' \<noteq> taker"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3571
  and "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3572
  shows "cntCS (e#s) th' = cntCS s th'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3573
  by (unfold cntCS_def holdents_kept[OF assms], simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3574
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3575
lemma readys_kept1: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3576
  assumes "th' \<noteq> taker"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3577
  and "th' \<in> readys (e#s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3578
  shows "th' \<in> readys s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3579
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3580
  { fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3581
    assume wait: "waiting s th' cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3582
    have n_wait: "\<not> waiting (e#s) th' cs'" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3583
        using assms(2)[unfolded readys_def] by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3584
    have False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3585
    proof(cases "cs' = cs")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3586
      case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3587
      with n_wait wait
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3588
      show ?thesis 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3589
        by (unfold s_waiting_def, fold wq_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3590
    next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3591
      case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3592
      have "th' \<in> set (th # rest) \<and> th' \<noteq> hd (th # rest)" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3593
        using wait[unfolded True s_waiting_def, folded wq_def, unfolded wq_s_cs] .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3594
      moreover have "\<not> (th' \<in> set rest \<and> th' \<noteq> hd (taker # rest'))" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3595
        using n_wait[unfolded True s_waiting_def, folded wq_def, 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3596
                    unfolded wq_es_cs set_wq', unfolded eq_wq'] .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3597
      ultimately have "th' = taker" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3598
      with assms(1)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3599
      show ?thesis by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3600
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3601
  } with assms(2) show ?thesis  
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3602
    by (unfold readys_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3603
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3604
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3605
lemma readys_kept2: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3606
  assumes "th' \<noteq> taker"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3607
  and "th' \<in> readys s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3608
  shows "th' \<in> readys (e#s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3609
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3610
  { fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3611
    assume wait: "waiting (e#s) th' cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3612
    have n_wait: "\<not> waiting s th' cs'" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3613
        using assms(2)[unfolded readys_def] by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3614
    have False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3615
    proof(cases "cs' = cs")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3616
      case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3617
      with n_wait wait
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3618
      show ?thesis 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3619
        by (unfold s_waiting_def, fold wq_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3620
    next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3621
      case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3622
      have "th' \<in> set rest \<and> th' \<noteq> hd (taker # rest')"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3623
          using  wait [unfolded True s_waiting_def, folded wq_def, 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3624
                    unfolded wq_es_cs set_wq', unfolded eq_wq']  .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3625
      moreover have "\<not> (th' \<in> set (th # rest) \<and> th' \<noteq> hd (th # rest))"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3626
          using n_wait[unfolded True s_waiting_def, folded wq_def, unfolded wq_s_cs] .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3627
      ultimately have "th' = taker" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3628
      with assms(1)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3629
      show ?thesis by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3630
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3631
  } with assms(2) show ?thesis  
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3632
    by (unfold readys_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3633
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3634
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3635
lemma readys_simp [simp]:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3636
  assumes "th' \<noteq> taker"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3637
  shows "(th' \<in> readys (e#s)) = (th' \<in> readys s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3638
  using readys_kept1[OF assms] readys_kept2[OF assms]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3639
  by metis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3640
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3641
lemma cnp_cnv_cncs_kept:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3642
  assumes "cntP s th' = cntV s th' + cntCS s th' + pvD s th'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3643
  shows "cntP (e#s) th' = cntV (e#s) th' +  cntCS (e#s) th' + pvD (e#s) th'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3644
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3645
  { assume eq_th': "th' = taker"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3646
    have ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3647
      apply (unfold eq_th' pvD_taker_es cntCS_es_taker)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3648
      by (insert neq_taker_th assms[unfolded eq_th'], unfold is_v, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3649
  } moreover {
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3650
    assume eq_th': "th' = th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3651
    have ?thesis 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3652
      apply (unfold eq_th' pvD_th_es cntCS_es_th)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3653
      by (insert assms[unfolded eq_th'], unfold is_v, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3654
  } moreover {
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3655
    assume h: "th' \<noteq> taker" "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3656
    have ?thesis using assms
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3657
      apply (unfold cntCS_kept[OF h], insert h, unfold is_v, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3658
      by (fold is_v, unfold pvD_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3659
  } ultimately show ?thesis by metis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3660
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3661
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3662
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3663
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3664
context valid_trace_v_e
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3665
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3666
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3667
lemma holdents_es_th:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3668
  "holdents (e#s) th = holdents s th - {cs}" (is "?L = ?R")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3669
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3670
  { fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3671
    assume "cs' \<in> ?L"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3672
    hence "holding (e#s) th cs'" by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3673
    hence "cs' \<in> ?R"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3674
    proof(cases rule:holding_esE)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3675
      case 1
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3676
      thus ?thesis by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3677
    qed 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3678
  } moreover {
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3679
    fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3680
    assume "cs' \<in> ?R"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3681
    hence "cs' \<noteq> cs" "holding s th cs'" by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3682
    from holding_esI2[OF this]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3683
    have "cs' \<in> ?L" by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3684
  } ultimately show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3685
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3686
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3687
lemma cntCS_es_th [simp]: "cntCS (e#s) th = cntCS s th - 1"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3688
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3689
  have "card (holdents s th - {cs}) = card (holdents s th) - 1"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3690
  proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3691
    have "cs \<in> holdents s th" using holding_th_cs_s
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3692
      by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3693
    moreover have "finite (holdents s th)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3694
        by (simp add: finite_holdents) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3695
    ultimately show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3696
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3697
  thus ?thesis by (unfold cntCS_def holdents_es_th)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3698
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3699
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3700
lemma holdents_kept:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3701
  assumes "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3702
  shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3703
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3704
  { fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3705
    assume h: "cs' \<in> ?L"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3706
    have "cs' \<in> ?R"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3707
    proof(cases "cs' = cs")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3708
      case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3709
      hence eq_wq: "wq (e#s) cs' = wq s cs'" by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3710
      from h have "holding (e#s) th' cs'" by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3711
      from this[unfolded s_holding_def, folded wq_def, unfolded eq_wq]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3712
      show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3713
        by (unfold holdents_def s_holding_def, fold wq_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3714
    next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3715
      case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3716
      from h[unfolded this]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3717
      have "holding (e#s) th' cs" by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3718
      from this[unfolded s_holding_def, folded wq_def, 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3719
            unfolded wq_es_cs nil_wq']
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3720
      show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3721
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3722
  } moreover {
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3723
    fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3724
    assume h: "cs' \<in> ?R"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3725
    have "cs' \<in> ?L"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3726
    proof(cases "cs' = cs")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3727
      case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3728
      hence eq_wq: "wq (e#s) cs' = wq s cs'" by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3729
      from h have "holding s th' cs'" by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3730
      from this[unfolded s_holding_def, folded wq_def, unfolded eq_wq]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3731
      show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3732
        by (unfold holdents_def s_holding_def, fold wq_def, insert eq_wq, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3733
    next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3734
      case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3735
      from h[unfolded this]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3736
      have "holding s th' cs" by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3737
      from held_unique[OF this holding_th_cs_s]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3738
      have "th' = th" .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3739
      with assms show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3740
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3741
  } ultimately show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3742
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3743
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3744
lemma cntCS_kept [simp]:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3745
  assumes "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3746
  shows "cntCS (e#s) th' = cntCS s th'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3747
  by (unfold cntCS_def holdents_kept[OF assms], simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3748
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3749
lemma readys_kept1: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3750
  assumes "th' \<in> readys (e#s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3751
  shows "th' \<in> readys s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3752
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3753
  { fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3754
    assume wait: "waiting s th' cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3755
    have n_wait: "\<not> waiting (e#s) th' cs'" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3756
        using assms(1)[unfolded readys_def] by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3757
    have False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3758
    proof(cases "cs' = cs")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3759
      case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3760
      with n_wait wait
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3761
      show ?thesis 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3762
        by (unfold s_waiting_def, fold wq_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3763
    next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3764
      case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3765
      have "th' \<in> set (th # rest) \<and> th' \<noteq> hd (th # rest)" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3766
        using wait[unfolded True s_waiting_def, folded wq_def, unfolded wq_s_cs] . 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3767
      hence "th' \<in> set rest" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3768
      with set_wq' have "th' \<in> set wq'" by metis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3769
      with nil_wq' show ?thesis by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3770
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3771
  } thus ?thesis using assms
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3772
    by (unfold readys_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3773
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3774
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3775
lemma readys_kept2: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3776
  assumes "th' \<in> readys s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3777
  shows "th' \<in> readys (e#s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3778
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3779
  { fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3780
    assume wait: "waiting (e#s) th' cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3781
    have n_wait: "\<not> waiting s th' cs'" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3782
        using assms[unfolded readys_def] by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3783
    have False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3784
    proof(cases "cs' = cs")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3785
      case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3786
      with n_wait wait
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3787
      show ?thesis 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3788
        by (unfold s_waiting_def, fold wq_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3789
    next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3790
      case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3791
      have "th' \<in> set [] \<and> th' \<noteq> hd []"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3792
        using wait[unfolded True s_waiting_def, folded wq_def, 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3793
              unfolded wq_es_cs nil_wq'] .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3794
      thus ?thesis by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3795
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3796
  } with assms show ?thesis  
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3797
    by (unfold readys_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3798
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3799
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3800
lemma readys_simp [simp]:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3801
  shows "(th' \<in> readys (e#s)) = (th' \<in> readys s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3802
  using readys_kept1[OF assms] readys_kept2[OF assms]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3803
  by metis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3804
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3805
lemma cnp_cnv_cncs_kept:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3806
  assumes "cntP s th' = cntV s th' + cntCS s th' + pvD s th'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3807
  shows "cntP (e#s) th' = cntV (e#s) th' +  cntCS (e#s) th' + pvD (e#s) th'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3808
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3809
  {
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3810
    assume eq_th': "th' = th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3811
    have ?thesis 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3812
      apply (unfold eq_th' pvD_th_es cntCS_es_th)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3813
      by (insert assms[unfolded eq_th'], unfold is_v, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3814
  } moreover {
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3815
    assume h: "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3816
    have ?thesis using assms
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3817
      apply (unfold cntCS_kept[OF h], insert h, unfold is_v, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3818
      by (fold is_v, unfold pvD_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3819
  } ultimately show ?thesis by metis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3820
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3821
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3822
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3823
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3824
context valid_trace_v
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3825
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3826
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3827
lemma cnp_cnv_cncs_kept:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3828
  assumes "cntP s th' = cntV s th' + cntCS s th' + pvD s th'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3829
  shows "cntP (e#s) th' = cntV (e#s) th' +  cntCS (e#s) th' + pvD (e#s) th'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3830
proof(cases "rest = []")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3831
  case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3832
  then interpret vt: valid_trace_v_e by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3833
  show ?thesis using assms using vt.cnp_cnv_cncs_kept by blast 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3834
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3835
  case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3836
  then interpret vt: valid_trace_v_n by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3837
  show ?thesis using assms using vt.cnp_cnv_cncs_kept by blast 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3838
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3839
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3840
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3841
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3842
context valid_trace_create
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3843
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3844
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3845
lemma th_not_live_s [simp]: "th \<notin> threads s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3846
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3847
  from pip_e[unfolded is_create]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3848
  show ?thesis by (cases, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3849
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3850
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3851
lemma th_not_ready_s [simp]: "th \<notin> readys s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3852
  using th_not_live_s by (unfold readys_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3853
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3854
lemma th_live_es [simp]: "th \<in> threads (e#s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3855
  by (unfold is_create, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3856
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3857
lemma not_waiting_th_s [simp]: "\<not> waiting s th cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3858
proof
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3859
  assume "waiting s th cs'"
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3860
  from this[unfolded s_waiting_def, folded wq_def, unfolded wq_kept]
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3861
  have "th \<in> set (wq s cs')" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3862
  from wq_threads[OF this] have "th \<in> threads s" .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3863
  with th_not_live_s show False by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3864
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3865
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3866
lemma not_holding_th_s [simp]: "\<not> holding s th cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3867
proof
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3868
  assume "holding s th cs'"
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3869
  from this[unfolded s_holding_def, folded wq_def, unfolded wq_kept]
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3870
  have "th \<in> set (wq s cs')" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3871
  from wq_threads[OF this] have "th \<in> threads s" .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3872
  with th_not_live_s show False by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3873
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3874
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3875
lemma not_waiting_th_es [simp]: "\<not> waiting (e#s) th cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3876
proof
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3877
  assume "waiting (e # s) th cs'"
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3878
  from this[unfolded s_waiting_def, folded wq_def, unfolded wq_kept]
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3879
  have "th \<in> set (wq s cs')" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3880
  from wq_threads[OF this] have "th \<in> threads s" .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3881
  with th_not_live_s show False by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3882
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3883
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3884
lemma not_holding_th_es [simp]: "\<not> holding (e#s) th cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3885
proof
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3886
  assume "holding (e # s) th cs'"
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3887
  from this[unfolded s_holding_def, folded wq_def, unfolded wq_kept]
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3888
  have "th \<in> set (wq s cs')" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3889
  from wq_threads[OF this] have "th \<in> threads s" .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3890
  with th_not_live_s show False by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3891
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3892
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3893
lemma ready_th_es [simp]: "th \<in> readys (e#s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3894
  by (simp add:readys_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3895
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3896
lemma holdents_th_s: "holdents s th = {}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3897
  by (unfold holdents_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3898
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3899
lemma holdents_th_es: "holdents (e#s) th = {}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3900
  by (unfold holdents_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3901
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3902
lemma cntCS_th_s [simp]: "cntCS s th = 0"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3903
  by (unfold cntCS_def, simp add:holdents_th_s)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3904
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3905
lemma cntCS_th_es [simp]: "cntCS (e#s) th = 0"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3906
  by (unfold cntCS_def, simp add:holdents_th_es)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3907
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3908
lemma pvD_th_s [simp]: "pvD s th = 0"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3909
  by (unfold pvD_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3910
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3911
lemma pvD_th_es [simp]: "pvD (e#s) th = 0"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3912
  by (unfold pvD_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3913
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3914
lemma holdents_kept:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3915
  assumes "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3916
  shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3917
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3918
  { fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3919
    assume h: "cs' \<in> ?L"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3920
    hence "cs' \<in> ?R"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3921
      by (unfold holdents_def s_holding_def, fold wq_def, 
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3922
             unfold wq_kept, auto)
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3923
  } moreover {
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3924
    fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3925
    assume h: "cs' \<in> ?R"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3926
    hence "cs' \<in> ?L"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3927
      by (unfold holdents_def s_holding_def, fold wq_def, 
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3928
             unfold wq_kept, auto)
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3929
  } ultimately show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3930
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3931
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3932
lemma cntCS_kept [simp]:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3933
  assumes "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3934
  shows "cntCS (e#s) th' = cntCS s th'" (is "?L = ?R")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3935
  using holdents_kept[OF assms]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3936
  by (unfold cntCS_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3937
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3938
lemma readys_kept1: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3939
  assumes "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3940
  and "th' \<in> readys (e#s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3941
  shows "th' \<in> readys s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3942
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3943
  { fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3944
    assume wait: "waiting s th' cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3945
    have n_wait: "\<not> waiting (e#s) th' cs'" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3946
      using assms by (auto simp:readys_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3947
    from wait[unfolded s_waiting_def, folded wq_def]
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3948
         n_wait[unfolded s_waiting_def, folded wq_def, unfolded wq_kept]
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3949
    have False by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3950
  } thus ?thesis using assms
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3951
    by (unfold readys_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3952
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3953
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3954
lemma readys_kept2: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3955
  assumes "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3956
  and "th' \<in> readys s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3957
  shows "th' \<in> readys (e#s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3958
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3959
  { fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3960
    assume wait: "waiting (e#s) th' cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3961
    have n_wait: "\<not> waiting s th' cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3962
      using assms(2) by (auto simp:readys_def)
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  3963
    from wait[unfolded s_waiting_def, folded wq_def, unfolded wq_kept]
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3964
         n_wait[unfolded s_waiting_def, folded wq_def]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3965
    have False by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3966
  } with assms show ?thesis  
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3967
    by (unfold readys_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3968
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3969
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3970
lemma readys_simp [simp]:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3971
  assumes "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3972
  shows "(th' \<in> readys (e#s)) = (th' \<in> readys s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3973
  using readys_kept1[OF assms] readys_kept2[OF assms]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3974
  by metis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3975
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3976
lemma pvD_kept [simp]:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3977
  assumes "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3978
  shows "pvD (e#s) th' = pvD s th'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3979
  using assms
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3980
  by (unfold pvD_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3981
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3982
lemma cnp_cnv_cncs_kept:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3983
  assumes "cntP s th' = cntV s th' + cntCS s th' + pvD s th'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3984
  shows "cntP (e#s) th' = cntV (e#s) th' +  cntCS (e#s) th' + pvD (e#s) th'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3985
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3986
  {
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3987
    assume eq_th': "th' = th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3988
    have ?thesis using assms
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3989
      by (unfold eq_th', simp, unfold is_create, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3990
  } moreover {
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3991
    assume h: "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3992
    hence ?thesis using assms
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3993
      by (simp, simp add:is_create)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3994
  } ultimately show ?thesis by metis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3995
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3996
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3997
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3998
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  3999
context valid_trace_exit
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4000
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4001
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4002
lemma th_live_s [simp]: "th \<in> threads s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4003
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4004
  from pip_e[unfolded is_exit]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4005
  show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4006
  by (cases, unfold runing_def readys_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4007
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4008
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4009
lemma th_ready_s [simp]: "th \<in> readys s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4010
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4011
  from pip_e[unfolded is_exit]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4012
  show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4013
  by (cases, unfold runing_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4014
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4015
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4016
lemma th_not_live_es [simp]: "th \<notin> threads (e#s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4017
  by (unfold is_exit, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4018
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4019
lemma not_holding_th_s [simp]: "\<not> holding s th cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4020
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4021
  from pip_e[unfolded is_exit]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4022
  show ?thesis 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4023
   by (cases, unfold holdents_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4024
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4025
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4026
lemma cntCS_th_s [simp]: "cntCS s th = 0"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4027
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4028
  from pip_e[unfolded is_exit]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4029
  show ?thesis 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4030
   by (cases, unfold cntCS_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4031
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4032
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4033
lemma not_holding_th_es [simp]: "\<not> holding (e#s) th cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4034
proof
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4035
  assume "holding (e # s) th cs'"
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4036
  from this[unfolded s_holding_def, folded wq_def, unfolded wq_kept]
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4037
  have "holding s th cs'" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4038
    by (unfold s_holding_def, fold wq_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4039
  with not_holding_th_s 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4040
  show False by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4041
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4042
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4043
lemma ready_th_es [simp]: "th \<notin> readys (e#s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4044
  by (simp add:readys_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4045
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4046
lemma holdents_th_s: "holdents s th = {}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4047
  by (unfold holdents_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4048
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4049
lemma holdents_th_es: "holdents (e#s) th = {}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4050
  by (unfold holdents_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4051
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4052
lemma cntCS_th_es [simp]: "cntCS (e#s) th = 0"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4053
  by (unfold cntCS_def, simp add:holdents_th_es)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4054
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4055
lemma pvD_th_s [simp]: "pvD s th = 0"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4056
  by (unfold pvD_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4057
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4058
lemma pvD_th_es [simp]: "pvD (e#s) th = 0"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4059
  by (unfold pvD_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4060
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4061
lemma holdents_kept:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4062
  assumes "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4063
  shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4064
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4065
  { fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4066
    assume h: "cs' \<in> ?L"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4067
    hence "cs' \<in> ?R"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4068
      by (unfold holdents_def s_holding_def, fold wq_def, 
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4069
             unfold wq_kept, auto)
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4070
  } moreover {
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4071
    fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4072
    assume h: "cs' \<in> ?R"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4073
    hence "cs' \<in> ?L"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4074
      by (unfold holdents_def s_holding_def, fold wq_def, 
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4075
             unfold wq_kept, auto)
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4076
  } ultimately show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4077
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4078
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4079
lemma cntCS_kept [simp]:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4080
  assumes "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4081
  shows "cntCS (e#s) th' = cntCS s th'" (is "?L = ?R")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4082
  using holdents_kept[OF assms]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4083
  by (unfold cntCS_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4084
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4085
lemma readys_kept1: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4086
  assumes "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4087
  and "th' \<in> readys (e#s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4088
  shows "th' \<in> readys s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4089
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4090
  { fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4091
    assume wait: "waiting s th' cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4092
    have n_wait: "\<not> waiting (e#s) th' cs'" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4093
      using assms by (auto simp:readys_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4094
    from wait[unfolded s_waiting_def, folded wq_def]
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4095
         n_wait[unfolded s_waiting_def, folded wq_def, unfolded wq_kept]
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4096
    have False by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4097
  } thus ?thesis using assms
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4098
    by (unfold readys_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4099
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4100
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4101
lemma readys_kept2: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4102
  assumes "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4103
  and "th' \<in> readys s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4104
  shows "th' \<in> readys (e#s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4105
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4106
  { fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4107
    assume wait: "waiting (e#s) th' cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4108
    have n_wait: "\<not> waiting s th' cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4109
      using assms(2) by (auto simp:readys_def)
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4110
    from wait[unfolded s_waiting_def, folded wq_def, unfolded wq_kept]
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4111
         n_wait[unfolded s_waiting_def, folded wq_def]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4112
    have False by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4113
  } with assms show ?thesis  
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4114
    by (unfold readys_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4115
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4116
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4117
lemma readys_simp [simp]:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4118
  assumes "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4119
  shows "(th' \<in> readys (e#s)) = (th' \<in> readys s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4120
  using readys_kept1[OF assms] readys_kept2[OF assms]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4121
  by metis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4122
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4123
lemma pvD_kept [simp]:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4124
  assumes "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4125
  shows "pvD (e#s) th' = pvD s th'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4126
  using assms
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4127
  by (unfold pvD_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4128
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4129
lemma cnp_cnv_cncs_kept:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4130
  assumes "cntP s th' = cntV s th' + cntCS s th' + pvD s th'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4131
  shows "cntP (e#s) th' = cntV (e#s) th' +  cntCS (e#s) th' + pvD (e#s) th'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4132
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4133
  {
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4134
    assume eq_th': "th' = th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4135
    have ?thesis using assms
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4136
      by (unfold eq_th', simp, unfold is_exit, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4137
  } moreover {
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4138
    assume h: "th' \<noteq> th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4139
    hence ?thesis using assms
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4140
      by (simp, simp add:is_exit)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4141
  } ultimately show ?thesis by metis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4142
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4143
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4144
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4145
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4146
context valid_trace_set
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4147
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4148
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4149
lemma th_live_s [simp]: "th \<in> threads s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4150
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4151
  from pip_e[unfolded is_set]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4152
  show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4153
  by (cases, unfold runing_def readys_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4154
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4155
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4156
lemma th_ready_s [simp]: "th \<in> readys s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4157
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4158
  from pip_e[unfolded is_set]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4159
  show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4160
  by (cases, unfold runing_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4161
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4162
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4163
lemma th_not_live_es [simp]: "th \<in> threads (e#s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4164
  by (unfold is_set, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4165
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4166
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4167
lemma holdents_kept:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4168
  shows "holdents (e#s) th' = holdents s th'" (is "?L = ?R")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4169
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4170
  { fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4171
    assume h: "cs' \<in> ?L"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4172
    hence "cs' \<in> ?R"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4173
      by (unfold holdents_def s_holding_def, fold wq_def, 
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4174
             unfold wq_kept, auto)
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4175
  } moreover {
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4176
    fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4177
    assume h: "cs' \<in> ?R"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4178
    hence "cs' \<in> ?L"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4179
      by (unfold holdents_def s_holding_def, fold wq_def, 
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4180
             unfold wq_kept, auto)
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4181
  } ultimately show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4182
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4183
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4184
lemma cntCS_kept [simp]:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4185
  shows "cntCS (e#s) th' = cntCS s th'" (is "?L = ?R")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4186
  using holdents_kept
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4187
  by (unfold cntCS_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4188
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4189
lemma threads_kept[simp]:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4190
  "threads (e#s) = threads s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4191
  by (unfold is_set, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4192
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4193
lemma readys_kept1: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4194
  assumes "th' \<in> readys (e#s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4195
  shows "th' \<in> readys s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4196
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4197
  { fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4198
    assume wait: "waiting s th' cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4199
    have n_wait: "\<not> waiting (e#s) th' cs'" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4200
      using assms by (auto simp:readys_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4201
    from wait[unfolded s_waiting_def, folded wq_def]
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4202
         n_wait[unfolded s_waiting_def, folded wq_def, unfolded wq_kept]
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4203
    have False by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4204
  } moreover have "th' \<in> threads s" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4205
    using assms[unfolded readys_def] by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4206
  ultimately show ?thesis 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4207
    by (unfold readys_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4208
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4209
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4210
lemma readys_kept2: 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4211
  assumes "th' \<in> readys s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4212
  shows "th' \<in> readys (e#s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4213
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4214
  { fix cs'
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4215
    assume wait: "waiting (e#s) th' cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4216
    have n_wait: "\<not> waiting s th' cs'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4217
      using assms by (auto simp:readys_def)
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4218
    from wait[unfolded s_waiting_def, folded wq_def, unfolded wq_kept]
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4219
         n_wait[unfolded s_waiting_def, folded wq_def]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4220
    have False by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4221
  } with assms show ?thesis  
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4222
    by (unfold readys_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4223
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4224
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4225
lemma readys_simp [simp]:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4226
  shows "(th' \<in> readys (e#s)) = (th' \<in> readys s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4227
  using readys_kept1 readys_kept2
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4228
  by metis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4229
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4230
lemma pvD_kept [simp]:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4231
  shows "pvD (e#s) th' = pvD s th'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4232
  by (unfold pvD_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4233
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4234
lemma cnp_cnv_cncs_kept:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4235
  assumes "cntP s th' = cntV s th' + cntCS s th' + pvD s th'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4236
  shows "cntP (e#s) th' = cntV (e#s) th' +  cntCS (e#s) th' + pvD (e#s) th'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4237
  using assms
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4238
  by (unfold is_set, simp, fold is_set, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4239
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4240
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4241
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4242
context valid_trace
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4243
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4244
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4245
lemma cnp_cnv_cncs: "cntP s th' = cntV s th' + cntCS s th' + pvD s th'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4246
proof(induct rule:ind)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4247
  case Nil
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4248
  thus ?case 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4249
    by (unfold cntP_def cntV_def pvD_def cntCS_def holdents_def 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4250
              s_holding_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4251
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4252
  case (Cons s e)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4253
  interpret vt_e: valid_trace_e s e using Cons by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4254
  show ?case
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4255
  proof(cases e)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4256
    case (Create th prio)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4257
    interpret vt_create: valid_trace_create s e th prio 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4258
      using Create by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4259
    show ?thesis using Cons by (simp add: vt_create.cnp_cnv_cncs_kept) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4260
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4261
    case (Exit th)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4262
    interpret vt_exit: valid_trace_exit s e th  
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4263
        using Exit by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4264
   show ?thesis using Cons by (simp add: vt_exit.cnp_cnv_cncs_kept) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4265
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4266
    case (P th cs)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4267
    interpret vt_p: valid_trace_p s e th cs using P by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4268
    show ?thesis using Cons by (simp add: vt_p.cnp_cnv_cncs_kept) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4269
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4270
    case (V th cs)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4271
    interpret vt_v: valid_trace_v s e th cs using V by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4272
    show ?thesis using Cons by (simp add: vt_v.cnp_cnv_cncs_kept) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4273
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4274
    case (Set th prio)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4275
    interpret vt_set: valid_trace_set s e th prio
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4276
        using Set by (unfold_locales, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4277
    show ?thesis using Cons by (simp add: vt_set.cnp_cnv_cncs_kept) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4278
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4279
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4280
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4281
end
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4282
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4283
section {* Corollaries of @{thm valid_trace.cnp_cnv_cncs} *}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4284
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4285
context valid_trace
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4286
begin
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4287
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4288
lemma not_thread_holdents:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4289
  assumes not_in: "th \<notin> threads s" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4290
  shows "holdents s th = {}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4291
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4292
  { fix cs
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4293
    assume "cs \<in> holdents s th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4294
    hence "holding s th cs" by (auto simp:holdents_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4295
    from this[unfolded s_holding_def, folded wq_def]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4296
    have "th \<in> set (wq s cs)" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4297
    with wq_threads have "th \<in> threads s" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4298
    with assms
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4299
    have False by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4300
  } thus ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4301
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4302
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4303
lemma not_thread_cncs:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4304
  assumes not_in: "th \<notin> threads s" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4305
  shows "cntCS s th = 0"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4306
  using not_thread_holdents[OF assms]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4307
  by (simp add:cntCS_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4308
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4309
lemma cnp_cnv_eq:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4310
  assumes "th \<notin> threads s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4311
  shows "cntP s th = cntV s th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4312
  using assms cnp_cnv_cncs not_thread_cncs pvD_def
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4313
  by (auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4314
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4315
lemma eq_pv_children:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4316
  assumes eq_pv: "cntP s th = cntV s th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4317
  shows "children (RAG s) (Th th) = {}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4318
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4319
    from cnp_cnv_cncs and eq_pv
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4320
    have "cntCS s th = 0" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4321
      by (auto split:if_splits)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4322
    from this[unfolded cntCS_def holdents_alt_def]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4323
    have card_0: "card (the_cs ` children (RAG s) (Th th)) = 0" .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4324
    have "finite (the_cs ` children (RAG s) (Th th))"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4325
      by (simp add: fsbtRAGs.finite_children)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4326
    from card_0[unfolded card_0_eq[OF this]]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4327
    show ?thesis by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4328
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4329
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4330
lemma eq_pv_holdents:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4331
  assumes eq_pv: "cntP s th = cntV s th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4332
  shows "holdents s th = {}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4333
  by (unfold holdents_alt_def eq_pv_children[OF assms], simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4334
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4335
lemma eq_pv_subtree:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4336
  assumes eq_pv: "cntP s th = cntV s th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4337
  shows "subtree (RAG s) (Th th) = {Th th}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4338
  using eq_pv_children[OF assms]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4339
    by (unfold subtree_children, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4340
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4341
lemma count_eq_RAG_plus:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4342
  assumes "cntP s th = cntV s th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4343
  shows "{th'. (Th th', Th th) \<in> (RAG s)^+} = {}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4344
proof(rule ccontr)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4345
    assume otherwise: "{th'. (Th th', Th th) \<in> (RAG s)\<^sup>+} \<noteq> {}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4346
    then obtain th' where "(Th th', Th th) \<in> (RAG s)^+" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4347
    from tranclD2[OF this]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4348
    obtain z where "z \<in> children (RAG s) (Th th)" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4349
      by (auto simp:children_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4350
    with eq_pv_children[OF assms]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4351
    show False by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4352
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4353
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4354
lemma eq_pv_dependants:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4355
  assumes eq_pv: "cntP s th = cntV s th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4356
  shows "dependants s th = {}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4357
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4358
  from count_eq_RAG_plus[OF assms, folded dependants_alt_def1]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4359
  show ?thesis .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4360
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4361
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4362
lemma count_eq_tRAG_plus:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4363
  assumes "cntP s th = cntV s th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4364
  shows "{th'. (Th th', Th th) \<in> (tRAG s)^+} = {}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4365
  using assms eq_pv_dependants dependants_alt_def eq_dependants by auto 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4366
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4367
lemma count_eq_RAG_plus_Th:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4368
  assumes "cntP s th = cntV s th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4369
  shows "{Th th' | th'. (Th th', Th th) \<in> (RAG s)^+} = {}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4370
  using count_eq_RAG_plus[OF assms] by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4371
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4372
lemma count_eq_tRAG_plus_Th:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4373
  assumes "cntP s th = cntV s th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4374
  shows "{Th th' | th'. (Th th', Th th) \<in> (tRAG s)^+} = {}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4375
   using count_eq_tRAG_plus[OF assms] by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4376
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4377
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4378
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4379
definition detached :: "state \<Rightarrow> thread \<Rightarrow> bool"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4380
  where "detached s th \<equiv> (\<not>(\<exists> cs. holding s th cs)) \<and> (\<not>(\<exists>cs. waiting s th cs))"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4381
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4382
lemma detached_test:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4383
  shows "detached s th = (Th th \<notin> Field (RAG s))"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4384
apply(simp add: detached_def Field_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4385
apply(simp add: s_RAG_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4386
apply(simp add: s_holding_abv s_waiting_abv)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4387
apply(simp add: Domain_iff Range_iff)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4388
apply(simp add: wq_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4389
apply(auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4390
done
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4391
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4392
context valid_trace
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4393
begin
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4394
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4395
lemma detached_intro:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4396
  assumes eq_pv: "cntP s th = cntV s th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4397
  shows "detached s th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4398
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4399
  from eq_pv cnp_cnv_cncs
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4400
  have "th \<in> readys s \<or> th \<notin> threads s" by (auto simp:pvD_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4401
  thus ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4402
  proof
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4403
    assume "th \<notin> threads s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4404
    with rg_RAG_threads dm_RAG_threads
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4405
    show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4406
      by (auto simp add: detached_def s_RAG_def s_waiting_abv 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4407
              s_holding_abv wq_def Domain_iff Range_iff)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4408
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4409
    assume "th \<in> readys s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4410
    moreover have "Th th \<notin> Range (RAG s)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4411
    proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4412
      from eq_pv_children[OF assms]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4413
      have "children (RAG s) (Th th) = {}" .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4414
      thus ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4415
      by (unfold children_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4416
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4417
    ultimately show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4418
      by (auto simp add: detached_def s_RAG_def s_waiting_abv 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4419
              s_holding_abv wq_def readys_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4420
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4421
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4422
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4423
lemma detached_elim:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4424
  assumes dtc: "detached s th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4425
  shows "cntP s th = cntV s th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4426
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4427
  have cncs_z: "cntCS s th = 0"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4428
  proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4429
    from dtc have "holdents s th = {}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4430
      unfolding detached_def holdents_test s_RAG_def
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4431
      by (simp add: s_waiting_abv wq_def s_holding_abv Domain_iff Range_iff)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4432
    thus ?thesis by (auto simp:cntCS_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4433
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4434
  show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4435
  proof(cases "th \<in> threads s")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4436
    case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4437
    with dtc 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4438
    have "th \<in> readys s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4439
      by (unfold readys_def detached_def Field_def Domain_def Range_def, 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4440
           auto simp:waiting_eq s_RAG_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4441
    with cncs_z  show ?thesis using cnp_cnv_cncs by (simp add:pvD_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4442
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4443
    case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4444
    with cncs_z and cnp_cnv_cncs show ?thesis by (simp add:pvD_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4445
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4446
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4447
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4448
lemma detached_eq:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4449
  shows "(detached s th) = (cntP s th = cntV s th)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4450
  by (insert vt, auto intro:detached_intro detached_elim)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4451
84
cfd644dfc3b4 The parallel of Implementation.thy, i.e. ExtGG.thy has been updated. And some errors in
zhangx
parents: 81
diff changeset
  4452
end
cfd644dfc3b4 The parallel of Implementation.thy, i.e. ExtGG.thy has been updated. And some errors in
zhangx
parents: 81
diff changeset
  4453
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4454
section {* Recursive definition of @{term "cp"} *}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4455
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4456
lemma cp_alt_def1: 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4457
  "cp s th = Max ((the_preced s o the_thread) ` (subtree (tRAG s) (Th th)))"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4458
proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4459
  have "(the_preced s ` the_thread ` subtree (tRAG s) (Th th)) =
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4460
       ((the_preced s \<circ> the_thread) ` subtree (tRAG s) (Th th))"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4461
       by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4462
  thus ?thesis by (unfold cp_alt_def, fold threads_set_eq, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4463
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4464
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4465
lemma cp_gen_def_cond: 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4466
  assumes "x = Th th"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4467
  shows "cp s th = cp_gen s (Th th)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4468
by (unfold cp_alt_def1 cp_gen_def, simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4469
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4470
lemma cp_gen_over_set:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4471
  assumes "\<forall> x \<in> A. \<exists> th. x = Th th"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4472
  shows "cp_gen s ` A = (cp s \<circ> the_thread) ` A"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4473
proof(rule f_image_eq)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4474
  fix a
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4475
  assume "a \<in> A"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4476
  from assms[rule_format, OF this]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4477
  obtain th where eq_a: "a = Th th" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4478
  show "cp_gen s a = (cp s \<circ> the_thread) a"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4479
    by  (unfold eq_a, simp, unfold cp_gen_def_cond[OF refl[of "Th th"]], simp)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4480
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4481
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4482
84
cfd644dfc3b4 The parallel of Implementation.thy, i.e. ExtGG.thy has been updated. And some errors in
zhangx
parents: 81
diff changeset
  4483
context valid_trace
cfd644dfc3b4 The parallel of Implementation.thy, i.e. ExtGG.thy has been updated. And some errors in
zhangx
parents: 81
diff changeset
  4484
begin
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4485
(* ddd *)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4486
lemma cp_gen_rec:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4487
  assumes "x = Th th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4488
  shows "cp_gen s x = Max ({the_preced s th} \<union> (cp_gen s) ` children (tRAG s) x)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4489
proof(cases "children (tRAG s) x = {}")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4490
  case True
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4491
  show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4492
    by (unfold True cp_gen_def subtree_children, simp add:assms)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4493
next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4494
  case False
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4495
  hence [simp]: "children (tRAG s) x \<noteq> {}" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4496
  note fsbttRAGs.finite_subtree[simp]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4497
  have [simp]: "finite (children (tRAG s) x)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4498
     by (intro rev_finite_subset[OF fsbttRAGs.finite_subtree], 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4499
            rule children_subtree)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4500
  { fix r x
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4501
    have "subtree r x \<noteq> {}" by (auto simp:subtree_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4502
  } note this[simp]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4503
  have [simp]: "\<exists>x\<in>children (tRAG s) x. subtree (tRAG s) x \<noteq> {}"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4504
  proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4505
    from False obtain q where "q \<in> children (tRAG s) x" by blast
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4506
    moreover have "subtree (tRAG s) q \<noteq> {}" by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4507
    ultimately show ?thesis by blast
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4508
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4509
  have h: "Max ((the_preced s \<circ> the_thread) `
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4510
                ({x} \<union> \<Union>(subtree (tRAG s) ` children (tRAG s) x))) =
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4511
        Max ({the_preced s th} \<union> cp_gen s ` children (tRAG s) x)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4512
                     (is "?L = ?R")
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4513
  proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4514
    let "Max (?f ` (?A \<union> \<Union> (?g ` ?B)))" = ?L
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4515
    let "Max (_ \<union> (?h ` ?B))" = ?R
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4516
    let ?L1 = "?f ` \<Union>(?g ` ?B)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4517
    have eq_Max_L1: "Max ?L1 = Max (?h ` ?B)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4518
    proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4519
      have "?L1 = ?f ` (\<Union> x \<in> ?B.(?g x))" by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4520
      also have "... =  (\<Union> x \<in> ?B. ?f ` (?g x))" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4521
      finally have "Max ?L1 = Max ..." by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4522
      also have "... = Max (Max ` (\<lambda>x. ?f ` subtree (tRAG s) x) ` ?B)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4523
        by (subst Max_UNION, simp+)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4524
      also have "... = Max (cp_gen s ` children (tRAG s) x)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4525
          by (unfold image_comp cp_gen_alt_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4526
      finally show ?thesis .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4527
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4528
    show ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4529
    proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4530
      have "?L = Max (?f ` ?A \<union> ?L1)" by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4531
      also have "... = max (the_preced s (the_thread x)) (Max ?L1)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4532
            by (subst Max_Un, simp+)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4533
      also have "... = max (?f x) (Max (?h ` ?B))"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4534
        by (unfold eq_Max_L1, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4535
      also have "... =?R"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4536
        by (rule max_Max_eq, (simp)+, unfold assms, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4537
      finally show ?thesis .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4538
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4539
  qed  thus ?thesis 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4540
          by (fold h subtree_children, unfold cp_gen_def, simp) 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4541
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4542
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4543
lemma cp_rec:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4544
  "cp s th = Max ({the_preced s th} \<union> 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4545
                     (cp s o the_thread) ` children (tRAG s) (Th th))"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4546
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4547
  have "Th th = Th th" by simp
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4548
  note h =  cp_gen_def_cond[OF this] cp_gen_rec[OF this]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4549
  show ?thesis 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4550
  proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4551
    have "cp_gen s ` children (tRAG s) (Th th) = 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4552
                (cp s \<circ> the_thread) ` children (tRAG s) (Th th)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4553
    proof(rule cp_gen_over_set)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4554
      show " \<forall>x\<in>children (tRAG s) (Th th). \<exists>th. x = Th th"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4555
        by (unfold tRAG_alt_def, auto simp:children_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4556
    qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4557
    thus ?thesis by (subst (1) h(1), unfold h(2), simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4558
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4559
qed
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4560
end
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4561
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4562
section {* Other properties useful in Implementation.thy or Correctness.thy *}
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4563
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4564
context valid_trace_e 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4565
begin
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4566
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4567
lemma actor_inv: 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4568
  assumes "\<not> isCreate e"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4569
  shows "actor e \<in> runing s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4570
  using pip_e assms 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4571
  by (induct, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4572
end
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4573
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4574
context valid_trace
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4575
begin
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4576
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4577
lemma readys_root:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4578
  assumes "th \<in> readys s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4579
  shows "root (RAG s) (Th th)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4580
proof -
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4581
  { fix x
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4582
    assume "x \<in> ancestors (RAG s) (Th th)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4583
    hence h: "(Th th, x) \<in> (RAG s)^+" by (auto simp:ancestors_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4584
    from tranclD[OF this]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4585
    obtain z where "(Th th, z) \<in> RAG s" by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4586
    with assms(1) have False
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4587
         apply (case_tac z, auto simp:readys_def s_RAG_def s_waiting_def cs_waiting_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4588
         by (fold wq_def, blast)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4589
  } thus ?thesis by (unfold root_def, auto)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4590
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4591
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4592
lemma readys_in_no_subtree:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4593
  assumes "th \<in> readys s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4594
  and "th' \<noteq> th"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4595
  shows "Th th \<notin> subtree (RAG s) (Th th')" 
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4596
proof
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4597
   assume "Th th \<in> subtree (RAG s) (Th th')"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4598
   thus False
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4599
   proof(cases rule:subtreeE)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4600
      case 1
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4601
      with assms show ?thesis by auto
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4602
   next
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4603
      case 2
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4604
      with readys_root[OF assms(1)]
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4605
      show ?thesis by (auto simp:root_def)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4606
   qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4607
qed
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4608
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4609
lemma not_in_thread_isolated:
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4610
  assumes "th \<notin> threads s"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4611
  shows "(Th th) \<notin> Field (RAG s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4612
proof
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4613
  assume "(Th th) \<in> Field (RAG s)"
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4614
  with dm_RAG_threads and rg_RAG_threads assms
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4615
  show False by (unfold Field_def, blast)
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4616
qed
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4617
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4618
lemma next_th_holding:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4619
  assumes nxt: "next_th s th cs th'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4620
  shows "holding (wq s) th cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4621
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4622
  from nxt[unfolded next_th_def]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4623
  obtain rest where h: "wq s cs = th # rest"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4624
                       "rest \<noteq> []" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4625
                       "th' = hd (SOME q. distinct q \<and> set q = set rest)" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4626
  thus ?thesis
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4627
    by (unfold cs_holding_def, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4628
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4629
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4630
lemma next_th_waiting:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4631
  assumes nxt: "next_th s th cs th'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4632
  shows "waiting (wq s) th' cs"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4633
proof -
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4634
  from nxt[unfolded next_th_def]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4635
  obtain rest where h: "wq s cs = th # rest"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4636
                       "rest \<noteq> []" 
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4637
                       "th' = hd (SOME q. distinct q \<and> set q = set rest)" by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4638
  from wq_distinct[of cs, unfolded h]
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4639
  have dst: "distinct (th # rest)" .
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4640
  have in_rest: "th' \<in> set rest"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4641
  proof(unfold h, rule someI2)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4642
    show "distinct rest \<and> set rest = set rest" using dst by auto
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4643
  next
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4644
    fix x assume "distinct x \<and> set x = set rest"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4645
    with h(2)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4646
    show "hd x \<in> set (rest)" by (cases x, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4647
  qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4648
  hence "th' \<in> set (wq s cs)" by (unfold h(1), auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4649
  moreover have "th' \<noteq> hd (wq s cs)"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4650
    by (unfold h(1), insert in_rest dst, auto)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4651
  ultimately show ?thesis by (auto simp:cs_waiting_def)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4652
qed
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4653
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4654
lemma next_th_RAG:
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4655
  assumes nxt: "next_th (s::event list) th cs th'"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4656
  shows "{(Cs cs, Th th), (Th th', Cs cs)} \<subseteq> RAG s"
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4657
  using vt assms next_th_holding next_th_waiting
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4658
  by (unfold s_RAG_def, simp)
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4659
112
b3795b1f030b Small improvements.
zhangx
parents: 109
diff changeset
  4660
end 
b3795b1f030b Small improvements.
zhangx
parents: 109
diff changeset
  4661
b3795b1f030b Small improvements.
zhangx
parents: 109
diff changeset
  4662
context valid_trace_p
b3795b1f030b Small improvements.
zhangx
parents: 109
diff changeset
  4663
begin
b3795b1f030b Small improvements.
zhangx
parents: 109
diff changeset
  4664
b3795b1f030b Small improvements.
zhangx
parents: 109
diff changeset
  4665
find_theorems readys th
b3795b1f030b Small improvements.
zhangx
parents: 109
diff changeset
  4666
81
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4667
end
c495eb16beb6 CpsG.thy restored. It was deleted. But now restored as a temporary holder of PIPBasics.thy.
zhangx
parents:
diff changeset
  4668
105
0c89419b4742 Commit to revert
zhangx
parents: 90
diff changeset
  4669
end