src/HOL/Hoare_Parallel/Graph.thy
author wenzelm
Sun, 11 Feb 2018 12:51:23 +0100
changeset 67593 5efb88c90051
parent 67443 3abf6a722518
child 72233 c17d0227205c
permissions -rw-r--r--
clarified command-line defaults;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
59189
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
     1
chapter \<open>Case Study: Single and Multi-Mutator Garbage Collection Algorithms\<close>
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
     2
59189
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
     3
section \<open>Formalization of the Memory\<close>
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
     4
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 13601
diff changeset
     5
theory Graph imports Main begin
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
     6
58310
91ea607a34d8 updated news
blanchet
parents: 58249
diff changeset
     7
datatype node = Black | White
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
     8
42174
d0be2722ce9f modernized specifications;
wenzelm
parents: 41842
diff changeset
     9
type_synonym nodes = "node list"
d0be2722ce9f modernized specifications;
wenzelm
parents: 41842
diff changeset
    10
type_synonym edge = "nat \<times> nat"
d0be2722ce9f modernized specifications;
wenzelm
parents: 41842
diff changeset
    11
type_synonym edges = "edge list"
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    12
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    13
consts Roots :: "nat set"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    14
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 32960
diff changeset
    15
definition Proper_Roots :: "nodes \<Rightarrow> bool" where
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    16
  "Proper_Roots M \<equiv> Roots\<noteq>{} \<and> Roots \<subseteq> {i. i<length M}"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    17
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 32960
diff changeset
    18
definition Proper_Edges :: "(nodes \<times> edges) \<Rightarrow> bool" where
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    19
  "Proper_Edges \<equiv> (\<lambda>(M,E). \<forall>i<length E. fst(E!i)<length M \<and> snd(E!i)<length M)"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    20
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 32960
diff changeset
    21
definition BtoW :: "(edge \<times> nodes) \<Rightarrow> bool" where
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    22
  "BtoW \<equiv> (\<lambda>(e,M). (M!fst e)=Black \<and> (M!snd e)\<noteq>Black)"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    23
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 32960
diff changeset
    24
definition Blacks :: "nodes \<Rightarrow> nat set" where
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    25
  "Blacks M \<equiv> {i. i<length M \<and> M!i=Black}"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    26
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 32960
diff changeset
    27
definition Reach :: "edges \<Rightarrow> nat set" where
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    28
  "Reach E \<equiv> {x. (\<exists>path. 1<length path \<and> path!(length path - 1)\<in>Roots \<and> x=path!0
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    29
              \<and> (\<forall>i<length path - 1. (\<exists>j<length E. E!j=(path!(i+1), path!i))))
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32642
diff changeset
    30
              \<or> x\<in>Roots}"
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    31
59189
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
    32
text\<open>Reach: the set of reachable nodes is the set of Roots together with the
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    33
nodes reachable from some Root by a path represented by a list of
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    34
  nodes (at least two since we traverse at least one edge), where two
59189
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
    35
consecutive nodes correspond to an edge in E.\<close>
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    36
59189
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
    37
subsection \<open>Proofs about Graphs\<close>
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    38
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    39
lemmas Graph_defs= Blacks_def Proper_Roots_def Proper_Edges_def BtoW_def
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    40
declare Graph_defs [simp]
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    41
59189
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
    42
subsubsection\<open>Graph 1\<close>
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    43
59189
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
    44
lemma Graph1_aux [rule_format]:
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    45
  "\<lbrakk> Roots\<subseteq>Blacks M; \<forall>i<length E. \<not>BtoW(E!i,M)\<rbrakk>
59189
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
    46
  \<Longrightarrow> 1< length path \<longrightarrow> (path!(length path - 1))\<in>Roots \<longrightarrow>
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
    47
  (\<forall>i<length path - 1. (\<exists>j. j < length E \<and> E!j=(path!(Suc i), path!i)))
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    48
  \<longrightarrow> M!(path!0) = Black"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    49
apply(induct_tac "path")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    50
 apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    51
apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    52
apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    53
apply(case_tac "list")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    54
 apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    55
apply simp
55417
01fbfb60c33e adapted to 'xxx_{case,rec}' renaming, to new theorem names, and to new variable names in theorems
blanchet
parents: 54863
diff changeset
    56
apply(rename_tac lista)
13601
fd3e3d6b37b2 Adapted to new simplifier.
berghofe
parents: 13022
diff changeset
    57
apply(rotate_tac -2)
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    58
apply(erule_tac x = "0" in all_dupE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    59
apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    60
apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    61
apply(erule allE , erule (1) notE impE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    62
apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    63
apply(erule mp)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    64
apply(case_tac "lista")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    65
 apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    66
apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    67
apply(erule mp)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    68
apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    69
apply(erule_tac x = "Suc i" in allE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    70
apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    71
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    72
59189
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
    73
lemma Graph1:
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
    74
  "\<lbrakk>Roots\<subseteq>Blacks M; Proper_Edges(M, E); \<forall>i<length E. \<not>BtoW(E!i,M) \<rbrakk>
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    75
  \<Longrightarrow> Reach E\<subseteq>Blacks M"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    76
apply (unfold Reach_def)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    77
apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    78
apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    79
apply(erule disjE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    80
 apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    81
 apply(rule conjI)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    82
  apply(subgoal_tac "0< length path - Suc 0")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    83
   apply(erule allE , erule (1) notE impE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    84
   apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    85
  apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    86
 apply(rule Graph1_aux)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    87
apply auto
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    88
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    89
59189
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
    90
subsubsection\<open>Graph 2\<close>
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    91
59189
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
    92
lemma Ex_first_occurrence [rule_format]:
58860
fee7cfa69c50 eliminated spurious semicolons;
wenzelm
parents: 58310
diff changeset
    93
  "P (n::nat) \<longrightarrow> (\<exists>m. P m \<and> (\<forall>i. i<m \<longrightarrow> \<not> P i))"
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    94
apply(rule nat_less_induct)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    95
apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    96
apply(case_tac "\<forall>m. m<n \<longrightarrow> \<not> P m")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    97
apply auto
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    98
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
    99
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   100
lemma Compl_lemma: "(n::nat)\<le>l \<Longrightarrow> (\<exists>m. m\<le>l \<and> n=l - m)"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   101
apply(rule_tac x = "l - n" in exI)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   102
apply arith
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   103
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   104
59189
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
   105
lemma Ex_last_occurrence:
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   106
  "\<lbrakk>P (n::nat); n\<le>l\<rbrakk> \<Longrightarrow> (\<exists>m. P (l - m) \<and> (\<forall>i. i<m \<longrightarrow> \<not>P (l - i)))"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   107
apply(drule Compl_lemma)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   108
apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   109
apply(erule Ex_first_occurrence)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   110
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   111
59189
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
   112
lemma Graph2:
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   113
  "\<lbrakk>T \<in> Reach E; R<length E\<rbrakk> \<Longrightarrow> T \<in> Reach (E[R:=(fst(E!R), T)])"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   114
apply (unfold Reach_def)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   115
apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   116
apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   117
apply(case_tac "\<forall>z<length path. fst(E!R)\<noteq>path!z")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   118
 apply(rule_tac x = "path" in exI)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   119
 apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   120
 apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   121
 apply(erule allE , erule (1) notE impE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   122
 apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   123
 apply(rule_tac x = "j" in exI)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   124
 apply(case_tac "j=R")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   125
  apply(erule_tac x = "Suc i" in allE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   126
  apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   127
 apply (force simp add:nth_list_update)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   128
apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   129
apply(erule exE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   130
apply(subgoal_tac "z \<le> length path - Suc 0")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   131
 prefer 2 apply arith
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   132
apply(drule_tac P = "\<lambda>m. m<length path \<and> fst(E!R)=path!m" in Ex_last_occurrence)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   133
 apply assumption
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   134
apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   135
apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   136
apply(rule_tac x = "(path!0)#(drop (length path - Suc m) path)" in exI)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   137
apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   138
apply(case_tac "length path - (length path - Suc m)")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   139
 apply arith
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   140
apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   141
apply(subgoal_tac "(length path - Suc m) + nat \<le> length path")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   142
 prefer 2 apply arith
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   143
apply(subgoal_tac "length path - Suc m + nat = length path - Suc 0")
59189
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
   144
 prefer 2 apply arith
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   145
apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   146
apply(case_tac "i")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   147
 apply(force simp add: nth_list_update)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   148
apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   149
apply(subgoal_tac "(length path - Suc m) + nata \<le> length path")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   150
 prefer 2 apply arith
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   151
apply(subgoal_tac "(length path - Suc m) + (Suc nata) \<le> length path")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   152
 prefer 2 apply arith
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   153
apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   154
apply(erule_tac x = "length path - Suc m + nata" in allE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   155
apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   156
apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   157
apply(rule_tac x = "j" in exI)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   158
apply(case_tac "R=j")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   159
 prefer 2 apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   160
apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   161
apply(drule_tac t = "path ! (length path - Suc m)" in sym)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   162
apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   163
apply(case_tac " length path - Suc 0 < m")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   164
 apply(subgoal_tac "(length path - Suc m)=0")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   165
  prefer 2 apply arith
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   166
 apply(simp del: diff_is_0_eq)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   167
 apply(subgoal_tac "Suc nata\<le>nat")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   168
 prefer 2 apply arith
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   169
 apply(drule_tac n = "Suc nata" in Compl_lemma)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   170
 apply clarify
31082
54a442b2d727 interface changes in linarith.ML
haftmann
parents: 26316
diff changeset
   171
 using [[linarith_split_limit = 0]]
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   172
 apply force
31082
54a442b2d727 interface changes in linarith.ML
haftmann
parents: 26316
diff changeset
   173
 using [[linarith_split_limit = 9]]
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   174
apply(drule leI)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   175
apply(subgoal_tac "Suc (length path - Suc m + nata)=(length path - Suc 0) - (m - Suc nata)")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   176
 apply(erule_tac x = "m - (Suc nata)" in allE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   177
 apply(case_tac "m")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   178
  apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   179
 apply simp
13601
fd3e3d6b37b2 Adapted to new simplifier.
berghofe
parents: 13022
diff changeset
   180
apply simp
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   181
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   182
20432
07ec57376051 lin_arith_prover: splitting reverted because of performance loss
webertj
parents: 20279
diff changeset
   183
59189
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
   184
subsubsection\<open>Graph 3\<close>
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   185
54863
82acc20ded73 prefer more canonical names for lemmas on min/max
haftmann
parents: 42174
diff changeset
   186
declare min.absorb1 [simp] min.absorb2 [simp]
32642
026e7c6a6d08 be more cautious wrt. simp rules: inf_absorb1, inf_absorb2, sup_absorb1, sup_absorb2 are no simp rules by default any longer
haftmann
parents: 32621
diff changeset
   187
59189
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
   188
lemma Graph3:
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   189
  "\<lbrakk> T\<in>Reach E; R<length E \<rbrakk> \<Longrightarrow> Reach(E[R:=(fst(E!R),T)]) \<subseteq> Reach E"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   190
apply (unfold Reach_def)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   191
apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   192
apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   193
apply(case_tac "\<exists>i<length path - 1. (fst(E!R),T)=(path!(Suc i),path!i)")
67443
3abf6a722518 standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents: 62042
diff changeset
   194
\<comment> \<open>the changed edge is part of the path\<close>
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   195
 apply(erule exE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   196
 apply(drule_tac P = "\<lambda>i. i<length path - 1 \<and> (fst(E!R),T)=(path!Suc i,path!i)" in Ex_first_occurrence)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   197
 apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   198
 apply(erule disjE)
67443
3abf6a722518 standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents: 62042
diff changeset
   199
\<comment> \<open>T is NOT a root\<close>
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   200
  apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   201
  apply(rule_tac x = "(take m path)@patha" in exI)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   202
  apply(subgoal_tac "\<not>(length path\<le>m)")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   203
   prefer 2 apply arith
32442
87d98857d154 tuned proofs
nipkow
parents: 31082
diff changeset
   204
  apply(simp)
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   205
  apply(rule conjI)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   206
   apply(subgoal_tac "\<not>(m + length patha - 1 < m)")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   207
    prefer 2 apply arith
32442
87d98857d154 tuned proofs
nipkow
parents: 31082
diff changeset
   208
   apply(simp add: nth_append)
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   209
  apply(rule conjI)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   210
   apply(case_tac "m")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   211
    apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   212
   apply(case_tac "path")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   213
    apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   214
   apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   215
  apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   216
  apply(case_tac "Suc i\<le>m")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   217
   apply(erule_tac x = "i" in allE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   218
   apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   219
   apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   220
   apply(rule_tac x = "j" in exI)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   221
   apply(case_tac "Suc i<m")
22230
bdec4a82f385 a few additions and deletions
nipkow
parents: 20432
diff changeset
   222
    apply(simp add: nth_append)
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   223
    apply(case_tac "R=j")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   224
     apply(simp add: nth_list_update)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   225
     apply(case_tac "i=m")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   226
      apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   227
     apply(erule_tac x = "i" in allE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   228
     apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   229
    apply(force simp add: nth_list_update)
22230
bdec4a82f385 a few additions and deletions
nipkow
parents: 20432
diff changeset
   230
   apply(simp add: nth_append)
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   231
   apply(subgoal_tac "i=m - 1")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   232
    prefer 2 apply arith
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   233
   apply(case_tac "R=j")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   234
    apply(erule_tac x = "m - 1" in allE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   235
    apply(simp add: nth_list_update)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   236
   apply(force simp add: nth_list_update)
32442
87d98857d154 tuned proofs
nipkow
parents: 31082
diff changeset
   237
  apply(simp add: nth_append)
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   238
  apply(rotate_tac -4)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   239
  apply(erule_tac x = "i - m" in allE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   240
  apply(subgoal_tac "Suc (i - m)=(Suc i - m)" )
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   241
    prefer 2 apply arith
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   242
   apply simp
67443
3abf6a722518 standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents: 62042
diff changeset
   243
\<comment> \<open>T is a root\<close>
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   244
 apply(case_tac "m=0")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   245
  apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   246
 apply(rule_tac x = "take (Suc m) path" in exI)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   247
 apply(subgoal_tac "\<not>(length path\<le>Suc m)" )
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   248
  prefer 2 apply arith
32442
87d98857d154 tuned proofs
nipkow
parents: 31082
diff changeset
   249
 apply clarsimp
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   250
 apply(erule_tac x = "i" in allE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   251
 apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   252
 apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   253
 apply(case_tac "R=j")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   254
  apply(force simp add: nth_list_update)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   255
 apply(force simp add: nth_list_update)
67443
3abf6a722518 standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents: 62042
diff changeset
   256
\<comment> \<open>the changed edge is not part of the path\<close>
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   257
apply(rule_tac x = "path" in exI)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   258
apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   259
apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   260
apply(erule_tac x = "i" in allE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   261
apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   262
apply(case_tac "R=j")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   263
 apply(erule_tac x = "i" in allE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   264
 apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   265
apply(force simp add: nth_list_update)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   266
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   267
59189
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
   268
subsubsection\<open>Graph 4\<close>
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   269
59189
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
   270
lemma Graph4:
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
   271
  "\<lbrakk>T \<in> Reach E; Roots\<subseteq>Blacks M; I\<le>length E; T<length M; R<length E;
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
   272
  \<forall>i<I. \<not>BtoW(E!i,M); R<I; M!fst(E!R)=Black; M!T\<noteq>Black\<rbrakk> \<Longrightarrow>
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   273
  (\<exists>r. I\<le>r \<and> r<length E \<and> BtoW(E[R:=(fst(E!R),T)]!r,M))"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   274
apply (unfold Reach_def)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   275
apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   276
apply(erule disjE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   277
 prefer 2 apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   278
apply clarify
67443
3abf6a722518 standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents: 62042
diff changeset
   279
\<comment> \<open>there exist a black node in the path to T\<close>
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   280
apply(case_tac "\<exists>m<length path. M!(path!m)=Black")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   281
 apply(erule exE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   282
 apply(drule_tac P = "\<lambda>m. m<length path \<and> M!(path!m)=Black" in Ex_first_occurrence)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   283
 apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   284
 apply(case_tac "ma")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   285
  apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   286
 apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   287
 apply(case_tac "length path")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   288
  apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   289
 apply simp
59807
22bc39064290 prefer local fixes;
wenzelm
parents: 59189
diff changeset
   290
 apply(erule_tac P = "\<lambda>i. i < nata \<longrightarrow> P i" and x = "nat" for P in allE)
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   291
 apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   292
 apply clarify
59807
22bc39064290 prefer local fixes;
wenzelm
parents: 59189
diff changeset
   293
 apply(erule_tac P = "\<lambda>i. i < Suc nat \<longrightarrow> P i" and x = "nat" for P in allE)
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   294
 apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   295
 apply(case_tac "j<I")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   296
  apply(erule_tac x = "j" in allE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   297
  apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   298
 apply(rule_tac x = "j" in exI)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   299
 apply(force  simp add: nth_list_update)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   300
apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   301
apply(rotate_tac -1)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   302
apply(erule_tac x = "length path - 1" in allE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   303
apply(case_tac "length path")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   304
 apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   305
apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   306
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   307
54863
82acc20ded73 prefer more canonical names for lemmas on min/max
haftmann
parents: 42174
diff changeset
   308
declare min.absorb1 [simp del] min.absorb2 [simp del]
32642
026e7c6a6d08 be more cautious wrt. simp rules: inf_absorb1, inf_absorb2, sup_absorb1, sup_absorb2 are no simp rules by default any longer
haftmann
parents: 32621
diff changeset
   309
59189
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
   310
subsubsection \<open>Graph 5\<close>
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   311
59189
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
   312
lemma Graph5:
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
   313
  "\<lbrakk> T \<in> Reach E ; Roots \<subseteq> Blacks M; \<forall>i<R. \<not>BtoW(E!i,M); T<length M;
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
   314
    R<length E; M!fst(E!R)=Black; M!snd(E!R)=Black; M!T \<noteq> Black\<rbrakk>
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   315
   \<Longrightarrow> (\<exists>r. R<r \<and> r<length E \<and> BtoW(E[R:=(fst(E!R),T)]!r,M))"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   316
apply (unfold Reach_def)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   317
apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   318
apply(erule disjE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   319
 prefer 2 apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   320
apply clarify
67443
3abf6a722518 standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents: 62042
diff changeset
   321
\<comment> \<open>there exist a black node in the path to T\<close>
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   322
apply(case_tac "\<exists>m<length path. M!(path!m)=Black")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   323
 apply(erule exE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   324
 apply(drule_tac P = "\<lambda>m. m<length path \<and> M!(path!m)=Black" in Ex_first_occurrence)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   325
 apply clarify
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   326
 apply(case_tac "ma")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   327
  apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   328
 apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   329
 apply(case_tac "length path")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   330
  apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   331
 apply simp
59807
22bc39064290 prefer local fixes;
wenzelm
parents: 59189
diff changeset
   332
 apply(erule_tac P = "\<lambda>i. i < nata \<longrightarrow> P i" and x = "nat" for P in allE)
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   333
 apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   334
 apply clarify
59807
22bc39064290 prefer local fixes;
wenzelm
parents: 59189
diff changeset
   335
 apply(erule_tac P = "\<lambda>i. i < Suc nat \<longrightarrow> P i" and x = "nat" for P in allE)
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   336
 apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   337
 apply(case_tac "j\<le>R")
26316
9e9e67e33557 removed redundant less_trans, less_linear, le_imp_less_or_eq, le_less_trans, less_le_trans (cf. Orderings.thy);
wenzelm
parents: 24742
diff changeset
   338
  apply(drule le_imp_less_or_eq [of _ R])
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   339
  apply(erule disjE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   340
   apply(erule allE , erule (1) notE impE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   341
   apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   342
  apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   343
 apply(rule_tac x = "j" in exI)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   344
 apply(force  simp add: nth_list_update)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   345
apply simp
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   346
apply(rotate_tac -1)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   347
apply(erule_tac x = "length path - 1" in allE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   348
apply(case_tac "length path")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   349
 apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   350
apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   351
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   352
59189
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
   353
subsubsection \<open>Other lemmas about graphs\<close>
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   354
59189
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
   355
lemma Graph6:
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   356
 "\<lbrakk>Proper_Edges(M,E); R<length E ; T<length M\<rbrakk> \<Longrightarrow> Proper_Edges(M,E[R:=(fst(E!R),T)])"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   357
apply (unfold Proper_Edges_def)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   358
 apply(force  simp add: nth_list_update)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   359
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   360
59189
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
   361
lemma Graph7:
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   362
 "\<lbrakk>Proper_Edges(M,E)\<rbrakk> \<Longrightarrow> Proper_Edges(M[T:=a],E)"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   363
apply (unfold Proper_Edges_def)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   364
apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   365
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   366
59189
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
   367
lemma Graph8:
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   368
 "\<lbrakk>Proper_Roots(M)\<rbrakk> \<Longrightarrow> Proper_Roots(M[T:=a])"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   369
apply (unfold Proper_Roots_def)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   370
apply force
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   371
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   372
59189
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
   373
text\<open>Some specific lemmata for the verification of garbage collection algorithms.\<close>
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   374
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   375
lemma Graph9: "j<length M \<Longrightarrow> Blacks M\<subseteq>Blacks (M[j := Black])"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   376
apply (unfold Blacks_def)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   377
 apply(force simp add: nth_list_update)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   378
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   379
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   380
lemma Graph10 [rule_format (no_asm)]: "\<forall>i. M!i=a \<longrightarrow>M[i:=a]=M"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   381
apply(induct_tac "M")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   382
apply auto
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   383
apply(case_tac "i")
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   384
apply auto
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   385
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   386
59189
ad8e0a789af6 update_cartouches;
wenzelm
parents: 58884
diff changeset
   387
lemma Graph11 [rule_format (no_asm)]:
13020
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   388
  "\<lbrakk> M!j\<noteq>Black;j<length M\<rbrakk> \<Longrightarrow> Blacks M \<subset> Blacks (M[j := Black])"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   389
apply (unfold Blacks_def)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   390
apply(rule psubsetI)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   391
 apply(force simp add: nth_list_update)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   392
apply safe
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   393
apply(erule_tac c = "j" in equalityCE)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   394
apply auto
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   395
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   396
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   397
lemma Graph12: "\<lbrakk>a\<subseteq>Blacks M;j<length M\<rbrakk> \<Longrightarrow> a\<subseteq>Blacks (M[j := Black])"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   398
apply (unfold Blacks_def)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   399
apply(force simp add: nth_list_update)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   400
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   401
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   402
lemma Graph13: "\<lbrakk>a\<subset> Blacks M;j<length M\<rbrakk> \<Longrightarrow> a \<subset> Blacks (M[j := Black])"
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   403
apply (unfold Blacks_def)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   404
apply(erule psubset_subset_trans)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   405
apply(force simp add: nth_list_update)
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   406
done
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   407
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   408
declare Graph_defs [simp del]
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   409
791e3b4c4039 HoareParallel Theories
prensani
parents:
diff changeset
   410
end