prio/PrioG.thy
author urbanc
Tue, 06 Mar 2012 11:30:45 +0000
changeset 337 f9d54f49c808
parent 336 f9e0d3274c14
child 339 b3add51e2e0f
permissions -rw-r--r--
typo
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
     1
theory PrioG
264
24199eb2c423 Newer version.
zhang
parents: 262
diff changeset
     2
imports PrioGDef 
262
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
336
f9e0d3274c14 fixed typo
urbanc
parents: 333
diff changeset
     5
309
e44c4055d430 more on the paper
urbanc
parents: 298
diff changeset
     6
lemma runing_ready: 
e44c4055d430 more on the paper
urbanc
parents: 298
diff changeset
     7
  shows "runing s \<subseteq> readys s"
e44c4055d430 more on the paper
urbanc
parents: 298
diff changeset
     8
  unfolding runing_def readys_def
e44c4055d430 more on the paper
urbanc
parents: 298
diff changeset
     9
  by auto 
e44c4055d430 more on the paper
urbanc
parents: 298
diff changeset
    10
e44c4055d430 more on the paper
urbanc
parents: 298
diff changeset
    11
lemma readys_threads:
e44c4055d430 more on the paper
urbanc
parents: 298
diff changeset
    12
  shows "readys s \<subseteq> threads s"
e44c4055d430 more on the paper
urbanc
parents: 298
diff changeset
    13
  unfolding readys_def
e44c4055d430 more on the paper
urbanc
parents: 298
diff changeset
    14
  by auto
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    15
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    16
lemma wq_v_neq:
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    17
   "cs \<noteq> cs' \<Longrightarrow> wq (V thread cs#s) cs' = wq s cs'"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    18
  by (auto simp:wq_def Let_def cp_def split:list.splits)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    19
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
    20
lemma wq_distinct: "vt s \<Longrightarrow> distinct (wq s cs)"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    21
proof(erule_tac vt.induct, simp add:wq_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    22
  fix s e
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    23
  assume h1: "step s e"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    24
  and h2: "distinct (wq s cs)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    25
  thus "distinct (wq (e # s) cs)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    26
  proof(induct rule:step.induct, auto simp: wq_def Let_def split:list.splits)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    27
    fix thread s
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    28
    assume h1: "(Cs cs, Th thread) \<notin> (depend s)\<^sup>+"
294
bc5bf9e9ada2 renamed waiting_queue -> wq_fun; cur_preced -> cprec_fun
urbanc
parents: 291
diff changeset
    29
      and h2: "thread \<in> set (wq_fun (schs s) cs)"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    30
      and h3: "thread \<in> runing s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    31
    show "False" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    32
    proof -
294
bc5bf9e9ada2 renamed waiting_queue -> wq_fun; cur_preced -> cprec_fun
urbanc
parents: 291
diff changeset
    33
      from h3 have "\<And> cs. thread \<in>  set (wq_fun (schs s) cs) \<Longrightarrow> 
bc5bf9e9ada2 renamed waiting_queue -> wq_fun; cur_preced -> cprec_fun
urbanc
parents: 291
diff changeset
    34
                             thread = hd ((wq_fun (schs s) cs))" 
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    35
        by (simp add:runing_def readys_def s_waiting_def wq_def)
294
bc5bf9e9ada2 renamed waiting_queue -> wq_fun; cur_preced -> cprec_fun
urbanc
parents: 291
diff changeset
    36
      from this [OF h2] have "thread = hd (wq_fun (schs s) cs)" .
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    37
      with h2
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    38
      have "(Cs cs, Th thread) \<in> (depend s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    39
        by (simp add:s_depend_def s_holding_def wq_def cs_holding_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    40
      with h1 show False by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    41
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    42
  next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    43
    fix thread s a list
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    44
    assume dst: "distinct list"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    45
    show "distinct (SOME q. distinct q \<and> set q = set list)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    46
    proof(rule someI2)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    47
      from dst show  "distinct list \<and> set list = set list" by auto
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
      fix q assume "distinct q \<and> set q = set list"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    50
      thus "distinct q" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    51
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    52
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    53
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    54
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
    55
lemma step_back_vt: "vt (e#s) \<Longrightarrow> vt s"
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
    56
  by(ind_cases "vt (e#s)", simp)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    57
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
    58
lemma step_back_step: "vt (e#s) \<Longrightarrow> step s e"
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
    59
  by(ind_cases "vt (e#s)", simp)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    60
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    61
lemma block_pre: 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    62
  fixes thread cs s
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
    63
  assumes vt_e: "vt (e#s)"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    64
  and s_ni: "thread \<notin>  set (wq s cs)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    65
  and s_i: "thread \<in> set (wq (e#s) cs)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    66
  shows "e = P thread cs"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    67
proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    68
  show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    69
  proof(cases e)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    70
    case (P th cs)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    71
    with assms
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    72
    show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    73
      by (auto simp:wq_def Let_def split:if_splits)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    74
  next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    75
    case (Create th prio)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    76
    with assms show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    77
      by (auto simp:wq_def Let_def split:if_splits)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    78
  next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    79
    case (Exit th)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    80
    with assms show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    81
      by (auto simp:wq_def Let_def split:if_splits)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    82
  next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    83
    case (Set th prio)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    84
    with assms show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    85
      by (auto simp:wq_def Let_def split:if_splits)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    86
  next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    87
    case (V th cs)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    88
    with assms show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    89
      apply (auto simp:wq_def Let_def split:if_splits)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    90
    proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    91
      fix q qs
294
bc5bf9e9ada2 renamed waiting_queue -> wq_fun; cur_preced -> cprec_fun
urbanc
parents: 291
diff changeset
    92
      assume h1: "thread \<notin> set (wq_fun (schs s) cs)"
bc5bf9e9ada2 renamed waiting_queue -> wq_fun; cur_preced -> cprec_fun
urbanc
parents: 291
diff changeset
    93
        and h2: "q # qs = wq_fun (schs s) cs"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    94
        and h3: "thread \<in> set (SOME q. distinct q \<and> set q = set qs)"
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
    95
        and vt: "vt (V th cs # s)"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    96
      from h1 and h2[symmetric] have "thread \<notin> set (q # qs)" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    97
      moreover have "thread \<in> set qs"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    98
      proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
    99
        have "set (SOME q. distinct q \<and> set q = set qs) = set qs"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   100
        proof(rule someI2)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   101
          from wq_distinct [OF step_back_vt[OF vt], of cs]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   102
          and h2[symmetric, folded wq_def]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   103
          show "distinct qs \<and> set qs = set qs" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   104
        next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   105
          fix x assume "distinct x \<and> set x = set qs"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   106
          thus "set x = set qs" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   107
        qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   108
        with h3 show ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   109
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   110
      ultimately show "False" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   111
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   112
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   113
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   114
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   115
lemma p_pre: "\<lbrakk>vt ((P thread cs)#s)\<rbrakk> \<Longrightarrow> 
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   116
  thread \<in> runing s \<and> (Cs cs, Th thread)  \<notin> (depend s)^+"
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   117
apply (ind_cases "vt ((P thread cs)#s)")
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   118
apply (ind_cases "step s (P thread cs)")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   119
by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   120
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   121
lemma abs1:
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   122
  fixes e es
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   123
  assumes ein: "e \<in> set es"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   124
  and neq: "hd es \<noteq> hd (es @ [x])"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   125
  shows "False"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   126
proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   127
  from ein have "es \<noteq> []" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   128
  then obtain e ess where "es = e # ess" by (cases es, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   129
  with neq show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   130
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   131
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   132
lemma q_head: "Q (hd es) \<Longrightarrow> hd es = hd [th\<leftarrow>es . Q th]"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   133
  by (cases es, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   134
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   135
inductive_cases evt_cons: "vt (a#s)"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   136
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   137
lemma abs2:
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   138
  assumes vt: "vt (e#s)"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   139
  and inq: "thread \<in> set (wq s cs)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   140
  and nh: "thread = hd (wq s cs)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   141
  and qt: "thread \<noteq> hd (wq (e#s) cs)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   142
  and inq': "thread \<in> set (wq (e#s) cs)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   143
  shows "False"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   144
proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   145
  from assms show "False"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   146
    apply (cases e)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   147
    apply ((simp split:if_splits add:Let_def wq_def)[1])+
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   148
    apply (insert abs1, fast)[1]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   149
    apply (auto simp:wq_def simp:Let_def split:if_splits list.splits)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   150
  proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   151
    fix th qs
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   152
    assume vt: "vt (V th cs # s)"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   153
      and th_in: "thread \<in> set (SOME q. distinct q \<and> set q = set qs)"
294
bc5bf9e9ada2 renamed waiting_queue -> wq_fun; cur_preced -> cprec_fun
urbanc
parents: 291
diff changeset
   154
      and eq_wq: "wq_fun (schs s) cs = thread # qs"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   155
    show "False"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   156
    proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   157
      from wq_distinct[OF step_back_vt[OF vt], of cs]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   158
        and eq_wq[folded wq_def] have "distinct (thread#qs)" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   159
      moreover have "thread \<in> set qs"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   160
      proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   161
        have "set (SOME q. distinct q \<and> set q = set qs) = set qs"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   162
        proof(rule someI2)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   163
          from wq_distinct [OF step_back_vt[OF vt], of cs]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   164
          and eq_wq [folded wq_def]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   165
          show "distinct qs \<and> set qs = set qs" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   166
        next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   167
          fix x assume "distinct x \<and> set x = set qs"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   168
          thus "set x = set qs" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   169
        qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   170
        with th_in show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   171
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   172
      ultimately show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   173
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   174
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   175
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   176
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   177
lemma vt_moment: "\<And> t. \<lbrakk>vt s; t \<le> length s\<rbrakk> \<Longrightarrow> vt (moment t s)"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   178
proof(induct s, simp)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   179
  fix a s t
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   180
  assume h: "\<And>t.\<lbrakk>vt s; t \<le> length s\<rbrakk> \<Longrightarrow> vt (moment t s)"
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   181
    and vt_a: "vt (a # s)"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   182
    and le_t: "t \<le> length (a # s)"
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   183
  show "vt (moment t (a # s))"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   184
  proof(cases "t = length (a#s)")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   185
    case True
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   186
    from True have "moment t (a#s) = a#s" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   187
    with vt_a show ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   188
  next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   189
    case False
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   190
    with le_t have le_t1: "t \<le> length s" by simp
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   191
    from vt_a have "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   192
      by (erule_tac evt_cons, simp)
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   193
    from h [OF this le_t1] have "vt (moment t s)" .
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   194
    moreover have "moment t (a#s) = moment t s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   195
    proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   196
      from moment_app [OF le_t1, of "[a]"] 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   197
      show ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   198
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   199
    ultimately show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   200
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   201
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   202
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   203
(* Wrong:
294
bc5bf9e9ada2 renamed waiting_queue -> wq_fun; cur_preced -> cprec_fun
urbanc
parents: 291
diff changeset
   204
    lemma \<lbrakk>thread \<in> set (wq_fun cs1 s); thread \<in> set (wq_fun cs2 s)\<rbrakk> \<Longrightarrow> cs1 = cs2"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   205
*)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   206
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   207
lemma waiting_unique_pre:
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   208
  fixes cs1 cs2 s thread
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   209
  assumes vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   210
  and h11: "thread \<in> set (wq s cs1)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   211
  and h12: "thread \<noteq> hd (wq s cs1)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   212
  assumes h21: "thread \<in> set (wq s cs2)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   213
  and h22: "thread \<noteq> hd (wq s cs2)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   214
  and neq12: "cs1 \<noteq> cs2"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   215
  shows "False"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   216
proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   217
  let "?Q cs s" = "thread \<in> set (wq s cs) \<and> thread \<noteq> hd (wq s cs)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   218
  from h11 and h12 have q1: "?Q cs1 s" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   219
  from h21 and h22 have q2: "?Q cs2 s" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   220
  have nq1: "\<not> ?Q cs1 []" by (simp add:wq_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   221
  have nq2: "\<not> ?Q cs2 []" by (simp add:wq_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   222
  from p_split [of "?Q cs1", OF q1 nq1]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   223
  obtain t1 where lt1: "t1 < length s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   224
    and np1: "\<not>(thread \<in> set (wq (moment t1 s) cs1) \<and>
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   225
        thread \<noteq> hd (wq (moment t1 s) cs1))"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   226
    and nn1: "(\<forall>i'>t1. thread \<in> set (wq (moment i' s) cs1) \<and>
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   227
             thread \<noteq> hd (wq (moment i' s) cs1))" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   228
  from p_split [of "?Q cs2", OF q2 nq2]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   229
  obtain t2 where lt2: "t2 < length s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   230
    and np2: "\<not>(thread \<in> set (wq (moment t2 s) cs2) \<and>
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   231
        thread \<noteq> hd (wq (moment t2 s) cs2))"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   232
    and nn2: "(\<forall>i'>t2. thread \<in> set (wq (moment i' s) cs2) \<and>
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   233
             thread \<noteq> hd (wq (moment i' s) cs2))" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   234
  show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   235
  proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   236
    { 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   237
      assume lt12: "t1 < t2"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   238
      let ?t3 = "Suc t2"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   239
      from lt2 have le_t3: "?t3 \<le> length s" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   240
      from moment_plus [OF this] 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   241
      obtain e where eq_m: "moment ?t3 s = e#moment t2 s" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   242
      have "t2 < ?t3" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   243
      from nn2 [rule_format, OF this] and eq_m
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   244
      have h1: "thread \<in> set (wq (e#moment t2 s) cs2)" and
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   245
        h2: "thread \<noteq> hd (wq (e#moment t2 s) cs2)" by auto
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   246
      have vt_e: "vt (e#moment t2 s)"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   247
      proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   248
        from vt_moment [OF vt le_t3]
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   249
        have "vt (moment ?t3 s)" .
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   250
        with eq_m show ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   251
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   252
      have ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   253
      proof(cases "thread \<in> set (wq (moment t2 s) cs2)")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   254
        case True
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   255
        from True and np2 have eq_th: "thread = hd (wq (moment t2 s) cs2)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   256
          by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   257
        from abs2 [OF vt_e True eq_th h2 h1]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   258
        show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   259
      next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   260
        case False
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   261
        from block_pre [OF vt_e False h1]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   262
        have "e = P thread cs2" .
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   263
        with vt_e have "vt ((P thread cs2)# moment t2 s)" by simp
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   264
        from p_pre [OF this] have "thread \<in> runing (moment t2 s)" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   265
        with runing_ready have "thread \<in> readys (moment t2 s)" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   266
        with nn1 [rule_format, OF lt12]
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   267
        show ?thesis  by (simp add:readys_def wq_def s_waiting_def, auto)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   268
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   269
    } moreover {
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   270
      assume lt12: "t2 < t1"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   271
      let ?t3 = "Suc t1"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   272
      from lt1 have le_t3: "?t3 \<le> length s" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   273
      from moment_plus [OF this] 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   274
      obtain e where eq_m: "moment ?t3 s = e#moment t1 s" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   275
      have lt_t3: "t1 < ?t3" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   276
      from nn1 [rule_format, OF this] and eq_m
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   277
      have h1: "thread \<in> set (wq (e#moment t1 s) cs1)" and
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   278
        h2: "thread \<noteq> hd (wq (e#moment t1 s) cs1)" by auto
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   279
      have vt_e: "vt  (e#moment t1 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 vt_moment [OF vt le_t3]
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   282
        have "vt (moment ?t3 s)" .
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   283
        with eq_m show ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   284
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   285
      have ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   286
      proof(cases "thread \<in> set (wq (moment t1 s) cs1)")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   287
        case True
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   288
        from True and np1 have eq_th: "thread = hd (wq (moment t1 s) cs1)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   289
          by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   290
        from abs2 [OF vt_e True eq_th h2 h1]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   291
        show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   292
      next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   293
        case False
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   294
        from block_pre [OF vt_e False h1]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   295
        have "e = P thread cs1" .
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   296
        with vt_e have "vt ((P thread cs1)# moment t1 s)" by simp
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   297
        from p_pre [OF this] have "thread \<in> runing (moment t1 s)" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   298
        with runing_ready have "thread \<in> readys (moment t1 s)" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   299
        with nn2 [rule_format, OF lt12]
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   300
        show ?thesis  by (simp add:readys_def wq_def s_waiting_def, auto)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   301
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   302
    } moreover {
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   303
      assume eqt12: "t1 = t2"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   304
      let ?t3 = "Suc t1"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   305
      from lt1 have le_t3: "?t3 \<le> length s" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   306
      from moment_plus [OF this] 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   307
      obtain e where eq_m: "moment ?t3 s = e#moment t1 s" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   308
      have lt_t3: "t1 < ?t3" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   309
      from nn1 [rule_format, OF this] and eq_m
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   310
      have h1: "thread \<in> set (wq (e#moment t1 s) cs1)" and
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   311
        h2: "thread \<noteq> hd (wq (e#moment t1 s) cs1)" by auto
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   312
      have vt_e: "vt (e#moment t1 s)"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   313
      proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   314
        from vt_moment [OF vt le_t3]
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   315
        have "vt (moment ?t3 s)" .
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   316
        with eq_m show ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   317
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   318
      have ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   319
      proof(cases "thread \<in> set (wq (moment t1 s) cs1)")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   320
        case True
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   321
        from True and np1 have eq_th: "thread = hd (wq (moment t1 s) cs1)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   322
          by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   323
        from abs2 [OF vt_e True eq_th h2 h1]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   324
        show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   325
      next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   326
        case False
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   327
        from block_pre [OF vt_e False h1]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   328
        have eq_e1: "e = P thread cs1" .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   329
        have lt_t3: "t1 < ?t3" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   330
        with eqt12 have "t2 < ?t3" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   331
        from nn2 [rule_format, OF this] and eq_m and eqt12
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   332
        have h1: "thread \<in> set (wq (e#moment t2 s) cs2)" and
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   333
          h2: "thread \<noteq> hd (wq (e#moment t2 s) cs2)" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   334
        show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   335
        proof(cases "thread \<in> set (wq (moment t2 s) cs2)")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   336
          case True
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   337
          from True and np2 have eq_th: "thread = hd (wq (moment t2 s) cs2)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   338
            by auto
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   339
          from vt_e and eqt12 have "vt (e#moment t2 s)" by simp 
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   340
          from abs2 [OF this True eq_th h2 h1]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   341
          show ?thesis .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   342
        next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   343
          case False
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   344
          have vt_e: "vt (e#moment t2 s)"
262
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 vt_moment [OF vt le_t3] eqt12
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   347
            have "vt (moment (Suc t2) s)" by auto
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   348
            with eq_m eqt12 show ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   349
          qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   350
          from block_pre [OF vt_e False h1]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   351
          have "e = P thread cs2" .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   352
          with eq_e1 neq12 show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   353
        qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   354
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   355
    } ultimately show ?thesis by arith
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   356
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   357
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   358
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   359
lemma waiting_unique:
264
24199eb2c423 Newer version.
zhang
parents: 262
diff changeset
   360
  fixes s cs1 cs2
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   361
  assumes "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   362
  and "waiting s th cs1"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   363
  and "waiting s th cs2"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   364
  shows "cs1 = cs2"
333
813e7257c7c3 some polishing of the repository
urbanc
parents: 309
diff changeset
   365
using waiting_unique_pre assms
309
e44c4055d430 more on the paper
urbanc
parents: 298
diff changeset
   366
unfolding wq_def s_waiting_def
e44c4055d430 more on the paper
urbanc
parents: 298
diff changeset
   367
by auto
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   368
309
e44c4055d430 more on the paper
urbanc
parents: 298
diff changeset
   369
(* not used *)
264
24199eb2c423 Newer version.
zhang
parents: 262
diff changeset
   370
lemma held_unique:
309
e44c4055d430 more on the paper
urbanc
parents: 298
diff changeset
   371
  fixes s::"state"
e44c4055d430 more on the paper
urbanc
parents: 298
diff changeset
   372
  assumes "holding s th1 cs"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   373
  and "holding s th2 cs"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   374
  shows "th1 = th2"
333
813e7257c7c3 some polishing of the repository
urbanc
parents: 309
diff changeset
   375
using assms
309
e44c4055d430 more on the paper
urbanc
parents: 298
diff changeset
   376
unfolding s_holding_def
e44c4055d430 more on the paper
urbanc
parents: 298
diff changeset
   377
by auto
e44c4055d430 more on the paper
urbanc
parents: 298
diff changeset
   378
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   379
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   380
lemma birthtime_lt: "th \<in> threads s \<Longrightarrow> birthtime th s < length s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   381
  apply (induct s, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   382
  by (case_tac a, auto split:if_splits)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   383
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   384
lemma birthtime_unique: 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   385
  "\<lbrakk>birthtime th1 s = birthtime th2 s; th1 \<in> threads s; th2 \<in> threads s\<rbrakk>
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   386
          \<Longrightarrow> th1 = th2"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   387
  apply (induct s, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   388
  by (case_tac a, auto split:if_splits dest:birthtime_lt)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   389
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   390
lemma preced_unique : 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   391
  assumes pcd_eq: "preced th1 s = preced th2 s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   392
  and th_in1: "th1 \<in> threads s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   393
  and th_in2: " th2 \<in> threads s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   394
  shows "th1 = th2"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   395
proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   396
  from pcd_eq have "birthtime th1 s = birthtime th2 s" by (simp add:preced_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   397
  from birthtime_unique [OF this th_in1 th_in2]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   398
  show ?thesis .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   399
qed
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 preced_linorder: 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   402
  assumes neq_12: "th1 \<noteq> th2"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   403
  and th_in1: "th1 \<in> threads s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   404
  and th_in2: " th2 \<in> threads s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   405
  shows "preced th1 s < preced th2 s \<or> preced th1 s > preced th2 s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   406
proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   407
  from preced_unique [OF _ th_in1 th_in2] and neq_12 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   408
  have "preced th1 s \<noteq> preced th2 s" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   409
  thus ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   410
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   411
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   412
lemma unique_minus:
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   413
  fixes x y z r
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   414
  assumes unique: "\<And> a b c. \<lbrakk>(a, b) \<in> r; (a, c) \<in> r\<rbrakk> \<Longrightarrow> b = c"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   415
  and xy: "(x, y) \<in> r"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   416
  and xz: "(x, z) \<in> r^+"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   417
  and neq: "y \<noteq> z"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   418
  shows "(y, z) \<in> r^+"
336
f9e0d3274c14 fixed typo
urbanc
parents: 333
diff changeset
   419
by (metis neq rtranclD tranclD unique xy xz)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   420
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   421
lemma unique_base:
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   422
  fixes r x y z
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   423
  assumes unique: "\<And> a b c. \<lbrakk>(a, b) \<in> r; (a, c) \<in> r\<rbrakk> \<Longrightarrow> b = c"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   424
  and xy: "(x, y) \<in> r"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   425
  and xz: "(x, z) \<in> r^+"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   426
  and neq_yz: "y \<noteq> z"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   427
  shows "(y, z) \<in> r^+"
336
f9e0d3274c14 fixed typo
urbanc
parents: 333
diff changeset
   428
by (metis neq_yz unique unique_minus xy xz)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   429
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   430
lemma unique_chain:
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   431
  fixes r x y z
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   432
  assumes unique: "\<And> a b c. \<lbrakk>(a, b) \<in> r; (a, c) \<in> r\<rbrakk> \<Longrightarrow> b = c"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   433
  and xy: "(x, y) \<in> r^+"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   434
  and xz: "(x, z) \<in> r^+"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   435
  and neq_yz: "y \<noteq> z"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   436
  shows "(y, z) \<in> r^+ \<or> (z, y) \<in> r^+"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   437
proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   438
  from xy xz neq_yz show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   439
  proof(induct)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   440
    case (base y)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   441
    have h1: "(x, y) \<in> r" and h2: "(x, z) \<in> r\<^sup>+" and h3: "y \<noteq> z" using base by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   442
    from unique_base [OF _ h1 h2 h3] and unique show ?case by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   443
  next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   444
    case (step y za)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   445
    show ?case
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   446
    proof(cases "y = z")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   447
      case True
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   448
      from True step show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   449
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   450
      case False
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   451
      from False step have "(y, z) \<in> r\<^sup>+ \<or> (z, y) \<in> r\<^sup>+" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   452
      thus ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   453
      proof
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   454
        assume "(z, y) \<in> r\<^sup>+"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   455
        with step have "(z, za) \<in> r\<^sup>+" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   456
        thus ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   457
      next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   458
        assume h: "(y, z) \<in> r\<^sup>+"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   459
        from step have yza: "(y, za) \<in> r" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   460
        from step have "za \<noteq> z" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   461
        from unique_minus [OF _ yza h this] and unique
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   462
        have "(za, z) \<in> r\<^sup>+" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   463
        thus ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   464
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   465
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   466
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   467
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   468
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   469
lemma depend_set_unchanged: "(depend (Set th prio # s)) = depend s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   470
apply (unfold s_depend_def s_waiting_def wq_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   471
by (simp add:Let_def)
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 depend_create_unchanged: "(depend (Create th prio # s)) = depend s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   474
apply (unfold s_depend_def s_waiting_def wq_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   475
by (simp add:Let_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   476
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   477
lemma depend_exit_unchanged: "(depend (Exit th # s)) = depend s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   478
apply (unfold s_depend_def s_waiting_def wq_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   479
by (simp add:Let_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   480
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   481
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   482
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   483
lemma step_v_hold_inv[elim_format]:
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   484
  "\<And>c t. \<lbrakk>vt (V th cs # s); 
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   485
  \<not> holding (wq s) t c; holding (wq (V th cs # s)) t c\<rbrakk> \<Longrightarrow> next_th s th cs t \<and> c = cs"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   486
proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   487
  fix c t
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   488
  assume vt: "vt (V th cs # s)"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   489
    and nhd: "\<not> holding (wq s) t c"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   490
    and hd: "holding (wq (V th cs # s)) t c"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   491
  show "next_th s th cs t \<and> c = cs"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   492
  proof(cases "c = cs")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   493
    case False
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   494
    with nhd hd show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   495
      by (unfold cs_holding_def wq_def, auto simp:Let_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   496
  next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   497
    case True
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   498
    with step_back_step [OF vt] 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   499
    have "step s (V th c)" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   500
    hence "next_th s th cs t"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   501
    proof(cases)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   502
      assume "holding s th c"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   503
      with nhd hd show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   504
        apply (unfold s_holding_def cs_holding_def wq_def next_th_def,
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   505
               auto simp:Let_def split:list.splits if_splits)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   506
        proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   507
          assume " hd (SOME q. distinct q \<and> q = []) \<in> set (SOME q. distinct q \<and> q = [])"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   508
          moreover have "\<dots> = set []"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   509
          proof(rule someI2)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   510
            show "distinct [] \<and> [] = []" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   511
          next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   512
            fix x assume "distinct x \<and> x = []"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   513
            thus "set x = set []" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   514
          qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   515
          ultimately show False by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   516
        next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   517
          assume " hd (SOME q. distinct q \<and> q = []) \<in> set (SOME q. distinct q \<and> q = [])"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   518
          moreover have "\<dots> = set []"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   519
          proof(rule someI2)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   520
            show "distinct [] \<and> [] = []" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   521
          next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   522
            fix x assume "distinct x \<and> x = []"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   523
            thus "set x = set []" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   524
          qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   525
          ultimately show False by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   526
        qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   527
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   528
    with True show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   529
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   530
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   531
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   532
lemma step_v_wait_inv[elim_format]:
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   533
    "\<And>t c. \<lbrakk>vt (V th cs # s); \<not> waiting (wq (V th cs # s)) t c; waiting (wq s) t c
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   534
           \<rbrakk>
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   535
          \<Longrightarrow> (next_th s th cs t \<and> cs = c)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   536
proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   537
  fix t c 
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   538
  assume vt: "vt (V th cs # s)"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   539
    and nw: "\<not> waiting (wq (V th cs # s)) t c"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   540
    and wt: "waiting (wq s) t c"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   541
  show "next_th s th cs t \<and> cs = c"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   542
  proof(cases "cs = c")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   543
    case False
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   544
    with nw wt show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   545
      by (auto simp:cs_waiting_def wq_def Let_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   546
  next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   547
    case True
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   548
    from nw[folded True] wt[folded True]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   549
    have "next_th s th cs t"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   550
      apply (unfold next_th_def, auto simp:cs_waiting_def wq_def Let_def split:list.splits)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   551
    proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   552
      fix a list
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   553
      assume t_in: "t \<in> set list"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   554
        and t_ni: "t \<notin> set (SOME q. distinct q \<and> set q = set list)"
294
bc5bf9e9ada2 renamed waiting_queue -> wq_fun; cur_preced -> cprec_fun
urbanc
parents: 291
diff changeset
   555
        and eq_wq: "wq_fun (schs s) cs = a # list"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   556
      have " set (SOME q. distinct q \<and> set q = set list) = set list"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   557
      proof(rule someI2)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   558
        from wq_distinct[OF step_back_vt[OF vt], of cs] and eq_wq[folded wq_def]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   559
        show "distinct list \<and> set list = set list" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   560
      next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   561
        show "\<And>x. distinct x \<and> set x = set list \<Longrightarrow> set x = set list"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   562
          by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   563
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   564
      with t_ni and t_in show "a = th" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   565
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   566
      fix a list
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   567
      assume t_in: "t \<in> set list"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   568
        and t_ni: "t \<notin> set (SOME q. distinct q \<and> set q = set list)"
294
bc5bf9e9ada2 renamed waiting_queue -> wq_fun; cur_preced -> cprec_fun
urbanc
parents: 291
diff changeset
   569
        and eq_wq: "wq_fun (schs s) cs = a # list"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   570
      have " set (SOME q. distinct q \<and> set q = set list) = set list"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   571
      proof(rule someI2)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   572
        from wq_distinct[OF step_back_vt[OF vt], of cs] and eq_wq[folded wq_def]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   573
        show "distinct list \<and> set list = set list" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   574
      next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   575
        show "\<And>x. distinct x \<and> set x = set list \<Longrightarrow> set x = set list"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   576
          by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   577
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   578
      with t_ni and t_in show "t = hd (SOME q. distinct q \<and> set q = set list)" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   579
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   580
      fix a list
294
bc5bf9e9ada2 renamed waiting_queue -> wq_fun; cur_preced -> cprec_fun
urbanc
parents: 291
diff changeset
   581
      assume eq_wq: "wq_fun (schs s) cs = a # list"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   582
      from step_back_step[OF vt]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   583
      show "a = th"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   584
      proof(cases)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   585
        assume "holding s th cs"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   586
        with eq_wq show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   587
          by (unfold s_holding_def wq_def, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   588
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   589
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   590
    with True show ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   591
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   592
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   593
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   594
lemma step_v_not_wait[consumes 3]:
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   595
  "\<lbrakk>vt (V th cs # s); next_th s th cs t; waiting (wq (V th cs # s)) t cs\<rbrakk> \<Longrightarrow> False"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   596
  by (unfold next_th_def cs_waiting_def wq_def, auto simp:Let_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   597
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   598
lemma step_v_release:
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   599
  "\<lbrakk>vt (V th cs # s); holding (wq (V th cs # s)) th cs\<rbrakk> \<Longrightarrow> False"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   600
proof -
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   601
  assume vt: "vt (V th cs # s)"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   602
    and hd: "holding (wq (V th cs # s)) th cs"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   603
  from step_back_step [OF vt] and hd
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   604
  show "False"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   605
  proof(cases)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   606
    assume "holding (wq (V th cs # s)) th cs" and "holding s th cs"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   607
    thus ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   608
      apply (unfold s_holding_def wq_def cs_holding_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   609
      apply (auto simp:Let_def split:list.splits)
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 list
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   612
      assume eq_wq[folded wq_def]: 
294
bc5bf9e9ada2 renamed waiting_queue -> wq_fun; cur_preced -> cprec_fun
urbanc
parents: 291
diff changeset
   613
        "wq_fun (schs s) cs = hd (SOME q. distinct q \<and> set q = set list) # list"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   614
      and hd_in: "hd (SOME q. distinct q \<and> set q = set list)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   615
            \<in> set (SOME q. distinct q \<and> set q = set list)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   616
      have "set (SOME q. distinct q \<and> set q = set list) = set list"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   617
      proof(rule someI2)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   618
        from wq_distinct[OF step_back_vt[OF vt], of cs] and eq_wq
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   619
        show "distinct list \<and> set list = set list" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   620
      next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   621
        show "\<And>x. distinct x \<and> set x = set list \<Longrightarrow> set x = set list"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   622
          by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   623
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   624
      moreover have "distinct  (hd (SOME q. distinct q \<and> set q = set list) # list)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   625
      proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   626
        from wq_distinct[OF step_back_vt[OF vt], of cs] and eq_wq
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   627
        show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   628
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   629
      moreover note eq_wq and hd_in
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   630
      ultimately show "False" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   631
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   632
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   633
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   634
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   635
lemma step_v_get_hold:
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   636
  "\<And>th'. \<lbrakk>vt (V th cs # s); \<not> holding (wq (V th cs # s)) th' cs; next_th s th cs th'\<rbrakk> \<Longrightarrow> False"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   637
  apply (unfold cs_holding_def next_th_def wq_def,
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   638
         auto simp:Let_def)
336
f9e0d3274c14 fixed typo
urbanc
parents: 333
diff changeset
   639
by (metis (lifting, full_types) List.member_def distinct.simps(2) hd_in_set member_rec(2) someI_ex step_back_vt wq_def wq_distinct)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   640
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   641
lemma step_v_release_inv[elim_format]:
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   642
"\<And>c t. \<lbrakk>vt (V th cs # s); \<not> holding (wq (V th cs # s)) t c; holding (wq s) t c\<rbrakk> \<Longrightarrow> 
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   643
  c = cs \<and> t = th"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   644
  apply (unfold cs_holding_def wq_def, auto simp:Let_def split:if_splits list.splits)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   645
  proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   646
    fix a list
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   647
    assume vt: "vt (V th cs # s)" and eq_wq: "wq_fun (schs s) cs = a # list"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   648
    from step_back_step [OF vt] show "a = th"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   649
    proof(cases)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   650
      assume "holding s th cs" with eq_wq
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   651
      show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   652
        by (unfold s_holding_def wq_def, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   653
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   654
  next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   655
    fix a list
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   656
    assume vt: "vt (V th cs # s)" and eq_wq: "wq_fun (schs s) cs = a # list"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   657
    from step_back_step [OF vt] show "a = th"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   658
    proof(cases)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   659
      assume "holding s th cs" with eq_wq
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   660
      show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   661
        by (unfold s_holding_def wq_def, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   662
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   663
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   664
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   665
lemma step_v_waiting_mono:
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   666
  "\<And>t c. \<lbrakk>vt (V th cs # s); waiting (wq (V th cs # s)) t c\<rbrakk> \<Longrightarrow> waiting (wq s) t c"
336
f9e0d3274c14 fixed typo
urbanc
parents: 333
diff changeset
   667
by (metis abs2 block_pre cs_waiting_def event.simps(20))
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   668
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   669
lemma step_depend_v:
289
a5dd2c966cbe attempt to fix problem by Xingyuan
urbanc
parents: 288
diff changeset
   670
fixes th::thread
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   671
assumes vt:
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   672
  "vt (V th cs#s)"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   673
shows "
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   674
  depend (V th cs # s) =
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   675
  depend s - {(Cs cs, Th th)} -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   676
  {(Th th', Cs cs) |th'. next_th s th cs th'} \<union>
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   677
  {(Cs cs, Th th') |th'.  next_th s th cs th'}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   678
  apply (insert vt, unfold s_depend_def) 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   679
  apply (auto split:if_splits list.splits simp:Let_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   680
  apply (auto elim: step_v_waiting_mono step_v_hold_inv 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   681
              step_v_release step_v_wait_inv
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   682
              step_v_get_hold step_v_release_inv)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   683
  apply (erule_tac step_v_not_wait, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   684
  done
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   685
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   686
lemma step_depend_p:
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   687
  "vt (P th cs#s) \<Longrightarrow>
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   688
  depend (P th cs # s) =  (if (wq s cs = []) then depend s \<union> {(Cs cs, Th th)}
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   689
                                             else depend s \<union> {(Th th, Cs cs)})"
288
64c9f151acf5 changes by Xingyuan
urbanc
parents: 287
diff changeset
   690
  apply(simp only: s_depend_def wq_def)
64c9f151acf5 changes by Xingyuan
urbanc
parents: 287
diff changeset
   691
  apply (auto split:list.splits prod.splits simp:Let_def wq_def cs_waiting_def cs_holding_def)
287
440382eb6427 more on the specification section
urbanc
parents: 264
diff changeset
   692
  apply(case_tac "csa = cs", auto)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   693
  apply(fold wq_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   694
  apply(drule_tac step_back_step)
287
440382eb6427 more on the specification section
urbanc
parents: 264
diff changeset
   695
  apply(ind_cases " step s (P (hd (wq s cs)) cs)")
440382eb6427 more on the specification section
urbanc
parents: 264
diff changeset
   696
  apply(auto simp:s_depend_def wq_def cs_holding_def)
440382eb6427 more on the specification section
urbanc
parents: 264
diff changeset
   697
  done
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   698
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   699
lemma simple_A:
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   700
  fixes A
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   701
  assumes h: "\<And> x y. \<lbrakk>x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> x = y"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   702
  shows "A = {} \<or> (\<exists> a. A = {a})"
336
f9e0d3274c14 fixed typo
urbanc
parents: 333
diff changeset
   703
by (metis assms insertCI nonempty_iff)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   704
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   705
lemma depend_target_th: "(Th th, x) \<in> depend (s::state) \<Longrightarrow> \<exists> cs. x = Cs cs"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   706
  by (unfold s_depend_def, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   707
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   708
lemma acyclic_depend: 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   709
  fixes s
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   710
  assumes vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   711
  shows "acyclic (depend s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   712
proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   713
  from vt show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   714
  proof(induct)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   715
    case (vt_cons s e)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   716
    assume ih: "acyclic (depend s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   717
      and stp: "step s e"
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   718
      and vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   719
    show ?case
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   720
    proof(cases e)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   721
      case (Create th prio)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   722
      with ih
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   723
      show ?thesis by (simp add:depend_create_unchanged)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   724
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   725
      case (Exit th)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   726
      with ih show ?thesis by (simp add:depend_exit_unchanged)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   727
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   728
      case (V th cs)
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   729
      from V vt stp have vtt: "vt (V th cs#s)" by auto
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   730
      from step_depend_v [OF this]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   731
      have eq_de: 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   732
        "depend (e # s) = 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   733
            depend s - {(Cs cs, Th th)} - {(Th th', Cs cs) |th'. next_th s th cs th'} \<union>
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   734
            {(Cs cs, Th th') |th'. next_th s th cs th'}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   735
        (is "?L = (?A - ?B - ?C) \<union> ?D") by (simp add:V)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   736
      from ih have ac: "acyclic (?A - ?B - ?C)" by (auto elim:acyclic_subset)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   737
      from step_back_step [OF vtt]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   738
      have "step s (V th cs)" .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   739
      thus ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   740
      proof(cases)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   741
        assume "holding s th cs"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   742
        hence th_in: "th \<in> set (wq s cs)" and
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   743
          eq_hd: "th = hd (wq s cs)" unfolding s_holding_def wq_def by auto
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   744
        then obtain rest where
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   745
          eq_wq: "wq s cs = th#rest"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   746
          by (cases "wq s cs", auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   747
        show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   748
        proof(cases "rest = []")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   749
          case False
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   750
          let ?th' = "hd (SOME q. distinct q \<and> set q = set rest)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   751
          from eq_wq False have eq_D: "?D = {(Cs cs, Th ?th')}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   752
            by (unfold next_th_def, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   753
          let ?E = "(?A - ?B - ?C)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   754
          have "(Th ?th', Cs cs) \<notin> ?E\<^sup>*"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   755
          proof
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   756
            assume "(Th ?th', Cs cs) \<in> ?E\<^sup>*"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   757
            hence " (Th ?th', Cs cs) \<in> ?E\<^sup>+" by (simp add: rtrancl_eq_or_trancl)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   758
            from tranclD [OF this]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   759
            obtain x where th'_e: "(Th ?th', x) \<in> ?E" by blast
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   760
            hence th_d: "(Th ?th', x) \<in> ?A" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   761
            from depend_target_th [OF this]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   762
            obtain cs' where eq_x: "x = Cs cs'" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   763
            with th_d have "(Th ?th', Cs cs') \<in> ?A" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   764
            hence wt_th': "waiting s ?th' cs'"
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   765
              unfolding s_depend_def s_waiting_def cs_waiting_def wq_def by simp
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   766
            hence "cs' = cs"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   767
            proof(rule waiting_unique [OF vt])
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   768
              from eq_wq wq_distinct[OF vt, of cs]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   769
              show "waiting s ?th' cs" 
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   770
                apply (unfold s_waiting_def wq_def, auto)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   771
              proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   772
                assume hd_in: "hd (SOME q. distinct q \<and> set q = set rest) \<notin> set rest"
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   773
                and eq_wq: "wq_fun (schs s) cs = th # rest"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   774
                have "(SOME q. distinct q \<and> set q = set rest) \<noteq> []"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   775
                proof(rule someI2)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   776
                  from wq_distinct[OF vt, of cs] and eq_wq
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   777
                  show "distinct rest \<and> set rest = set rest" unfolding wq_def by auto
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   778
                next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   779
                  fix x assume "distinct x \<and> set x = set rest"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   780
                  with False show "x \<noteq> []" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   781
                qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   782
                hence "hd (SOME q. distinct q \<and> set q = set rest) \<in> 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   783
                                  set (SOME q. distinct q \<and> set q = set rest)" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   784
                moreover have "\<dots> = set rest" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   785
                proof(rule someI2)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   786
                  from wq_distinct[OF vt, of cs] and eq_wq
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   787
                  show "distinct rest \<and> set rest = set rest" unfolding wq_def by auto
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   788
                next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   789
                  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
   790
                qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   791
                moreover note hd_in
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   792
                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
   793
              next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   794
                assume hd_in: "hd (SOME q. distinct q \<and> set q = set rest) \<notin> set rest"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   795
                and 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
   796
                have "(SOME q. distinct q \<and> set q = set rest) \<noteq> []"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   797
                proof(rule someI2)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   798
                  from wq_distinct[OF vt, of cs] and eq_wq
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   799
                  show "distinct rest \<and> set rest = set rest" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   800
                next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   801
                  fix x assume "distinct x \<and> set x = set rest"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   802
                  with False show "x \<noteq> []" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   803
                qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   804
                hence "hd (SOME q. distinct q \<and> set q = set rest) \<in> 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   805
                                  set (SOME q. distinct q \<and> set q = set rest)" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   806
                moreover have "\<dots> = set rest" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   807
                proof(rule someI2)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   808
                  from wq_distinct[OF vt, of cs] and eq_wq
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   809
                  show "distinct rest \<and> set rest = set rest" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   810
                next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   811
                  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
   812
                qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   813
                moreover note hd_in
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   814
                ultimately show False by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   815
              qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   816
            qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   817
            with th'_e eq_x have "(Th ?th', Cs cs) \<in> ?E" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   818
            with False
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   819
            show "False" by (auto simp: next_th_def eq_wq)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   820
          qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   821
          with acyclic_insert[symmetric] and ac
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   822
            and eq_de eq_D show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   823
        next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   824
          case True
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   825
          with eq_wq
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   826
          have eq_D: "?D = {}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   827
            by (unfold next_th_def, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   828
          with eq_de ac
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   829
          show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   830
        qed 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   831
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   832
  next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   833
    case (P th cs)
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   834
    from P vt stp have vtt: "vt (P th cs#s)" by auto
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   835
    from step_depend_p [OF this] P
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   836
    have "depend (e # s) = 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   837
      (if wq s cs = [] then depend s \<union> {(Cs cs, Th th)} else 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   838
      depend s \<union> {(Th th, Cs cs)})" (is "?L = ?R")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   839
      by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   840
    moreover have "acyclic ?R"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   841
    proof(cases "wq s cs = []")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   842
      case True
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   843
      hence eq_r: "?R =  depend s \<union> {(Cs cs, Th th)}" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   844
      have "(Th th, Cs cs) \<notin> (depend s)\<^sup>*"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   845
      proof
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   846
        assume "(Th th, Cs cs) \<in> (depend s)\<^sup>*"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   847
        hence "(Th th, Cs cs) \<in> (depend s)\<^sup>+" by (simp add: rtrancl_eq_or_trancl)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   848
        from tranclD2 [OF this]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   849
        obtain x where "(x, Cs cs) \<in> depend s" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   850
        with True show False by (auto simp:s_depend_def cs_waiting_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   851
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   852
      with acyclic_insert ih eq_r show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   853
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   854
      case False
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   855
      hence eq_r: "?R =  depend s \<union> {(Th th, Cs cs)}" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   856
      have "(Cs cs, Th th) \<notin> (depend s)\<^sup>*"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   857
      proof
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   858
        assume "(Cs cs, Th th) \<in> (depend s)\<^sup>*"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   859
        hence "(Cs cs, Th th) \<in> (depend s)\<^sup>+" by (simp add: rtrancl_eq_or_trancl)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   860
          moreover from step_back_step [OF vtt] have "step s (P th cs)" .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   861
          ultimately show False
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   862
          proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   863
            show " \<lbrakk>(Cs cs, Th th) \<in> (depend s)\<^sup>+; step s (P th cs)\<rbrakk> \<Longrightarrow> False"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   864
              by (ind_cases "step s (P th cs)", simp)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   865
          qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   866
        qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   867
        with acyclic_insert ih eq_r show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   868
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   869
      ultimately show ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   870
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   871
      case (Set thread prio)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   872
      with ih
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   873
      thm depend_set_unchanged
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   874
      show ?thesis by (simp add:depend_set_unchanged)
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
  next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   877
    case vt_nil
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   878
    show "acyclic (depend ([]::state))"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   879
      by (auto simp: s_depend_def cs_waiting_def 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   880
                      cs_holding_def wq_def acyclic_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   881
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   882
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   883
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   884
lemma finite_depend: 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   885
  fixes s
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   886
  assumes vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   887
  shows "finite (depend s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   888
proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   889
  from vt show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   890
  proof(induct)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   891
    case (vt_cons s e)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   892
    assume ih: "finite (depend s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   893
      and stp: "step s e"
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   894
      and vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   895
    show ?case
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   896
    proof(cases e)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   897
      case (Create th prio)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   898
      with ih
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   899
      show ?thesis by (simp add:depend_create_unchanged)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   900
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   901
      case (Exit th)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   902
      with ih show ?thesis by (simp add:depend_exit_unchanged)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   903
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   904
      case (V th cs)
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   905
      from V vt stp have vtt: "vt (V th cs#s)" by auto
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   906
      from step_depend_v [OF this]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   907
      have eq_de: "depend (e # s) = 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   908
                   depend s - {(Cs cs, Th th)} - {(Th th', Cs cs) |th'. next_th s th cs th'} \<union>
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   909
                      {(Cs cs, Th th') |th'. next_th s th cs th'}
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   910
"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   911
        (is "?L = (?A - ?B - ?C) \<union> ?D") by (simp add:V)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   912
      moreover from ih have ac: "finite (?A - ?B - ?C)" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   913
      moreover have "finite ?D"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   914
      proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   915
        have "?D = {} \<or> (\<exists> a. ?D = {a})" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   916
          by (unfold next_th_def, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   917
        thus ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   918
        proof
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   919
          assume h: "?D = {}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   920
          show ?thesis by (unfold h, simp)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   921
        next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   922
          assume "\<exists> a. ?D = {a}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   923
          thus ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   924
        qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   925
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   926
      ultimately show ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   927
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   928
      case (P th cs)
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   929
      from P vt stp have vtt: "vt (P th cs#s)" by auto
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   930
      from step_depend_p [OF this] P
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   931
      have "depend (e # s) = 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   932
              (if wq s cs = [] then depend s \<union> {(Cs cs, Th th)} else 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   933
                                    depend s \<union> {(Th th, Cs cs)})" (is "?L = ?R")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   934
        by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   935
      moreover have "finite ?R"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   936
      proof(cases "wq s cs = []")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   937
        case True
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   938
        hence eq_r: "?R =  depend s \<union> {(Cs cs, Th th)}" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   939
        with True and ih show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   940
      next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   941
        case False
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   942
        hence "?R = depend s \<union> {(Th th, Cs cs)}" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   943
        with False and ih show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   944
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   945
      ultimately show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   946
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   947
      case (Set thread prio)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   948
      with ih
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   949
      show ?thesis by (simp add:depend_set_unchanged)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   950
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   951
  next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   952
    case vt_nil
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   953
    show "finite (depend ([]::state))"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   954
      by (auto simp: s_depend_def cs_waiting_def 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   955
                   cs_holding_def wq_def acyclic_def)
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
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   958
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   959
text {* Several useful lemmas *}
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   960
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   961
lemma wf_dep_converse: 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   962
  fixes s
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   963
  assumes vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   964
  shows "wf ((depend s)^-1)"
336
f9e0d3274c14 fixed typo
urbanc
parents: 333
diff changeset
   965
by (metis acyclic_depend assms finite_acyclic_wf_converse finite_depend)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   966
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   967
lemma hd_np_in: "x \<in> set l \<Longrightarrow> hd l \<in> set l"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   968
by (induct l, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   969
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   970
lemma th_chasing: "(Th th, Cs cs) \<in> depend (s::state) \<Longrightarrow> \<exists> th'. (Cs cs, Th th') \<in> depend s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   971
  by (auto simp:s_depend_def s_holding_def cs_holding_def cs_waiting_def wq_def dest:hd_np_in)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   972
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   973
lemma wq_threads: 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   974
  fixes s cs
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   975
  assumes vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   976
  and h: "th \<in> set (wq s cs)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   977
  shows "th \<in> threads s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   978
proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   979
 from vt and h show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   980
  proof(induct arbitrary: th cs)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   981
    case (vt_cons s e)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   982
    assume ih: "\<And>th cs. th \<in> set (wq s cs) \<Longrightarrow> th \<in> threads s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   983
      and stp: "step s e"
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
   984
      and vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   985
      and h: "th \<in> set (wq (e # s) cs)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   986
    show ?case
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   987
    proof(cases e)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   988
      case (Create th' prio)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   989
      with ih h show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   990
        by (auto simp:wq_def Let_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   991
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   992
      case (Exit th')
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   993
      with stp ih h show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   994
        apply (auto simp:wq_def Let_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   995
        apply (ind_cases "step s (Exit th')")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   996
        apply (auto simp:runing_def readys_def s_holding_def s_waiting_def holdents_def
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   997
               s_depend_def s_holding_def cs_holding_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   998
        by (fold wq_def, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
   999
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1000
      case (V th' cs')
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1001
      show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1002
      proof(cases "cs' = cs")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1003
        case False
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1004
        with h
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1005
        show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1006
          apply(unfold wq_def V, auto simp:Let_def V split:prod.splits, fold wq_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1007
          by (drule_tac ih, simp)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1008
      next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1009
        case True
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1010
        from h
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1011
        show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1012
        proof(unfold V wq_def)
294
bc5bf9e9ada2 renamed waiting_queue -> wq_fun; cur_preced -> cprec_fun
urbanc
parents: 291
diff changeset
  1013
          assume th_in: "th \<in> set (wq_fun (schs (V th' cs' # s)) cs)" (is "th \<in> set ?l")
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1014
          show "th \<in> threads (V th' cs' # s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1015
          proof(cases "cs = cs'")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1016
            case False
294
bc5bf9e9ada2 renamed waiting_queue -> wq_fun; cur_preced -> cprec_fun
urbanc
parents: 291
diff changeset
  1017
            hence "?l = wq_fun (schs s) cs" by (simp add:Let_def)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1018
            with th_in have " th \<in> set (wq s cs)" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1019
              by (fold wq_def, simp)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1020
            from ih [OF this] show ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1021
          next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1022
            case True
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1023
            show ?thesis
294
bc5bf9e9ada2 renamed waiting_queue -> wq_fun; cur_preced -> cprec_fun
urbanc
parents: 291
diff changeset
  1024
            proof(cases "wq_fun (schs s) cs'")
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1025
              case Nil
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1026
              with h V show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1027
                apply (auto simp:wq_def Let_def split:if_splits)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1028
                by (fold wq_def, drule_tac ih, simp)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1029
            next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1030
              case (Cons a rest)
294
bc5bf9e9ada2 renamed waiting_queue -> wq_fun; cur_preced -> cprec_fun
urbanc
parents: 291
diff changeset
  1031
              assume eq_wq: "wq_fun (schs s) cs' = a # rest"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1032
              with h V show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1033
                apply (auto simp:Let_def wq_def split:if_splits)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1034
              proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1035
                assume th_in: "th \<in> set (SOME q. distinct q \<and> set q = set rest)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1036
                have "set (SOME q. distinct q \<and> set q = set rest) = set rest" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1037
                proof(rule someI2)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1038
                  from wq_distinct[OF vt, of cs'] and eq_wq[folded wq_def]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1039
                  show "distinct rest \<and> set rest = set rest" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1040
                next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1041
                  show "\<And>x. distinct x \<and> set x = set rest \<Longrightarrow> set x = set rest"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1042
                    by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1043
                qed
294
bc5bf9e9ada2 renamed waiting_queue -> wq_fun; cur_preced -> cprec_fun
urbanc
parents: 291
diff changeset
  1044
                with eq_wq th_in have "th \<in> set (wq_fun (schs s) cs')" by auto
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1045
                from ih[OF this[folded wq_def]] show "th \<in> threads s" .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1046
              next
294
bc5bf9e9ada2 renamed waiting_queue -> wq_fun; cur_preced -> cprec_fun
urbanc
parents: 291
diff changeset
  1047
                assume th_in: "th \<in> set (wq_fun (schs s) cs)"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1048
                from ih[OF this[folded wq_def]]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1049
                show "th \<in> threads s" .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1050
              qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1051
            qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1052
          qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1053
        qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1054
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1055
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1056
      case (P th' cs')
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1057
      from h stp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1058
      show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1059
        apply (unfold P wq_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1060
        apply (auto simp:Let_def split:if_splits, fold wq_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1061
        apply (auto intro:ih)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1062
        apply(ind_cases "step s (P th' cs')")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1063
        by (unfold runing_def readys_def, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1064
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1065
      case (Set thread prio)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1066
      with ih h show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1067
        by (auto simp:wq_def Let_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1068
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1069
  next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1070
    case vt_nil
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1071
    thus ?case by (auto simp:wq_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1072
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1073
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1074
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1075
lemma range_in: "\<lbrakk>vt s; (Th th) \<in> Range (depend (s::state))\<rbrakk> \<Longrightarrow> th \<in> threads s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1076
  apply(unfold s_depend_def cs_waiting_def cs_holding_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1077
  by (auto intro:wq_threads)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1078
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1079
lemma readys_v_eq:
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1080
  fixes th thread cs rest
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1081
  assumes vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1082
  and neq_th: "th \<noteq> thread"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1083
  and eq_wq: "wq s cs = thread#rest"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1084
  and not_in: "th \<notin>  set rest"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1085
  shows "(th \<in> readys (V thread cs#s)) = (th \<in> readys s)"
336
f9e0d3274c14 fixed typo
urbanc
parents: 333
diff changeset
  1086
using assms 
f9e0d3274c14 fixed typo
urbanc
parents: 333
diff changeset
  1087
apply (auto simp:readys_def)
f9e0d3274c14 fixed typo
urbanc
parents: 333
diff changeset
  1088
apply(simp add:s_waiting_def[folded wq_def])
f9e0d3274c14 fixed typo
urbanc
parents: 333
diff changeset
  1089
apply (erule_tac x = csa in allE)
f9e0d3274c14 fixed typo
urbanc
parents: 333
diff changeset
  1090
apply (simp add:s_waiting_def wq_def Let_def split:if_splits)
f9e0d3274c14 fixed typo
urbanc
parents: 333
diff changeset
  1091
apply (case_tac "csa = cs", simp)
f9e0d3274c14 fixed typo
urbanc
parents: 333
diff changeset
  1092
apply (erule_tac x = cs in allE)
f9e0d3274c14 fixed typo
urbanc
parents: 333
diff changeset
  1093
apply(auto simp add: s_waiting_def[folded wq_def] Let_def split: list.splits)
f9e0d3274c14 fixed typo
urbanc
parents: 333
diff changeset
  1094
apply(auto simp add: wq_def)
f9e0d3274c14 fixed typo
urbanc
parents: 333
diff changeset
  1095
apply (auto simp:s_waiting_def wq_def Let_def split:list.splits)
f9e0d3274c14 fixed typo
urbanc
parents: 333
diff changeset
  1096
by (metis (lifting, full_types) distinct.simps(2) someI_ex wq_def wq_distinct)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1097
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1098
lemma chain_building:
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1099
  assumes vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1100
  shows "node \<in> Domain (depend s) \<longrightarrow> (\<exists> th'. th' \<in> readys s \<and> (node, Th th') \<in> (depend s)^+)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1101
proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1102
  from wf_dep_converse [OF vt]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1103
  have h: "wf ((depend s)\<inverse>)" .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1104
  show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1105
  proof(induct rule:wf_induct [OF h])
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1106
    fix x
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1107
    assume ih [rule_format]: 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1108
      "\<forall>y. (y, x) \<in> (depend s)\<inverse> \<longrightarrow> 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1109
           y \<in> Domain (depend s) \<longrightarrow> (\<exists>th'. th' \<in> readys s \<and> (y, Th th') \<in> (depend s)\<^sup>+)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1110
    show "x \<in> Domain (depend s) \<longrightarrow> (\<exists>th'. th' \<in> readys s \<and> (x, Th th') \<in> (depend s)\<^sup>+)"
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 x_d: "x \<in> Domain (depend s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1113
      show "\<exists>th'. th' \<in> readys s \<and> (x, Th th') \<in> (depend s)\<^sup>+"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1114
      proof(cases x)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1115
        case (Th th)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1116
        from x_d Th obtain cs where x_in: "(Th th, Cs cs) \<in> depend s" by (auto simp:s_depend_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1117
        with Th have x_in_r: "(Cs cs, x) \<in> (depend s)^-1" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1118
        from th_chasing [OF x_in] obtain th' where "(Cs cs, Th th') \<in> depend s" by blast
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1119
        hence "Cs cs \<in> Domain (depend s)" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1120
        from ih [OF x_in_r this] obtain th'
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1121
          where th'_ready: " th' \<in> readys s" and cs_in: "(Cs cs, Th th') \<in> (depend s)\<^sup>+" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1122
        have "(x, Th th') \<in> (depend s)\<^sup>+" using Th x_in cs_in by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1123
        with th'_ready show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1124
      next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1125
        case (Cs cs)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1126
        from x_d Cs obtain th' where th'_d: "(Th th', x) \<in> (depend s)^-1" by (auto simp:s_depend_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1127
        show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1128
        proof(cases "th' \<in> readys s")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1129
          case True
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1130
          from True and th'_d show ?thesis by auto
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
          case False
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1133
          from th'_d and range_in [OF vt] have "th' \<in> threads s" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1134
          with False have "Th th' \<in> Domain (depend s)" 
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1135
            by (auto simp:readys_def wq_def s_waiting_def s_depend_def cs_waiting_def Domain_def)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1136
          from ih [OF th'_d this]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1137
          obtain th'' where 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1138
            th''_r: "th'' \<in> readys s" and 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1139
            th''_in: "(Th th', Th th'') \<in> (depend s)\<^sup>+" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1140
          from th'_d and th''_in 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1141
          have "(x, Th th'') \<in> (depend s)\<^sup>+" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1142
          with th''_r show ?thesis by auto
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
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1145
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1146
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1147
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1148
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1149
lemma th_chain_to_ready:
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1150
  fixes s th
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1151
  assumes vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1152
  and th_in: "th \<in> threads s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1153
  shows "th \<in> readys s \<or> (\<exists> th'. th' \<in> readys s \<and> (Th th, Th th') \<in> (depend s)^+)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1154
proof(cases "th \<in> readys s")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1155
  case True
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1156
  thus ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1157
next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1158
  case False
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1159
  from False and th_in have "Th th \<in> Domain (depend s)" 
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1160
    by (auto simp:readys_def s_waiting_def s_depend_def wq_def cs_waiting_def Domain_def)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1161
  from chain_building [rule_format, OF vt this]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1162
  show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1163
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1164
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1165
lemma waiting_eq: "waiting s th cs = waiting (wq s) th cs"
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1166
  by  (unfold s_waiting_def cs_waiting_def wq_def, auto)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1167
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1168
lemma holding_eq: "holding (s::state) th cs = holding (wq s) th cs"
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1169
  by (unfold s_holding_def wq_def cs_holding_def, simp)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1170
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1171
lemma holding_unique: "\<lbrakk>holding (s::state) th1 cs; holding s th2 cs\<rbrakk> \<Longrightarrow> th1 = th2"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1172
  by (unfold s_holding_def cs_holding_def, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1173
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1174
lemma unique_depend: "\<lbrakk>vt s; (n, n1) \<in> depend s; (n, n2) \<in> depend s\<rbrakk> \<Longrightarrow> n1 = n2"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1175
  apply(unfold s_depend_def, auto, fold waiting_eq holding_eq)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1176
  by(auto elim:waiting_unique holding_unique)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1177
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1178
lemma trancl_split: "(a, b) \<in> r^+ \<Longrightarrow> \<exists> c. (a, c) \<in> r"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1179
by (induct rule:trancl_induct, auto)
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 dchain_unique:
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1182
  assumes vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1183
  and th1_d: "(n, Th th1) \<in> (depend s)^+"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1184
  and th1_r: "th1 \<in> readys s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1185
  and th2_d: "(n, Th th2) \<in> (depend s)^+"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1186
  and th2_r: "th2 \<in> readys s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1187
  shows "th1 = th2"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1188
proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1189
  { assume neq: "th1 \<noteq> th2"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1190
    hence "Th th1 \<noteq> Th th2" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1191
    from unique_chain [OF _ th1_d th2_d this] and unique_depend [OF vt]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1192
    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
  1193
    hence "False"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1194
    proof
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1195
      assume "(Th th1, Th th2) \<in> (depend s)\<^sup>+"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1196
      from trancl_split [OF this]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1197
      obtain n where dd: "(Th th1, n) \<in> depend s" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1198
      then obtain cs where eq_n: "n = Cs cs"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1199
        by (auto simp:s_depend_def s_holding_def cs_holding_def cs_waiting_def wq_def dest:hd_np_in)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1200
      from dd eq_n have "th1 \<notin> readys s"
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1201
        by (auto simp:readys_def s_depend_def wq_def s_waiting_def cs_waiting_def)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1202
      with th1_r show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1203
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1204
      assume "(Th th2, Th th1) \<in> (depend s)\<^sup>+"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1205
      from trancl_split [OF this]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1206
      obtain n where dd: "(Th th2, n) \<in> depend s" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1207
      then obtain cs where eq_n: "n = Cs cs"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1208
        by (auto simp:s_depend_def s_holding_def cs_holding_def cs_waiting_def wq_def dest:hd_np_in)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1209
      from dd eq_n have "th2 \<notin> readys s"
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1210
        by (auto simp:readys_def wq_def s_depend_def s_waiting_def cs_waiting_def)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1211
      with th2_r show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1212
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1213
  } thus ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1214
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1215
             
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1216
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1217
lemma step_holdents_p_add:
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1218
  fixes th cs s
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1219
  assumes vt: "vt (P th cs#s)"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1220
  and "wq s cs = []"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1221
  shows "holdents (P th cs#s) th = holdents s th \<union> {cs}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1222
proof -
333
813e7257c7c3 some polishing of the repository
urbanc
parents: 309
diff changeset
  1223
  from assms show ?thesis
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1224
  unfolding  holdents_def step_depend_p[OF vt] by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1225
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1226
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1227
lemma step_holdents_p_eq:
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1228
  fixes th cs s
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1229
  assumes vt: "vt (P th cs#s)"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1230
  and "wq s cs \<noteq> []"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1231
  shows "holdents (P th cs#s) th = holdents s th"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1232
proof -
333
813e7257c7c3 some polishing of the repository
urbanc
parents: 309
diff changeset
  1233
  from assms show ?thesis
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1234
  unfolding  holdents_def step_depend_p[OF vt] by auto
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
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1238
lemma finite_holding:
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1239
  fixes s th cs
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1240
  assumes vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1241
  shows "finite (holdents s th)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1242
proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1243
  let ?F = "\<lambda> (x, y). the_cs x"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1244
  from finite_depend [OF vt]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1245
  have "finite (depend s)" .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1246
  hence "finite (?F `(depend s))" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1247
  moreover have "{cs . (Cs cs, Th th) \<in> depend s} \<subseteq> \<dots>" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1248
  proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1249
    { have h: "\<And> a A f. a \<in> A \<Longrightarrow> f a \<in> f ` A" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1250
      fix x assume "(Cs x, Th th) \<in> depend s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1251
      hence "?F (Cs x, Th th) \<in> ?F `(depend s)" by (rule h)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1252
      moreover have "?F (Cs x, Th th) = x" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1253
      ultimately have "x \<in> (\<lambda>(x, y). the_cs x) ` depend s" by simp 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1254
    } thus ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1255
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1256
  ultimately show ?thesis by (unfold holdents_def, auto intro:finite_subset)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1257
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1258
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1259
lemma cntCS_v_dec: 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1260
  fixes s thread cs
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1261
  assumes vtv: "vt (V thread cs#s)"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1262
  shows "(cntCS (V thread cs#s) thread + 1) = cntCS s thread"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1263
proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1264
  from step_back_step[OF vtv]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1265
  have cs_in: "cs \<in> holdents s thread" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1266
    apply (cases, unfold holdents_def s_depend_def, simp)
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1267
    by (unfold cs_holding_def s_holding_def wq_def, auto)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1268
  moreover have cs_not_in: 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1269
    "(holdents (V thread cs#s) thread) = holdents s thread - {cs}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1270
    apply (insert wq_distinct[OF step_back_vt[OF vtv], of cs])
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1271
    apply (unfold holdents_def, unfold step_depend_v[OF vtv],
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1272
            auto simp:next_th_def)
336
f9e0d3274c14 fixed typo
urbanc
parents: 333
diff changeset
  1273
    apply (metis (lifting, full_types) hd_in_set hd_np_in someI_ex)
f9e0d3274c14 fixed typo
urbanc
parents: 333
diff changeset
  1274
    by (metis (lifting, full_types) hd_in_set hd_np_in someI_ex)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1275
  ultimately 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1276
  have "holdents s thread = insert cs (holdents (V thread cs#s) thread)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1277
    by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1278
  moreover have "card \<dots> = 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1279
                    Suc (card ((holdents (V thread cs#s) thread) - {cs}))"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1280
  proof(rule card_insert)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1281
    from finite_holding [OF vtv]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1282
    show " finite (holdents (V thread cs # s) thread)" .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1283
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1284
  moreover from cs_not_in 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1285
  have "cs \<notin> (holdents (V thread cs#s) thread)" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1286
  ultimately show ?thesis by (simp add:cntCS_def)
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
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1289
lemma cnp_cnv_cncs:
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1290
  fixes s th
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1291
  assumes vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1292
  shows "cntP s th = cntV s th + (if (th \<in> readys s \<or> th \<notin> threads s) 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1293
                                       then cntCS s th else cntCS s th + 1)"
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 vt show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1296
  proof(induct arbitrary:th)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1297
    case (vt_cons s e)
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1298
    assume vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1299
    and ih: "\<And>th. cntP s th  = cntV s th +
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1300
               (if (th \<in> readys s \<or> th \<notin> threads s) then cntCS s th else cntCS s th + 1)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1301
    and stp: "step s e"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1302
    from stp show ?case
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1303
    proof(cases)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1304
      case (thread_create thread prio)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1305
      assume eq_e: "e = Create thread prio"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1306
        and not_in: "thread \<notin> threads s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1307
      show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1308
      proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1309
        { fix cs 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1310
          assume "thread \<in> set (wq s cs)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1311
          from wq_threads [OF vt this] have "thread \<in> threads s" .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1312
          with not_in have "False" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1313
        } with eq_e have eq_readys: "readys (e#s) = readys s \<union> {thread}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1314
          by (auto simp:readys_def threads.simps s_waiting_def 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1315
            wq_def cs_waiting_def Let_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1316
        from eq_e have eq_cnp: "cntP (e#s) th = cntP s th" by (simp add:cntP_def count_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1317
        from eq_e have eq_cnv: "cntV (e#s) th = cntV s th" by (simp add:cntV_def count_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1318
        have eq_cncs: "cntCS (e#s) th = cntCS s th"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1319
          unfolding cntCS_def holdents_def
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1320
          by (simp add:depend_create_unchanged eq_e)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1321
        { assume "th \<noteq> thread"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1322
          with eq_readys eq_e
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1323
          have "(th \<in> readys (e # s) \<or> th \<notin> threads (e # s)) = 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1324
                      (th \<in> readys (s) \<or> th \<notin> threads (s))" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1325
            by (simp add:threads.simps)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1326
          with eq_cnp eq_cnv eq_cncs ih not_in
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1327
          have ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1328
        } moreover {
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1329
          assume eq_th: "th = thread"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1330
          with not_in ih have " cntP s th  = cntV s th + cntCS s th" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1331
          moreover from eq_th and eq_readys have "th \<in> readys (e#s)" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1332
          moreover note eq_cnp eq_cnv eq_cncs
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1333
          ultimately have ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1334
        } ultimately show ?thesis by blast
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1335
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1336
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1337
      case (thread_exit thread)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1338
      assume eq_e: "e = Exit thread" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1339
      and is_runing: "thread \<in> runing s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1340
      and no_hold: "holdents s thread = {}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1341
      from eq_e have eq_cnp: "cntP (e#s) th = cntP s th" by (simp add:cntP_def count_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1342
      from eq_e have eq_cnv: "cntV (e#s) th = cntV s th" by (simp add:cntV_def count_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1343
      have eq_cncs: "cntCS (e#s) th = cntCS s th"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1344
        unfolding cntCS_def holdents_def
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1345
        by (simp add:depend_exit_unchanged eq_e)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1346
      { assume "th \<noteq> thread"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1347
        with eq_e
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1348
        have "(th \<in> readys (e # s) \<or> th \<notin> threads (e # s)) = 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1349
          (th \<in> readys (s) \<or> th \<notin> threads (s))" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1350
          apply (simp add:threads.simps readys_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1351
          apply (subst s_waiting_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1352
          apply (simp add:Let_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1353
          apply (subst s_waiting_def, simp)
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1354
          done
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1355
        with eq_cnp eq_cnv eq_cncs ih
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1356
        have ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1357
      } moreover {
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1358
        assume eq_th: "th = thread"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1359
        with ih is_runing have " cntP s th = cntV s th + cntCS s th" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1360
          by (simp add:runing_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1361
        moreover from eq_th eq_e have "th \<notin> threads (e#s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1362
          by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1363
        moreover note eq_cnp eq_cnv eq_cncs
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1364
        ultimately have ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1365
      } ultimately show ?thesis by blast
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1366
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1367
      case (thread_P thread cs)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1368
      assume eq_e: "e = P thread cs"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1369
        and is_runing: "thread \<in> runing s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1370
        and no_dep: "(Cs cs, Th thread) \<notin> (depend s)\<^sup>+"
333
813e7257c7c3 some polishing of the repository
urbanc
parents: 309
diff changeset
  1371
      from thread_P vt stp ih have vtp: "vt (P thread cs#s)" by auto
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1372
      show ?thesis 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1373
      proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1374
        { have hh: "\<And> A B C. (B = C) \<Longrightarrow> (A \<and> B) = (A \<and> C)" by blast
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1375
          assume neq_th: "th \<noteq> thread"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1376
          with eq_e
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1377
          have eq_readys: "(th \<in> readys (e#s)) = (th \<in> readys (s))"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1378
            apply (simp add:readys_def s_waiting_def wq_def Let_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1379
            apply (rule_tac hh, clarify)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1380
            apply (intro iffI allI, clarify)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1381
            apply (erule_tac x = csa in allE, auto)
294
bc5bf9e9ada2 renamed waiting_queue -> wq_fun; cur_preced -> cprec_fun
urbanc
parents: 291
diff changeset
  1382
            apply (subgoal_tac "wq_fun (schs s) cs \<noteq> []", auto)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1383
            apply (erule_tac x = cs in allE, auto)
294
bc5bf9e9ada2 renamed waiting_queue -> wq_fun; cur_preced -> cprec_fun
urbanc
parents: 291
diff changeset
  1384
            by (case_tac "(wq_fun (schs s) cs)", auto)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1385
          moreover from neq_th eq_e have "cntCS (e # s) th = cntCS s th"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1386
            apply (simp add:cntCS_def holdents_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1387
            by (unfold  step_depend_p [OF vtp], auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1388
          moreover from eq_e neq_th have "cntP (e # s) th = cntP s th"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1389
            by (simp add:cntP_def count_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1390
          moreover from eq_e neq_th have "cntV (e#s) th = cntV s th"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1391
            by (simp add:cntV_def count_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1392
          moreover from eq_e neq_th have "threads (e#s) = threads s" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1393
          moreover note ih [of th] 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1394
          ultimately have ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1395
        } moreover {
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1396
          assume eq_th: "th = thread"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1397
          have ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1398
          proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1399
            from eq_e eq_th have eq_cnp: "cntP (e # s) th  = 1 + (cntP s th)" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1400
              by (simp add:cntP_def count_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1401
            from eq_e eq_th have eq_cnv: "cntV (e#s) th = cntV s th"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1402
              by (simp add:cntV_def count_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1403
            show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1404
            proof (cases "wq s cs = []")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1405
              case True
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1406
              with is_runing
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1407
              have "th \<in> readys (e#s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1408
                apply (unfold eq_e wq_def, unfold readys_def s_depend_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1409
                apply (simp add: wq_def[symmetric] runing_def eq_th s_waiting_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1410
                by (auto simp:readys_def wq_def Let_def s_waiting_def wq_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1411
              moreover have "cntCS (e # s) th = 1 + cntCS s th"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1412
              proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1413
                have "card {csa. csa = cs \<or> (Cs csa, Th thread) \<in> depend s} =
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1414
                  Suc (card {cs. (Cs cs, Th thread) \<in> depend s})" (is "card ?L = Suc (card ?R)")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1415
                proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1416
                  have "?L = insert cs ?R" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1417
                  moreover have "card \<dots> = Suc (card (?R - {cs}))" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1418
                  proof(rule card_insert)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1419
                    from finite_holding [OF vt, of thread]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1420
                    show " finite {cs. (Cs cs, Th thread) \<in> depend s}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1421
                      by (unfold holdents_def, simp)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1422
                  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1423
                  moreover have "?R - {cs} = ?R"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1424
                  proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1425
                    have "cs \<notin> ?R"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1426
                    proof
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1427
                      assume "cs \<in> {cs. (Cs cs, Th thread) \<in> depend s}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1428
                      with no_dep show False by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1429
                    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1430
                    thus ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1431
                  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1432
                  ultimately show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1433
                qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1434
                thus ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1435
                  apply (unfold eq_e eq_th cntCS_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1436
                  apply (simp add: holdents_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1437
                  by (unfold step_depend_p [OF vtp], auto simp:True)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1438
              qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1439
              moreover from is_runing have "th \<in> readys s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1440
                by (simp add:runing_def eq_th)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1441
              moreover note eq_cnp eq_cnv ih [of th]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1442
              ultimately show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1443
            next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1444
              case False
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1445
              have eq_wq: "wq (e#s) cs = wq s cs @ [th]"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1446
                    by (unfold eq_th eq_e wq_def, auto simp:Let_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1447
              have "th \<notin> readys (e#s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1448
              proof
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1449
                assume "th \<in> readys (e#s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1450
                hence "\<forall>cs. \<not> waiting (e # s) th cs" by (simp add:readys_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1451
                from this[rule_format, of cs] have " \<not> waiting (e # s) th cs" .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1452
                hence "th \<in> set (wq (e#s) cs) \<Longrightarrow> th = hd (wq (e#s) cs)" 
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1453
                  by (simp add:s_waiting_def wq_def)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1454
                moreover from eq_wq have "th \<in> set (wq (e#s) cs)" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1455
                ultimately have "th = hd (wq (e#s) cs)" by blast
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1456
                with eq_wq have "th = hd (wq s cs @ [th])" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1457
                hence "th = hd (wq s cs)" using False by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1458
                with False eq_wq wq_distinct [OF vtp, of cs]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1459
                show False by (fold eq_e, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1460
              qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1461
              moreover from is_runing have "th \<in> threads (e#s)" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1462
                by (unfold eq_e, auto simp:runing_def readys_def eq_th)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1463
              moreover have "cntCS (e # s) th = cntCS s th"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1464
                apply (unfold cntCS_def holdents_def eq_e step_depend_p[OF vtp])
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1465
                by (auto simp:False)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1466
              moreover note eq_cnp eq_cnv ih[of th]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1467
              moreover from is_runing have "th \<in> readys s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1468
                by (simp add:runing_def eq_th)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1469
              ultimately show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1470
            qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1471
          qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1472
        } ultimately show ?thesis by blast
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1473
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1474
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1475
      case (thread_V thread cs)
333
813e7257c7c3 some polishing of the repository
urbanc
parents: 309
diff changeset
  1476
      from assms vt stp ih thread_V have vtv: "vt (V thread cs # s)" by auto
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1477
      assume eq_e: "e = V thread cs"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1478
        and is_runing: "thread \<in> runing s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1479
        and hold: "holding s thread cs"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1480
      from hold obtain rest 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1481
        where eq_wq: "wq s cs = thread # rest"
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1482
        by (case_tac "wq s cs", auto simp: wq_def s_holding_def)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1483
      have eq_threads: "threads (e#s) = threads s" by (simp add: eq_e)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1484
      have eq_set: "set (SOME q. distinct q \<and> set q = set rest) = set rest"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1485
      proof(rule someI2)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1486
        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
  1487
        show "distinct rest \<and> set rest = set rest" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1488
      next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1489
        show "\<And>x. distinct x \<and> set x = set rest \<Longrightarrow> set x = set rest"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1490
          by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1491
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1492
      show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1493
      proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1494
        { assume eq_th: "th = thread"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1495
          from eq_th have eq_cnp: "cntP (e # s) th = cntP s th"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1496
            by (unfold eq_e, simp add:cntP_def count_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1497
          moreover from eq_th have eq_cnv: "cntV (e#s) th = 1 + cntV s th"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1498
            by (unfold eq_e, simp add:cntV_def count_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1499
          moreover from cntCS_v_dec [OF vtv] 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1500
          have "cntCS (e # s) thread + 1 = cntCS s thread"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1501
            by (simp add:eq_e)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1502
          moreover from is_runing have rd_before: "thread \<in> readys s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1503
            by (unfold runing_def, simp)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1504
          moreover have "thread \<in> readys (e # s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1505
          proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1506
            from is_runing
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1507
            have "thread \<in> threads (e#s)" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1508
              by (unfold eq_e, auto simp:runing_def readys_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1509
            moreover have "\<forall> cs1. \<not> waiting (e#s) thread cs1"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1510
            proof
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1511
              fix cs1
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1512
              { assume eq_cs: "cs1 = cs" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1513
                have "\<not> waiting (e # s) thread cs1"
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
                  from eq_wq
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1516
                  have "thread \<notin> set (wq (e#s) cs1)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1517
                    apply(unfold eq_e wq_def eq_cs s_holding_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1518
                    apply (auto simp:Let_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1519
                  proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1520
                    assume "thread \<in> set (SOME q. distinct q \<and> set q = set rest)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1521
                    with eq_set have "thread \<in> set rest" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1522
                    with wq_distinct[OF step_back_vt[OF vtv], of cs]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1523
                    and eq_wq show False by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1524
                  qed
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1525
                  thus ?thesis by (simp add:wq_def s_waiting_def)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1526
                qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1527
              } moreover {
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1528
                assume neq_cs: "cs1 \<noteq> cs"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1529
                  have "\<not> waiting (e # s) thread cs1" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1530
                  proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1531
                    from wq_v_neq [OF neq_cs[symmetric]]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1532
                    have "wq (V thread cs # s) cs1 = wq s cs1" .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1533
                    moreover have "\<not> waiting s thread cs1" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1534
                    proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1535
                      from runing_ready and is_runing
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1536
                      have "thread \<in> readys s" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1537
                      thus ?thesis by (simp add:readys_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1538
                    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1539
                    ultimately show ?thesis 
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1540
                      by (auto simp:wq_def s_waiting_def eq_e)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1541
                  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1542
              } ultimately show "\<not> waiting (e # s) thread cs1" by blast
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
            ultimately show ?thesis by (simp add:readys_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1545
          qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1546
          moreover note eq_th ih
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1547
          ultimately have ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1548
        } moreover {
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1549
          assume neq_th: "th \<noteq> thread"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1550
          from neq_th eq_e have eq_cnp: "cntP (e # s) th = cntP s th" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1551
            by (simp add:cntP_def count_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1552
          from neq_th eq_e have eq_cnv: "cntV (e # s) th = cntV s th" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1553
            by (simp add:cntV_def count_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1554
          have ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1555
          proof(cases "th \<in> set rest")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1556
            case False
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1557
            have "(th \<in> readys (e # s)) = (th \<in> readys s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1558
              apply (insert step_back_vt[OF vtv])
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1559
              by (unfold eq_e, rule readys_v_eq [OF _ neq_th eq_wq False], auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1560
            moreover have "cntCS (e#s) th = cntCS s th"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1561
              apply (insert neq_th, unfold eq_e cntCS_def holdents_def step_depend_v[OF vtv], auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1562
              proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1563
                have "{csa. (Cs csa, Th th) \<in> depend s \<or> csa = cs \<and> next_th s thread cs th} =
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1564
                      {cs. (Cs cs, Th th) \<in> depend s}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1565
                proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1566
                  from False eq_wq
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1567
                  have " next_th s thread cs th \<Longrightarrow> (Cs cs, Th th) \<in> depend s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1568
                    apply (unfold next_th_def, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1569
                  proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1570
                    assume ne: "rest \<noteq> []"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1571
                      and 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
  1572
                      and eq_wq: "wq s cs = thread # rest"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1573
                    from eq_set ni have "hd (SOME q. distinct q \<and> set q = set rest) \<notin> 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1574
                                  set (SOME q. distinct q \<and> set q = set rest)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1575
                                  " by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1576
                    moreover have "(SOME q. distinct q \<and> set q = set rest) \<noteq> []"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1577
                    proof(rule someI2)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1578
                      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
  1579
                      show "distinct rest \<and> set rest = set rest" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1580
                    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1581
                      fix x assume "distinct x \<and> set x = set rest"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1582
                      with ne show "x \<noteq> []" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1583
                    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1584
                    ultimately show 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1585
                      "(Cs cs, Th (hd (SOME q. distinct q \<and> set q = set rest))) \<in> depend s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1586
                      by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1587
                  qed    
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1588
                  thus ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1589
                qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1590
                thus "card {csa. (Cs csa, Th th) \<in> depend s \<or> csa = cs \<and> next_th s thread cs th} =
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1591
                             card {cs. (Cs cs, Th th) \<in> depend s}" by simp 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1592
              qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1593
            moreover note ih eq_cnp eq_cnv eq_threads
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1594
            ultimately show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1595
          next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1596
            case True
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1597
            assume th_in: "th \<in> set rest"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1598
            show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1599
            proof(cases "next_th s thread cs th")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1600
              case False
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1601
              with eq_wq and th_in have 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1602
                neq_hd: "th \<noteq> hd (SOME q. distinct q \<and> set q = set rest)" (is "th \<noteq> hd ?rest")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1603
                by (auto simp:next_th_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1604
              have "(th \<in> readys (e # s)) = (th \<in> readys s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1605
              proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1606
                from eq_wq and th_in
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1607
                have "\<not> th \<in> readys s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1608
                  apply (auto simp:readys_def s_waiting_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1609
                  apply (rule_tac x = cs in exI, auto)
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1610
                  by (insert wq_distinct[OF step_back_vt[OF vtv], of cs], auto simp add: wq_def)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1611
                moreover 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1612
                from eq_wq and th_in and neq_hd
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1613
                have "\<not> (th \<in> readys (e # s))"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1614
                  apply (auto simp:readys_def s_waiting_def eq_e wq_def Let_def split:list.splits)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1615
                  by (rule_tac x = cs in exI, auto simp:eq_set)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1616
                ultimately show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1617
              qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1618
              moreover have "cntCS (e#s) th = cntCS s th" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1619
              proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1620
                from eq_wq and  th_in and neq_hd
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1621
                have "(holdents (e # s) th) = (holdents s th)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1622
                  apply (unfold eq_e step_depend_v[OF vtv], 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1623
                         auto simp:next_th_def eq_set s_depend_def holdents_def wq_def
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1624
                                   Let_def cs_holding_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1625
                  by (insert wq_distinct[OF step_back_vt[OF vtv], of cs], auto simp:wq_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1626
                thus ?thesis by (simp add:cntCS_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1627
              qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1628
              moreover note ih eq_cnp eq_cnv eq_threads
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1629
              ultimately show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1630
            next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1631
              case True
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1632
              let ?rest = " (SOME q. distinct q \<and> set q = set rest)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1633
              let ?t = "hd ?rest"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1634
              from True eq_wq th_in neq_th
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1635
              have "th \<in> readys (e # s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1636
                apply (auto simp:eq_e readys_def s_waiting_def wq_def
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1637
                        Let_def next_th_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1638
              proof -
294
bc5bf9e9ada2 renamed waiting_queue -> wq_fun; cur_preced -> cprec_fun
urbanc
parents: 291
diff changeset
  1639
                assume eq_wq: "wq_fun (schs s) cs = thread # rest"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1640
                  and t_in: "?t \<in> set rest"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1641
                show "?t \<in> threads s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1642
                proof(rule wq_threads[OF step_back_vt[OF vtv]])
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1643
                  from eq_wq and t_in
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1644
                  show "?t \<in> set (wq s cs)" by (auto simp:wq_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1645
                qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1646
              next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1647
                fix csa
294
bc5bf9e9ada2 renamed waiting_queue -> wq_fun; cur_preced -> cprec_fun
urbanc
parents: 291
diff changeset
  1648
                assume eq_wq: "wq_fun (schs s) cs = thread # rest"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1649
                  and t_in: "?t \<in> set rest"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1650
                  and neq_cs: "csa \<noteq> cs"
294
bc5bf9e9ada2 renamed waiting_queue -> wq_fun; cur_preced -> cprec_fun
urbanc
parents: 291
diff changeset
  1651
                  and t_in': "?t \<in>  set (wq_fun (schs s) csa)"
bc5bf9e9ada2 renamed waiting_queue -> wq_fun; cur_preced -> cprec_fun
urbanc
parents: 291
diff changeset
  1652
                show "?t = hd (wq_fun (schs s) csa)"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1653
                proof -
294
bc5bf9e9ada2 renamed waiting_queue -> wq_fun; cur_preced -> cprec_fun
urbanc
parents: 291
diff changeset
  1654
                  { assume neq_hd': "?t \<noteq> hd (wq_fun (schs s) csa)"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1655
                    from wq_distinct[OF step_back_vt[OF vtv], of cs] and 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1656
                    eq_wq[folded wq_def] and t_in eq_wq
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1657
                    have "?t \<noteq> thread" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1658
                    with eq_wq and t_in
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1659
                    have w1: "waiting s ?t cs"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1660
                      by (auto simp:s_waiting_def wq_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1661
                    from t_in' neq_hd'
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1662
                    have w2: "waiting s ?t csa"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1663
                      by (auto simp:s_waiting_def wq_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1664
                    from waiting_unique[OF step_back_vt[OF vtv] w1 w2]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1665
                    and neq_cs have "False" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1666
                  } thus ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1667
                qed
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
              moreover have "cntP s th = cntV s th + cntCS s th + 1"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1670
              proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1671
                have "th \<notin> readys s" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1672
                proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1673
                  from True eq_wq neq_th th_in
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1674
                  show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1675
                    apply (unfold readys_def s_waiting_def, auto)
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1676
                    by (rule_tac x = cs in exI, auto simp add: wq_def)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1677
                qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1678
                moreover have "th \<in> threads s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1679
                proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1680
                  from th_in eq_wq
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1681
                  have "th \<in> set (wq s cs)" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1682
                  from wq_threads [OF step_back_vt[OF vtv] this] 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1683
                  show ?thesis .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1684
                qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1685
                ultimately show ?thesis using ih by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1686
              qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1687
              moreover from True neq_th have "cntCS (e # s) th = 1 + cntCS s th"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1688
                apply (unfold cntCS_def holdents_def eq_e step_depend_v[OF vtv], auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1689
              proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1690
                show "card {csa. (Cs csa, Th th) \<in> depend s \<or> csa = cs} =
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1691
                               Suc (card {cs. (Cs cs, Th th) \<in> depend s})"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1692
                  (is "card ?A = Suc (card ?B)")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1693
                proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1694
                  have "?A = insert cs ?B" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1695
                  hence "card ?A = card (insert cs ?B)" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1696
                  also have "\<dots> = Suc (card ?B)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1697
                  proof(rule card_insert_disjoint)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1698
                    have "?B \<subseteq> ((\<lambda> (x, y). the_cs x) ` depend s)" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1699
                      apply (auto simp:image_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1700
                      by (rule_tac x = "(Cs x, Th th)" in bexI, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1701
                    with finite_depend[OF step_back_vt[OF vtv]]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1702
                    show "finite {cs. (Cs cs, Th th) \<in> depend s}" by (auto intro:finite_subset)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1703
                  next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1704
                    show "cs \<notin> {cs. (Cs cs, Th th) \<in> depend s}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1705
                    proof
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1706
                      assume "cs \<in> {cs. (Cs cs, Th th) \<in> depend s}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1707
                      hence "(Cs cs, Th th) \<in> depend s" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1708
                      with True neq_th eq_wq show False
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1709
                        by (auto simp:next_th_def s_depend_def cs_holding_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1710
                    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1711
                  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1712
                  finally show ?thesis .
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
              qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1715
              moreover note eq_cnp eq_cnv
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1716
              ultimately show ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1717
            qed
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
        } ultimately show ?thesis by blast
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1720
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1721
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1722
      case (thread_set thread prio)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1723
      assume eq_e: "e = Set thread prio"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1724
        and is_runing: "thread \<in> runing s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1725
      show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1726
      proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1727
        from eq_e have eq_cnp: "cntP (e#s) th = cntP s th" by (simp add:cntP_def count_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1728
        from eq_e have eq_cnv: "cntV (e#s) th = cntV s th" by (simp add:cntV_def count_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1729
        have eq_cncs: "cntCS (e#s) th = cntCS s th"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1730
          unfolding cntCS_def holdents_def
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1731
          by (simp add:depend_set_unchanged eq_e)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1732
        from eq_e have eq_readys: "readys (e#s) = readys s" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1733
          by (simp add:readys_def cs_waiting_def s_waiting_def wq_def,
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1734
                  auto simp:Let_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1735
        { assume "th \<noteq> thread"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1736
          with eq_readys eq_e
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1737
          have "(th \<in> readys (e # s) \<or> th \<notin> threads (e # s)) = 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1738
                      (th \<in> readys (s) \<or> th \<notin> threads (s))" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1739
            by (simp add:threads.simps)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1740
          with eq_cnp eq_cnv eq_cncs ih is_runing
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1741
          have ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1742
        } moreover {
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1743
          assume eq_th: "th = thread"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1744
          with is_runing ih have " cntP s th  = cntV s th + cntCS s th" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1745
            by (unfold runing_def, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1746
          moreover from eq_th and eq_readys is_runing have "th \<in> readys (e#s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1747
            by (simp add:runing_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1748
          moreover note eq_cnp eq_cnv eq_cncs
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1749
          ultimately have ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1750
        } ultimately show ?thesis by blast
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1751
      qed   
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1752
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1753
  next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1754
    case vt_nil
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1755
    show ?case 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1756
      by (unfold cntP_def cntV_def cntCS_def, 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1757
        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
  1758
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1759
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1760
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1761
lemma not_thread_cncs:
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1762
  fixes th s
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1763
  assumes vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1764
  and not_in: "th \<notin> threads s" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1765
  shows "cntCS s th = 0"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1766
proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1767
  from vt not_in show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1768
  proof(induct arbitrary:th)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1769
    case (vt_cons s e th)
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1770
    assume vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1771
      and ih: "\<And>th. th \<notin> threads s \<Longrightarrow> cntCS s th = 0"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1772
      and stp: "step s e"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1773
      and not_in: "th \<notin> threads (e # s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1774
    from stp show ?case
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1775
    proof(cases)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1776
      case (thread_create thread prio)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1777
      assume eq_e: "e = Create thread prio"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1778
        and not_in': "thread \<notin> threads s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1779
      have "cntCS (e # s) th = cntCS s th"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1780
        apply (unfold eq_e cntCS_def holdents_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1781
        by (simp add:depend_create_unchanged)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1782
      moreover have "th \<notin> threads s" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1783
      proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1784
        from not_in eq_e show ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1785
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1786
      moreover note ih ultimately show ?thesis 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
      case (thread_exit thread)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1789
      assume eq_e: "e = Exit thread"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1790
      and nh: "holdents s thread = {}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1791
      have eq_cns: "cntCS (e # s) th = cntCS s th"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1792
        apply (unfold eq_e cntCS_def holdents_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1793
        by (simp add:depend_exit_unchanged)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1794
      show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1795
      proof(cases "th = thread")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1796
        case True
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1797
        have "cntCS s th = 0" by (unfold cntCS_def, auto simp:nh True)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1798
        with eq_cns show ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1799
      next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1800
        case False
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1801
        with not_in and eq_e
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1802
        have "th \<notin> threads s" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1803
        from ih[OF this] and eq_cns show ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1804
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1805
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1806
      case (thread_P thread cs)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1807
      assume eq_e: "e = P thread cs"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1808
      and is_runing: "thread \<in> runing s"
333
813e7257c7c3 some polishing of the repository
urbanc
parents: 309
diff changeset
  1809
      from assms thread_P ih vt stp thread_P have vtp: "vt (P thread cs#s)" by auto
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1810
      have neq_th: "th \<noteq> thread" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1811
      proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1812
        from not_in eq_e have "th \<notin> threads s" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1813
        moreover from is_runing have "thread \<in> threads s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1814
          by (simp add:runing_def readys_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1815
        ultimately show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1816
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1817
      hence "cntCS (e # s) th  = cntCS s th "
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1818
        apply (unfold cntCS_def holdents_def eq_e)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1819
        by (unfold step_depend_p[OF vtp], auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1820
      moreover have "cntCS s th = 0"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1821
      proof(rule ih)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1822
        from not_in eq_e show "th \<notin> threads s" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1823
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1824
      ultimately show ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1825
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1826
      case (thread_V thread cs)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1827
      assume eq_e: "e = V thread cs"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1828
        and is_runing: "thread \<in> runing s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1829
        and hold: "holding s thread cs"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1830
      have neq_th: "th \<noteq> thread" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1831
      proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1832
        from not_in eq_e have "th \<notin> threads s" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1833
        moreover from is_runing have "thread \<in> threads s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1834
          by (simp add:runing_def readys_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1835
        ultimately show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1836
      qed
333
813e7257c7c3 some polishing of the repository
urbanc
parents: 309
diff changeset
  1837
      from assms thread_V vt stp ih have vtv: "vt (V thread cs#s)" by auto
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1838
      from hold obtain rest 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1839
        where eq_wq: "wq s cs = thread # rest"
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1840
        by (case_tac "wq s cs", auto simp: wq_def s_holding_def)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1841
      from not_in eq_e eq_wq
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1842
      have "\<not> next_th s thread cs th"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1843
        apply (auto simp:next_th_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1844
      proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1845
        assume ne: "rest \<noteq> []"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1846
          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
  1847
        have "?t \<in> set rest"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1848
        proof(rule someI2)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1849
          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
  1850
          show "distinct rest \<and> set rest = set rest" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1851
        next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1852
          fix x assume "distinct x \<and> set x = set rest" with ne
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1853
          show "hd x \<in> set rest" by (cases x, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1854
        qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1855
        with eq_wq have "?t \<in> set (wq s cs)" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1856
        from wq_threads[OF step_back_vt[OF vtv], OF this] and ni
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1857
        show False by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1858
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1859
      moreover note neq_th eq_wq
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1860
      ultimately have "cntCS (e # s) th  = cntCS s th"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1861
        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
  1862
      moreover have "cntCS s th = 0"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1863
      proof(rule ih)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1864
        from not_in eq_e show "th \<notin> threads s" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1865
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1866
      ultimately show ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1867
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1868
      case (thread_set thread prio)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1869
      print_facts
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1870
      assume eq_e: "e = Set thread prio"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1871
        and is_runing: "thread \<in> runing s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1872
      from not_in and eq_e have "th \<notin> threads s" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1873
      from ih [OF this] and eq_e
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
        apply (unfold eq_e cntCS_def holdents_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1876
        by (simp add:depend_set_unchanged)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1877
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1878
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1879
      case vt_nil
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1880
      show ?case
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1881
      by (unfold cntCS_def, 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1882
        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
  1883
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1884
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1885
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1886
lemma eq_waiting: "waiting (wq (s::state)) th cs = waiting s th cs"
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1887
  by (auto simp:s_waiting_def cs_waiting_def wq_def)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1888
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1889
lemma dm_depend_threads:
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1890
  fixes th s
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1891
  assumes vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1892
  and in_dom: "(Th th) \<in> Domain (depend s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1893
  shows "th \<in> threads s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1894
proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1895
  from in_dom obtain n where "(Th th, n) \<in> depend s" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1896
  moreover from depend_target_th[OF this] obtain cs where "n = Cs cs" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1897
  ultimately have "(Th th, Cs cs) \<in> depend s" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1898
  hence "th \<in> set (wq s cs)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1899
    by (unfold s_depend_def, auto simp:cs_waiting_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1900
  from wq_threads [OF vt this] show ?thesis .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1901
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1902
290
6a6d0bd16035 more on paper
urbanc
parents: 289
diff changeset
  1903
lemma cp_eq_cpreced: "cp s th = cpreced (wq s) s th"
291
5ef9f6ebe827 more on paper; modified schs functions; it is still compatible with the old definition
urbanc
parents: 290
diff changeset
  1904
unfolding cp_def wq_def
5ef9f6ebe827 more on paper; modified schs functions; it is still compatible with the old definition
urbanc
parents: 290
diff changeset
  1905
apply(induct s rule: schs.induct)
5ef9f6ebe827 more on paper; modified schs functions; it is still compatible with the old definition
urbanc
parents: 290
diff changeset
  1906
apply(simp add: Let_def cpreced_initial)
5ef9f6ebe827 more on paper; modified schs functions; it is still compatible with the old definition
urbanc
parents: 290
diff changeset
  1907
apply(simp add: Let_def)
5ef9f6ebe827 more on paper; modified schs functions; it is still compatible with the old definition
urbanc
parents: 290
diff changeset
  1908
apply(simp add: Let_def)
5ef9f6ebe827 more on paper; modified schs functions; it is still compatible with the old definition
urbanc
parents: 290
diff changeset
  1909
apply(simp add: Let_def)
5ef9f6ebe827 more on paper; modified schs functions; it is still compatible with the old definition
urbanc
parents: 290
diff changeset
  1910
apply(subst (2) schs.simps)
5ef9f6ebe827 more on paper; modified schs functions; it is still compatible with the old definition
urbanc
parents: 290
diff changeset
  1911
apply(simp add: Let_def)
5ef9f6ebe827 more on paper; modified schs functions; it is still compatible with the old definition
urbanc
parents: 290
diff changeset
  1912
apply(subst (2) schs.simps)
5ef9f6ebe827 more on paper; modified schs functions; it is still compatible with the old definition
urbanc
parents: 290
diff changeset
  1913
apply(simp add: Let_def)
5ef9f6ebe827 more on paper; modified schs functions; it is still compatible with the old definition
urbanc
parents: 290
diff changeset
  1914
done
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1915
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1916
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1917
lemma runing_unique:
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1918
  fixes th1 th2 s
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  1919
  assumes vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1920
  and runing_1: "th1 \<in> runing s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1921
  and runing_2: "th2 \<in> runing s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1922
  shows "th1 = th2"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1923
proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1924
  from runing_1 and runing_2 have "cp s th1 = cp s th2"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1925
    by (unfold runing_def, simp)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1926
  hence eq_max: "Max ((\<lambda>th. preced th s) ` ({th1} \<union> dependents (wq s) th1)) =
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1927
                 Max ((\<lambda>th. preced th s) ` ({th2} \<union> dependents (wq s) th2))"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1928
    (is "Max (?f ` ?A) = Max (?f ` ?B)")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1929
    by (unfold cp_eq_cpreced cpreced_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1930
  obtain th1' where th1_in: "th1' \<in> ?A" and eq_f_th1: "?f th1' = Max (?f ` ?A)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1931
  proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1932
    have h1: "finite (?f ` ?A)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1933
    proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1934
      have "finite ?A" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1935
      proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1936
        have "finite (dependents (wq s) th1)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1937
        proof-
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1938
          have "finite {th'. (Th th', Th th1) \<in> (depend (wq s))\<^sup>+}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1939
          proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1940
            let ?F = "\<lambda> (x, y). the_th x"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1941
            have "{th'. (Th th', Th th1) \<in> (depend (wq s))\<^sup>+} \<subseteq> ?F ` ((depend (wq s))\<^sup>+)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1942
              apply (auto simp:image_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1943
              by (rule_tac x = "(Th x, Th th1)" in bexI, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1944
            moreover have "finite \<dots>"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1945
            proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1946
              from finite_depend[OF vt] have "finite (depend s)" .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1947
              hence "finite ((depend (wq s))\<^sup>+)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1948
                apply (unfold finite_trancl)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1949
                by (auto simp: s_depend_def cs_depend_def wq_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1950
              thus ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1951
            qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1952
            ultimately show ?thesis by (auto intro:finite_subset)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1953
          qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1954
          thus ?thesis by (simp add:cs_dependents_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1955
        qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1956
        thus ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1957
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1958
      thus ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1959
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1960
    moreover have h2: "(?f ` ?A) \<noteq> {}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1961
    proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1962
      have "?A \<noteq> {}" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1963
      thus ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1964
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1965
    from Max_in [OF h1 h2]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1966
    have "Max (?f ` ?A) \<in> (?f ` ?A)" .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1967
    thus ?thesis by (auto intro:that)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1968
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1969
  obtain th2' where th2_in: "th2' \<in> ?B" and eq_f_th2: "?f th2' = Max (?f ` ?B)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1970
  proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1971
    have h1: "finite (?f ` ?B)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1972
    proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1973
      have "finite ?B" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1974
      proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1975
        have "finite (dependents (wq s) th2)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1976
        proof-
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1977
          have "finite {th'. (Th th', Th th2) \<in> (depend (wq s))\<^sup>+}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1978
          proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1979
            let ?F = "\<lambda> (x, y). the_th x"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1980
            have "{th'. (Th th', Th th2) \<in> (depend (wq s))\<^sup>+} \<subseteq> ?F ` ((depend (wq s))\<^sup>+)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1981
              apply (auto simp:image_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1982
              by (rule_tac x = "(Th x, Th th2)" in bexI, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1983
            moreover have "finite \<dots>"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1984
            proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1985
              from finite_depend[OF vt] have "finite (depend s)" .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1986
              hence "finite ((depend (wq s))\<^sup>+)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1987
                apply (unfold finite_trancl)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1988
                by (auto simp: s_depend_def cs_depend_def wq_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1989
              thus ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1990
            qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1991
            ultimately show ?thesis by (auto intro:finite_subset)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1992
          qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1993
          thus ?thesis by (simp add:cs_dependents_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1994
        qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1995
        thus ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1996
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1997
      thus ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1998
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  1999
    moreover have h2: "(?f ` ?B) \<noteq> {}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2000
    proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2001
      have "?B \<noteq> {}" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2002
      thus ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2003
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2004
    from Max_in [OF h1 h2]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2005
    have "Max (?f ` ?B) \<in> (?f ` ?B)" .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2006
    thus ?thesis by (auto intro:that)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2007
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2008
  from eq_f_th1 eq_f_th2 eq_max 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2009
  have eq_preced: "preced th1' s = preced th2' s" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2010
  hence eq_th12: "th1' = th2'"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2011
  proof (rule preced_unique)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2012
    from th1_in have "th1' = th1 \<or> (th1' \<in> dependents (wq s) th1)" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2013
    thus "th1' \<in> threads s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2014
    proof
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2015
      assume "th1' \<in> dependents (wq s) th1"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2016
      hence "(Th th1') \<in> Domain ((depend s)^+)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2017
        apply (unfold cs_dependents_def cs_depend_def s_depend_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2018
        by (auto simp:Domain_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2019
      hence "(Th th1') \<in> Domain (depend s)" by (simp add:trancl_domain)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2020
      from dm_depend_threads[OF vt this] show ?thesis .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2021
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2022
      assume "th1' = th1"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2023
      with runing_1 show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2024
        by (unfold runing_def readys_def, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2025
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2026
  next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2027
    from th2_in have "th2' = th2 \<or> (th2' \<in> dependents (wq s) th2)" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2028
    thus "th2' \<in> threads s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2029
    proof
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2030
      assume "th2' \<in> dependents (wq s) th2"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2031
      hence "(Th th2') \<in> Domain ((depend s)^+)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2032
        apply (unfold cs_dependents_def cs_depend_def s_depend_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2033
        by (auto simp:Domain_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2034
      hence "(Th th2') \<in> Domain (depend s)" by (simp add:trancl_domain)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2035
      from dm_depend_threads[OF vt this] show ?thesis .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2036
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2037
      assume "th2' = th2"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2038
      with runing_2 show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2039
        by (unfold runing_def readys_def, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2040
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2041
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2042
  from th1_in have "th1' = th1 \<or> th1' \<in> dependents (wq s) th1" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2043
  thus ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2044
  proof
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2045
    assume eq_th': "th1' = th1"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2046
    from th2_in have "th2' = th2 \<or> th2' \<in> dependents (wq s) th2" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2047
    thus ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2048
    proof
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2049
      assume "th2' = th2" thus ?thesis using eq_th' eq_th12 by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2050
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2051
      assume "th2' \<in> dependents (wq s) th2"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2052
      with eq_th12 eq_th' have "th1 \<in> dependents (wq s) th2" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2053
      hence "(Th th1, Th th2) \<in> (depend s)^+"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2054
        by (unfold cs_dependents_def s_depend_def cs_depend_def, simp)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2055
      hence "Th th1 \<in> Domain ((depend s)^+)" using Domain_def [of "(depend s)^+"]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2056
        by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2057
      hence "Th th1 \<in> Domain (depend s)" by (simp add:trancl_domain)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2058
      then obtain n where d: "(Th th1, n) \<in> depend s" by (auto simp:Domain_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2059
      from depend_target_th [OF this]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2060
      obtain cs' where "n = Cs cs'" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2061
      with d have "(Th th1, Cs cs') \<in> depend s" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2062
      with runing_1 have "False"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2063
        apply (unfold runing_def readys_def s_depend_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2064
        by (auto simp:eq_waiting)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2065
      thus ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2066
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2067
  next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2068
    assume th1'_in: "th1' \<in> dependents (wq s) th1"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2069
    from th2_in have "th2' = th2 \<or> th2' \<in> dependents (wq s) th2" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2070
    thus ?thesis 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2071
    proof
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2072
      assume "th2' = th2"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2073
      with th1'_in eq_th12 have "th2 \<in> dependents (wq s) th1" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2074
      hence "(Th th2, Th th1) \<in> (depend s)^+"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2075
        by (unfold cs_dependents_def s_depend_def cs_depend_def, simp)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2076
      hence "Th th2 \<in> Domain ((depend s)^+)" using Domain_def [of "(depend s)^+"]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2077
        by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2078
      hence "Th th2 \<in> Domain (depend s)" by (simp add:trancl_domain)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2079
      then obtain n where d: "(Th th2, n) \<in> depend s" by (auto simp:Domain_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2080
      from depend_target_th [OF this]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2081
      obtain cs' where "n = Cs cs'" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2082
      with d have "(Th th2, Cs cs') \<in> depend s" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2083
      with runing_2 have "False"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2084
        apply (unfold runing_def readys_def s_depend_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2085
        by (auto simp:eq_waiting)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2086
      thus ?thesis by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2087
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2088
      assume "th2' \<in> dependents (wq s) th2"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2089
      with eq_th12 have "th1' \<in> dependents (wq s) th2" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2090
      hence h1: "(Th th1', Th th2) \<in> (depend s)^+"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2091
        by (unfold cs_dependents_def s_depend_def cs_depend_def, simp)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2092
      from th1'_in have h2: "(Th th1', Th th1) \<in> (depend s)^+"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2093
        by (unfold cs_dependents_def s_depend_def cs_depend_def, simp)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2094
      show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2095
      proof(rule dchain_unique[OF vt h1 _ h2, symmetric])
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2096
        from runing_1 show "th1 \<in> readys s" by (simp add:runing_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2097
        from runing_2 show "th2 \<in> readys s" by (simp add:runing_def) 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2098
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2099
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2100
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2101
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2102
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2103
lemma create_pre:
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2104
  assumes stp: "step s e"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2105
  and not_in: "th \<notin> threads s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2106
  and is_in: "th \<in> threads (e#s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2107
  obtains prio where "e = Create th prio"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2108
proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2109
  from assms  
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2110
  show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2111
  proof(cases)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2112
    case (thread_create thread prio)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2113
    with is_in not_in have "e = Create th prio" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2114
    from that[OF this] show ?thesis .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2115
  next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2116
    case (thread_exit thread)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2117
    with assms show ?thesis by (auto intro!:that)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2118
  next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2119
    case (thread_P thread)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2120
    with assms show ?thesis by (auto intro!:that)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2121
  next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2122
    case (thread_V thread)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2123
    with assms show ?thesis by (auto intro!:that)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2124
  next 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2125
    case (thread_set thread)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2126
    with assms show ?thesis by (auto intro!:that)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2127
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2128
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2129
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2130
lemma length_down_to_in: 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2131
  assumes le_ij: "i \<le> j"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2132
    and le_js: "j \<le> length s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2133
  shows "length (down_to j i s) = j - i"
336
f9e0d3274c14 fixed typo
urbanc
parents: 333
diff changeset
  2134
by (metis down_to_def le_ij le_js length_from_to_in length_rev)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2135
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2136
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2137
lemma moment_head: 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2138
  assumes le_it: "Suc i \<le> length t"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2139
  obtains e where "moment (Suc i) t = e#moment i t"
336
f9e0d3274c14 fixed typo
urbanc
parents: 333
diff changeset
  2140
by (metis assms moment_plus)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2141
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2142
lemma cnp_cnv_eq:
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2143
  fixes th s
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  2144
  assumes "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2145
  and "th \<notin> threads s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2146
  shows "cntP s th = cntV s th"
336
f9e0d3274c14 fixed typo
urbanc
parents: 333
diff changeset
  2147
by (metis (full_types) add_0_right assms(1) assms(2) cnp_cnv_cncs not_thread_cncs)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2148
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2149
lemma eq_depend: 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2150
  "depend (wq s) = depend s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2151
by (unfold cs_depend_def s_depend_def, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2152
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2153
lemma count_eq_dependents:
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  2154
  assumes vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2155
  and eq_pv: "cntP s th = cntV s th"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2156
  shows "dependents (wq s) th = {}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2157
proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2158
  from cnp_cnv_cncs[OF vt] and eq_pv
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2159
  have "cntCS s th = 0" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2160
    by (auto split:if_splits)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2161
  moreover have "finite {cs. (Cs cs, Th th) \<in> depend s}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2162
  proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2163
    from finite_holding[OF vt, of th] show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2164
      by (simp add:holdents_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2165
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2166
  ultimately have h: "{cs. (Cs cs, Th th) \<in> depend s} = {}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2167
    by (unfold cntCS_def holdents_def cs_dependents_def, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2168
  show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2169
  proof(unfold cs_dependents_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2170
    { assume "{th'. (Th th', Th th) \<in> (depend (wq s))\<^sup>+} \<noteq> {}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2171
      then obtain th' where "(Th th', Th th) \<in> (depend (wq s))\<^sup>+" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2172
      hence "False"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2173
      proof(cases)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2174
        assume "(Th th', Th th) \<in> depend (wq s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2175
        thus "False" by (auto simp:cs_depend_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2176
      next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2177
        fix c
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2178
        assume "(c, Th th) \<in> depend (wq s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2179
        with h and eq_depend show "False"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2180
          by (cases c, auto simp:cs_depend_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2181
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2182
    } thus "{th'. (Th th', Th th) \<in> (depend (wq s))\<^sup>+} = {}" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2183
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2184
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2185
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2186
lemma dependents_threads:
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2187
  fixes s th
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  2188
  assumes vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2189
  shows "dependents (wq s) th \<subseteq> threads s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2190
proof
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2191
  { fix th th'
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2192
    assume h: "th \<in> {th'a. (Th th'a, Th th') \<in> (depend (wq s))\<^sup>+}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2193
    have "Th th \<in> Domain (depend s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2194
    proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2195
      from h obtain th' where "(Th th, Th th') \<in> (depend (wq s))\<^sup>+" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2196
      hence "(Th th) \<in> Domain ( (depend (wq s))\<^sup>+)" by (auto simp:Domain_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2197
      with trancl_domain have "(Th th) \<in> Domain (depend (wq s))" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2198
      thus ?thesis using eq_depend by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2199
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2200
    from dm_depend_threads[OF vt this]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2201
    have "th \<in> threads s" .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2202
  } note hh = this
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2203
  fix th1 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2204
  assume "th1 \<in> dependents (wq s) th"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2205
  hence "th1 \<in> {th'a. (Th th'a, Th th) \<in> (depend (wq s))\<^sup>+}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2206
    by (unfold cs_dependents_def, simp)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2207
  from hh [OF this] show "th1 \<in> threads s" .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2208
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2209
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2210
lemma finite_threads:
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  2211
  assumes vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2212
  shows "finite (threads s)"
309
e44c4055d430 more on the paper
urbanc
parents: 298
diff changeset
  2213
using vt
e44c4055d430 more on the paper
urbanc
parents: 298
diff changeset
  2214
by (induct) (auto elim: step.cases)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2215
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2216
lemma Max_f_mono:
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2217
  assumes seq: "A \<subseteq> B"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2218
  and np: "A \<noteq> {}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2219
  and fnt: "finite B"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2220
  shows "Max (f ` A) \<le> Max (f ` B)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2221
proof(rule Max_mono)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2222
  from seq show "f ` A \<subseteq> f ` B" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2223
next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2224
  from np show "f ` A \<noteq> {}" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2225
next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2226
  from fnt and seq show "finite (f ` B)" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2227
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2228
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2229
lemma cp_le:
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  2230
  assumes vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2231
  and th_in: "th \<in> threads s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2232
  shows "cp s th \<le> Max ((\<lambda> th. (preced th s)) ` threads s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2233
proof(unfold cp_eq_cpreced cpreced_def cs_dependents_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2234
  show "Max ((\<lambda>th. preced th s) ` ({th} \<union> {th'. (Th th', Th th) \<in> (depend (wq s))\<^sup>+}))
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2235
         \<le> Max ((\<lambda>th. preced th s) ` threads s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2236
    (is "Max (?f ` ?A) \<le> Max (?f ` ?B)")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2237
  proof(rule Max_f_mono)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2238
    show "{th} \<union> {th'. (Th th', Th th) \<in> (depend (wq s))\<^sup>+} \<noteq> {}" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2239
  next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2240
    from finite_threads [OF vt]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2241
    show "finite (threads s)" .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2242
  next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2243
    from th_in
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2244
    show "{th} \<union> {th'. (Th th', Th th) \<in> (depend (wq s))\<^sup>+} \<subseteq> threads s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2245
      apply (auto simp:Domain_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2246
      apply (rule_tac dm_depend_threads[OF vt])
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2247
      apply (unfold trancl_domain [of "depend s", symmetric])
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2248
      by (unfold cs_depend_def s_depend_def, auto simp:Domain_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2249
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2250
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2251
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2252
lemma le_cp:
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  2253
  assumes vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2254
  shows "preced th s \<le> cp s th"
336
f9e0d3274c14 fixed typo
urbanc
parents: 333
diff changeset
  2255
apply(unfold cp_eq_cpreced preced_def cpreced_def, simp)
f9e0d3274c14 fixed typo
urbanc
parents: 333
diff changeset
  2256
by (metis (mono_tags) Max_ge assms dependents_threads finite_imageI finite_insert finite_threads insertI1 preced_def rev_finite_subset)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2257
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2258
lemma max_cp_eq: 
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  2259
  assumes vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2260
  shows "Max ((cp s) ` threads s) = Max ((\<lambda> th. (preced th s)) ` threads s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2261
  (is "?l = ?r")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2262
proof(cases "threads s = {}")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2263
  case True
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2264
  thus ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2265
next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2266
  case False
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2267
  have "?l \<in> ((cp s) ` threads s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2268
  proof(rule Max_in)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2269
    from finite_threads[OF vt] 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2270
    show "finite (cp s ` threads s)" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2271
  next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2272
    from False show "cp s ` threads s \<noteq> {}" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2273
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2274
  then obtain th 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2275
    where th_in: "th \<in> threads s" and eq_l: "?l = cp s th" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2276
  have "\<dots> \<le> ?r" by (rule cp_le[OF vt th_in])
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2277
  moreover have "?r \<le> cp s th" (is "Max (?f ` ?A) \<le> cp s th")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2278
  proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2279
    have "?r \<in> (?f ` ?A)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2280
    proof(rule Max_in)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2281
      from finite_threads[OF vt]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2282
      show " finite ((\<lambda>th. preced th s) ` threads s)" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2283
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2284
      from False show " (\<lambda>th. preced th s) ` threads s \<noteq> {}" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2285
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2286
    then obtain th' where 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2287
      th_in': "th' \<in> ?A " and eq_r: "?r = ?f th'" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2288
    from le_cp [OF vt, of th']  eq_r
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2289
    have "?r \<le> cp s th'" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2290
    moreover have "\<dots> \<le> cp s th"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2291
    proof(fold eq_l)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2292
      show " cp s th' \<le> Max (cp s ` threads s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2293
      proof(rule Max_ge)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2294
        from th_in' show "cp s th' \<in> cp s ` threads s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2295
          by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2296
      next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2297
        from finite_threads[OF vt]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2298
        show "finite (cp s ` threads s)" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2299
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2300
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2301
    ultimately show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2302
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2303
  ultimately show ?thesis using eq_l by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2304
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2305
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2306
lemma max_cp_readys_threads_pre:
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  2307
  assumes vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2308
  and np: "threads s \<noteq> {}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2309
  shows "Max (cp s ` readys s) = Max (cp s ` threads s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2310
proof(unfold max_cp_eq[OF vt])
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2311
  show "Max (cp s ` readys s) = Max ((\<lambda>th. preced th s) ` threads s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2312
  proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2313
    let ?p = "Max ((\<lambda>th. preced th s) ` threads s)" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2314
    let ?f = "(\<lambda>th. preced th s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2315
    have "?p \<in> ((\<lambda>th. preced th s) ` threads s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2316
    proof(rule Max_in)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2317
      from finite_threads[OF vt] show "finite (?f ` threads s)" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2318
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2319
      from np show "?f ` threads s \<noteq> {}" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2320
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2321
    then obtain tm where tm_max: "?f tm = ?p" and tm_in: "tm \<in> threads s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2322
      by (auto simp:Image_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2323
    from th_chain_to_ready [OF vt tm_in]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2324
    have "tm \<in> readys s \<or> (\<exists>th'. th' \<in> readys s \<and> (Th tm, Th th') \<in> (depend s)\<^sup>+)" .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2325
    thus ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2326
    proof
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2327
      assume "\<exists>th'. th' \<in> readys s \<and> (Th tm, Th th') \<in> (depend s)\<^sup>+ "
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2328
      then obtain th' where th'_in: "th' \<in> readys s" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2329
        and tm_chain:"(Th tm, Th th') \<in> (depend s)\<^sup>+" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2330
      have "cp s th' = ?f tm"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2331
      proof(subst cp_eq_cpreced, subst cpreced_def, rule Max_eqI)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2332
        from dependents_threads[OF vt] finite_threads[OF vt]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2333
        show "finite ((\<lambda>th. preced th s) ` ({th'} \<union> dependents (wq s) th'))" 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2334
          by (auto intro:finite_subset)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2335
      next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2336
        fix p assume p_in: "p \<in> (\<lambda>th. preced th s) ` ({th'} \<union> dependents (wq s) th')"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2337
        from tm_max have " preced tm s = Max ((\<lambda>th. preced th s) ` threads s)" .
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2338
        moreover have "p \<le> \<dots>"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2339
        proof(rule Max_ge)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2340
          from finite_threads[OF vt]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2341
          show "finite ((\<lambda>th. preced th s) ` threads s)" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2342
        next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2343
          from p_in and th'_in and dependents_threads[OF vt, of th']
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2344
          show "p \<in> (\<lambda>th. preced th s) ` threads s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2345
            by (auto simp:readys_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2346
        qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2347
        ultimately show "p \<le> preced tm s" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2348
      next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2349
        show "preced tm s \<in> (\<lambda>th. preced th s) ` ({th'} \<union> dependents (wq s) th')"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2350
        proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2351
          from tm_chain
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2352
          have "tm \<in> dependents (wq s) th'"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2353
            by (unfold cs_dependents_def s_depend_def cs_depend_def, auto)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2354
          thus ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2355
        qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2356
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2357
      with tm_max
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2358
      have h: "cp s th' = Max ((\<lambda>th. preced th s) ` threads s)" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2359
      show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2360
      proof (fold h, rule Max_eqI)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2361
        fix q 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2362
        assume "q \<in> cp s ` readys s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2363
        then obtain th1 where th1_in: "th1 \<in> readys s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2364
          and eq_q: "q = cp s th1" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2365
        show "q \<le> cp s th'"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2366
          apply (unfold h eq_q)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2367
          apply (unfold cp_eq_cpreced cpreced_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2368
          apply (rule Max_mono)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2369
        proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2370
          from dependents_threads [OF vt, of th1] th1_in
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2371
          show "(\<lambda>th. preced th s) ` ({th1} \<union> dependents (wq s) th1) \<subseteq> 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2372
                 (\<lambda>th. preced th s) ` threads s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2373
            by (auto simp:readys_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2374
        next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2375
          show "(\<lambda>th. preced th s) ` ({th1} \<union> dependents (wq s) th1) \<noteq> {}" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2376
        next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2377
          from finite_threads[OF vt] 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2378
          show " finite ((\<lambda>th. preced th s) ` threads s)" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2379
        qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2380
      next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2381
        from finite_threads[OF vt]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2382
        show "finite (cp s ` readys s)" by (auto simp:readys_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2383
      next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2384
        from th'_in
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2385
        show "cp s th' \<in> cp s ` readys s" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2386
      qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2387
    next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2388
      assume tm_ready: "tm \<in> readys s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2389
      show ?thesis
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2390
      proof(fold tm_max)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2391
        have cp_eq_p: "cp s tm = preced tm s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2392
        proof(unfold cp_eq_cpreced cpreced_def, rule Max_eqI)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2393
          fix y 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2394
          assume hy: "y \<in> (\<lambda>th. preced th s) ` ({tm} \<union> dependents (wq s) tm)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2395
          show "y \<le> preced tm s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2396
          proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2397
            { fix y'
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2398
              assume hy' : "y' \<in> ((\<lambda>th. preced th s) ` dependents (wq s) tm)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2399
              have "y' \<le> preced tm s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2400
              proof(unfold tm_max, rule Max_ge)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2401
                from hy' dependents_threads[OF vt, of tm]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2402
                show "y' \<in> (\<lambda>th. preced th s) ` threads s" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2403
              next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2404
                from finite_threads[OF vt] 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2405
                show "finite ((\<lambda>th. preced th s) ` threads s)" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2406
              qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2407
            } with hy show ?thesis by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2408
          qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2409
        next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2410
          from dependents_threads[OF vt, of tm] finite_threads[OF vt]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2411
          show "finite ((\<lambda>th. preced th s) ` ({tm} \<union> dependents (wq s) tm))"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2412
            by (auto intro:finite_subset)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2413
        next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2414
          show "preced tm s \<in> (\<lambda>th. preced th s) ` ({tm} \<union> dependents (wq s) tm)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2415
            by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2416
        qed 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2417
        moreover have "Max (cp s ` readys s) = cp s tm"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2418
        proof(rule Max_eqI)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2419
          from tm_ready show "cp s tm \<in> cp s ` readys s" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2420
        next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2421
          from finite_threads[OF vt]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2422
          show "finite (cp s ` readys s)" by (auto simp:readys_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2423
        next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2424
          fix y assume "y \<in> cp s ` readys s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2425
          then obtain th1 where th1_readys: "th1 \<in> readys s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2426
            and h: "y = cp s th1" by auto
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2427
          show "y \<le> cp s tm"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2428
            apply(unfold cp_eq_p h)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2429
            apply(unfold cp_eq_cpreced cpreced_def tm_max, rule Max_mono)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2430
          proof -
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2431
            from finite_threads[OF vt]
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2432
            show "finite ((\<lambda>th. preced th s) ` threads s)" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2433
          next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2434
            show "(\<lambda>th. preced th s) ` ({th1} \<union> dependents (wq s) th1) \<noteq> {}"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2435
              by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2436
          next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2437
            from dependents_threads[OF vt, of th1] th1_readys
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2438
            show "(\<lambda>th. preced th s) ` ({th1} \<union> dependents (wq s) th1) 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2439
                    \<subseteq> (\<lambda>th. preced th s) ` threads s"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2440
              by (auto simp:readys_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2441
          qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2442
        qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2443
        ultimately show " Max (cp s ` readys s) = preced tm s" by simp
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2444
      qed 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2445
    qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2446
  qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2447
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2448
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2449
lemma max_cp_readys_threads:
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  2450
  assumes vt: "vt s"
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2451
  shows "Max (cp s ` readys s) = Max (cp s ` threads s)"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2452
proof(cases "threads s = {}")
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2453
  case True
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2454
  thus ?thesis 
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2455
    by (auto simp:readys_def)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2456
next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2457
  case False
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2458
  show ?thesis by (rule max_cp_readys_threads_pre[OF vt False])
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2459
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2460
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2461
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2462
lemma eq_holding: "holding (wq s) th cs = holding s th cs"
298
f2e0d031a395 completed model section; vt has only state as argument
urbanc
parents: 294
diff changeset
  2463
  apply (unfold s_holding_def cs_holding_def wq_def, simp)
262
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2464
  done
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2465
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2466
lemma f_image_eq:
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2467
  assumes h: "\<And> a. a \<in> A \<Longrightarrow> f a = g a"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2468
  shows "f ` A = g ` A"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2469
proof
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2470
  show "f ` A \<subseteq> g ` A"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2471
    by(rule image_subsetI, auto intro:h)
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2472
next
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2473
  show "g ` A \<subseteq> f ` A"
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2474
   by(rule image_subsetI, auto intro:h[symmetric])
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2475
qed
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2476
4190df6f4488 initial version of the PIP formalisation
urbanc
parents:
diff changeset
  2477
end