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