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