src/HOL/Hoare/SchorrWaite.thy
author nipkow
Sun, 23 Mar 2003 11:57:07 +0100
changeset 13875 12997e3ddd8d
parent 13820 87a8ab465b29
child 16417 9bc16273c2d4
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13820
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
     1
(*  Title:      HOL/Hoare/SchorrWaite.thy
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
     2
    ID:         $Id$
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
     3
    Author:     Farhad Mehta
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
     4
    Copyright   2003 TUM
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
     5
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
     6
Proof of the Schorr-Waite graph marking algorithm.
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
     7
*)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
     8
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
     9
13875
12997e3ddd8d *** empty log message ***
nipkow
parents: 13820
diff changeset
    10
theory SchorrWaite = HeapSyntax:
13820
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    11
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    12
section {* Machinery for the Schorr-Waite proof*}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    13
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    14
constdefs
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    15
  -- "Relations induced by a mapping"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    16
  rel :: "('a \<Rightarrow> 'a ref) \<Rightarrow> ('a \<times> 'a) set"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    17
  "rel m == {(x,y). m x = Ref y}"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    18
  relS :: "('a \<Rightarrow> 'a ref) set \<Rightarrow> ('a \<times> 'a) set"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    19
  "relS M == (\<Union> m \<in> M. rel m)"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    20
  addrs :: "'a ref set \<Rightarrow> 'a set"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    21
  "addrs P == {a. Ref a \<in> P}"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    22
  reachable :: "('a \<times> 'a) set \<Rightarrow> 'a ref set \<Rightarrow> 'a set"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    23
  "reachable r P == (r\<^sup>* `` addrs P)"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    24
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    25
lemmas rel_defs = relS_def rel_def
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    26
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    27
text {* Rewrite rules for relations induced by a mapping*}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    28
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    29
lemma self_reachable: "b \<in> B \<Longrightarrow> b \<in> R\<^sup>* `` B"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    30
apply blast
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    31
done
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    32
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    33
lemma oneStep_reachable: "b \<in> R``B \<Longrightarrow> b \<in> R\<^sup>* `` B"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    34
apply blast
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    35
done
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    36
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    37
lemma still_reachable: "\<lbrakk>B\<subseteq>Ra\<^sup>*``A; \<forall> (x,y) \<in> Rb-Ra. y\<in> (Ra\<^sup>*``A)\<rbrakk> \<Longrightarrow> Rb\<^sup>* `` B \<subseteq> Ra\<^sup>* `` A "
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    38
apply (clarsimp simp only:Image_iff intro:subsetI)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    39
apply (erule rtrancl_induct)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    40
 apply blast
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    41
apply (subgoal_tac "(y, z) \<in> Ra\<union>(Rb-Ra)")
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    42
 apply (erule UnE)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    43
 apply (auto intro:rtrancl_into_rtrancl)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    44
apply blast
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    45
done
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    46
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    47
lemma still_reachable_eq: "\<lbrakk> A\<subseteq>Rb\<^sup>*``B; B\<subseteq>Ra\<^sup>*``A; \<forall> (x,y) \<in> Ra-Rb. y \<in>(Rb\<^sup>*``B); \<forall> (x,y) \<in> Rb-Ra. y\<in> (Ra\<^sup>*``A)\<rbrakk> \<Longrightarrow> Ra\<^sup>*``A =  Rb\<^sup>*``B "
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    48
apply (rule equalityI)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    49
 apply (erule still_reachable ,assumption)+
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    50
done
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    51
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    52
lemma reachable_null: "reachable mS {Null} = {}"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    53
apply (simp add: reachable_def addrs_def)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    54
done
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    55
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    56
lemma reachable_empty: "reachable mS {} = {}"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    57
apply (simp add: reachable_def addrs_def)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    58
done
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    59
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    60
lemma reachable_union: "(reachable mS aS \<union> reachable mS bS) = reachable mS (aS \<union> bS)"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    61
apply (simp add: reachable_def rel_defs addrs_def)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    62
apply blast
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    63
done
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    64
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    65
lemma reachable_union_sym: "reachable r (insert a aS) = (r\<^sup>* `` addrs {a}) \<union> reachable r aS"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    66
apply (simp add: reachable_def rel_defs addrs_def)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    67
apply blast
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    68
done
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    69
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    70
lemma rel_upd1: "(a,b) \<notin> rel (r(q:=t)) \<Longrightarrow> (a,b) \<in> rel r \<Longrightarrow> a=q"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    71
apply (rule classical)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    72
apply (simp add:rel_defs fun_upd_apply)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    73
done
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    74
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    75
lemma rel_upd2: "(a,b)  \<notin> rel r \<Longrightarrow> (a,b) \<in> rel (r(q:=t)) \<Longrightarrow> a=q"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    76
apply (rule classical)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    77
apply (simp add:rel_defs fun_upd_apply)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    78
done
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    79
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    80
constdefs
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    81
  -- "Restriction of a relation"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    82
  restr ::"('a \<times> 'a) set \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> ('a \<times> 'a) set"       ("(_/ | _)" [50, 51] 50)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    83
  "restr r m == {(x,y). (x,y) \<in> r \<and> \<not> m x}"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    84
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    85
text {* Rewrite rules for the restriction of a relation *}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    86
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    87
lemma restr_identity[simp]:
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    88
 " (\<forall>x. \<not> m x) \<Longrightarrow> (R |m) = R"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    89
by (auto simp add:restr_def)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    90
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    91
lemma restr_rtrancl[simp]: " \<lbrakk>m l\<rbrakk> \<Longrightarrow> (R | m)\<^sup>* `` {l} = {l}"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    92
by (auto simp add:restr_def elim:converse_rtranclE)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    93
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    94
lemma [simp]: " \<lbrakk>m l\<rbrakk> \<Longrightarrow> (l,x) \<in> (R | m)\<^sup>* = (l=x)"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    95
by (auto simp add:restr_def elim:converse_rtranclE)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    96
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    97
lemma restr_upd: "((rel (r (q := t)))|(m(q := True))) = ((rel (r))|(m(q := True))) "
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    98
apply (auto simp:restr_def rel_def fun_upd_apply)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
    99
apply (rename_tac a b)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   100
apply (case_tac "a=q")
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   101
 apply auto
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   102
done
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   103
	      
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   104
lemma restr_un: "((r \<union> s)|m) = (r|m) \<union> (s|m)"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   105
  by (auto simp add:restr_def)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   106
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   107
lemma rel_upd3: "(a, b) \<notin> (r|(m(q := t))) \<Longrightarrow> (a,b) \<in> (r|m) \<Longrightarrow> a = q "
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   108
apply (rule classical)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   109
apply (simp add:restr_def fun_upd_apply)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   110
done	
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   111
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   112
constdefs
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   113
  -- "A short form for the stack mapping function for List"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   114
  S :: "('a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> 'a ref) \<Rightarrow> ('a \<Rightarrow> 'a ref) \<Rightarrow> ('a \<Rightarrow> 'a ref)"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   115
  "S c l r == (\<lambda>x. if c x then r x else l x)"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   116
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   117
text {* Rewrite rules for Lists using S as their mapping *}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   118
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   119
lemma [rule_format,simp]:
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   120
 "\<forall>p. a \<notin> set stack \<longrightarrow> List (S c l r) p stack = List (S (c(a:=x)) (l(a:=y)) (r(a:=z))) p stack"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   121
apply(induct_tac stack)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   122
 apply(simp add:fun_upd_apply S_def)+
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   123
done
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   124
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   125
lemma [rule_format,simp]:
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   126
 "\<forall>p. a \<notin> set stack \<longrightarrow> List (S c l (r(a:=z))) p stack = List (S c l r) p stack"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   127
apply(induct_tac stack)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   128
 apply(simp add:fun_upd_apply S_def)+
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   129
done
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   130
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   131
lemma [rule_format,simp]:
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   132
 "\<forall>p. a \<notin> set stack \<longrightarrow> List (S c (l(a:=z)) r) p stack = List (S c l r) p stack"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   133
apply(induct_tac stack)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   134
 apply(simp add:fun_upd_apply S_def)+
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   135
done
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   136
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   137
lemma [rule_format,simp]:
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   138
 "\<forall>p. a \<notin> set stack \<longrightarrow> List (S (c(a:=z)) l r) p stack = List (S c l r) p stack"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   139
apply(induct_tac stack)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   140
 apply(simp add:fun_upd_apply S_def)+
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   141
done
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   142
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   143
consts
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   144
  --"Recursive definition of what is means for a the graph/stack structure to be reconstructible"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   145
  stkOk :: "('a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> 'a ref) \<Rightarrow> ('a \<Rightarrow> 'a ref) \<Rightarrow> ('a \<Rightarrow> 'a ref) \<Rightarrow> ('a \<Rightarrow> 'a ref) \<Rightarrow> 'a ref \<Rightarrow>'a list \<Rightarrow>  bool"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   146
primrec
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   147
stkOk_nil:  "stkOk c l r iL iR t [] = True"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   148
stkOk_cons: "stkOk c l r iL iR t (p#stk) = (stkOk c l r iL iR (Ref p) (stk) \<and> 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   149
                                  iL p = (if c p then l p else t) \<and>
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   150
                                  iR p = (if c p then t else r p))"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   151
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   152
text {* Rewrite rules for stkOk *}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   153
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   154
lemma [simp]: "\<And>t. \<lbrakk> x \<notin> set xs; Ref x\<noteq>t \<rbrakk> \<Longrightarrow>
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   155
  stkOk (c(x := f)) l r iL iR t xs = stkOk c l r iL iR t xs"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   156
apply (induct xs)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   157
 apply (auto simp:eq_sym_conv)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   158
done
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   159
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   160
lemma [simp]: "\<And>t. \<lbrakk> x \<notin> set xs; Ref x\<noteq>t \<rbrakk> \<Longrightarrow>
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   161
 stkOk c (l(x := g)) r iL iR t xs = stkOk c l r iL iR t xs"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   162
apply (induct xs)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   163
 apply (auto simp:eq_sym_conv)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   164
done
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   165
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   166
lemma [simp]: "\<And>t. \<lbrakk> x \<notin> set xs; Ref x\<noteq>t \<rbrakk> \<Longrightarrow>
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   167
 stkOk c l (r(x := g)) iL iR t xs = stkOk c l r iL iR t xs"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   168
apply (induct xs)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   169
 apply (auto simp:eq_sym_conv)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   170
done
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   171
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   172
lemma stkOk_r_rewrite [simp]: "\<And>x. x \<notin> set xs \<Longrightarrow>
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   173
  stkOk c l (r(x := g)) iL iR (Ref x) xs = stkOk c l r iL iR (Ref x) xs"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   174
apply (induct xs)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   175
 apply (auto simp:eq_sym_conv)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   176
done
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   177
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   178
lemma [simp]: "\<And>x. x \<notin> set xs \<Longrightarrow>
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   179
 stkOk c (l(x := g)) r iL iR (Ref x) xs = stkOk c l r iL iR (Ref x) xs"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   180
apply (induct xs)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   181
 apply (auto simp:eq_sym_conv)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   182
done
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   183
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   184
lemma [simp]: "\<And>x. x \<notin> set xs \<Longrightarrow>
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   185
 stkOk (c(x := g)) l r iL iR (Ref x) xs = stkOk c l r iL iR (Ref x) xs"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   186
apply (induct xs)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   187
 apply (auto simp:eq_sym_conv)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   188
done
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   189
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   190
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   191
section{*The Schorr-Waite algorithm*}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   192
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   193
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   194
theorem SchorrWaiteAlgorithm: 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   195
"VARS c m l r t p q root
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   196
 {R = reachable (relS {l, r}) {root} \<and> (\<forall>x. \<not> m x) \<and> iR = r \<and> iL = l} 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   197
 t := root; p := Null;
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   198
 WHILE p \<noteq> Null \<or> t \<noteq> Null \<and> \<not> t^.m
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   199
 INV {\<exists>stack.
13875
12997e3ddd8d *** empty log message ***
nipkow
parents: 13820
diff changeset
   200
          List (S c l r) p stack \<and>                                         (*i1*)
12997e3ddd8d *** empty log message ***
nipkow
parents: 13820
diff changeset
   201
          (\<forall>x \<in> set stack. m x) \<and>                                        (*i2*)
12997e3ddd8d *** empty log message ***
nipkow
parents: 13820
diff changeset
   202
          R = reachable (relS{l, r}) {t,p} \<and>                           (*i3*)
12997e3ddd8d *** empty log message ***
nipkow
parents: 13820
diff changeset
   203
          (\<forall>x. x \<in> R \<and> \<not>m x \<longrightarrow>                                        (*i4*)
13820
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   204
                 x \<in> reachable (relS{l,r}|m) ({t}\<union>set(map r stack))) \<and>
13875
12997e3ddd8d *** empty log message ***
nipkow
parents: 13820
diff changeset
   205
          (\<forall>x. m x \<longrightarrow> x \<in> R) \<and>                                         (*i5*)
12997e3ddd8d *** empty log message ***
nipkow
parents: 13820
diff changeset
   206
          (\<forall>x. x \<notin> set stack \<longrightarrow> r x = iR x \<and> l x = iL x) \<and>       (*i6*)
12997e3ddd8d *** empty log message ***
nipkow
parents: 13820
diff changeset
   207
          (stkOk c l r iL iR t stack)                                    (*i7*) }
13820
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   208
 DO IF t = Null \<or> t^.m
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   209
      THEN IF p^.c
13875
12997e3ddd8d *** empty log message ***
nipkow
parents: 13820
diff changeset
   210
               THEN q := t; t := p; p := p^.r; t^.r := q               (*pop*)
12997e3ddd8d *** empty log message ***
nipkow
parents: 13820
diff changeset
   211
               ELSE q := t; t := p^.r; p^.r := p^.l;                      (*swing*)
13820
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   212
                        p^.l := q; p^.c := True          FI    
13875
12997e3ddd8d *** empty log message ***
nipkow
parents: 13820
diff changeset
   213
      ELSE q := p; p := t; t := t^.l; p^.l := q;                         (*push*)
13820
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   214
               p^.m := True; p^.c := False            FI       OD
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   215
 {(\<forall>x. (x \<in> R) = m x) \<and> (r = iR \<and> l = iL) }"
13875
12997e3ddd8d *** empty log message ***
nipkow
parents: 13820
diff changeset
   216
  (is "VARS c m l r t p q root {?Pre c m l r root} (?c1; ?c2; ?c3) {?Post c m l r}")
13820
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   217
proof (vcg)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   218
  let "While {(c, m, l, r, t, p, q, root). ?whileB m t p}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   219
    {(c, m, l, r, t, p, q, root). ?inv c m l r t p} ?body" = ?c3
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   220
  {
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   221
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   222
    fix c m l r t p q root
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   223
    assume "?Pre c m l r root"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   224
    thus "?inv c m l r root Null"  by (auto simp add: reachable_def addrs_def)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   225
  next
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   226
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   227
    fix c m l r t p q
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   228
    let "\<exists>stack. ?Inv stack"  =  "?inv c m l r t p"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   229
    assume a: "?inv c m l r t p \<and> \<not>(p \<noteq> Null \<or> t \<noteq> Null \<and> \<not> t^.m)"  
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   230
    then obtain stack where inv: "?Inv stack" by blast
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   231
    from a have pNull: "p = Null" and tDisj: "t=Null \<or> (t\<noteq>Null \<and> t^.m )" by auto
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   232
    let "?I1 \<and> _ \<and> _ \<and> ?I4 \<and> ?I5 \<and> ?I6 \<and> _"  =  "?Inv stack"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   233
    from inv have i1: "?I1" and i4: "?I4" and i5: "?I5" and i6: "?I6" by simp+
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   234
    from pNull i1 have stackEmpty: "stack = []" by simp
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   235
    from tDisj i4 have RisMarked[rule_format]: "\<forall>x.  x \<in> R \<longrightarrow> m x"  by(auto simp: reachable_def addrs_def stackEmpty)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   236
    from i5 i6 show "(\<forall>x.(x \<in> R) = m x) \<and> r = iR \<and> l = iL"  by(auto simp: stackEmpty expand_fun_eq intro:RisMarked)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   237
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   238
  next   
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   239
      fix c m l r t p q root
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   240
      let "\<exists>stack. ?Inv stack"  =  "?inv c m l r t p"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   241
      let "\<exists>stack. ?popInv stack"  =  "?inv c m l (r(p \<rightarrow> t)) p (p^.r)"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   242
      let "\<exists>stack. ?swInv stack"  =
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   243
        "?inv (c(p \<rightarrow> True)) m (l(p \<rightarrow> t)) (r(p \<rightarrow> p^.l)) (p^.r) p"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   244
      let "\<exists>stack. ?puInv stack"  =
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   245
        "?inv (c(t \<rightarrow> False)) (m(t \<rightarrow> True)) (l(t \<rightarrow> p)) r (t^.l) t"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   246
      let "?ifB1"  =  "(t = Null \<or> t^.m)"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   247
      let "?ifB2"  =  "p^.c" 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   248
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   249
      assume "(\<exists>stack.?Inv stack) \<and> (p \<noteq> Null \<or> t \<noteq> Null \<and> \<not> t^.m)" (is "_ \<and> ?whileB")
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   250
      then obtain stack where inv: "?Inv stack" and whileB: "?whileB" by blast
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   251
      let "?I1 \<and> ?I2 \<and> ?I3 \<and> ?I4 \<and> ?I5 \<and> ?I6 \<and> ?I7" = "?Inv stack"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   252
      from inv have i1: "?I1" and i2: "?I2" and i3: "?I3" and i4: "?I4"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   253
                  and i5: "?I5" and i6: "?I6" and i7: "?I7" by simp+        
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   254
      have stackDist: "distinct (stack)" using i1 by (rule List_distinct)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   255
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   256
      show "(?ifB1 \<longrightarrow> (?ifB2 \<longrightarrow> (\<exists>stack.?popInv stack)) \<and> 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   257
                            (\<not>?ifB2 \<longrightarrow> (\<exists>stack.?swInv stack)) ) \<and>
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   258
	      (\<not>?ifB1 \<longrightarrow> (\<exists>stack.?puInv stack))"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   259
      proof - 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   260
	{
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   261
	  assume ifB1: "t = Null \<or> t^.m" and ifB2: "p^.c"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   262
	  from ifB1 whileB have pNotNull: "p \<noteq> Null" by auto
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   263
	  then obtain addr_p where addr_p_eq: "p = Ref addr_p" by auto
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   264
	  with i1 obtain stack_tl where stack_eq: "stack = (addr p) # stack_tl"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   265
	    by auto
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   266
	  with i2 have m_addr_p: "p^.m" by auto
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   267
	  have stackDist: "distinct (stack)" using i1 by (rule List_distinct)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   268
	  from stack_eq stackDist have p_notin_stack_tl: "addr p \<notin> set stack_tl" by simp
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   269
	  let "?poI1\<and> ?poI2\<and> ?poI3\<and> ?poI4\<and> ?poI5\<and> ?poI6\<and> ?poI7" = "?popInv stack_tl"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   270
	  have "?popInv stack_tl"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   271
	  proof -
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   272
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   273
	    -- {*List property is maintained:*}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   274
	    from i1 p_notin_stack_tl ifB2
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   275
	    have poI1: "List (S c l (r(p \<rightarrow> t))) (p^.r) stack_tl" 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   276
	      by(simp add: addr_p_eq stack_eq, simp add: S_def)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   277
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   278
	    moreover
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   279
	    -- {*Everything on the stack is marked:*}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   280
	    from i2 have poI2: "\<forall> x \<in> set stack_tl. m x" by (simp add:stack_eq)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   281
	    moreover
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   282
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   283
	    -- {*Everything is still reachable:*}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   284
	    let "(R = reachable ?Ra ?A)" = "?I3"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   285
	    let "?Rb" = "(relS {l, r(p \<rightarrow> t)})"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   286
	    let "?B" = "{p, p^.r}"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   287
	    -- {*Our goal is @{text"R = reachable ?Rb ?B"}.*}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   288
	    have "?Ra\<^sup>* `` addrs ?A = ?Rb\<^sup>* `` addrs ?B" (is "?L = ?R")
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   289
	    proof
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   290
	      show "?L \<subseteq> ?R"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   291
	      proof (rule still_reachable)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   292
		show "addrs ?A \<subseteq> ?Rb\<^sup>* `` addrs ?B" by(fastsimp simp:addrs_def relS_def rel_def addr_p_eq 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   293
		     intro:oneStep_reachable Image_iff[THEN iffD2])
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   294
		show "\<forall>(x,y) \<in> ?Ra-?Rb. y \<in> (?Rb\<^sup>* `` addrs ?B)" by (clarsimp simp:relS_def) 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   295
	             (fastsimp simp add:rel_def Image_iff addrs_def dest:rel_upd1)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   296
	      qed
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   297
	      show "?R \<subseteq> ?L"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   298
	      proof (rule still_reachable)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   299
		show "addrs ?B \<subseteq> ?Ra\<^sup>* `` addrs ?A"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   300
		  by(fastsimp simp:addrs_def rel_defs addr_p_eq 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   301
		      intro:oneStep_reachable Image_iff[THEN iffD2])
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   302
	      next
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   303
		show "\<forall>(x, y)\<in>?Rb-?Ra. y\<in>(?Ra\<^sup>*``addrs ?A)"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   304
		  by (clarsimp simp:relS_def) 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   305
	             (fastsimp simp add:rel_def Image_iff addrs_def dest:rel_upd2)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   306
	      qed
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   307
	    qed
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   308
	    with i3 have poI3: "R = reachable ?Rb ?B"  by (simp add:reachable_def) 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   309
	    moreover
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   310
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   311
	    -- "If it is reachable and not marked, it is still reachable using..."
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   312
	    let "\<forall>x. x \<in> R \<and> \<not> m x \<longrightarrow> x \<in> reachable ?Ra ?A"  =  ?I4	    
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   313
	    let "?Rb" = "relS {l, r(p \<rightarrow> t)} | m"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   314
	    let "?B" = "{p} \<union> set (map (r(p \<rightarrow> t)) stack_tl)"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   315
	    -- {*Our goal is @{text"\<forall>x. x \<in> R \<and> \<not> m x \<longrightarrow> x \<in> reachable ?Rb ?B"}.*}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   316
	    let ?T = "{t, p^.r}"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   317
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   318
	    have "?Ra\<^sup>* `` addrs ?A \<subseteq> ?Rb\<^sup>* `` (addrs ?B \<union> addrs ?T)"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   319
	    proof (rule still_reachable)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   320
	      have rewrite: "\<forall>s\<in>set stack_tl. (r(p \<rightarrow> t)) s = r s"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   321
		by (auto simp add:p_notin_stack_tl intro:fun_upd_other)	
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   322
	      show "addrs ?A \<subseteq> ?Rb\<^sup>* `` (addrs ?B \<union> addrs ?T)"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   323
		by (fastsimp cong:map_cong simp:stack_eq addrs_def rewrite intro:self_reachable)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   324
	      show "\<forall>(x, y)\<in>?Ra-?Rb. y\<in>(?Rb\<^sup>*``(addrs ?B \<union> addrs ?T))"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   325
		by (clarsimp simp:restr_def relS_def) 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   326
	          (fastsimp simp add:rel_def Image_iff addrs_def dest:rel_upd1)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   327
 	    qed
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   328
	    -- "We now bring a term from the right to the left of the subset relation."
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   329
	    hence subset: "?Ra\<^sup>* `` addrs ?A - ?Rb\<^sup>* `` addrs ?T \<subseteq> ?Rb\<^sup>* `` addrs ?B"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   330
	      by blast
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   331
	    have poI4: "\<forall>x. x \<in> R \<and> \<not> m x \<longrightarrow> x \<in> reachable ?Rb ?B"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   332
	    proof (rule allI, rule impI)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   333
	      fix x
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   334
	      assume a: "x \<in> R \<and> \<not> m x"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   335
	      -- {*First, a disjunction on @{term"p^.r"} used later in the proof*}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   336
	      have pDisj:"p^.r = Null \<or> (p^.r \<noteq> Null \<and> p^.r^.m)" using poI1 poI2 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   337
		by auto
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   338
	      -- {*@{term x} belongs to the left hand side of @{thm[source] subset}:*}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   339
	      have incl: "x \<in> ?Ra\<^sup>*``addrs ?A" using  a i4 by (simp only:reachable_def, clarsimp)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   340
	      have excl: "x \<notin> ?Rb\<^sup>*`` addrs ?T" using pDisj ifB1 a by (auto simp add:addrs_def)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   341
	      -- {*And therefore also belongs to the right hand side of @{thm[source]subset},*}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   342
	      -- {*which corresponds to our goal.*}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   343
	      from incl excl subset  show "x \<in> reachable ?Rb ?B" by (auto simp add:reachable_def)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   344
	    qed
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   345
	    moreover
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   346
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   347
	    -- "If it is marked, then it is reachable"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   348
	    from i5 have poI5: "\<forall>x. m x \<longrightarrow> x \<in> R" .
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   349
	    moreover
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   350
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   351
	    -- {*If it is not on the stack, then its @{term l} and @{term r} fields are unchanged*}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   352
	    from i7 i6 ifB2 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   353
	    have poI6: "\<forall>x. x \<notin> set stack_tl \<longrightarrow> (r(p \<rightarrow> t)) x = iR x \<and> l x = iL x" 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   354
	      by(auto simp: addr_p_eq stack_eq fun_upd_apply)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   355
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   356
	    moreover
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   357
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   358
	    -- {*If it is on the stack, then its @{term l} and @{term r} fields can be reconstructed*}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   359
	    from p_notin_stack_tl i7 have poI7: "stkOk c l (r(p \<rightarrow> t)) iL iR p stack_tl"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   360
	      by (clarsimp simp:stack_eq addr_p_eq)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   361
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   362
	    ultimately show "?popInv stack_tl" by simp
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   363
	  qed
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   364
	  hence "\<exists>stack. ?popInv stack" ..
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   365
	}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   366
	moreover
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   367
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   368
	-- "Proofs of the Swing and Push arm follow."
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   369
	-- "Since they are in principle simmilar to the Pop arm proof,"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   370
	-- "we show fewer comments and use frequent pattern matching."
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   371
	{
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   372
	  -- "Swing arm"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   373
	  assume ifB1: "?ifB1" and nifB2: "\<not>?ifB2"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   374
	  from ifB1 whileB have pNotNull: "p \<noteq> Null" by clarsimp
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   375
	  then obtain addr_p where addr_p_eq: "p = Ref addr_p" by clarsimp
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   376
	  with i1 obtain stack_tl where stack_eq: "stack = (addr p) # stack_tl" by clarsimp
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   377
	  with i2 have m_addr_p: "p^.m" by clarsimp
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   378
	  from stack_eq stackDist have p_notin_stack_tl: "(addr p) \<notin> set stack_tl"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   379
	    by simp
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   380
	  let "?swI1\<and>?swI2\<and>?swI3\<and>?swI4\<and>?swI5\<and>?swI6\<and>?swI7" = "?swInv stack"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   381
	  have "?swInv stack"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   382
	  proof -
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   383
	    
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   384
	    -- {*List property is maintained:*}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   385
	    from i1 p_notin_stack_tl nifB2
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   386
	    have swI1: "?swI1"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   387
	      by (simp add:addr_p_eq stack_eq, simp add:S_def)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   388
	    moreover
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   389
	    
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   390
	    -- {*Everything on the stack is marked:*}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   391
	    from i2
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   392
	    have swI2: "?swI2" .
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   393
	    moreover
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   394
	    
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   395
	    -- {*Everything is still reachable:*}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   396
	    let "R = reachable ?Ra ?A" = "?I3"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   397
	    let "R = reachable ?Rb ?B" = "?swI3"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   398
	    have "?Ra\<^sup>* `` addrs ?A = ?Rb\<^sup>* `` addrs ?B"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   399
	    proof (rule still_reachable_eq)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   400
	      show "addrs ?A \<subseteq> ?Rb\<^sup>* `` addrs ?B"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   401
		by(fastsimp simp:addrs_def rel_defs addr_p_eq intro:oneStep_reachable Image_iff[THEN iffD2])
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   402
	    next
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   403
	      show "addrs ?B \<subseteq> ?Ra\<^sup>* `` addrs ?A"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   404
		by(fastsimp simp:addrs_def rel_defs addr_p_eq intro:oneStep_reachable Image_iff[THEN iffD2])
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   405
	    next
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   406
	      show "\<forall>(x, y)\<in>?Ra-?Rb. y\<in>(?Rb\<^sup>*``addrs ?B)"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   407
		by (clarsimp simp:relS_def) (fastsimp simp add:rel_def Image_iff addrs_def fun_upd_apply dest:rel_upd1)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   408
	    next
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   409
	      show "\<forall>(x, y)\<in>?Rb-?Ra. y\<in>(?Ra\<^sup>*``addrs ?A)"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   410
		by (clarsimp simp:relS_def) (fastsimp simp add:rel_def Image_iff addrs_def fun_upd_apply dest:rel_upd2)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   411
	    qed
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   412
	    with i3
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   413
	    have swI3: "?swI3" by (simp add:reachable_def) 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   414
	    moreover
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   415
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   416
	    -- "If it is reachable and not marked, it is still reachable using..."
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   417
	    let "\<forall>x. x \<in> R \<and> \<not> m x \<longrightarrow> x \<in> reachable ?Ra ?A" = ?I4
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   418
	    let "\<forall>x. x \<in> R \<and> \<not> m x \<longrightarrow> x \<in> reachable ?Rb ?B" = ?swI4
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   419
	    let ?T = "{t}"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   420
	    have "?Ra\<^sup>*``addrs ?A \<subseteq> ?Rb\<^sup>*``(addrs ?B \<union> addrs ?T)"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   421
	    proof (rule still_reachable)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   422
	      have rewrite: "(\<forall>s\<in>set stack_tl. (r(addr p := l(addr p))) s = r s)"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   423
		by (auto simp add:p_notin_stack_tl intro:fun_upd_other)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   424
	      show "addrs ?A \<subseteq> ?Rb\<^sup>* `` (addrs ?B \<union> addrs ?T)"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   425
		by (fastsimp cong:map_cong simp:stack_eq addrs_def rewrite intro:self_reachable)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   426
	    next
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   427
	      show "\<forall>(x, y)\<in>?Ra-?Rb. y\<in>(?Rb\<^sup>*``(addrs ?B \<union> addrs ?T))"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   428
		by (clarsimp simp:relS_def restr_def) (fastsimp simp add:rel_def Image_iff addrs_def fun_upd_apply dest:rel_upd1)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   429
	    qed
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   430
	    then have subset: "?Ra\<^sup>*``addrs ?A - ?Rb\<^sup>*``addrs ?T \<subseteq> ?Rb\<^sup>*``addrs ?B"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   431
	      by blast
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   432
	    have ?swI4
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   433
	    proof (rule allI, rule impI)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   434
	      fix x
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   435
	      assume a: "x \<in> R \<and>\<not> m x"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   436
	      with i4 addr_p_eq stack_eq  have inc: "x \<in> ?Ra\<^sup>*``addrs ?A" 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   437
		by (simp only:reachable_def, clarsimp)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   438
	      with ifB1 a 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   439
	      have exc: "x \<notin> ?Rb\<^sup>*`` addrs ?T" 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   440
		by (auto simp add:addrs_def)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   441
	      from inc exc subset  show "x \<in> reachable ?Rb ?B" 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   442
		by (auto simp add:reachable_def)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   443
	    qed
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   444
	    moreover
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   445
	    
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   446
	    -- "If it is marked, then it is reachable"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   447
	    from i5
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   448
	    have "?swI5" .
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   449
	    moreover
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   450
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   451
	    -- {*If it is not on the stack, then its @{term l} and @{term r} fields are unchanged*}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   452
	    from i6 stack_eq
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   453
	    have "?swI6"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   454
	      by clarsimp 	    
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   455
	    moreover
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   456
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   457
	    -- {*If it is on the stack, then its @{term l} and @{term r} fields can be reconstructed*}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   458
	    from stackDist i7 nifB2 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   459
	    have "?swI7"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   460
	      by (clarsimp simp:addr_p_eq stack_eq)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   461
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   462
	    ultimately show ?thesis by auto
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   463
	  qed
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   464
	  then have "\<exists>stack. ?swInv stack" by blast
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   465
	}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   466
	moreover
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   467
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   468
	{
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   469
	  -- "Push arm"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   470
	  assume nifB1: "\<not>?ifB1"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   471
	  from nifB1 whileB have tNotNull: "t \<noteq> Null" by clarsimp
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   472
	  then obtain addr_t where addr_t_eq: "t = Ref addr_t" by clarsimp
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   473
	  with i1 obtain new_stack where new_stack_eq: "new_stack = (addr t) # stack" by clarsimp
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   474
	  from tNotNull nifB1 have n_m_addr_t: "\<not> (t^.m)" by clarsimp
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   475
	  with i2 have t_notin_stack: "(addr t) \<notin> set stack" by blast
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   476
	  let "?puI1\<and>?puI2\<and>?puI3\<and>?puI4\<and>?puI5\<and>?puI6\<and>?puI7" = "?puInv new_stack"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   477
	  have "?puInv new_stack"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   478
	  proof -
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   479
	    
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   480
	    -- {*List property is maintained:*}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   481
	    from i1 t_notin_stack
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   482
	    have puI1: "?puI1"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   483
	      by (simp add:addr_t_eq new_stack_eq, simp add:S_def)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   484
	    moreover
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   485
	    
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   486
	    -- {*Everything on the stack is marked:*}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   487
	    from i2
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   488
	    have puI2: "?puI2" 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   489
	      by (simp add:new_stack_eq fun_upd_apply)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   490
	    moreover
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   491
	    
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   492
	    -- {*Everything is still reachable:*}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   493
	    let "R = reachable ?Ra ?A" = "?I3"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   494
	    let "R = reachable ?Rb ?B" = "?puI3"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   495
	    have "?Ra\<^sup>* `` addrs ?A = ?Rb\<^sup>* `` addrs ?B"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   496
	    proof (rule still_reachable_eq)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   497
	      show "addrs ?A \<subseteq> ?Rb\<^sup>* `` addrs ?B"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   498
		by(fastsimp simp:addrs_def rel_defs addr_t_eq intro:oneStep_reachable Image_iff[THEN iffD2])
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   499
	    next
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   500
	      show "addrs ?B \<subseteq> ?Ra\<^sup>* `` addrs ?A"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   501
		by(fastsimp simp:addrs_def rel_defs addr_t_eq intro:oneStep_reachable Image_iff[THEN iffD2])
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   502
	    next
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   503
	      show "\<forall>(x, y)\<in>?Ra-?Rb. y\<in>(?Rb\<^sup>*``addrs ?B)"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   504
		by (clarsimp simp:relS_def) (fastsimp simp add:rel_def Image_iff addrs_def dest:rel_upd1)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   505
	    next
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   506
	      show "\<forall>(x, y)\<in>?Rb-?Ra. y\<in>(?Ra\<^sup>*``addrs ?A)"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   507
		by (clarsimp simp:relS_def) (fastsimp simp add:rel_def Image_iff addrs_def fun_upd_apply dest:rel_upd2)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   508
	    qed
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   509
	    with i3
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   510
	    have puI3: "?puI3" by (simp add:reachable_def) 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   511
	    moreover
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   512
	    
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   513
	    -- "If it is reachable and not marked, it is still reachable using..."
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   514
	    let "\<forall>x. x \<in> R \<and> \<not> m x \<longrightarrow> x \<in> reachable ?Ra ?A" = ?I4
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   515
	    let "\<forall>x. x \<in> R \<and> \<not> ?new_m x \<longrightarrow> x \<in> reachable ?Rb ?B" = ?puI4
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   516
	    let ?T = "{t}"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   517
	    have "?Ra\<^sup>*``addrs ?A \<subseteq> ?Rb\<^sup>*``(addrs ?B \<union> addrs ?T)"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   518
	    proof (rule still_reachable)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   519
	      show "addrs ?A \<subseteq> ?Rb\<^sup>* `` (addrs ?B \<union> addrs ?T)"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   520
		by (fastsimp simp:new_stack_eq addrs_def intro:self_reachable)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   521
	    next
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   522
	      show "\<forall>(x, y)\<in>?Ra-?Rb. y\<in>(?Rb\<^sup>*``(addrs ?B \<union> addrs ?T))"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   523
		by (clarsimp simp:relS_def new_stack_eq restr_un restr_upd) 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   524
	           (fastsimp simp add:rel_def Image_iff restr_def addrs_def fun_upd_apply addr_t_eq dest:rel_upd3)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   525
	    qed
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   526
	    then have subset: "?Ra\<^sup>*``addrs ?A - ?Rb\<^sup>*``addrs ?T \<subseteq> ?Rb\<^sup>*``addrs ?B"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   527
	      by blast
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   528
	    have ?puI4
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   529
	    proof (rule allI, rule impI)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   530
	      fix x
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   531
	      assume a: "x \<in> R \<and> \<not> ?new_m x"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   532
	      have xDisj: "x=(addr t) \<or> x\<noteq>(addr t)" by simp
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   533
	      with i4 a have inc: "x \<in> ?Ra\<^sup>*``addrs ?A"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   534
		by (fastsimp simp:addr_t_eq addrs_def reachable_def intro:self_reachable)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   535
	      have exc: "x \<notin> ?Rb\<^sup>*`` addrs ?T"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   536
		using xDisj a n_m_addr_t
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   537
		by (clarsimp simp add:addrs_def addr_t_eq) 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   538
	      from inc exc subset  show "x \<in> reachable ?Rb ?B" 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   539
		by (auto simp add:reachable_def)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   540
	    qed  
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   541
	    moreover
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   542
	    
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   543
	    -- "If it is marked, then it is reachable"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   544
	    from i5
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   545
	    have "?puI5"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   546
	      by (auto simp:addrs_def i3 reachable_def addr_t_eq fun_upd_apply intro:self_reachable)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   547
	    moreover
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   548
	    
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   549
	    -- {*If it is not on the stack, then its @{term l} and @{term r} fields are unchanged*}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   550
	    from i6 
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   551
	    have "?puI6"
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   552
	      by (simp add:new_stack_eq)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   553
	    moreover
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   554
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   555
	    -- {*If it is on the stack, then its @{term l} and @{term r} fields can be reconstructed*}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   556
	    from stackDist i6 t_notin_stack i7
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   557
	    have "?puI7" by (clarsimp simp:addr_t_eq new_stack_eq)
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   558
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   559
	    ultimately show ?thesis by auto
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   560
	  qed
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   561
	  then have "\<exists>stack. ?puInv stack" by blast
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   562
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   563
	}
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   564
	ultimately show ?thesis by blast
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   565
      qed
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   566
    }
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   567
  qed
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   568
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   569
end
87a8ab465b29 Proof of the Schorr-Waite graph marking algorithm.
mehta
parents:
diff changeset
   570