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