CpsG.thy
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Thu, 15 May 2014 16:02:44 +0100
changeset 33 9b9f2117561f
parent 32 e861aff29655
child 35 92f61f6a0fe7
permissions -rw-r--r--
simplified the cp_rec proof
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
     1
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     2
theory CpsG
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     3
imports PrioG 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     6
lemma not_thread_holdents:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     7
  fixes th s
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     8
  assumes vt: "vt s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     9
  and not_in: "th \<notin> threads s" 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    10
  shows "holdents s th = {}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    11
proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    12
  from vt not_in show ?thesis
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    13
  proof(induct arbitrary:th)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    14
    case (vt_cons s e th)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    15
    assume vt: "vt s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    16
      and ih: "\<And>th. th \<notin> threads s \<Longrightarrow> holdents s th = {}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    17
      and stp: "step s e"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    18
      and not_in: "th \<notin> threads (e # s)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    19
    from stp show ?case
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    20
    proof(cases)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    21
      case (thread_create thread prio)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    22
      assume eq_e: "e = Create thread prio"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    23
        and not_in': "thread \<notin> threads s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    24
      have "holdents (e # s) th = holdents s th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    25
        apply (unfold eq_e holdents_test)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    26
        by (simp add:depend_create_unchanged)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    27
      moreover have "th \<notin> threads s" 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    28
      proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    29
        from not_in eq_e show ?thesis by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    30
      qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    31
      moreover note ih ultimately show ?thesis by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    32
    next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    33
      case (thread_exit thread)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    34
      assume eq_e: "e = Exit thread"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    35
      and nh: "holdents s thread = {}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    36
      show ?thesis
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    37
      proof(cases "th = thread")
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    38
        case True
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    39
        with nh eq_e
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    40
        show ?thesis 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    41
          by (auto simp:holdents_test depend_exit_unchanged)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    42
      next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    43
        case False
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    44
        with not_in and eq_e
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    45
        have "th \<notin> threads s" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    46
        from ih[OF this] False eq_e show ?thesis 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    47
          by (auto simp:holdents_test depend_exit_unchanged)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    48
      qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    49
    next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    50
      case (thread_P thread cs)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    51
      assume eq_e: "e = P thread cs"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    52
      and is_runing: "thread \<in> runing s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    53
      from assms thread_exit ih stp not_in vt eq_e have vtp: "vt (P thread cs#s)" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    54
      have neq_th: "th \<noteq> thread" 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    55
      proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    56
        from not_in eq_e have "th \<notin> threads s" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    57
        moreover from is_runing have "thread \<in> threads s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    58
          by (simp add:runing_def readys_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    59
        ultimately show ?thesis by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    60
      qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    61
      hence "holdents (e # s) th  = holdents s th "
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    62
        apply (unfold cntCS_def holdents_test eq_e)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    63
        by (unfold step_depend_p[OF vtp], auto)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    64
      moreover have "holdents s th = {}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    65
      proof(rule ih)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    66
        from not_in eq_e show "th \<notin> threads s" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    67
      qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    68
      ultimately show ?thesis by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    69
    next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    70
      case (thread_V thread cs)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    71
      assume eq_e: "e = V thread cs"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    72
        and is_runing: "thread \<in> runing s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    73
        and hold: "holding s thread cs"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    74
      have neq_th: "th \<noteq> thread" 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    75
      proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    76
        from not_in eq_e have "th \<notin> threads s" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    77
        moreover from is_runing have "thread \<in> threads s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    78
          by (simp add:runing_def readys_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    79
        ultimately show ?thesis by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    80
      qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    81
      from assms thread_V eq_e ih stp not_in vt have vtv: "vt (V thread cs#s)" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    82
      from hold obtain rest 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    83
        where eq_wq: "wq s cs = thread # rest"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    84
        by (case_tac "wq s cs", auto simp: wq_def s_holding_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    85
      from not_in eq_e eq_wq
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    86
      have "\<not> next_th s thread cs th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    87
        apply (auto simp:next_th_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    88
      proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    89
        assume ne: "rest \<noteq> []"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    90
          and ni: "hd (SOME q. distinct q \<and> set q = set rest) \<notin> threads s" (is "?t \<notin> threads s")
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    91
        have "?t \<in> set rest"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    92
        proof(rule someI2)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    93
          from wq_distinct[OF step_back_vt[OF vtv], of cs] and eq_wq
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    94
          show "distinct rest \<and> set rest = set rest" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    95
        next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    96
          fix x assume "distinct x \<and> set x = set rest" with ne
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    97
          show "hd x \<in> set rest" by (cases x, auto)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    98
        qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    99
        with eq_wq have "?t \<in> set (wq s cs)" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   100
        from wq_threads[OF step_back_vt[OF vtv], OF this] and ni
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   101
        show False by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   102
      qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   103
      moreover note neq_th eq_wq
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   104
      ultimately have "holdents (e # s) th  = holdents s th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   105
        by (unfold eq_e cntCS_def holdents_test step_depend_v[OF vtv], auto)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   106
      moreover have "holdents s th = {}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   107
      proof(rule ih)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   108
        from not_in eq_e show "th \<notin> threads s" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   109
      qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   110
      ultimately show ?thesis by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   111
    next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   112
      case (thread_set thread prio)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   113
      print_facts
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   114
      assume eq_e: "e = Set thread prio"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   115
        and is_runing: "thread \<in> runing s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   116
      from not_in and eq_e have "th \<notin> threads s" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   117
      from ih [OF this] and eq_e
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   118
      show ?thesis 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   119
        apply (unfold eq_e cntCS_def holdents_test)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   120
        by (simp add:depend_set_unchanged)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   121
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   122
    next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   123
      case vt_nil
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   124
      show ?case
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   125
      by (auto simp:count_def holdents_test s_depend_def wq_def cs_holding_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   126
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   127
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   128
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   129
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   130
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   131
lemma next_th_neq: 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   132
  assumes vt: "vt s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   133
  and nt: "next_th s th cs th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   134
  shows "th' \<noteq> th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   135
proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   136
  from nt show ?thesis
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   137
    apply (auto simp:next_th_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   138
  proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   139
    fix rest
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   140
    assume eq_wq: "wq s cs = hd (SOME q. distinct q \<and> set q = set rest) # rest"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   141
      and ne: "rest \<noteq> []"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   142
    have "hd (SOME q. distinct q \<and> set q = set rest) \<in> set rest" 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   143
    proof(rule someI2)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   144
      from wq_distinct[OF vt, of cs] eq_wq
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   145
      show "distinct rest \<and> set rest = set rest" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   146
    next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   147
      fix x
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   148
      assume "distinct x \<and> set x = set rest"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   149
      hence eq_set: "set x = set rest" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   150
      with ne have "x \<noteq> []" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   151
      hence "hd x \<in> set x" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   152
      with eq_set show "hd x \<in> set rest" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   153
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   154
    with wq_distinct[OF vt, of cs] eq_wq show False by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   155
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   156
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   157
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   158
lemma next_th_unique: 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   159
  assumes nt1: "next_th s th cs th1"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   160
  and nt2: "next_th s th cs th2"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   161
  shows "th1 = th2"
33
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   162
using assms by (unfold next_th_def, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   163
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   164
lemma wf_depend:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   165
  assumes vt: "vt s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   166
  shows "wf (depend s)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   167
proof(rule finite_acyclic_wf)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   168
  from finite_depend[OF vt] show "finite (depend s)" .
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   169
next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   170
  from acyclic_depend[OF vt] show "acyclic (depend s)" .
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   171
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   172
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   173
lemma Max_Union:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   174
  assumes fc: "finite C"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   175
  and ne: "C \<noteq> {}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   176
  and fa: "\<And> A. A \<in> C \<Longrightarrow> finite A \<and> A \<noteq> {}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   177
  shows "Max (\<Union> C) = Max (Max ` C)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   178
proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   179
  from fc ne fa show ?thesis
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   180
  proof(induct)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   181
    case (insert x F)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   182
    assume ih: "\<lbrakk>F \<noteq> {}; \<And>A. A \<in> F \<Longrightarrow> finite A \<and> A \<noteq> {}\<rbrakk> \<Longrightarrow> Max (\<Union>F) = Max (Max ` F)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   183
    and h: "\<And> A. A \<in> insert x F \<Longrightarrow> finite A \<and> A \<noteq> {}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   184
    show ?case (is "?L = ?R")
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   185
    proof(cases "F = {}")
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   186
      case False
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   187
      from Union_insert have "?L = Max (x \<union> (\<Union> F))" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   188
      also have "\<dots> = max (Max x) (Max(\<Union> F))"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   189
      proof(rule Max_Un)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   190
        from h[of x] show "finite x" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   191
      next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   192
        from h[of x] show "x \<noteq> {}" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   193
      next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   194
        show "finite (\<Union>F)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   195
        proof(rule finite_Union)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   196
          show "finite F" by fact
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   197
        next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   198
          from h show "\<And>M. M \<in> F \<Longrightarrow> finite M" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   199
        qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   200
      next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   201
        from False and h show "\<Union>F \<noteq> {}" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   202
      qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   203
      also have "\<dots> = ?R"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   204
      proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   205
        have "?R = Max (Max ` ({x} \<union> F))" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   206
        also have "\<dots> = Max ({Max x} \<union> (Max ` F))" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   207
        also have "\<dots> = max (Max x) (Max (\<Union>F))"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   208
        proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   209
          have "Max ({Max x} \<union> Max ` F) = max (Max {Max x}) (Max (Max ` F))"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   210
          proof(rule Max_Un)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   211
            show "finite {Max x}" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   212
          next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   213
            show "{Max x} \<noteq> {}" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   214
          next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   215
            from insert show "finite (Max ` F)" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   216
          next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   217
            from False show "Max ` F \<noteq> {}" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   218
          qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   219
          moreover have "Max {Max x} = Max x" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   220
          moreover have "Max (\<Union>F) = Max (Max ` F)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   221
          proof(rule ih)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   222
            show "F \<noteq> {}" by fact
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   223
          next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   224
            from h show "\<And>A. A \<in> F \<Longrightarrow> finite A \<and> A \<noteq> {}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   225
              by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   226
          qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   227
          ultimately show ?thesis by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   228
        qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   229
        finally show ?thesis by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   230
      qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   231
      finally show ?thesis by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   232
    next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   233
      case True
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   234
      thus ?thesis by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   235
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   236
  next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   237
    case empty
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   238
    assume "{} \<noteq> {}" show ?case by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   239
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   240
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   241
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   242
definition child :: "state \<Rightarrow> (node \<times> node) set"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   243
  where "child s \<equiv>
33
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   244
            {(Th th', Th th) | th th'. \<exists>cs. (Th th', Cs cs) \<in> depend s \<and> (Cs cs, Th th) \<in> depend s}"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   245
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   246
definition children :: "state \<Rightarrow> thread \<Rightarrow> thread set"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   247
  where "children s th \<equiv> {th'. (Th th', Th th) \<in> child s}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   248
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   249
lemma children_def2:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   250
  "children s th \<equiv> {th'. \<exists> cs. (Th th', Cs cs) \<in> depend s \<and> (Cs cs, Th th) \<in> depend s}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   251
unfolding child_def children_def by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   252
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   253
lemma children_dependants: "children s th \<subseteq> dependants (wq s) th"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   254
  by (unfold children_def child_def cs_dependants_def, auto simp:eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   255
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   256
lemma child_unique:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   257
  assumes vt: "vt s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   258
  and ch1: "(Th th, Th th1) \<in> child s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   259
  and ch2: "(Th th, Th th2) \<in> child s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   260
  shows "th1 = th2"
33
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   261
using ch1 ch2 
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   262
proof(unfold child_def, clarsimp)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   263
  fix cs csa
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   264
  assume h1: "(Th th, Cs cs) \<in> depend s"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   265
    and h2: "(Cs cs, Th th1) \<in> depend s"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   266
    and h3: "(Th th, Cs csa) \<in> depend s"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   267
    and h4: "(Cs csa, Th th2) \<in> depend s"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   268
  from unique_depend[OF vt h1 h3] have "cs = csa" by simp
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   269
  with h4 have "(Cs cs, Th th2) \<in> depend s" by simp
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   270
  from unique_depend[OF vt h2 this]
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   271
  show "th1 = th2" by simp
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   272
qed 
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   273
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   274
lemma depend_children:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   275
  assumes h: "(Th th1, Th th2) \<in> (depend s)^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   276
  shows "th1 \<in> children s th2 \<or> (\<exists> th3. th3 \<in> children s th2 \<and> (Th th1, Th th3) \<in> (depend s)^+)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   277
proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   278
  from h show ?thesis
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   279
  proof(induct rule: tranclE)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   280
    fix c th2
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   281
    assume h1: "(Th th1, c) \<in> (depend s)\<^sup>+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   282
    and h2: "(c, Th th2) \<in> depend s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   283
    from h2 obtain cs where eq_c: "c = Cs cs"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   284
      by (case_tac c, auto simp:s_depend_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   285
    show "th1 \<in> children s th2 \<or> (\<exists>th3. th3 \<in> children s th2 \<and> (Th th1, Th th3) \<in> (depend s)\<^sup>+)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   286
    proof(rule tranclE[OF h1])
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   287
      fix ca
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   288
      assume h3: "(Th th1, ca) \<in> (depend s)\<^sup>+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   289
        and h4: "(ca, c) \<in> depend s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   290
      show "th1 \<in> children s th2 \<or> (\<exists>th3. th3 \<in> children s th2 \<and> (Th th1, Th th3) \<in> (depend s)\<^sup>+)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   291
      proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   292
        from eq_c and h4 obtain th3 where eq_ca: "ca = Th th3"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   293
          by (case_tac ca, auto simp:s_depend_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   294
        from eq_ca h4 h2 eq_c
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   295
        have "th3 \<in> children s th2" by (auto simp:children_def child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   296
        moreover from h3 eq_ca have "(Th th1, Th th3) \<in> (depend s)\<^sup>+" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   297
        ultimately show ?thesis by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   298
      qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   299
    next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   300
      assume "(Th th1, c) \<in> depend s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   301
      with h2 eq_c
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   302
      have "th1 \<in> children s th2"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   303
        by (auto simp:children_def child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   304
      thus ?thesis by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   305
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   306
  next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   307
    assume "(Th th1, Th th2) \<in> depend s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   308
    thus ?thesis
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   309
      by (auto simp:s_depend_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   310
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   311
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   312
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   313
lemma sub_child: "child s \<subseteq> (depend s)^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   314
  by (unfold child_def, auto)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   315
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   316
lemma wf_child: 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   317
  assumes vt: "vt s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   318
  shows "wf (child s)"
33
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   319
apply(rule wf_subset)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   320
apply(rule wf_trancl[OF wf_depend[OF vt]])
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   321
apply(rule sub_child)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   322
done
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   323
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   324
lemma depend_child_pre:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   325
  assumes vt: "vt s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   326
  shows
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   327
  "(Th th, n) \<in> (depend s)^+ \<longrightarrow> (\<forall> th'. n = (Th th') \<longrightarrow> (Th th, Th th') \<in> (child s)^+)" (is "?P n")
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   328
proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   329
  from wf_trancl[OF wf_depend[OF vt]]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   330
  have wf: "wf ((depend s)^+)" .
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   331
  show ?thesis
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   332
  proof(rule wf_induct[OF wf, of ?P], clarsimp)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   333
    fix th'
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   334
    assume ih[rule_format]: "\<forall>y. (y, Th th') \<in> (depend s)\<^sup>+ \<longrightarrow>
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   335
               (Th th, y) \<in> (depend s)\<^sup>+ \<longrightarrow> (\<forall>th'. y = Th th' \<longrightarrow> (Th th, Th th') \<in> (child s)\<^sup>+)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   336
    and h: "(Th th, Th th') \<in> (depend s)\<^sup>+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   337
    show "(Th th, Th th') \<in> (child s)\<^sup>+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   338
    proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   339
      from depend_children[OF h]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   340
      have "th \<in> children s th' \<or> (\<exists>th3. th3 \<in> children s th' \<and> (Th th, Th th3) \<in> (depend s)\<^sup>+)" .
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   341
      thus ?thesis
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   342
      proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   343
        assume "th \<in> children s th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   344
        thus "(Th th, Th th') \<in> (child s)\<^sup>+" by (auto simp:children_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   345
      next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   346
        assume "\<exists>th3. th3 \<in> children s th' \<and> (Th th, Th th3) \<in> (depend s)\<^sup>+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   347
        then obtain th3 where th3_in: "th3 \<in> children s th'" 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   348
          and th_dp: "(Th th, Th th3) \<in> (depend s)\<^sup>+" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   349
        from th3_in have "(Th th3, Th th') \<in> (depend s)^+" by (auto simp:children_def child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   350
        from ih[OF this th_dp, of th3] have "(Th th, Th th3) \<in> (child s)\<^sup>+" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   351
        with th3_in show "(Th th, Th th') \<in> (child s)\<^sup>+" by (auto simp:children_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   352
      qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   353
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   354
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   355
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   356
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   357
lemma depend_child: "\<lbrakk>vt s; (Th th, Th th') \<in> (depend s)^+\<rbrakk> \<Longrightarrow> (Th th, Th th') \<in> (child s)^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   358
  by (insert depend_child_pre, auto)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   359
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   360
lemma child_depend_p:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   361
  assumes "(n1, n2) \<in> (child s)^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   362
  shows "(n1, n2) \<in> (depend s)^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   363
proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   364
  from assms show ?thesis
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   365
  proof(induct)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   366
    case (base y)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   367
    with sub_child show ?case by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   368
  next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   369
    case (step y z)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   370
    assume "(y, z) \<in> child s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   371
    with sub_child have "(y, z) \<in> (depend s)^+" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   372
    moreover have "(n1, y) \<in> (depend s)^+" by fact
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   373
    ultimately show ?case by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   374
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   375
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   376
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   377
lemma child_depend_eq: 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   378
  assumes vt: "vt s"
33
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   379
  shows "(Th th1, Th th2) \<in> (child s)^+  \<longleftrightarrow> (Th th1, Th th2) \<in> (depend s)^+"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   380
  by (auto intro: depend_child[OF vt] child_depend_p)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   381
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   382
lemma children_no_dep:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   383
  fixes s th th1 th2 th3
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   384
  assumes vt: "vt s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   385
  and ch1: "(Th th1, Th th) \<in> child s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   386
  and ch2: "(Th th2, Th th) \<in> child s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   387
  and ch3: "(Th th1, Th th2) \<in> (depend s)^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   388
  shows "False"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   389
proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   390
  from depend_child[OF vt ch3]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   391
  have "(Th th1, Th th2) \<in> (child s)\<^sup>+" .
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   392
  thus ?thesis
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   393
  proof(rule converse_tranclE)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   394
    assume "(Th th1, Th th2) \<in> child s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   395
    from child_unique[OF vt ch1 this] have "th = th2" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   396
    with ch2 have "(Th th2, Th th2) \<in> child s" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   397
    with wf_child[OF vt] show ?thesis by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   398
  next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   399
    fix c
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   400
    assume h1: "(Th th1, c) \<in> child s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   401
      and h2: "(c, Th th2) \<in> (child s)\<^sup>+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   402
    from h1 obtain th3 where eq_c: "c = Th th3" by (unfold child_def, auto)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   403
    with h1 have "(Th th1, Th th3) \<in> child s" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   404
    from child_unique[OF vt ch1 this] have eq_th3: "th3 = th" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   405
    with eq_c and h2 have "(Th th, Th th2) \<in> (child s)\<^sup>+" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   406
    with ch2 have "(Th th, Th th) \<in> (child s)\<^sup>+" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   407
    moreover have "wf ((child s)\<^sup>+)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   408
    proof(rule wf_trancl)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   409
      from wf_child[OF vt] show "wf (child s)" .
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   410
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   411
    ultimately show False by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   412
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   413
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   414
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   415
lemma unique_depend_p:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   416
  assumes vt: "vt s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   417
  and dp1: "(n, n1) \<in> (depend s)^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   418
  and dp2: "(n, n2) \<in> (depend s)^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   419
  and neq: "n1 \<noteq> n2"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   420
  shows "(n1, n2) \<in> (depend s)^+ \<or> (n2, n1) \<in> (depend s)^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   421
proof(rule unique_chain [OF _ dp1 dp2 neq])
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   422
  from unique_depend[OF vt]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   423
  show "\<And>a b c. \<lbrakk>(a, b) \<in> depend s; (a, c) \<in> depend s\<rbrakk> \<Longrightarrow> b = c" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   424
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   425
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   426
lemma dependants_child_unique:
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   427
  fixes s th th1 th2 th3
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   428
  assumes vt: "vt s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   429
  and ch1: "(Th th1, Th th) \<in> child s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   430
  and ch2: "(Th th2, Th th) \<in> child s"
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   431
  and dp1: "th3 \<in> dependants s th1"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   432
  and dp2: "th3 \<in> dependants s th2"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   433
shows "th1 = th2"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   434
proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   435
  { assume neq: "th1 \<noteq> th2"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   436
    from dp1 have dp1: "(Th th3, Th th1) \<in> (depend s)^+" 
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   437
      by (simp add:s_dependants_def eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   438
    from dp2 have dp2: "(Th th3, Th th2) \<in> (depend s)^+" 
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   439
      by (simp add:s_dependants_def eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   440
    from unique_depend_p[OF vt dp1 dp2] and neq
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   441
    have "(Th th1, Th th2) \<in> (depend s)\<^sup>+ \<or> (Th th2, Th th1) \<in> (depend s)\<^sup>+" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   442
    hence False
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   443
    proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   444
      assume "(Th th1, Th th2) \<in> (depend s)\<^sup>+ "
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   445
      from children_no_dep[OF vt ch1 ch2 this] show ?thesis .
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   446
    next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   447
      assume " (Th th2, Th th1) \<in> (depend s)\<^sup>+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   448
      from children_no_dep[OF vt ch2 ch1 this] show ?thesis .
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   449
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   450
  } thus ?thesis by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   451
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   452
33
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   453
lemma depend_plus_elim:
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   454
  assumes "vt s"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   455
  fixes x
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   456
  assumes "(Th x, Th th) \<in> (depend (wq s))\<^sup>+"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   457
  shows "\<exists>th'\<in>children s th. x = th' \<or> (Th x, Th th') \<in> (depend (wq s))\<^sup>+"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   458
  using assms(2)[unfolded eq_depend, folded child_depend_eq[OF `vt s`]]
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   459
  apply (unfold children_def)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   460
  by (metis assms(2) children_def depend_children eq_depend)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   461
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   462
lemma dependants_expand_pre: 
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   463
  assumes "vt s"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   464
  shows "dependants (wq s) th = (\<Union> th' \<in> children s th. {th'} \<union> dependants (wq s) th')"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   465
  apply (unfold cs_dependants_def)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   466
  apply (auto elim!:depend_plus_elim[OF assms])
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   467
  apply (metis children_def eq_depend mem_Collect_eq set_mp sub_child)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   468
  apply (unfold children_def, auto)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   469
  apply (unfold eq_depend, fold  child_depend_eq[OF `vt s`])
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   470
  by (metis trancl.simps)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   471
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   472
lemma dependants_expand:
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   473
  assumes "vt s"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   474
  shows "dependants (wq s) th = (\<Union> ((\<lambda> th. {th} \<union> dependants (wq s) th) ` (children s th)))"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   475
  apply (subst dependants_expand_pre[OF assms])
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   476
  by simp
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   477
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   478
lemma finite_children:
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   479
  assumes "vt s"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   480
  shows "finite (children s th)"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   481
  using children_dependants dependants_threads[OF assms] finite_threads[OF assms]
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   482
  by (metis rev_finite_subset)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   483
  
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   484
lemma finite_dependants:
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   485
  assumes "vt s"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   486
  shows "finite (dependants (wq s) th')"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   487
  using dependants_threads[OF assms] finite_threads[OF assms]
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   488
  by (metis rev_finite_subset)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   489
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   490
lemma Max_insert:
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   491
  assumes "finite B"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   492
  and  "B \<noteq> {}"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   493
  shows "Max ({x} \<union> B) = max x (Max B)"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   494
  by (metis Max_insert assms insert_is_Un)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   495
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   496
lemma dependands_expand2:
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   497
  assumes "vt s"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   498
  shows "dependants (wq s) th = (children s th) \<union> (\<Union>((dependants (wq s)) ` children s th))"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   499
  by (subst dependants_expand[OF assms]) (auto)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   500
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   501
abbreviation
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   502
  "preceds s Ths \<equiv> {preced th s| th. th \<in> Ths}"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   503
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   504
lemma image_compr:
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   505
  "f ` A = {f x | x. x \<in> A}"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   506
by auto
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   507
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   508
lemma Un_compr:
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   509
  "{f th | th. R th \<or> Q th} = ({f th | th. R th} \<union> {f th' | th'. Q th'})"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   510
by auto
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   511
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   512
lemma in_disj:
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   513
  shows "x \<in> A \<or> (\<exists>y \<in> A. x \<in> Q y) \<longleftrightarrow> (\<exists>y \<in> A. x = y \<or> x \<in> Q y)"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   514
by metis
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   515
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   516
lemma UN_exists:
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   517
  shows "(\<Union>x \<in> A. {f y | y. Q y x}) = ({f y | y. (\<exists>x \<in> A. Q y x)})"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   518
by auto
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   519
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   520
lemma cp_rec:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   521
  fixes s th
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   522
  assumes vt: "vt s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   523
  shows "cp s th = Max ({preced th s} \<union> (cp s ` children s th))"
33
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   524
proof(cases "children s th = {}")
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   525
  case True
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   526
  show ?thesis
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   527
    unfolding cp_eq_cpreced cpreced_def 
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   528
    by (subst dependants_expand[OF `vt s`]) (simp add: True)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   529
next
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   530
  case False
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   531
  show ?thesis (is "?LHS = ?RHS")
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   532
  proof -
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   533
    have eq_cp: "cp s = (\<lambda>th. Max (preceds s ({th} \<union> dependants (wq s) th)))"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   534
      by (simp add: fun_eq_iff cp_eq_cpreced cpreced_def Un_compr image_compr[symmetric])
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   535
  
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   536
    have not_emptyness_facts[simp]: 
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   537
      "dependants (wq s) th \<noteq> {}" "children s th \<noteq> {}"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   538
      using False dependands_expand2[OF assms] by(auto simp only: Un_empty)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   539
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   540
    have finiteness_facts[simp]:
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   541
      "\<And>th. finite (dependants (wq s) th)" "\<And>th. finite (children s th)"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   542
      by (simp_all add: finite_dependants[OF `vt s`] finite_children[OF `vt s`])
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   543
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   544
    (* expanding definition *)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   545
    have "?LHS = Max ({preced th s} \<union> preceds s (dependants (wq s) th))"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   546
      unfolding eq_cp by (simp add: Un_compr)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   547
    
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   548
    (* moving Max in *)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   549
    also have "\<dots> = max (Max {preced th s}) (Max (preceds s (dependants (wq s) th)))"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   550
      by (simp add: Max_Un)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   551
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   552
    (* expanding dependants *)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   553
    also have "\<dots> = max (Max {preced th s}) 
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   554
      (Max (preceds s (children s th \<union> \<Union>(dependants (wq s) ` children s th))))"
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   555
      by (subst dependands_expand2[OF `vt s`]) (simp)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   556
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   557
    (* moving out big Union *)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   558
    also have "\<dots> = max (Max {preced th s})
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   559
      (Max (preceds s (\<Union> ({children s th} \<union> (dependants (wq s) ` children s th)))))"  
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   560
      by simp
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   561
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   562
    (* moving in small union *)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   563
    also have "\<dots> = max (Max {preced th s})
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   564
      (Max (preceds s (\<Union> ((\<lambda>th. {th} \<union> (dependants (wq s) th)) ` children s th))))"  
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   565
      by (simp add: in_disj)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   566
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   567
    (* moving in preceds *)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   568
    also have "\<dots> = max (Max {preced th s})  
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   569
      (Max (\<Union> ((\<lambda>th. preceds s ({th} \<union> (dependants (wq s) th))) ` children s th)))" 
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   570
      by (simp add: UN_exists)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   571
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   572
    (* moving in Max *)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   573
    also have "\<dots> = max (Max {preced th s})  
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   574
      (Max ((\<lambda>th. Max (preceds s ({th} \<union> (dependants (wq s) th)))) ` children s th))" 
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   575
      by (subst Max_Union) (auto simp add: image_image)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   576
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   577
    (* folding cp + moving out Max *)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   578
    also have "\<dots> = ?RHS" 
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   579
      unfolding eq_cp by (simp add: Max_insert)
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   580
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
   581
    finally show "?LHS = ?RHS" .
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   582
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   583
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   584
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   585
definition cps:: "state \<Rightarrow> (thread \<times> precedence) set"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   586
where "cps s = {(th, cp s th) | th . th \<in> threads s}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   587
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   588
locale step_set_cps =
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   589
  fixes s' th prio s 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   590
  defines s_def : "s \<equiv> (Set th prio#s')"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   591
  assumes vt_s: "vt s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   592
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   593
context step_set_cps 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   594
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   595
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   596
lemma eq_preced:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   597
  fixes th'
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   598
  assumes "th' \<noteq> th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   599
  shows "preced th' s = preced th' s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   600
proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   601
  from assms show ?thesis 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   602
    by (unfold s_def, auto simp:preced_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   603
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   604
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   605
lemma eq_dep: "depend s = depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   606
  by (unfold s_def depend_set_unchanged, auto)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   607
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   608
lemma eq_cp_pre:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   609
  fixes th' 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   610
  assumes neq_th: "th' \<noteq> th"
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   611
  and nd: "th \<notin> dependants s th'"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   612
  shows "cp s th' = cp s' th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   613
  apply (unfold cp_eq_cpreced cpreced_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   614
proof -
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   615
  have eq_dp: "\<And> th. dependants (wq s) th = dependants (wq s') th"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   616
    by (unfold cs_dependants_def, auto simp:eq_dep eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   617
  moreover {
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   618
    fix th1 
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   619
    assume "th1 \<in> {th'} \<union> dependants (wq s') th'"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   620
    hence "th1 = th' \<or> th1 \<in> dependants (wq s') th'" by auto
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   621
    hence "preced th1 s = preced th1 s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   622
    proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   623
      assume "th1 = th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   624
      with eq_preced[OF neq_th]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   625
      show "preced th1 s = preced th1 s'" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   626
    next
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   627
      assume "th1 \<in> dependants (wq s') th'"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   628
      with nd and eq_dp have "th1 \<noteq> th"
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   629
        by (auto simp:eq_depend cs_dependants_def s_dependants_def eq_dep)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   630
      from eq_preced[OF this] show "preced th1 s = preced th1 s'" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   631
    qed
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   632
  } ultimately have "((\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th')) = 
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   633
                     ((\<lambda>th. preced th s') ` ({th'} \<union> dependants (wq s') th'))" 
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   634
    by (auto simp:image_def)
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   635
  thus "Max ((\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th')) =
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   636
        Max ((\<lambda>th. preced th s') ` ({th'} \<union> dependants (wq s') th'))" by simp
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   637
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   638
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   639
lemma no_dependants:
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   640
  assumes "th' \<noteq> th"
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   641
  shows "th \<notin> dependants s th'"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   642
proof
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   643
  assume h: "th \<in> dependants s th'"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   644
  from step_back_step [OF vt_s[unfolded s_def]]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   645
  have "step s' (Set th prio)" .
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   646
  hence "th \<in> runing s'" by (cases, simp)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   647
  hence rd_th: "th \<in> readys s'" 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   648
    by (simp add:readys_def runing_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   649
  from h have "(Th th, Th th') \<in> (depend s')\<^sup>+"
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   650
    by (unfold s_dependants_def, unfold eq_depend, unfold eq_dep, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   651
  from tranclD[OF this]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   652
  obtain z where "(Th th, z) \<in> depend s'" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   653
  with rd_th show "False"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   654
    apply (case_tac z, auto simp:readys_def s_waiting_def s_depend_def s_waiting_def cs_waiting_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   655
    by (fold wq_def, blast)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   656
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   657
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   658
(* Result improved *)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   659
lemma eq_cp:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   660
 fixes th' 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   661
  assumes neq_th: "th' \<noteq> th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   662
  shows "cp s th' = cp s' th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   663
proof(rule eq_cp_pre [OF neq_th])
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   664
  from no_dependants[OF neq_th] 
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   665
  show "th \<notin> dependants s th'" .
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   666
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   667
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   668
lemma eq_up:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   669
  fixes th' th''
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   670
  assumes dp1: "th \<in> dependants s th'"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   671
  and dp2: "th' \<in> dependants s th''"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   672
  and eq_cps: "cp s th' = cp s' th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   673
  shows "cp s th'' = cp s' th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   674
proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   675
  from dp2
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   676
  have "(Th th', Th th'') \<in> (depend (wq s))\<^sup>+" by (simp add:s_dependants_def)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   677
  from depend_child[OF vt_s this[unfolded eq_depend]]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   678
  have ch_th': "(Th th', Th th'') \<in> (child s)\<^sup>+" .
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   679
  moreover { fix n th''
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   680
    have "\<lbrakk>(Th th', n) \<in> (child s)^+\<rbrakk> \<Longrightarrow>
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   681
                   (\<forall> th'' . n = Th th'' \<longrightarrow> cp s th'' = cp s' th'')"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   682
    proof(erule trancl_induct, auto)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   683
      fix y th''
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   684
      assume y_ch: "(y, Th th'') \<in> child s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   685
        and ih: "\<forall>th''. y = Th th'' \<longrightarrow> cp s th'' = cp s' th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   686
        and ch': "(Th th', y) \<in> (child s)\<^sup>+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   687
      from y_ch obtain thy where eq_y: "y = Th thy" by (auto simp:child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   688
      with ih have eq_cpy:"cp s thy = cp s' thy" by blast
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   689
      from dp1 have "(Th th, Th th') \<in> (depend s)^+" by (auto simp:s_dependants_def eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   690
      moreover from child_depend_p[OF ch'] and eq_y
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   691
      have "(Th th', Th thy) \<in> (depend s)^+" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   692
      ultimately have dp_thy: "(Th th, Th thy) \<in> (depend s)^+" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   693
      show "cp s th'' = cp s' th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   694
        apply (subst cp_rec[OF vt_s])
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   695
      proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   696
        have "preced th'' s = preced th'' s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   697
        proof(rule eq_preced)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   698
          show "th'' \<noteq> th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   699
          proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   700
            assume "th'' = th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   701
            with dp_thy y_ch[unfolded eq_y] 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   702
            have "(Th th, Th th) \<in> (depend s)^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   703
              by (auto simp:child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   704
            with wf_trancl[OF wf_depend[OF vt_s]] 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   705
            show False by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   706
          qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   707
        qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   708
        moreover { 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   709
          fix th1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   710
          assume th1_in: "th1 \<in> children s th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   711
          have "cp s th1 = cp s' th1"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   712
          proof(cases "th1 = thy")
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   713
            case True
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   714
            with eq_cpy show ?thesis by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   715
          next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   716
            case False
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   717
            have neq_th1: "th1 \<noteq> th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   718
            proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   719
              assume eq_th1: "th1 = th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   720
              with dp_thy have "(Th th1, Th thy) \<in> (depend s)^+" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   721
              from children_no_dep[OF vt_s _ _ this] and 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   722
              th1_in y_ch eq_y show False by (auto simp:children_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   723
            qed
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   724
            have "th \<notin> dependants s th1"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   725
            proof
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   726
              assume h:"th \<in> dependants s th1"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   727
              from eq_y dp_thy have "th \<in> dependants s thy" by (auto simp:s_dependants_def eq_depend)
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   728
              from dependants_child_unique[OF vt_s _ _ h this]
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   729
              th1_in y_ch eq_y have "th1 = thy" by (auto simp:children_def child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   730
              with False show False by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   731
            qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   732
            from eq_cp_pre[OF neq_th1 this]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   733
            show ?thesis .
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   734
          qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   735
        }
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   736
        ultimately have "{preced th'' s} \<union> (cp s ` children s th'') = 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   737
          {preced th'' s'} \<union> (cp s' ` children s th'')" by (auto simp:image_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   738
        moreover have "children s th'' = children s' th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   739
          by (unfold children_def child_def s_def depend_set_unchanged, simp)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   740
        ultimately show "Max ({preced th'' s} \<union> cp s ` children s th'') = cp s' th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   741
          by (simp add:cp_rec[OF step_back_vt[OF vt_s[unfolded s_def]]])
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   742
      qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   743
    next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   744
      fix th''
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   745
      assume dp': "(Th th', Th th'') \<in> child s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   746
      show "cp s th'' = cp s' th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   747
        apply (subst cp_rec[OF vt_s])
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   748
      proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   749
        have "preced th'' s = preced th'' s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   750
        proof(rule eq_preced)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   751
          show "th'' \<noteq> th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   752
          proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   753
            assume "th'' = th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   754
            with dp1 dp'
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   755
            have "(Th th, Th th) \<in> (depend s)^+"
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   756
              by (auto simp:child_def s_dependants_def eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   757
            with wf_trancl[OF wf_depend[OF vt_s]] 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   758
            show False by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   759
          qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   760
        qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   761
        moreover { 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   762
          fix th1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   763
          assume th1_in: "th1 \<in> children s th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   764
          have "cp s th1 = cp s' th1"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   765
          proof(cases "th1 = th'")
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   766
            case True
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   767
            with eq_cps show ?thesis by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   768
          next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   769
            case False
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   770
            have neq_th1: "th1 \<noteq> th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   771
            proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   772
              assume eq_th1: "th1 = th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   773
              with dp1 have "(Th th1, Th th') \<in> (depend s)^+" 
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   774
                by (auto simp:s_dependants_def eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   775
              from children_no_dep[OF vt_s _ _ this]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   776
              th1_in dp'
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   777
              show False by (auto simp:children_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   778
            qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   779
            thus ?thesis
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   780
            proof(rule eq_cp_pre)
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   781
              show "th \<notin> dependants s th1"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   782
              proof
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   783
                assume "th \<in> dependants s th1"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   784
                from dependants_child_unique[OF vt_s _ _ this dp1]
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   785
                th1_in dp' have "th1 = th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   786
                  by (auto simp:children_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   787
                with False show False by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   788
              qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   789
            qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   790
          qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   791
        }
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   792
        ultimately have "{preced th'' s} \<union> (cp s ` children s th'') = 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   793
          {preced th'' s'} \<union> (cp s' ` children s th'')" by (auto simp:image_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   794
        moreover have "children s th'' = children s' th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   795
          by (unfold children_def child_def s_def depend_set_unchanged, simp)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   796
        ultimately show "Max ({preced th'' s} \<union> cp s ` children s th'') = cp s' th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   797
          by (simp add:cp_rec[OF step_back_vt[OF vt_s[unfolded s_def]]])
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   798
      qed     
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   799
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   800
  }
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   801
  ultimately show ?thesis by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   802
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   803
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   804
lemma eq_up_self:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   805
  fixes th' th''
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   806
  assumes dp: "th \<in> dependants s th''"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   807
  and eq_cps: "cp s th = cp s' th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   808
  shows "cp s th'' = cp s' th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   809
proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   810
  from dp
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   811
  have "(Th th, Th th'') \<in> (depend (wq s))\<^sup>+" by (simp add:s_dependants_def)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   812
  from depend_child[OF vt_s this[unfolded eq_depend]]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   813
  have ch_th': "(Th th, Th th'') \<in> (child s)\<^sup>+" .
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   814
  moreover { fix n th''
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   815
    have "\<lbrakk>(Th th, n) \<in> (child s)^+\<rbrakk> \<Longrightarrow>
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   816
                   (\<forall> th'' . n = Th th'' \<longrightarrow> cp s th'' = cp s' th'')"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   817
    proof(erule trancl_induct, auto)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   818
      fix y th''
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   819
      assume y_ch: "(y, Th th'') \<in> child s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   820
        and ih: "\<forall>th''. y = Th th'' \<longrightarrow> cp s th'' = cp s' th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   821
        and ch': "(Th th, y) \<in> (child s)\<^sup>+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   822
      from y_ch obtain thy where eq_y: "y = Th thy" by (auto simp:child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   823
      with ih have eq_cpy:"cp s thy = cp s' thy" by blast
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   824
      from child_depend_p[OF ch'] and eq_y
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   825
      have dp_thy: "(Th th, Th thy) \<in> (depend s)^+" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   826
      show "cp s th'' = cp s' th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   827
        apply (subst cp_rec[OF vt_s])
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   828
      proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   829
        have "preced th'' s = preced th'' s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   830
        proof(rule eq_preced)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   831
          show "th'' \<noteq> th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   832
          proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   833
            assume "th'' = th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   834
            with dp_thy y_ch[unfolded eq_y] 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   835
            have "(Th th, Th th) \<in> (depend s)^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   836
              by (auto simp:child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   837
            with wf_trancl[OF wf_depend[OF vt_s]] 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   838
            show False by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   839
          qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   840
        qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   841
        moreover { 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   842
          fix th1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   843
          assume th1_in: "th1 \<in> children s th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   844
          have "cp s th1 = cp s' th1"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   845
          proof(cases "th1 = thy")
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   846
            case True
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   847
            with eq_cpy show ?thesis by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   848
          next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   849
            case False
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   850
            have neq_th1: "th1 \<noteq> th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   851
            proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   852
              assume eq_th1: "th1 = th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   853
              with dp_thy have "(Th th1, Th thy) \<in> (depend s)^+" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   854
              from children_no_dep[OF vt_s _ _ this] and 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   855
              th1_in y_ch eq_y show False by (auto simp:children_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   856
            qed
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   857
            have "th \<notin> dependants s th1"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   858
            proof
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   859
              assume h:"th \<in> dependants s th1"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   860
              from eq_y dp_thy have "th \<in> dependants s thy" by (auto simp:s_dependants_def eq_depend)
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   861
              from dependants_child_unique[OF vt_s _ _ h this]
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   862
              th1_in y_ch eq_y have "th1 = thy" by (auto simp:children_def child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   863
              with False show False by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   864
            qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   865
            from eq_cp_pre[OF neq_th1 this]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   866
            show ?thesis .
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   867
          qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   868
        }
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   869
        ultimately have "{preced th'' s} \<union> (cp s ` children s th'') = 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   870
          {preced th'' s'} \<union> (cp s' ` children s th'')" by (auto simp:image_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   871
        moreover have "children s th'' = children s' th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   872
          by (unfold children_def child_def s_def depend_set_unchanged, simp)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   873
        ultimately show "Max ({preced th'' s} \<union> cp s ` children s th'') = cp s' th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   874
          by (simp add:cp_rec[OF step_back_vt[OF vt_s[unfolded s_def]]])
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   875
      qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   876
    next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   877
      fix th''
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   878
      assume dp': "(Th th, Th th'') \<in> child s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   879
      show "cp s th'' = cp s' th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   880
        apply (subst cp_rec[OF vt_s])
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   881
      proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   882
        have "preced th'' s = preced th'' s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   883
        proof(rule eq_preced)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   884
          show "th'' \<noteq> th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   885
          proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   886
            assume "th'' = th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   887
            with dp dp'
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   888
            have "(Th th, Th th) \<in> (depend s)^+"
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   889
              by (auto simp:child_def s_dependants_def eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   890
            with wf_trancl[OF wf_depend[OF vt_s]] 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   891
            show False by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   892
          qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   893
        qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   894
        moreover { 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   895
          fix th1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   896
          assume th1_in: "th1 \<in> children s th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   897
          have "cp s th1 = cp s' th1"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   898
          proof(cases "th1 = th")
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   899
            case True
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   900
            with eq_cps show ?thesis by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   901
          next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   902
            case False
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   903
            assume neq_th1: "th1 \<noteq> th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   904
            thus ?thesis
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   905
            proof(rule eq_cp_pre)
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   906
              show "th \<notin> dependants s th1"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   907
              proof
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   908
                assume "th \<in> dependants s th1"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
   909
                hence "(Th th, Th th1) \<in> (depend s)^+" by (auto simp:s_dependants_def eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   910
                from children_no_dep[OF vt_s _ _ this]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   911
                and th1_in dp' show False
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   912
                  by (auto simp:children_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   913
              qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   914
            qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   915
          qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   916
        }
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   917
        ultimately have "{preced th'' s} \<union> (cp s ` children s th'') = 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   918
          {preced th'' s'} \<union> (cp s' ` children s th'')" by (auto simp:image_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   919
        moreover have "children s th'' = children s' th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   920
          by (unfold children_def child_def s_def depend_set_unchanged, simp)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   921
        ultimately show "Max ({preced th'' s} \<union> cp s ` children s th'') = cp s' th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   922
          by (simp add:cp_rec[OF step_back_vt[OF vt_s[unfolded s_def]]])
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   923
      qed     
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   924
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   925
  }
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   926
  ultimately show ?thesis by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   927
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   928
end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   929
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   930
lemma next_waiting:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   931
  assumes vt: "vt s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   932
  and nxt: "next_th s th cs th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   933
  shows "waiting s th' cs"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   934
proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   935
  from assms show ?thesis
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   936
    apply (auto simp:next_th_def s_waiting_def[folded wq_def])
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   937
  proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   938
    fix rest
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   939
    assume ni: "hd (SOME q. distinct q \<and> set q = set rest) \<notin> set rest"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   940
      and eq_wq: "wq s cs = th # rest"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   941
      and ne: "rest \<noteq> []"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   942
    have "set (SOME q. distinct q \<and> set q = set rest) = set rest" 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   943
    proof(rule someI2)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   944
      from wq_distinct[OF vt, of cs] eq_wq
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   945
      show "distinct rest \<and> set rest = set rest" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   946
    next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   947
      show "\<And>x. distinct x \<and> set x = set rest \<Longrightarrow> set x = set rest" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   948
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   949
    with ni
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   950
    have "hd (SOME q. distinct q \<and> set q = set rest) \<notin>  set (SOME q. distinct q \<and> set q = set rest)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   951
      by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   952
    moreover have "(SOME q. distinct q \<and> set q = set rest) \<noteq> []"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   953
    proof(rule someI2)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   954
      from wq_distinct[OF vt, of cs] eq_wq
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   955
      show "distinct rest \<and> set rest = set rest" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   956
    next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   957
      from ne show "\<And>x. distinct x \<and> set x = set rest \<Longrightarrow> x \<noteq> []" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   958
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   959
    ultimately show "hd (SOME q. distinct q \<and> set q = set rest) = th" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   960
  next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   961
    fix rest
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   962
    assume eq_wq: "wq s cs = hd (SOME q. distinct q \<and> set q = set rest) # rest"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   963
      and ne: "rest \<noteq> []"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   964
    have "(SOME q. distinct q \<and> set q = set rest) \<noteq> []"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   965
    proof(rule someI2)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   966
      from wq_distinct[OF vt, of cs] eq_wq
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   967
      show "distinct rest \<and> set rest = set rest" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   968
    next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   969
      from ne show "\<And>x. distinct x \<and> set x = set rest \<Longrightarrow> x \<noteq> []" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   970
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   971
    hence "hd (SOME q. distinct q \<and> set q = set rest) \<in> set (SOME q. distinct q \<and> set q = set rest)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   972
      by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   973
    moreover have "set (SOME q. distinct q \<and> set q = set rest) = set rest" 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   974
    proof(rule someI2)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   975
      from wq_distinct[OF vt, of cs] eq_wq
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   976
      show "distinct rest \<and> set rest = set rest" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   977
    next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   978
      show "\<And>x. distinct x \<and> set x = set rest \<Longrightarrow> set x = set rest" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   979
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   980
    ultimately have "hd (SOME q. distinct q \<and> set q = set rest) \<in> set rest" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   981
    with eq_wq and wq_distinct[OF vt, of cs]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   982
    show False by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   983
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   984
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   985
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   986
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   987
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   988
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   989
locale step_v_cps =
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   990
  fixes s' th cs s 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   991
  defines s_def : "s \<equiv> (V th cs#s')"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   992
  assumes vt_s: "vt s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   993
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   994
locale step_v_cps_nt = step_v_cps +
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   995
  fixes th'
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   996
  assumes nt: "next_th s' th cs th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   997
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   998
context step_v_cps_nt
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   999
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1000
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1001
lemma depend_s:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1002
  "depend s = (depend s' - {(Cs cs, Th th), (Th th', Cs cs)}) \<union>
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1003
                                         {(Cs cs, Th th')}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1004
proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1005
  from step_depend_v[OF vt_s[unfolded s_def], folded s_def]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1006
    and nt show ?thesis  by (auto intro:next_th_unique)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1007
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1008
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1009
lemma dependants_kept:
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1010
  fixes th''
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1011
  assumes neq1: "th'' \<noteq> th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1012
  and neq2: "th'' \<noteq> th'"
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1013
  shows "dependants (wq s) th'' = dependants (wq s') th''"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1014
proof(auto)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1015
  fix x
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1016
  assume "x \<in> dependants (wq s) th''"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1017
  hence dp: "(Th x, Th th'') \<in> (depend s)^+"
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1018
    by (auto simp:cs_dependants_def eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1019
  { fix n
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1020
    have "(n, Th th'') \<in> (depend s)^+ \<Longrightarrow>  (n, Th th'') \<in> (depend s')^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1021
    proof(induct rule:converse_trancl_induct)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1022
      fix y 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1023
      assume "(y, Th th'') \<in> depend s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1024
      with depend_s neq1 neq2
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1025
      have "(y, Th th'') \<in> depend s'" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1026
      thus "(y, Th th'') \<in> (depend s')\<^sup>+" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1027
    next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1028
      fix y z 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1029
      assume yz: "(y, z) \<in> depend s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1030
        and ztp: "(z, Th th'') \<in> (depend s)\<^sup>+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1031
        and ztp': "(z, Th th'') \<in> (depend s')\<^sup>+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1032
      have "y \<noteq> Cs cs \<and> y \<noteq> Th th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1033
      proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1034
        show "y \<noteq> Cs cs"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1035
        proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1036
          assume eq_y: "y = Cs cs"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1037
          with yz have dp_yz: "(Cs cs, z) \<in> depend s" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1038
          from depend_s
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1039
          have cst': "(Cs cs, Th th') \<in> depend s" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1040
          from unique_depend[OF vt_s this dp_yz] 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1041
          have eq_z: "z = Th th'" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1042
          with ztp have "(Th th', Th th'') \<in> (depend s)^+" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1043
          from converse_tranclE[OF this]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1044
          obtain cs' where dp'': "(Th th', Cs cs') \<in> depend s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1045
            by (auto simp:s_depend_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1046
          with depend_s have dp': "(Th th', Cs cs') \<in> depend s'" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1047
          from dp'' eq_y yz eq_z have "(Cs cs, Cs cs') \<in> (depend s)^+" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1048
          moreover have "cs' = cs"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1049
          proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1050
            from next_waiting[OF step_back_vt[OF vt_s[unfolded s_def]] nt]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1051
            have "(Th th', Cs cs) \<in> depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1052
              by (auto simp:s_waiting_def wq_def s_depend_def cs_waiting_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1053
            from unique_depend[OF step_back_vt[OF vt_s[unfolded s_def]] this dp']
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1054
            show ?thesis by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1055
          qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1056
          ultimately have "(Cs cs, Cs cs) \<in> (depend s)^+" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1057
          moreover note wf_trancl[OF wf_depend[OF vt_s]]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1058
          ultimately show False by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1059
        qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1060
      next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1061
        show "y \<noteq> Th th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1062
        proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1063
          assume eq_y: "y = Th th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1064
          with yz have dps: "(Th th', z) \<in> depend s" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1065
          with depend_s have dps': "(Th th', z) \<in> depend s'" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1066
          have "z = Cs cs"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1067
          proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1068
            from next_waiting[OF step_back_vt[OF vt_s[unfolded s_def]] nt]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1069
            have "(Th th', Cs cs) \<in> depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1070
              by (auto simp:s_waiting_def wq_def s_depend_def cs_waiting_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1071
            from unique_depend[OF step_back_vt[OF vt_s[unfolded s_def]] dps' this]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1072
            show ?thesis .
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1073
          qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1074
          with dps depend_s show False by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1075
        qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1076
      qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1077
      with depend_s yz have "(y, z) \<in> depend s'" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1078
      with ztp'
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1079
      show "(y, Th th'') \<in> (depend s')\<^sup>+" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1080
    qed    
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1081
  }
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1082
  from this[OF dp]
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1083
  show "x \<in> dependants (wq s') th''" 
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1084
    by (auto simp:cs_dependants_def eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1085
next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1086
  fix x
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1087
  assume "x \<in> dependants (wq s') th''"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1088
  hence dp: "(Th x, Th th'') \<in> (depend s')^+"
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1089
    by (auto simp:cs_dependants_def eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1090
  { fix n
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1091
    have "(n, Th th'') \<in> (depend s')^+ \<Longrightarrow>  (n, Th th'') \<in> (depend s)^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1092
    proof(induct rule:converse_trancl_induct)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1093
      fix y 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1094
      assume "(y, Th th'') \<in> depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1095
      with depend_s neq1 neq2
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1096
      have "(y, Th th'') \<in> depend s" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1097
      thus "(y, Th th'') \<in> (depend s)\<^sup>+" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1098
    next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1099
      fix y z 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1100
      assume yz: "(y, z) \<in> depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1101
        and ztp: "(z, Th th'') \<in> (depend s')\<^sup>+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1102
        and ztp': "(z, Th th'') \<in> (depend s)\<^sup>+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1103
      have "y \<noteq> Cs cs \<and> y \<noteq> Th th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1104
      proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1105
        show "y \<noteq> Cs cs"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1106
        proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1107
          assume eq_y: "y = Cs cs"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1108
          with yz have dp_yz: "(Cs cs, z) \<in> depend s'" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1109
          from this have eq_z: "z = Th th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1110
          proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1111
            from step_back_step[OF vt_s[unfolded s_def]]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1112
            have "(Cs cs, Th th) \<in> depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1113
              by(cases, auto simp: wq_def s_depend_def cs_holding_def s_holding_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1114
            from unique_depend[OF step_back_vt[OF vt_s[unfolded s_def]] this dp_yz]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1115
            show ?thesis by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1116
          qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1117
          from converse_tranclE[OF ztp]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1118
          obtain u where "(z, u) \<in> depend s'" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1119
          moreover 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1120
          from step_back_step[OF vt_s[unfolded s_def]]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1121
          have "th \<in> readys s'" by (cases, simp add:runing_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1122
          moreover note eq_z
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1123
          ultimately show False 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1124
            by (auto simp:readys_def wq_def s_depend_def s_waiting_def cs_waiting_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1125
        qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1126
      next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1127
        show "y \<noteq> Th th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1128
        proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1129
          assume eq_y: "y = Th th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1130
          with yz have dps: "(Th th', z) \<in> depend s'" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1131
          have "z = Cs cs"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1132
          proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1133
            from next_waiting[OF step_back_vt[OF vt_s[unfolded s_def]] nt]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1134
            have "(Th th', Cs cs) \<in> depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1135
              by (auto simp:s_waiting_def wq_def s_depend_def cs_waiting_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1136
            from unique_depend[OF step_back_vt[OF vt_s[unfolded s_def]] dps this]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1137
            show ?thesis .
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1138
          qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1139
          with ztp have cs_i: "(Cs cs, Th th'') \<in>  (depend s')\<^sup>+" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1140
          from step_back_step[OF vt_s[unfolded s_def]]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1141
          have cs_th: "(Cs cs, Th th) \<in> depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1142
            by(cases, auto simp: s_depend_def wq_def cs_holding_def s_holding_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1143
          have "(Cs cs, Th th'') \<notin>  depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1144
          proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1145
            assume "(Cs cs, Th th'') \<in> depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1146
            from unique_depend[OF step_back_vt[OF vt_s[unfolded s_def]] this cs_th]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1147
            and neq1 show "False" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1148
          qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1149
          with converse_tranclE[OF cs_i]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1150
          obtain u where cu: "(Cs cs, u) \<in> depend s'"  
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1151
            and u_t: "(u, Th th'') \<in> (depend s')\<^sup>+" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1152
          have "u = Th th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1153
          proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1154
            from unique_depend[OF step_back_vt[OF vt_s[unfolded s_def]] cu cs_th]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1155
            show ?thesis .
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1156
          qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1157
          with u_t have "(Th th, Th th'') \<in> (depend s')\<^sup>+" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1158
          from converse_tranclE[OF this]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1159
          obtain v where "(Th th, v) \<in> (depend s')" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1160
          moreover from step_back_step[OF vt_s[unfolded s_def]]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1161
          have "th \<in> readys s'" by (cases, simp add:runing_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1162
          ultimately show False 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1163
            by (auto simp:readys_def wq_def s_depend_def s_waiting_def cs_waiting_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1164
        qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1165
      qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1166
      with depend_s yz have "(y, z) \<in> depend s" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1167
      with ztp'
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1168
      show "(y, Th th'') \<in> (depend s)\<^sup>+" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1169
    qed    
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1170
  }
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1171
  from this[OF dp]
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1172
  show "x \<in> dependants (wq s) th''"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1173
    by (auto simp:cs_dependants_def eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1174
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1175
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1176
lemma cp_kept:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1177
  fixes th''
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1178
  assumes neq1: "th'' \<noteq> th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1179
  and neq2: "th'' \<noteq> th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1180
  shows "cp s th'' = cp s' th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1181
proof -
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1182
  from dependants_kept[OF neq1 neq2]
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1183
  have "dependants (wq s) th'' = dependants (wq s') th''" .
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1184
  moreover {
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1185
    fix th1
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1186
    assume "th1 \<in> dependants (wq s) th''"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1187
    have "preced th1 s = preced th1 s'" 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1188
      by (unfold s_def, auto simp:preced_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1189
  }
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1190
  moreover have "preced th'' s = preced th'' s'" 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1191
    by (unfold s_def, auto simp:preced_def)
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1192
  ultimately have "((\<lambda>th. preced th s) ` ({th''} \<union> dependants (wq s) th'')) = 
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1193
    ((\<lambda>th. preced th s') ` ({th''} \<union> dependants (wq s') th''))"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1194
    by (auto simp:image_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1195
  thus ?thesis
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1196
    by (unfold cp_eq_cpreced cpreced_def, simp)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1197
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1198
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1199
end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1200
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1201
locale step_v_cps_nnt = step_v_cps +
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1202
  assumes nnt: "\<And> th'. (\<not> next_th s' th cs th')"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1203
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1204
context step_v_cps_nnt
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1205
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1206
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1207
lemma nw_cs: "(Th th1, Cs cs) \<notin> depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1208
proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1209
  assume "(Th th1, Cs cs) \<in> depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1210
  thus "False"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1211
    apply (auto simp:s_depend_def cs_waiting_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1212
  proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1213
    assume h1: "th1 \<in> set (wq s' cs)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1214
      and h2: "th1 \<noteq> hd (wq s' cs)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1215
    from step_back_step[OF vt_s[unfolded s_def]]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1216
    show "False"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1217
    proof(cases)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1218
      assume "holding s' th cs" 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1219
      then obtain rest where
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1220
        eq_wq: "wq s' cs = th#rest"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1221
        apply (unfold s_holding_def wq_def[symmetric])
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1222
        by (case_tac "(wq s' cs)", auto)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1223
      with h1 h2 have ne: "rest \<noteq> []" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1224
      with eq_wq
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1225
      have "next_th s' th cs (hd (SOME q. distinct q \<and> set q = set rest))"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1226
        by(unfold next_th_def, rule_tac x = "rest" in exI, auto)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1227
      with nnt show ?thesis by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1228
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1229
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1230
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1231
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1232
lemma depend_s: "depend s = depend s' - {(Cs cs, Th th)}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1233
proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1234
  from nnt and  step_depend_v[OF vt_s[unfolded s_def], folded s_def]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1235
  show ?thesis by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1236
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1237
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1238
lemma child_kept_left:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1239
  assumes 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1240
  "(n1, n2) \<in> (child s')^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1241
  shows "(n1, n2) \<in> (child s)^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1242
proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1243
  from assms show ?thesis 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1244
  proof(induct rule: converse_trancl_induct)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1245
    case (base y)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1246
    from base obtain th1 cs1 th2
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1247
      where h1: "(Th th1, Cs cs1) \<in> depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1248
      and h2: "(Cs cs1, Th th2) \<in> depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1249
      and eq_y: "y = Th th1" and eq_n2: "n2 = Th th2"  by (auto simp:child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1250
    have "cs1 \<noteq> cs"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1251
    proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1252
      assume eq_cs: "cs1 = cs"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1253
      with h1 have "(Th th1, Cs cs1) \<in> depend s'" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1254
      with nw_cs eq_cs show False by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1255
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1256
    with h1 h2 depend_s have 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1257
      h1': "(Th th1, Cs cs1) \<in> depend s" and
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1258
      h2': "(Cs cs1, Th th2) \<in> depend s" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1259
    hence "(Th th1, Th th2) \<in> child s" by (auto simp:child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1260
    with eq_y eq_n2 have "(y, n2) \<in> child s" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1261
    thus ?case by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1262
  next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1263
    case (step y z)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1264
    have "(y, z) \<in> child s'" by fact
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1265
    then obtain th1 cs1 th2
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1266
      where h1: "(Th th1, Cs cs1) \<in> depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1267
      and h2: "(Cs cs1, Th th2) \<in> depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1268
      and eq_y: "y = Th th1" and eq_z: "z = Th th2"  by (auto simp:child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1269
    have "cs1 \<noteq> cs"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1270
    proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1271
      assume eq_cs: "cs1 = cs"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1272
      with h1 have "(Th th1, Cs cs1) \<in> depend s'" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1273
      with nw_cs eq_cs show False by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1274
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1275
    with h1 h2 depend_s have 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1276
      h1': "(Th th1, Cs cs1) \<in> depend s" and
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1277
      h2': "(Cs cs1, Th th2) \<in> depend s" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1278
    hence "(Th th1, Th th2) \<in> child s" by (auto simp:child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1279
    with eq_y eq_z have "(y, z) \<in> child s" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1280
    moreover have "(z, n2) \<in> (child s)^+" by fact
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1281
    ultimately show ?case by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1282
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1283
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1284
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1285
lemma  child_kept_right:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1286
  assumes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1287
  "(n1, n2) \<in> (child s)^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1288
  shows "(n1, n2) \<in> (child s')^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1289
proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1290
  from assms show ?thesis
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1291
  proof(induct)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1292
    case (base y)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1293
    from base and depend_s 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1294
    have "(n1, y) \<in> child s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1295
      by (auto simp:child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1296
    thus ?case by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1297
  next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1298
    case (step y z)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1299
    have "(y, z) \<in> child s" by fact
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1300
    with depend_s have "(y, z) \<in> child s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1301
      by (auto simp:child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1302
    moreover have "(n1, y) \<in> (child s')\<^sup>+" by fact
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1303
    ultimately show ?case by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1304
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1305
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1306
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1307
lemma eq_child: "(child s)^+ = (child s')^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1308
  by (insert child_kept_left child_kept_right, auto)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1309
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1310
lemma eq_cp:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1311
  fixes th' 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1312
  shows "cp s th' = cp s' th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1313
  apply (unfold cp_eq_cpreced cpreced_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1314
proof -
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1315
  have eq_dp: "\<And> th. dependants (wq s) th = dependants (wq s') th"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1316
    apply (unfold cs_dependants_def, unfold eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1317
  proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1318
    from eq_child
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1319
    have "\<And>th. {th'. (Th th', Th th) \<in> (child s)\<^sup>+} = {th'. (Th th', Th th) \<in> (child s')\<^sup>+}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1320
      by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1321
    with child_depend_eq[OF vt_s] child_depend_eq[OF step_back_vt[OF vt_s[unfolded s_def]]]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1322
    show "\<And>th. {th'. (Th th', Th th) \<in> (depend s)\<^sup>+} = {th'. (Th th', Th th) \<in> (depend s')\<^sup>+}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1323
      by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1324
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1325
  moreover {
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1326
    fix th1 
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1327
    assume "th1 \<in> {th'} \<union> dependants (wq s') th'"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1328
    hence "th1 = th' \<or> th1 \<in> dependants (wq s') th'" by auto
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1329
    hence "preced th1 s = preced th1 s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1330
    proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1331
      assume "th1 = th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1332
      show "preced th1 s = preced th1 s'" by (simp add:s_def preced_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1333
    next
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1334
      assume "th1 \<in> dependants (wq s') th'"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1335
      show "preced th1 s = preced th1 s'" by (simp add:s_def preced_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1336
    qed
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1337
  } ultimately have "((\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th')) = 
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1338
                     ((\<lambda>th. preced th s') ` ({th'} \<union> dependants (wq s') th'))" 
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1339
    by (auto simp:image_def)
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1340
  thus "Max ((\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th')) =
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1341
        Max ((\<lambda>th. preced th s') ` ({th'} \<union> dependants (wq s') th'))" by simp
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1342
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1343
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1344
end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1345
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1346
locale step_P_cps =
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1347
  fixes s' th cs s 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1348
  defines s_def : "s \<equiv> (P th cs#s')"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1349
  assumes vt_s: "vt s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1350
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1351
locale step_P_cps_ne =step_P_cps +
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1352
  assumes ne: "wq s' cs \<noteq> []"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1353
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1354
locale step_P_cps_e =step_P_cps +
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1355
  assumes ee: "wq s' cs = []"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1356
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1357
context step_P_cps_e
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1358
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1359
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1360
lemma depend_s: "depend s = depend s' \<union> {(Cs cs, Th th)}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1361
proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1362
  from ee and  step_depend_p[OF vt_s[unfolded s_def], folded s_def]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1363
  show ?thesis by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1364
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1365
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1366
lemma child_kept_left:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1367
  assumes 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1368
  "(n1, n2) \<in> (child s')^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1369
  shows "(n1, n2) \<in> (child s)^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1370
proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1371
  from assms show ?thesis 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1372
  proof(induct rule: converse_trancl_induct)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1373
    case (base y)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1374
    from base obtain th1 cs1 th2
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1375
      where h1: "(Th th1, Cs cs1) \<in> depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1376
      and h2: "(Cs cs1, Th th2) \<in> depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1377
      and eq_y: "y = Th th1" and eq_n2: "n2 = Th th2"  by (auto simp:child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1378
    have "cs1 \<noteq> cs"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1379
    proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1380
      assume eq_cs: "cs1 = cs"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1381
      with h1 have "(Th th1, Cs cs) \<in> depend s'" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1382
      with ee show False
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1383
        by (auto simp:s_depend_def cs_waiting_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1384
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1385
    with h1 h2 depend_s have 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1386
      h1': "(Th th1, Cs cs1) \<in> depend s" and
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1387
      h2': "(Cs cs1, Th th2) \<in> depend s" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1388
    hence "(Th th1, Th th2) \<in> child s" by (auto simp:child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1389
    with eq_y eq_n2 have "(y, n2) \<in> child s" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1390
    thus ?case by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1391
  next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1392
    case (step y z)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1393
    have "(y, z) \<in> child s'" by fact
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1394
    then obtain th1 cs1 th2
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1395
      where h1: "(Th th1, Cs cs1) \<in> depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1396
      and h2: "(Cs cs1, Th th2) \<in> depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1397
      and eq_y: "y = Th th1" and eq_z: "z = Th th2"  by (auto simp:child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1398
    have "cs1 \<noteq> cs"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1399
    proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1400
      assume eq_cs: "cs1 = cs"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1401
      with h1 have "(Th th1, Cs cs) \<in> depend s'" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1402
      with ee show False 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1403
        by (auto simp:s_depend_def cs_waiting_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1404
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1405
    with h1 h2 depend_s have 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1406
      h1': "(Th th1, Cs cs1) \<in> depend s" and
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1407
      h2': "(Cs cs1, Th th2) \<in> depend s" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1408
    hence "(Th th1, Th th2) \<in> child s" by (auto simp:child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1409
    with eq_y eq_z have "(y, z) \<in> child s" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1410
    moreover have "(z, n2) \<in> (child s)^+" by fact
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1411
    ultimately show ?case by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1412
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1413
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1414
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1415
lemma  child_kept_right:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1416
  assumes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1417
  "(n1, n2) \<in> (child s)^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1418
  shows "(n1, n2) \<in> (child s')^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1419
proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1420
  from assms show ?thesis
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1421
  proof(induct)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1422
    case (base y)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1423
    from base and depend_s
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1424
    have "(n1, y) \<in> child s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1425
      apply (auto simp:child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1426
      proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1427
        fix th'
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1428
        assume "(Th th', Cs cs) \<in> depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1429
        with ee have "False"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1430
          by (auto simp:s_depend_def cs_waiting_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1431
        thus "\<exists>cs. (Th th', Cs cs) \<in> depend s' \<and> (Cs cs, Th th) \<in> depend s'" by auto 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1432
      qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1433
    thus ?case by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1434
  next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1435
    case (step y z)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1436
    have "(y, z) \<in> child s" by fact
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1437
    with depend_s have "(y, z) \<in> child s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1438
      apply (auto simp:child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1439
      proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1440
        fix th'
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1441
        assume "(Th th', Cs cs) \<in> depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1442
        with ee have "False"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1443
          by (auto simp:s_depend_def cs_waiting_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1444
        thus "\<exists>cs. (Th th', Cs cs) \<in> depend s' \<and> (Cs cs, Th th) \<in> depend s'" by auto 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1445
      qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1446
    moreover have "(n1, y) \<in> (child s')\<^sup>+" by fact
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1447
    ultimately show ?case by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1448
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1449
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1450
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1451
lemma eq_child: "(child s)^+ = (child s')^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1452
  by (insert child_kept_left child_kept_right, auto)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1453
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1454
lemma eq_cp:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1455
  fixes th' 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1456
  shows "cp s th' = cp s' th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1457
  apply (unfold cp_eq_cpreced cpreced_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1458
proof -
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1459
  have eq_dp: "\<And> th. dependants (wq s) th = dependants (wq s') th"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1460
    apply (unfold cs_dependants_def, unfold eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1461
  proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1462
    from eq_child
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1463
    have "\<And>th. {th'. (Th th', Th th) \<in> (child s)\<^sup>+} = {th'. (Th th', Th th) \<in> (child s')\<^sup>+}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1464
      by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1465
    with child_depend_eq[OF vt_s] child_depend_eq[OF step_back_vt[OF vt_s[unfolded s_def]]]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1466
    show "\<And>th. {th'. (Th th', Th th) \<in> (depend s)\<^sup>+} = {th'. (Th th', Th th) \<in> (depend s')\<^sup>+}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1467
      by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1468
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1469
  moreover {
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1470
    fix th1 
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1471
    assume "th1 \<in> {th'} \<union> dependants (wq s') th'"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1472
    hence "th1 = th' \<or> th1 \<in> dependants (wq s') th'" by auto
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1473
    hence "preced th1 s = preced th1 s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1474
    proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1475
      assume "th1 = th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1476
      show "preced th1 s = preced th1 s'" by (simp add:s_def preced_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1477
    next
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1478
      assume "th1 \<in> dependants (wq s') th'"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1479
      show "preced th1 s = preced th1 s'" by (simp add:s_def preced_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1480
    qed
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1481
  } ultimately have "((\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th')) = 
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1482
                     ((\<lambda>th. preced th s') ` ({th'} \<union> dependants (wq s') th'))" 
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1483
    by (auto simp:image_def)
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1484
  thus "Max ((\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th')) =
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1485
        Max ((\<lambda>th. preced th s') ` ({th'} \<union> dependants (wq s') th'))" by simp
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1486
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1487
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1488
end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1489
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1490
context step_P_cps_ne
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1491
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1492
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1493
lemma depend_s: "depend s = depend s' \<union> {(Th th, Cs cs)}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1494
proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1495
  from step_depend_p[OF vt_s[unfolded s_def]] and ne
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1496
  show ?thesis by (simp add:s_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1497
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1498
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1499
lemma eq_child_left:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1500
  assumes nd: "(Th th, Th th') \<notin> (child s)^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1501
  shows "(n1, Th th') \<in> (child s)^+ \<Longrightarrow> (n1, Th th') \<in> (child s')^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1502
proof(induct rule:converse_trancl_induct)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1503
  case (base y)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1504
  from base obtain th1 cs1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1505
    where h1: "(Th th1, Cs cs1) \<in> depend s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1506
    and h2: "(Cs cs1, Th th') \<in> depend s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1507
    and eq_y: "y = Th th1"   by (auto simp:child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1508
  have "th1 \<noteq> th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1509
  proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1510
    assume "th1 = th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1511
    with base eq_y have "(Th th, Th th') \<in> child s" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1512
    with nd show False by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1513
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1514
  with h1 h2 depend_s 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1515
  have h1': "(Th th1, Cs cs1) \<in> depend s'" and 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1516
       h2': "(Cs cs1, Th th') \<in> depend s'" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1517
  with eq_y show ?case by (auto simp:child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1518
next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1519
  case (step y z)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1520
  have yz: "(y, z) \<in> child s" by fact
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1521
  then obtain th1 cs1 th2
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1522
    where h1: "(Th th1, Cs cs1) \<in> depend s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1523
    and h2: "(Cs cs1, Th th2) \<in> depend s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1524
    and eq_y: "y = Th th1" and eq_z: "z = Th th2"  by (auto simp:child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1525
  have "th1 \<noteq> th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1526
  proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1527
    assume "th1 = th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1528
    with yz eq_y have "(Th th, z) \<in> child s" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1529
    moreover have "(z, Th th') \<in> (child s)^+" by fact
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1530
    ultimately have "(Th th, Th th') \<in> (child s)^+" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1531
    with nd show False by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1532
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1533
  with h1 h2 depend_s have h1': "(Th th1, Cs cs1) \<in> depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1534
                       and h2': "(Cs cs1, Th th2) \<in> depend s'" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1535
  with eq_y eq_z have "(y, z) \<in> child s'" by (auto simp:child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1536
  moreover have "(z, Th th') \<in> (child s')^+" by fact
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1537
  ultimately show ?case by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1538
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1539
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1540
lemma eq_child_right:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1541
  shows "(n1, Th th') \<in> (child s')^+ \<Longrightarrow> (n1, Th th') \<in> (child s)^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1542
proof(induct rule:converse_trancl_induct)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1543
  case (base y)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1544
  with depend_s show ?case by (auto simp:child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1545
next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1546
  case (step y z)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1547
  have "(y, z) \<in> child s'" by fact
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1548
  with depend_s have "(y, z) \<in> child s" by (auto simp:child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1549
  moreover have "(z, Th th') \<in> (child s)^+" by fact
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1550
  ultimately show ?case by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1551
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1552
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1553
lemma eq_child:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1554
  assumes nd: "(Th th, Th th') \<notin> (child s)^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1555
  shows "((n1, Th th') \<in> (child s)^+) = ((n1, Th th') \<in> (child s')^+)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1556
  by (insert eq_child_left[OF nd] eq_child_right, auto)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1557
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1558
lemma eq_cp:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1559
  fixes th' 
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1560
  assumes nd: "th \<notin> dependants s th'"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1561
  shows "cp s th' = cp s' th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1562
  apply (unfold cp_eq_cpreced cpreced_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1563
proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1564
  have nd': "(Th th, Th th') \<notin> (child s)^+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1565
  proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1566
    assume "(Th th, Th th') \<in> (child s)\<^sup>+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1567
    with child_depend_eq[OF vt_s]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1568
    have "(Th th, Th th') \<in> (depend s)\<^sup>+" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1569
    with nd show False 
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1570
      by (simp add:s_dependants_def eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1571
  qed
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1572
  have eq_dp: "dependants (wq s) th' = dependants (wq s') th'"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1573
  proof(auto)
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1574
    fix x assume " x \<in> dependants (wq s) th'"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1575
    thus "x \<in> dependants (wq s') th'"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1576
      apply (auto simp:cs_dependants_def eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1577
    proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1578
      assume "(Th x, Th th') \<in> (depend s)\<^sup>+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1579
      with  child_depend_eq[OF vt_s] have "(Th x, Th th') \<in> (child s)\<^sup>+" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1580
      with eq_child[OF nd'] have "(Th x, Th th') \<in> (child s')^+" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1581
      with child_depend_eq[OF step_back_vt[OF vt_s[unfolded s_def]]]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1582
      show "(Th x, Th th') \<in> (depend s')\<^sup>+" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1583
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1584
  next
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1585
    fix x assume "x \<in> dependants (wq s') th'"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1586
    thus "x \<in> dependants (wq s) th'"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1587
      apply (auto simp:cs_dependants_def eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1588
    proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1589
      assume "(Th x, Th th') \<in> (depend s')\<^sup>+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1590
      with child_depend_eq[OF step_back_vt[OF vt_s[unfolded s_def]]] 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1591
      have "(Th x, Th th') \<in> (child s')\<^sup>+" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1592
      with eq_child[OF nd'] have "(Th x, Th th') \<in> (child s)^+" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1593
      with  child_depend_eq[OF vt_s]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1594
      show "(Th x, Th th') \<in> (depend s)\<^sup>+" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1595
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1596
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1597
  moreover {
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1598
    fix th1 have "preced th1 s = preced th1 s'" by (simp add:s_def preced_def)
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1599
  } ultimately have "((\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th')) = 
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1600
                     ((\<lambda>th. preced th s') ` ({th'} \<union> dependants (wq s') th'))" 
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1601
    by (auto simp:image_def)
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1602
  thus "Max ((\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th')) =
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1603
        Max ((\<lambda>th. preced th s') ` ({th'} \<union> dependants (wq s') th'))" by simp
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1604
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1605
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1606
lemma eq_up:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1607
  fixes th' th''
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1608
  assumes dp1: "th \<in> dependants s th'"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1609
  and dp2: "th' \<in> dependants s th''"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1610
  and eq_cps: "cp s th' = cp s' th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1611
  shows "cp s th'' = cp s' th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1612
proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1613
  from dp2
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1614
  have "(Th th', Th th'') \<in> (depend (wq s))\<^sup>+" by (simp add:s_dependants_def)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1615
  from depend_child[OF vt_s this[unfolded eq_depend]]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1616
  have ch_th': "(Th th', Th th'') \<in> (child s)\<^sup>+" .
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1617
  moreover {
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1618
    fix n th''
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1619
    have "\<lbrakk>(Th th', n) \<in> (child s)^+\<rbrakk> \<Longrightarrow>
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1620
                   (\<forall> th'' . n = Th th'' \<longrightarrow> cp s th'' = cp s' th'')"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1621
    proof(erule trancl_induct, auto)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1622
      fix y th''
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1623
      assume y_ch: "(y, Th th'') \<in> child s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1624
        and ih: "\<forall>th''. y = Th th'' \<longrightarrow> cp s th'' = cp s' th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1625
        and ch': "(Th th', y) \<in> (child s)\<^sup>+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1626
      from y_ch obtain thy where eq_y: "y = Th thy" by (auto simp:child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1627
      with ih have eq_cpy:"cp s thy = cp s' thy" by blast
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1628
      from dp1 have "(Th th, Th th') \<in> (depend s)^+" by (auto simp:s_dependants_def eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1629
      moreover from child_depend_p[OF ch'] and eq_y
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1630
      have "(Th th', Th thy) \<in> (depend s)^+" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1631
      ultimately have dp_thy: "(Th th, Th thy) \<in> (depend s)^+" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1632
      show "cp s th'' = cp s' th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1633
        apply (subst cp_rec[OF vt_s])
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1634
      proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1635
        have "preced th'' s = preced th'' s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1636
          by (simp add:s_def preced_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1637
        moreover { 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1638
          fix th1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1639
          assume th1_in: "th1 \<in> children s th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1640
          have "cp s th1 = cp s' th1"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1641
          proof(cases "th1 = thy")
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1642
            case True
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1643
            with eq_cpy show ?thesis by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1644
          next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1645
            case False
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1646
            have neq_th1: "th1 \<noteq> th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1647
            proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1648
              assume eq_th1: "th1 = th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1649
              with dp_thy have "(Th th1, Th thy) \<in> (depend s)^+" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1650
              from children_no_dep[OF vt_s _ _ this] and 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1651
              th1_in y_ch eq_y show False by (auto simp:children_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1652
            qed
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1653
            have "th \<notin> dependants s th1"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1654
            proof
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1655
              assume h:"th \<in> dependants s th1"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1656
              from eq_y dp_thy have "th \<in> dependants s thy" by (auto simp:s_dependants_def eq_depend)
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1657
              from dependants_child_unique[OF vt_s _ _ h this]
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1658
              th1_in y_ch eq_y have "th1 = thy" by (auto simp:children_def child_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1659
              with False show False by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1660
            qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1661
            from eq_cp[OF this]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1662
            show ?thesis .
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1663
          qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1664
        }
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1665
        ultimately have "{preced th'' s} \<union> (cp s ` children s th'') = 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1666
          {preced th'' s'} \<union> (cp s' ` children s th'')" by (auto simp:image_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1667
        moreover have "children s th'' = children s' th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1668
          apply (unfold children_def child_def s_def depend_set_unchanged, simp)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1669
          apply (fold s_def, auto simp:depend_s)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1670
          proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1671
            assume "(Cs cs, Th th'') \<in> depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1672
            with depend_s have cs_th': "(Cs cs, Th th'') \<in> depend s" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1673
            from dp1 have "(Th th, Th th') \<in> (depend s)^+"
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1674
              by (auto simp:s_dependants_def eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1675
            from converse_tranclE[OF this]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1676
            obtain cs1 where h1: "(Th th, Cs cs1) \<in> depend s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1677
              and h2: "(Cs cs1 , Th th') \<in> (depend s)\<^sup>+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1678
              by (auto simp:s_depend_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1679
            have eq_cs: "cs1 = cs" 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1680
            proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1681
              from depend_s have "(Th th, Cs cs) \<in> depend s" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1682
              from unique_depend[OF vt_s this h1]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1683
              show ?thesis by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1684
            qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1685
            have False
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1686
            proof(rule converse_tranclE[OF h2])
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1687
              assume "(Cs cs1, Th th') \<in> depend s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1688
              with eq_cs have "(Cs cs, Th th') \<in> depend s" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1689
              from unique_depend[OF vt_s this cs_th']
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1690
              have "th' = th''" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1691
              with ch' y_ch have "(Th th'', Th th'') \<in> (child s)^+" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1692
              with wf_trancl[OF wf_child[OF vt_s]] 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1693
              show False by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1694
            next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1695
              fix y
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1696
              assume "(Cs cs1, y) \<in> depend s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1697
                and ytd: " (y, Th th') \<in> (depend s)\<^sup>+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1698
              with eq_cs have csy: "(Cs cs, y) \<in> depend s" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1699
              from unique_depend[OF vt_s this cs_th']
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1700
              have "y = Th th''" .
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1701
              with ytd have "(Th th'', Th th') \<in> (depend s)^+" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1702
              from depend_child[OF vt_s this]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1703
              have "(Th th'', Th th') \<in> (child s)\<^sup>+" .
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1704
              moreover from ch' y_ch have ch'': "(Th th', Th th'') \<in> (child s)^+" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1705
              ultimately have "(Th th'', Th th'') \<in> (child s)^+" by auto 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1706
              with wf_trancl[OF wf_child[OF vt_s]] 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1707
              show False by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1708
            qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1709
            thus "\<exists>cs. (Th th, Cs cs) \<in> depend s' \<and> (Cs cs, Th th'') \<in> depend s'" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1710
          qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1711
          ultimately show "Max ({preced th'' s} \<union> cp s ` children s th'') = cp s' th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1712
          by (simp add:cp_rec[OF step_back_vt[OF vt_s[unfolded s_def]]])
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1713
      qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1714
    next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1715
      fix th''
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1716
      assume dp': "(Th th', Th th'') \<in> child s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1717
      show "cp s th'' = cp s' th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1718
        apply (subst cp_rec[OF vt_s])
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1719
      proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1720
        have "preced th'' s = preced th'' s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1721
          by (simp add:s_def preced_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1722
        moreover { 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1723
          fix th1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1724
          assume th1_in: "th1 \<in> children s th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1725
          have "cp s th1 = cp s' th1"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1726
          proof(cases "th1 = th'")
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1727
            case True
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1728
            with eq_cps show ?thesis by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1729
          next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1730
            case False
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1731
            have neq_th1: "th1 \<noteq> th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1732
            proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1733
              assume eq_th1: "th1 = th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1734
              with dp1 have "(Th th1, Th th') \<in> (depend s)^+" 
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1735
                by (auto simp:s_dependants_def eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1736
              from children_no_dep[OF vt_s _ _ this]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1737
              th1_in dp'
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1738
              show False by (auto simp:children_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1739
            qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1740
            show ?thesis
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1741
            proof(rule eq_cp)
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1742
              show "th \<notin> dependants s th1"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1743
              proof
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1744
                assume "th \<in> dependants s th1"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1745
                from dependants_child_unique[OF vt_s _ _ this dp1]
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1746
                th1_in dp' have "th1 = th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1747
                  by (auto simp:children_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1748
                with False show False by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1749
              qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1750
            qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1751
          qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1752
        }
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1753
        ultimately have "{preced th'' s} \<union> (cp s ` children s th'') = 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1754
          {preced th'' s'} \<union> (cp s' ` children s th'')" by (auto simp:image_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1755
        moreover have "children s th'' = children s' th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1756
          apply (unfold children_def child_def s_def depend_set_unchanged, simp)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1757
          apply (fold s_def, auto simp:depend_s)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1758
          proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1759
            assume "(Cs cs, Th th'') \<in> depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1760
            with depend_s have cs_th': "(Cs cs, Th th'') \<in> depend s" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1761
            from dp1 have "(Th th, Th th') \<in> (depend s)^+"
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1762
              by (auto simp:s_dependants_def eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1763
            from converse_tranclE[OF this]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1764
            obtain cs1 where h1: "(Th th, Cs cs1) \<in> depend s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1765
              and h2: "(Cs cs1 , Th th') \<in> (depend s)\<^sup>+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1766
              by (auto simp:s_depend_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1767
            have eq_cs: "cs1 = cs" 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1768
            proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1769
              from depend_s have "(Th th, Cs cs) \<in> depend s" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1770
              from unique_depend[OF vt_s this h1]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1771
              show ?thesis by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1772
            qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1773
            have False
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1774
            proof(rule converse_tranclE[OF h2])
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1775
              assume "(Cs cs1, Th th') \<in> depend s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1776
              with eq_cs have "(Cs cs, Th th') \<in> depend s" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1777
              from unique_depend[OF vt_s this cs_th']
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1778
              have "th' = th''" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1779
              with dp' have "(Th th'', Th th'') \<in> (child s)^+" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1780
              with wf_trancl[OF wf_child[OF vt_s]] 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1781
              show False by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1782
            next
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1783
              fix y
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1784
              assume "(Cs cs1, y) \<in> depend s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1785
                and ytd: " (y, Th th') \<in> (depend s)\<^sup>+"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1786
              with eq_cs have csy: "(Cs cs, y) \<in> depend s" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1787
              from unique_depend[OF vt_s this cs_th']
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1788
              have "y = Th th''" .
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1789
              with ytd have "(Th th'', Th th') \<in> (depend s)^+" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1790
              from depend_child[OF vt_s this]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1791
              have "(Th th'', Th th') \<in> (child s)\<^sup>+" .
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1792
              moreover from dp' have ch'': "(Th th', Th th'') \<in> (child s)^+" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1793
              ultimately have "(Th th'', Th th'') \<in> (child s)^+" by auto 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1794
              with wf_trancl[OF wf_child[OF vt_s]] 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1795
              show False by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1796
            qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1797
            thus "\<exists>cs. (Th th, Cs cs) \<in> depend s' \<and> (Cs cs, Th th'') \<in> depend s'" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1798
          qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1799
        ultimately show "Max ({preced th'' s} \<union> cp s ` children s th'') = cp s' th''"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1800
          by (simp add:cp_rec[OF step_back_vt[OF vt_s[unfolded s_def]]])
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1801
      qed     
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1802
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1803
  }
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1804
  ultimately show ?thesis by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1805
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1806
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1807
end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1808
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1809
locale step_create_cps =
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1810
  fixes s' th prio s 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1811
  defines s_def : "s \<equiv> (Create th prio#s')"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1812
  assumes vt_s: "vt s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1813
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1814
context step_create_cps
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1815
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1816
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1817
lemma eq_dep: "depend s = depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1818
  by (unfold s_def depend_create_unchanged, auto)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1819
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1820
lemma eq_cp:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1821
  fixes th' 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1822
  assumes neq_th: "th' \<noteq> th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1823
  shows "cp s th' = cp s' th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1824
  apply (unfold cp_eq_cpreced cpreced_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1825
proof -
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1826
  have nd: "th \<notin> dependants s th'"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1827
  proof
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1828
    assume "th \<in> dependants s th'"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1829
    hence "(Th th, Th th') \<in> (depend s)^+" by (simp add:s_dependants_def eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1830
    with eq_dep have "(Th th, Th th') \<in> (depend s')^+" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1831
    from converse_tranclE[OF this]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1832
    obtain y where "(Th th, y) \<in> depend s'" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1833
    with dm_depend_threads[OF step_back_vt[OF vt_s[unfolded s_def]]]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1834
    have in_th: "th \<in> threads s'" by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1835
    from step_back_step[OF vt_s[unfolded s_def]]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1836
    show False
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1837
    proof(cases)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1838
      assume "th \<notin> threads s'" 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1839
      with in_th show ?thesis by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1840
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1841
  qed
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1842
  have eq_dp: "\<And> th. dependants (wq s) th = dependants (wq s') th"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1843
    by (unfold cs_dependants_def, auto simp:eq_dep eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1844
  moreover {
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1845
    fix th1 
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1846
    assume "th1 \<in> {th'} \<union> dependants (wq s') th'"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1847
    hence "th1 = th' \<or> th1 \<in> dependants (wq s') th'" by auto
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1848
    hence "preced th1 s = preced th1 s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1849
    proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1850
      assume "th1 = th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1851
      with neq_th
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1852
      show "preced th1 s = preced th1 s'" by (auto simp:s_def preced_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1853
    next
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1854
      assume "th1 \<in> dependants (wq s') th'"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1855
      with nd and eq_dp have "th1 \<noteq> th"
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1856
        by (auto simp:eq_depend cs_dependants_def s_dependants_def eq_dep)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1857
      thus "preced th1 s = preced th1 s'" by (auto simp:s_def preced_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1858
    qed
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1859
  } ultimately have "((\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th')) = 
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1860
                     ((\<lambda>th. preced th s') ` ({th'} \<union> dependants (wq s') th'))" 
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1861
    by (auto simp:image_def)
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1862
  thus "Max ((\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th')) =
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1863
        Max ((\<lambda>th. preced th s') ` ({th'} \<union> dependants (wq s') th'))" by simp
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1864
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1865
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1866
lemma nil_dependants: "dependants s th = {}"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1867
proof -
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1868
  from step_back_step[OF vt_s[unfolded s_def]]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1869
  show ?thesis
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1870
  proof(cases)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1871
    assume "th \<notin> threads s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1872
    from not_thread_holdents[OF step_back_vt[OF vt_s[unfolded s_def]] this]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1873
    have hdn: " holdents s' th = {}" .
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1874
    have "dependants s' th = {}"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1875
    proof -
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1876
      { assume "dependants s' th \<noteq> {}"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1877
        then obtain th' where dp: "(Th th', Th th) \<in> (depend s')^+"
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1878
          by (auto simp:s_dependants_def eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1879
        from tranclE[OF this] obtain cs' where 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1880
          "(Cs cs', Th th) \<in> depend s'" by (auto simp:s_depend_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1881
        with hdn
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1882
        have False by (auto simp:holdents_test)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1883
      } thus ?thesis by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1884
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1885
    thus ?thesis 
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1886
      by (unfold s_def s_dependants_def eq_depend depend_create_unchanged, simp)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1887
  qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1888
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1889
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1890
lemma eq_cp_th: "cp s th = preced th s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1891
  apply (unfold cp_eq_cpreced cpreced_def)
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1892
  by (insert nil_dependants, unfold s_dependants_def cs_dependants_def, auto)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1893
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1894
end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1895
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1896
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1897
locale step_exit_cps =
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1898
  fixes s' th prio s 
33
9b9f2117561f simplified the cp_rec proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 32
diff changeset
  1899
  defines s_def : "s \<equiv> Exit th # s'"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1900
  assumes vt_s: "vt s"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1901
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1902
context step_exit_cps
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1903
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1904
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1905
lemma eq_dep: "depend s = depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1906
  by (unfold s_def depend_exit_unchanged, auto)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1907
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1908
lemma eq_cp:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1909
  fixes th' 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1910
  assumes neq_th: "th' \<noteq> th"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1911
  shows "cp s th' = cp s' th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1912
  apply (unfold cp_eq_cpreced cpreced_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1913
proof -
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1914
  have nd: "th \<notin> dependants s th'"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1915
  proof
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1916
    assume "th \<in> dependants s th'"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1917
    hence "(Th th, Th th') \<in> (depend s)^+" by (simp add:s_dependants_def eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1918
    with eq_dep have "(Th th, Th th') \<in> (depend s')^+" by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1919
    from converse_tranclE[OF this]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1920
    obtain cs' where bk: "(Th th, Cs cs') \<in> depend s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1921
      by (auto simp:s_depend_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1922
    from step_back_step[OF vt_s[unfolded s_def]]
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1923
    show False
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1924
    proof(cases)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1925
      assume "th \<in> runing s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1926
      with bk show ?thesis
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1927
        apply (unfold runing_def readys_def s_waiting_def s_depend_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1928
        by (auto simp:cs_waiting_def wq_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1929
    qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1930
  qed
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1931
  have eq_dp: "\<And> th. dependants (wq s) th = dependants (wq s') th"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1932
    by (unfold cs_dependants_def, auto simp:eq_dep eq_depend)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1933
  moreover {
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1934
    fix th1 
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1935
    assume "th1 \<in> {th'} \<union> dependants (wq s') th'"
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1936
    hence "th1 = th' \<or> th1 \<in> dependants (wq s') th'" by auto
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1937
    hence "preced th1 s = preced th1 s'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1938
    proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1939
      assume "th1 = th'"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1940
      with neq_th
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1941
      show "preced th1 s = preced th1 s'" by (auto simp:s_def preced_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1942
    next
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1943
      assume "th1 \<in> dependants (wq s') th'"
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1944
      with nd and eq_dp have "th1 \<noteq> th"
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1945
        by (auto simp:eq_depend cs_dependants_def s_dependants_def eq_dep)
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1946
      thus "preced th1 s = preced th1 s'" by (auto simp:s_def preced_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1947
    qed
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1948
  } ultimately have "((\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th')) = 
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1949
                     ((\<lambda>th. preced th s') ` ({th'} \<union> dependants (wq s') th'))" 
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1950
    by (auto simp:image_def)
32
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1951
  thus "Max ((\<lambda>th. preced th s) ` ({th'} \<union> dependants (wq s) th')) =
e861aff29655 made some modifications.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 0
diff changeset
  1952
        Max ((\<lambda>th. preced th s') ` ({th'} \<union> dependants (wq s') th'))" by simp
0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1953
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1954
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1955
end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1956
end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1957