src/HOL/Hoare/SchorrWaite.thy
changeset 36866 426d5781bb25
parent 32960 69916a850301
child 38353 d98baa2cf589
equal deleted inserted replaced
36865:7330e4eefbd7 36866:426d5781bb25
     9 
     9 
    10 theory SchorrWaite imports HeapSyntax begin
    10 theory SchorrWaite imports HeapSyntax begin
    11 
    11 
    12 section {* Machinery for the Schorr-Waite proof*}
    12 section {* Machinery for the Schorr-Waite proof*}
    13 
    13 
    14 constdefs
    14 definition
    15   -- "Relations induced by a mapping"
    15   -- "Relations induced by a mapping"
    16   rel :: "('a \<Rightarrow> 'a ref) \<Rightarrow> ('a \<times> 'a) set"
    16   rel :: "('a \<Rightarrow> 'a ref) \<Rightarrow> ('a \<times> 'a) set"
    17   "rel m == {(x,y). m x = Ref y}"
    17   where "rel m = {(x,y). m x = Ref y}"
       
    18 
       
    19 definition
    18   relS :: "('a \<Rightarrow> 'a ref) set \<Rightarrow> ('a \<times> 'a) set"
    20   relS :: "('a \<Rightarrow> 'a ref) set \<Rightarrow> ('a \<times> 'a) set"
    19   "relS M == (\<Union> m \<in> M. rel m)"
    21   where "relS M = (\<Union> m \<in> M. rel m)"
       
    22 
       
    23 definition
    20   addrs :: "'a ref set \<Rightarrow> 'a set"
    24   addrs :: "'a ref set \<Rightarrow> 'a set"
    21   "addrs P == {a. Ref a \<in> P}"
    25   where "addrs P = {a. Ref a \<in> P}"
       
    26 
       
    27 definition
    22   reachable :: "('a \<times> 'a) set \<Rightarrow> 'a ref set \<Rightarrow> 'a set"
    28   reachable :: "('a \<times> 'a) set \<Rightarrow> 'a ref set \<Rightarrow> 'a set"
    23   "reachable r P == (r\<^sup>* `` addrs P)"
    29   where "reachable r P = (r\<^sup>* `` addrs P)"
    24 
    30 
    25 lemmas rel_defs = relS_def rel_def
    31 lemmas rel_defs = relS_def rel_def
    26 
    32 
    27 text {* Rewrite rules for relations induced by a mapping*}
    33 text {* Rewrite rules for relations induced by a mapping*}
    28 
    34 
    75 lemma rel_upd2: "(a,b)  \<notin> rel r \<Longrightarrow> (a,b) \<in> rel (r(q:=t)) \<Longrightarrow> a=q"
    81 lemma rel_upd2: "(a,b)  \<notin> rel r \<Longrightarrow> (a,b) \<in> rel (r(q:=t)) \<Longrightarrow> a=q"
    76 apply (rule classical)
    82 apply (rule classical)
    77 apply (simp add:rel_defs fun_upd_apply)
    83 apply (simp add:rel_defs fun_upd_apply)
    78 done
    84 done
    79 
    85 
    80 constdefs
    86 definition
    81   -- "Restriction of a relation"
    87   -- "Restriction of a relation"
    82   restr ::"('a \<times> 'a) set \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> ('a \<times> 'a) set"       ("(_/ | _)" [50, 51] 50)
    88   restr ::"('a \<times> 'a) set \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> ('a \<times> 'a) set"       ("(_/ | _)" [50, 51] 50)
    83   "restr r m == {(x,y). (x,y) \<in> r \<and> \<not> m x}"
    89   where "restr r m = {(x,y). (x,y) \<in> r \<and> \<not> m x}"
    84 
    90 
    85 text {* Rewrite rules for the restriction of a relation *}
    91 text {* Rewrite rules for the restriction of a relation *}
    86 
    92 
    87 lemma restr_identity[simp]:
    93 lemma restr_identity[simp]:
    88  " (\<forall>x. \<not> m x) \<Longrightarrow> (R |m) = R"
    94  " (\<forall>x. \<not> m x) \<Longrightarrow> (R |m) = R"
   107 lemma rel_upd3: "(a, b) \<notin> (r|(m(q := t))) \<Longrightarrow> (a,b) \<in> (r|m) \<Longrightarrow> a = q "
   113 lemma rel_upd3: "(a, b) \<notin> (r|(m(q := t))) \<Longrightarrow> (a,b) \<in> (r|m) \<Longrightarrow> a = q "
   108 apply (rule classical)
   114 apply (rule classical)
   109 apply (simp add:restr_def fun_upd_apply)
   115 apply (simp add:restr_def fun_upd_apply)
   110 done
   116 done
   111 
   117 
   112 constdefs
   118 definition
   113   -- "A short form for the stack mapping function for List"
   119   -- "A short form for the stack mapping function for List"
   114   S :: "('a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> 'a ref) \<Rightarrow> ('a \<Rightarrow> 'a ref) \<Rightarrow> ('a \<Rightarrow> 'a ref)"
   120   S :: "('a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> 'a ref) \<Rightarrow> ('a \<Rightarrow> 'a ref) \<Rightarrow> ('a \<Rightarrow> 'a ref)"
   115   "S c l r == (\<lambda>x. if c x then r x else l x)"
   121   where "S c l r = (\<lambda>x. if c x then r x else l x)"
   116 
   122 
   117 text {* Rewrite rules for Lists using S as their mapping *}
   123 text {* Rewrite rules for Lists using S as their mapping *}
   118 
   124 
   119 lemma [rule_format,simp]:
   125 lemma [rule_format,simp]:
   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"
   126  "\<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"