src/HOL/Library/Multiset.thy
changeset 11464 ddea204de5bc
parent 10714 07f75bf77a33
child 11549 e7265e70fd7c
     1.1 --- a/src/HOL/Library/Multiset.thy	Mon Aug 06 13:12:06 2001 +0200
     1.2 +++ b/src/HOL/Library/Multiset.thy	Mon Aug 06 13:43:24 2001 +0200
     1.3 @@ -16,7 +16,7 @@
     1.4  
     1.5  typedef 'a multiset = "{f::'a => nat. finite {x . 0 < f x}}"
     1.6  proof
     1.7 -  show "(\\<lambda>x. 0::nat) \\<in> ?multiset" by simp
     1.8 +  show "(\<lambda>x. 0::nat) \<in> ?multiset" by simp
     1.9  qed
    1.10  
    1.11  lemmas multiset_typedef [simp] =
    1.12 @@ -25,23 +25,23 @@
    1.13  
    1.14  constdefs
    1.15    Mempty :: "'a multiset"    ("{#}")
    1.16 -  "{#} == Abs_multiset (\\<lambda>a. 0)"
    1.17 +  "{#} == Abs_multiset (\<lambda>a. 0)"
    1.18  
    1.19    single :: "'a => 'a multiset"    ("{#_#}")
    1.20 -  "{#a#} == Abs_multiset (\\<lambda>b. if b = a then 1 else 0)"
    1.21 +  "{#a#} == Abs_multiset (\<lambda>b. if b = a then 1' else 0)"
    1.22  
    1.23    count :: "'a multiset => 'a => nat"
    1.24    "count == Rep_multiset"
    1.25  
    1.26    MCollect :: "'a multiset => ('a => bool) => 'a multiset"
    1.27 -  "MCollect M P == Abs_multiset (\\<lambda>x. if P x then Rep_multiset M x else 0)"
    1.28 +  "MCollect M P == Abs_multiset (\<lambda>x. if P x then Rep_multiset M x else 0)"
    1.29  
    1.30  syntax
    1.31    "_Melem" :: "'a => 'a multiset => bool"    ("(_/ :# _)" [50, 51] 50)
    1.32    "_MCollect" :: "pttrn => 'a multiset => bool => 'a multiset"    ("(1{# _ : _./ _#})")
    1.33  translations
    1.34    "a :# M" == "0 < count M a"
    1.35 -  "{#x:M. P#}" == "MCollect M (\\<lambda>x. P)"
    1.36 +  "{#x:M. P#}" == "MCollect M (\<lambda>x. P)"
    1.37  
    1.38  constdefs
    1.39    set_of :: "'a multiset => 'a set"
    1.40 @@ -52,8 +52,8 @@
    1.41  instance multiset :: ("term") zero ..
    1.42  
    1.43  defs (overloaded)
    1.44 -  union_def: "M + N == Abs_multiset (\\<lambda>a. Rep_multiset M a + Rep_multiset N a)"
    1.45 -  diff_def: "M - N == Abs_multiset (\\<lambda>a. Rep_multiset M a - Rep_multiset N a)"
    1.46 +  union_def: "M + N == Abs_multiset (\<lambda>a. Rep_multiset M a + Rep_multiset N a)"
    1.47 +  diff_def: "M - N == Abs_multiset (\<lambda>a. Rep_multiset M a - Rep_multiset N a)"
    1.48    Zero_def [simp]: "0 == {#}"
    1.49    size_def: "size M == setsum (count M) (set_of M)"
    1.50  
    1.51 @@ -62,16 +62,16 @@
    1.52   \medskip Preservation of the representing set @{term multiset}.
    1.53  *}
    1.54  
    1.55 -lemma const0_in_multiset [simp]: "(\\<lambda>a. 0) \\<in> multiset"
    1.56 +lemma const0_in_multiset [simp]: "(\<lambda>a. 0) \<in> multiset"
    1.57    apply (simp add: multiset_def)
    1.58    done
    1.59  
    1.60 -lemma only1_in_multiset [simp]: "(\\<lambda>b. if b = a then 1 else 0) \\<in> multiset"
    1.61 +lemma only1_in_multiset [simp]: "(\<lambda>b. if b = a then 1' else 0) \<in> multiset"
    1.62    apply (simp add: multiset_def)
    1.63    done
    1.64  
    1.65  lemma union_preserves_multiset [simp]:
    1.66 -    "M \\<in> multiset ==> N \\<in> multiset ==> (\\<lambda>a. M a + N a) \\<in> multiset"
    1.67 +    "M \<in> multiset ==> N \<in> multiset ==> (\<lambda>a. M a + N a) \<in> multiset"
    1.68    apply (unfold multiset_def)
    1.69    apply simp
    1.70    apply (drule finite_UnI)
    1.71 @@ -80,7 +80,7 @@
    1.72    done
    1.73  
    1.74  lemma diff_preserves_multiset [simp]:
    1.75 -    "M \\<in> multiset ==> (\\<lambda>a. M a - N a) \\<in> multiset"
    1.76 +    "M \<in> multiset ==> (\<lambda>a. M a - N a) \<in> multiset"
    1.77    apply (unfold multiset_def)
    1.78    apply simp
    1.79    apply (rule finite_subset)
    1.80 @@ -94,7 +94,7 @@
    1.81  
    1.82  subsubsection {* Union *}
    1.83  
    1.84 -theorem union_empty [simp]: "M + {#} = M \\<and> {#} + M = M"
    1.85 +theorem union_empty [simp]: "M + {#} = M \<and> {#} + M = M"
    1.86    apply (simp add: union_def Mempty_def)
    1.87    done
    1.88  
    1.89 @@ -124,7 +124,7 @@
    1.90  
    1.91  subsubsection {* Difference *}
    1.92  
    1.93 -theorem diff_empty [simp]: "M - {#} = M \\<and> {#} - M = {#}"
    1.94 +theorem diff_empty [simp]: "M - {#} = M \<and> {#} - M = {#}"
    1.95    apply (simp add: Mempty_def diff_def)
    1.96    done
    1.97  
    1.98 @@ -139,7 +139,7 @@
    1.99    apply (simp add: count_def Mempty_def)
   1.100    done
   1.101  
   1.102 -theorem count_single [simp]: "count {#b#} a = (if b = a then 1 else 0)"
   1.103 +theorem count_single [simp]: "count {#b#} a = (if b = a then 1' else 0)"
   1.104    apply (simp add: count_def single_def)
   1.105    done
   1.106  
   1.107 @@ -162,7 +162,7 @@
   1.108    apply (simp add: set_of_def)
   1.109    done
   1.110  
   1.111 -theorem set_of_union [simp]: "set_of (M + N) = set_of M \\<union> set_of N"
   1.112 +theorem set_of_union [simp]: "set_of (M + N) = set_of M \<union> set_of N"
   1.113    apply (auto simp add: set_of_def)
   1.114    done
   1.115  
   1.116 @@ -170,7 +170,7 @@
   1.117    apply (auto simp add: set_of_def Mempty_def count_def expand_fun_eq)
   1.118    done
   1.119  
   1.120 -theorem mem_set_of_iff [simp]: "(x \\<in> set_of M) = (x :# M)"
   1.121 +theorem mem_set_of_iff [simp]: "(x \<in> set_of M) = (x :# M)"
   1.122    apply (auto simp add: set_of_def)
   1.123    done
   1.124  
   1.125 @@ -191,7 +191,7 @@
   1.126    done
   1.127  
   1.128  theorem setsum_count_Int:
   1.129 -    "finite A ==> setsum (count N) (A \\<inter> set_of N) = setsum (count N) A"
   1.130 +    "finite A ==> setsum (count N) (A \<inter> set_of N) = setsum (count N) A"
   1.131    apply (erule finite_induct)
   1.132     apply simp
   1.133    apply (simp add: Int_insert_left set_of_def)
   1.134 @@ -199,7 +199,7 @@
   1.135  
   1.136  theorem size_union [simp]: "size (M + N::'a multiset) = size M + size N"
   1.137    apply (unfold size_def)
   1.138 -  apply (subgoal_tac "count (M + N) = (\\<lambda>a. count M a + count N a)")
   1.139 +  apply (subgoal_tac "count (M + N) = (\<lambda>a. count M a + count N a)")
   1.140     prefer 2
   1.141     apply (rule ext)
   1.142     apply simp
   1.143 @@ -214,7 +214,7 @@
   1.144    apply (simp add: set_of_def count_def expand_fun_eq)
   1.145    done
   1.146  
   1.147 -theorem size_eq_Suc_imp_elem: "size M = Suc n ==> \\<exists>a. a :# M"
   1.148 +theorem size_eq_Suc_imp_elem: "size M = Suc n ==> \<exists>a. a :# M"
   1.149    apply (unfold size_def)
   1.150    apply (drule setsum_SucD)
   1.151    apply auto
   1.152 @@ -223,11 +223,11 @@
   1.153  
   1.154  subsubsection {* Equality of multisets *}
   1.155  
   1.156 -theorem multiset_eq_conv_count_eq: "(M = N) = (\\<forall>a. count M a = count N a)"
   1.157 +theorem multiset_eq_conv_count_eq: "(M = N) = (\<forall>a. count M a = count N a)"
   1.158    apply (simp add: count_def expand_fun_eq)
   1.159    done
   1.160  
   1.161 -theorem single_not_empty [simp]: "{#a#} \\<noteq> {#} \\<and> {#} \\<noteq> {#a#}"
   1.162 +theorem single_not_empty [simp]: "{#a#} \<noteq> {#} \<and> {#} \<noteq> {#a#}"
   1.163    apply (simp add: single_def Mempty_def expand_fun_eq)
   1.164    done
   1.165  
   1.166 @@ -235,11 +235,11 @@
   1.167    apply (auto simp add: single_def expand_fun_eq)
   1.168    done
   1.169  
   1.170 -theorem union_eq_empty [iff]: "(M + N = {#}) = (M = {#} \\<and> N = {#})"
   1.171 +theorem union_eq_empty [iff]: "(M + N = {#}) = (M = {#} \<and> N = {#})"
   1.172    apply (auto simp add: union_def Mempty_def expand_fun_eq)
   1.173    done
   1.174  
   1.175 -theorem empty_eq_union [iff]: "({#} = M + N) = (M = {#} \\<and> N = {#})"
   1.176 +theorem empty_eq_union [iff]: "({#} = M + N) = (M = {#} \<and> N = {#})"
   1.177    apply (auto simp add: union_def Mempty_def expand_fun_eq)
   1.178    done
   1.179  
   1.180 @@ -252,7 +252,7 @@
   1.181    done
   1.182  
   1.183  theorem union_is_single:
   1.184 -    "(M + N = {#a#}) = (M = {#a#} \\<and> N={#} \\<or> M = {#} \\<and> N = {#a#})"
   1.185 +    "(M + N = {#a#}) = (M = {#a#} \<and> N={#} \<or> M = {#} \<and> N = {#a#})"
   1.186    apply (unfold Mempty_def single_def union_def)
   1.187    apply (simp add: add_is_1 expand_fun_eq)
   1.188    apply blast
   1.189 @@ -260,16 +260,16 @@
   1.190  
   1.191  theorem single_is_union:
   1.192    "({#a#} = M + N) =
   1.193 -    ({#a#} = M \\<and> N = {#} \\<or> M = {#} \\<and> {#a#} = N)"
   1.194 +    ({#a#} = M \<and> N = {#} \<or> M = {#} \<and> {#a#} = N)"
   1.195    apply (unfold Mempty_def single_def union_def)
   1.196 -  apply (simp add: add_is_1 expand_fun_eq)
   1.197 +  apply (simp add: add_is_1 one_is_add expand_fun_eq)
   1.198    apply (blast dest: sym)
   1.199    done
   1.200  
   1.201  theorem add_eq_conv_diff:
   1.202    "(M + {#a#} = N + {#b#}) =
   1.203 -    (M = N \\<and> a = b \\<or>
   1.204 -      M = N - {#a#} + {#b#} \\<and> N = M - {#b#} + {#a#})"
   1.205 +    (M = N \<and> a = b \<or>
   1.206 +      M = N - {#a#} + {#b#} \<and> N = M - {#b#} + {#a#})"
   1.207    apply (unfold single_def union_def diff_def)
   1.208    apply (simp (no_asm) add: expand_fun_eq)
   1.209    apply (rule conjI)
   1.210 @@ -291,7 +291,7 @@
   1.211  (*
   1.212  val prems = Goal
   1.213   "[| !!F. [| finite F; !G. G < F --> P G |] ==> P F |] ==> finite F --> P F";
   1.214 -by (res_inst_tac [("a","F"),("f","\\<lambda>A. if finite A then card A else 0")]
   1.215 +by (res_inst_tac [("a","F"),("f","\<lambda>A. if finite A then card A else 0")]
   1.216       measure_induct 1);
   1.217  by (Clarify_tac 1);
   1.218  by (resolve_tac prems 1);
   1.219 @@ -320,7 +320,7 @@
   1.220  
   1.221  lemma setsum_decr:
   1.222    "finite F ==> 0 < f a ==>
   1.223 -    setsum (f (a := f a - 1)) F = (if a \\<in> F then setsum f F - 1 else setsum f F)"
   1.224 +    setsum (f (a := f a - 1')) F = (if a \<in> F then setsum f F - 1 else setsum f F)"
   1.225    apply (erule finite_induct)
   1.226     apply auto
   1.227    apply (drule_tac a = a in mk_disjoint_insert)
   1.228 @@ -328,8 +328,8 @@
   1.229    done
   1.230  
   1.231  lemma rep_multiset_induct_aux:
   1.232 -  "P (\\<lambda>a. 0) ==> (!!f b. f \\<in> multiset ==> P f ==> P (f (b := f b + 1)))
   1.233 -    ==> \\<forall>f. f \\<in> multiset --> setsum f {x. 0 < f x} = n --> P f"
   1.234 +  "P (\<lambda>a. 0) ==> (!!f b. f \<in> multiset ==> P f ==> P (f (b := f b + 1')))
   1.235 +    ==> \<forall>f. f \<in> multiset --> setsum f {x. 0 < f x} = n --> P f"
   1.236  proof -
   1.237    case antecedent
   1.238    note prems = this [unfolded multiset_def]
   1.239 @@ -338,7 +338,7 @@
   1.240      apply (induct_tac n)
   1.241       apply simp
   1.242       apply clarify
   1.243 -     apply (subgoal_tac "f = (\\<lambda>a.0)")
   1.244 +     apply (subgoal_tac "f = (\<lambda>a.0)")
   1.245        apply simp
   1.246        apply (rule prems)
   1.247       apply (rule ext)
   1.248 @@ -347,14 +347,14 @@
   1.249      apply (frule setsum_SucD)
   1.250      apply clarify
   1.251      apply (rename_tac a)
   1.252 -    apply (subgoal_tac "finite {x. 0 < (f (a := f a - 1)) x}")
   1.253 +    apply (subgoal_tac "finite {x. 0 < (f (a := f a - 1')) x}")
   1.254       prefer 2
   1.255       apply (rule finite_subset)
   1.256        prefer 2
   1.257        apply assumption
   1.258       apply simp
   1.259       apply blast
   1.260 -    apply (subgoal_tac "f = (f (a := f a - 1))(a := (f (a := f a - 1)) a + 1)")
   1.261 +    apply (subgoal_tac "f = (f (a := f a - 1'))(a := (f (a := f a - 1')) a + 1')")
   1.262       prefer 2
   1.263       apply (rule ext)
   1.264       apply (simp (no_asm_simp))
   1.265 @@ -363,10 +363,10 @@
   1.266      apply (erule allE, erule impE, erule_tac [2] mp)
   1.267       apply blast
   1.268      apply (simp (no_asm_simp) add: setsum_decr del: fun_upd_apply)
   1.269 -    apply (subgoal_tac "{x. x \\<noteq> a --> 0 < f x} = {x. 0 < f x}")
   1.270 +    apply (subgoal_tac "{x. x \<noteq> a --> 0 < f x} = {x. 0 < f x}")
   1.271       prefer 2
   1.272       apply blast
   1.273 -    apply (subgoal_tac "{x. x \\<noteq> a \\<and> 0 < f x} = {x. 0 < f x} - {a}")
   1.274 +    apply (subgoal_tac "{x. x \<noteq> a \<and> 0 < f x} = {x. 0 < f x} - {a}")
   1.275       prefer 2
   1.276       apply blast
   1.277      apply (simp add: le_imp_diff_is_add setsum_diff1 cong: conj_cong)
   1.278 @@ -374,8 +374,8 @@
   1.279  qed
   1.280  
   1.281  theorem rep_multiset_induct:
   1.282 -  "f \\<in> multiset ==> P (\\<lambda>a. 0) ==>
   1.283 -    (!!f b. f \\<in> multiset ==> P f ==> P (f (b := f b + 1))) ==> P f"
   1.284 +  "f \<in> multiset ==> P (\<lambda>a. 0) ==>
   1.285 +    (!!f b. f \<in> multiset ==> P f ==> P (f (b := f b + 1'))) ==> P f"
   1.286    apply (insert rep_multiset_induct_aux)
   1.287    apply blast
   1.288    done
   1.289 @@ -390,7 +390,7 @@
   1.290      apply (rule Rep_multiset_inverse [THEN subst])
   1.291      apply (rule Rep_multiset [THEN rep_multiset_induct])
   1.292       apply (rule prem1)
   1.293 -    apply (subgoal_tac "f (b := f b + 1) = (\\<lambda>a. f a + (if a = b then 1 else 0))")
   1.294 +    apply (subgoal_tac "f (b := f b + 1') = (\<lambda>a. f a + (if a = b then 1' else 0))")
   1.295       prefer 2
   1.296       apply (simp add: expand_fun_eq)
   1.297      apply (erule ssubst)
   1.298 @@ -401,7 +401,7 @@
   1.299  
   1.300  
   1.301  lemma MCollect_preserves_multiset:
   1.302 -    "M \\<in> multiset ==> (\\<lambda>x. if P x then M x else 0) \\<in> multiset"
   1.303 +    "M \<in> multiset ==> (\<lambda>x. if P x then M x else 0) \<in> multiset"
   1.304    apply (simp add: multiset_def)
   1.305    apply (rule finite_subset)
   1.306     apply auto
   1.307 @@ -413,11 +413,11 @@
   1.308    apply (simp add: MCollect_preserves_multiset)
   1.309    done
   1.310  
   1.311 -theorem set_of_MCollect [simp]: "set_of {# x:M. P x #} = set_of M \\<inter> {x. P x}"
   1.312 +theorem set_of_MCollect [simp]: "set_of {# x:M. P x #} = set_of M \<inter> {x. P x}"
   1.313    apply (auto simp add: set_of_def)
   1.314    done
   1.315  
   1.316 -theorem multiset_partition: "M = {# x:M. P x #} + {# x:M. \\<not> P x #}"
   1.317 +theorem multiset_partition: "M = {# x:M. P x #} + {# x:M. \<not> P x #}"
   1.318    apply (subst multiset_eq_conv_count_eq)
   1.319    apply auto
   1.320    done
   1.321 @@ -427,7 +427,7 @@
   1.322  
   1.323  theorem add_eq_conv_ex:
   1.324    "(M + {#a#} = N + {#b#}) =
   1.325 -    (M = N \\<and> a = b \\<or> (\\<exists>K. M = K + {#b#} \\<and> N = K + {#a#}))"
   1.326 +    (M = N \<and> a = b \<or> (\<exists>K. M = K + {#b#} \<and> N = K + {#a#}))"
   1.327    apply (auto simp add: add_eq_conv_diff)
   1.328    done
   1.329  
   1.330 @@ -437,41 +437,41 @@
   1.331  subsubsection {* Well-foundedness *}
   1.332  
   1.333  constdefs
   1.334 -  mult1 :: "('a \\<times> 'a) set => ('a multiset \\<times> 'a multiset) set"
   1.335 +  mult1 :: "('a \<times> 'a) set => ('a multiset \<times> 'a multiset) set"
   1.336    "mult1 r ==
   1.337 -    {(N, M). \\<exists>a M0 K. M = M0 + {#a#} \\<and> N = M0 + K \\<and>
   1.338 -      (\\<forall>b. b :# K --> (b, a) \\<in> r)}"
   1.339 +    {(N, M). \<exists>a M0 K. M = M0 + {#a#} \<and> N = M0 + K \<and>
   1.340 +      (\<forall>b. b :# K --> (b, a) \<in> r)}"
   1.341  
   1.342 -  mult :: "('a \\<times> 'a) set => ('a multiset \\<times> 'a multiset) set"
   1.343 +  mult :: "('a \<times> 'a) set => ('a multiset \<times> 'a multiset) set"
   1.344    "mult r == (mult1 r)\<^sup>+"
   1.345  
   1.346 -lemma not_less_empty [iff]: "(M, {#}) \\<notin> mult1 r"
   1.347 +lemma not_less_empty [iff]: "(M, {#}) \<notin> mult1 r"
   1.348    by (simp add: mult1_def)
   1.349  
   1.350 -lemma less_add: "(N, M0 + {#a#}) \\<in> mult1 r ==>
   1.351 -    (\\<exists>M. (M, M0) \\<in> mult1 r \\<and> N = M + {#a#}) \\<or>
   1.352 -    (\\<exists>K. (\\<forall>b. b :# K --> (b, a) \\<in> r) \\<and> N = M0 + K)"
   1.353 -  (concl is "?case1 (mult1 r) \\<or> ?case2")
   1.354 +lemma less_add: "(N, M0 + {#a#}) \<in> mult1 r ==>
   1.355 +    (\<exists>M. (M, M0) \<in> mult1 r \<and> N = M + {#a#}) \<or>
   1.356 +    (\<exists>K. (\<forall>b. b :# K --> (b, a) \<in> r) \<and> N = M0 + K)"
   1.357 +  (concl is "?case1 (mult1 r) \<or> ?case2")
   1.358  proof (unfold mult1_def)
   1.359 -  let ?r = "\\<lambda>K a. \\<forall>b. b :# K --> (b, a) \\<in> r"
   1.360 -  let ?R = "\\<lambda>N M. \\<exists>a M0 K. M = M0 + {#a#} \\<and> N = M0 + K \\<and> ?r K a"
   1.361 +  let ?r = "\<lambda>K a. \<forall>b. b :# K --> (b, a) \<in> r"
   1.362 +  let ?R = "\<lambda>N M. \<exists>a M0 K. M = M0 + {#a#} \<and> N = M0 + K \<and> ?r K a"
   1.363    let ?case1 = "?case1 {(N, M). ?R N M}"
   1.364  
   1.365 -  assume "(N, M0 + {#a#}) \\<in> {(N, M). ?R N M}"
   1.366 -  hence "\\<exists>a' M0' K.
   1.367 -      M0 + {#a#} = M0' + {#a'#} \\<and> N = M0' + K \\<and> ?r K a'" by simp
   1.368 -  thus "?case1 \\<or> ?case2"
   1.369 +  assume "(N, M0 + {#a#}) \<in> {(N, M). ?R N M}"
   1.370 +  hence "\<exists>a' M0' K.
   1.371 +      M0 + {#a#} = M0' + {#a'#} \<and> N = M0' + K \<and> ?r K a'" by simp
   1.372 +  thus "?case1 \<or> ?case2"
   1.373    proof (elim exE conjE)
   1.374      fix a' M0' K
   1.375      assume N: "N = M0' + K" and r: "?r K a'"
   1.376      assume "M0 + {#a#} = M0' + {#a'#}"
   1.377 -    hence "M0 = M0' \\<and> a = a' \\<or>
   1.378 -        (\\<exists>K'. M0 = K' + {#a'#} \\<and> M0' = K' + {#a#})"
   1.379 +    hence "M0 = M0' \<and> a = a' \<or>
   1.380 +        (\<exists>K'. M0 = K' + {#a'#} \<and> M0' = K' + {#a#})"
   1.381        by (simp only: add_eq_conv_ex)
   1.382      thus ?thesis
   1.383      proof (elim disjE conjE exE)
   1.384        assume "M0 = M0'" "a = a'"
   1.385 -      with N r have "?r K a \\<and> N = M0 + K" by simp
   1.386 +      with N r have "?r K a \<and> N = M0 + K" by simp
   1.387        hence ?case2 .. thus ?thesis ..
   1.388      next
   1.389        fix K'
   1.390 @@ -485,78 +485,78 @@
   1.391    qed
   1.392  qed
   1.393  
   1.394 -lemma all_accessible: "wf r ==> \\<forall>M. M \\<in> acc (mult1 r)"
   1.395 +lemma all_accessible: "wf r ==> \<forall>M. M \<in> acc (mult1 r)"
   1.396  proof
   1.397    let ?R = "mult1 r"
   1.398    let ?W = "acc ?R"
   1.399    {
   1.400      fix M M0 a
   1.401 -    assume M0: "M0 \\<in> ?W"
   1.402 -      and wf_hyp: "\\<forall>b. (b, a) \\<in> r --> (\\<forall>M \\<in> ?W. M + {#b#} \\<in> ?W)"
   1.403 -      and acc_hyp: "\\<forall>M. (M, M0) \\<in> ?R --> M + {#a#} \\<in> ?W"
   1.404 -    have "M0 + {#a#} \\<in> ?W"
   1.405 +    assume M0: "M0 \<in> ?W"
   1.406 +      and wf_hyp: "\<forall>b. (b, a) \<in> r --> (\<forall>M \<in> ?W. M + {#b#} \<in> ?W)"
   1.407 +      and acc_hyp: "\<forall>M. (M, M0) \<in> ?R --> M + {#a#} \<in> ?W"
   1.408 +    have "M0 + {#a#} \<in> ?W"
   1.409      proof (rule accI [of "M0 + {#a#}"])
   1.410        fix N
   1.411 -      assume "(N, M0 + {#a#}) \\<in> ?R"
   1.412 -      hence "((\\<exists>M. (M, M0) \\<in> ?R \\<and> N = M + {#a#}) \\<or>
   1.413 -          (\\<exists>K. (\\<forall>b. b :# K --> (b, a) \\<in> r) \\<and> N = M0 + K))"
   1.414 +      assume "(N, M0 + {#a#}) \<in> ?R"
   1.415 +      hence "((\<exists>M. (M, M0) \<in> ?R \<and> N = M + {#a#}) \<or>
   1.416 +          (\<exists>K. (\<forall>b. b :# K --> (b, a) \<in> r) \<and> N = M0 + K))"
   1.417          by (rule less_add)
   1.418 -      thus "N \\<in> ?W"
   1.419 +      thus "N \<in> ?W"
   1.420        proof (elim exE disjE conjE)
   1.421 -        fix M assume "(M, M0) \\<in> ?R" and N: "N = M + {#a#}"
   1.422 -        from acc_hyp have "(M, M0) \\<in> ?R --> M + {#a#} \\<in> ?W" ..
   1.423 -        hence "M + {#a#} \\<in> ?W" ..
   1.424 -        thus "N \\<in> ?W" by (simp only: N)
   1.425 +        fix M assume "(M, M0) \<in> ?R" and N: "N = M + {#a#}"
   1.426 +        from acc_hyp have "(M, M0) \<in> ?R --> M + {#a#} \<in> ?W" ..
   1.427 +        hence "M + {#a#} \<in> ?W" ..
   1.428 +        thus "N \<in> ?W" by (simp only: N)
   1.429        next
   1.430          fix K
   1.431          assume N: "N = M0 + K"
   1.432 -        assume "\\<forall>b. b :# K --> (b, a) \\<in> r"
   1.433 -        have "?this --> M0 + K \\<in> ?W" (is "?P K")
   1.434 +        assume "\<forall>b. b :# K --> (b, a) \<in> r"
   1.435 +        have "?this --> M0 + K \<in> ?W" (is "?P K")
   1.436          proof (induct K)
   1.437 -          from M0 have "M0 + {#} \\<in> ?W" by simp
   1.438 +          from M0 have "M0 + {#} \<in> ?W" by simp
   1.439            thus "?P {#}" ..
   1.440  
   1.441            fix K x assume hyp: "?P K"
   1.442            show "?P (K + {#x#})"
   1.443            proof
   1.444 -            assume a: "\\<forall>b. b :# (K + {#x#}) --> (b, a) \\<in> r"
   1.445 -            hence "(x, a) \\<in> r" by simp
   1.446 -            with wf_hyp have b: "\\<forall>M \\<in> ?W. M + {#x#} \\<in> ?W" by blast
   1.447 +            assume a: "\<forall>b. b :# (K + {#x#}) --> (b, a) \<in> r"
   1.448 +            hence "(x, a) \<in> r" by simp
   1.449 +            with wf_hyp have b: "\<forall>M \<in> ?W. M + {#x#} \<in> ?W" by blast
   1.450  
   1.451 -            from a hyp have "M0 + K \\<in> ?W" by simp
   1.452 -            with b have "(M0 + K) + {#x#} \\<in> ?W" ..
   1.453 -            thus "M0 + (K + {#x#}) \\<in> ?W" by (simp only: union_assoc)
   1.454 +            from a hyp have "M0 + K \<in> ?W" by simp
   1.455 +            with b have "(M0 + K) + {#x#} \<in> ?W" ..
   1.456 +            thus "M0 + (K + {#x#}) \<in> ?W" by (simp only: union_assoc)
   1.457            qed
   1.458          qed
   1.459 -        hence "M0 + K \\<in> ?W" ..
   1.460 -        thus "N \\<in> ?W" by (simp only: N)
   1.461 +        hence "M0 + K \<in> ?W" ..
   1.462 +        thus "N \<in> ?W" by (simp only: N)
   1.463        qed
   1.464      qed
   1.465    } note tedious_reasoning = this
   1.466  
   1.467    assume wf: "wf r"
   1.468    fix M
   1.469 -  show "M \\<in> ?W"
   1.470 +  show "M \<in> ?W"
   1.471    proof (induct M)
   1.472 -    show "{#} \\<in> ?W"
   1.473 +    show "{#} \<in> ?W"
   1.474      proof (rule accI)
   1.475 -      fix b assume "(b, {#}) \\<in> ?R"
   1.476 -      with not_less_empty show "b \\<in> ?W" by contradiction
   1.477 +      fix b assume "(b, {#}) \<in> ?R"
   1.478 +      with not_less_empty show "b \<in> ?W" by contradiction
   1.479      qed
   1.480  
   1.481 -    fix M a assume "M \\<in> ?W"
   1.482 -    from wf have "\\<forall>M \\<in> ?W. M + {#a#} \\<in> ?W"
   1.483 +    fix M a assume "M \<in> ?W"
   1.484 +    from wf have "\<forall>M \<in> ?W. M + {#a#} \<in> ?W"
   1.485      proof induct
   1.486        fix a
   1.487 -      assume "\\<forall>b. (b, a) \\<in> r --> (\\<forall>M \\<in> ?W. M + {#b#} \\<in> ?W)"
   1.488 -      show "\\<forall>M \\<in> ?W. M + {#a#} \\<in> ?W"
   1.489 +      assume "\<forall>b. (b, a) \<in> r --> (\<forall>M \<in> ?W. M + {#b#} \<in> ?W)"
   1.490 +      show "\<forall>M \<in> ?W. M + {#a#} \<in> ?W"
   1.491        proof
   1.492 -        fix M assume "M \\<in> ?W"
   1.493 -        thus "M + {#a#} \\<in> ?W"
   1.494 +        fix M assume "M \<in> ?W"
   1.495 +        thus "M + {#a#} \<in> ?W"
   1.496            by (rule acc_induct) (rule tedious_reasoning)
   1.497        qed
   1.498      qed
   1.499 -    thus "M + {#a#} \\<in> ?W" ..
   1.500 +    thus "M + {#a#} \<in> ?W" ..
   1.501    qed
   1.502  qed
   1.503  
   1.504 @@ -578,9 +578,9 @@
   1.505  text {* One direction. *}
   1.506  
   1.507  lemma mult_implies_one_step:
   1.508 -  "trans r ==> (M, N) \\<in> mult r ==>
   1.509 -    \\<exists>I J K. N = I + J \\<and> M = I + K \\<and> J \\<noteq> {#} \\<and>
   1.510 -    (\\<forall>k \\<in> set_of K. \\<exists>j \\<in> set_of J. (k, j) \\<in> r)"
   1.511 +  "trans r ==> (M, N) \<in> mult r ==>
   1.512 +    \<exists>I J K. N = I + J \<and> M = I + K \<and> J \<noteq> {#} \<and>
   1.513 +    (\<forall>k \<in> set_of K. \<exists>j \<in> set_of J. (k, j) \<in> r)"
   1.514    apply (unfold mult_def mult1_def set_of_def)
   1.515    apply (erule converse_trancl_induct)
   1.516    apply clarify
   1.517 @@ -592,7 +592,7 @@
   1.518     apply (simp (no_asm))
   1.519     apply (rule_tac x = "(K - {#a#}) + Ka" in exI)
   1.520     apply (simp (no_asm_simp) add: union_assoc [symmetric])
   1.521 -   apply (drule_tac f = "\\<lambda>M. M - {#a#}" in arg_cong)
   1.522 +   apply (drule_tac f = "\<lambda>M. M - {#a#}" in arg_cong)
   1.523     apply (simp add: diff_union_single_conv)
   1.524     apply (simp (no_asm_use) add: trans_def)
   1.525     apply blast
   1.526 @@ -603,7 +603,7 @@
   1.527     apply (rule conjI)
   1.528      apply (simp add: multiset_eq_conv_count_eq split: nat_diff_split)
   1.529     apply (rule conjI)
   1.530 -    apply (drule_tac f = "\\<lambda>M. M - {#a#}" in arg_cong)
   1.531 +    apply (drule_tac f = "\<lambda>M. M - {#a#}" in arg_cong)
   1.532      apply simp
   1.533      apply (simp add: multiset_eq_conv_count_eq split: nat_diff_split)
   1.534     apply (simp (no_asm_use) add: trans_def)
   1.535 @@ -617,7 +617,7 @@
   1.536    apply (simp add: multiset_eq_conv_count_eq)
   1.537    done
   1.538  
   1.539 -lemma size_eq_Suc_imp_eq_union: "size M = Suc n ==> \\<exists>a N. M = N + {#a#}"
   1.540 +lemma size_eq_Suc_imp_eq_union: "size M = Suc n ==> \<exists>a N. M = N + {#a#}"
   1.541    apply (erule size_eq_Suc_imp_elem [THEN exE])
   1.542    apply (drule elem_imp_eq_diff_union)
   1.543    apply auto
   1.544 @@ -625,8 +625,8 @@
   1.545  
   1.546  lemma one_step_implies_mult_aux:
   1.547    "trans r ==>
   1.548 -    \\<forall>I J K. (size J = n \\<and> J \\<noteq> {#} \\<and> (\\<forall>k \\<in> set_of K. \\<exists>j \\<in> set_of J. (k, j) \\<in> r))
   1.549 -      --> (I + K, I + J) \\<in> mult r"
   1.550 +    \<forall>I J K. (size J = n \<and> J \<noteq> {#} \<and> (\<forall>k \<in> set_of K. \<exists>j \<in> set_of J. (k, j) \<in> r))
   1.551 +      --> (I + K, I + J) \<in> mult r"
   1.552    apply (induct_tac n)
   1.553     apply auto
   1.554    apply (frule size_eq_Suc_imp_eq_union)
   1.555 @@ -640,15 +640,15 @@
   1.556     apply (rule r_into_trancl)
   1.557     apply (simp add: mult1_def set_of_def)
   1.558     apply blast
   1.559 -  txt {* Now we know @{term "J' \\<noteq> {#}"}. *}
   1.560 -  apply (cut_tac M = K and P = "\\<lambda>x. (x, a) \\<in> r" in multiset_partition)
   1.561 -  apply (erule_tac P = "\\<forall>k \\<in> set_of K. ?P k" in rev_mp)
   1.562 +  txt {* Now we know @{term "J' \<noteq> {#}"}. *}
   1.563 +  apply (cut_tac M = K and P = "\<lambda>x. (x, a) \<in> r" in multiset_partition)
   1.564 +  apply (erule_tac P = "\<forall>k \<in> set_of K. ?P k" in rev_mp)
   1.565    apply (erule ssubst)
   1.566    apply (simp add: Ball_def)
   1.567    apply auto
   1.568    apply (subgoal_tac
   1.569 -    "((I + {# x : K. (x, a) \\<in> r #}) + {# x : K. (x, a) \\<notin> r #},
   1.570 -      (I + {# x : K. (x, a) \\<in> r #}) + J') \\<in> mult r")
   1.571 +    "((I + {# x : K. (x, a) \<in> r #}) + {# x : K. (x, a) \<notin> r #},
   1.572 +      (I + {# x : K. (x, a) \<in> r #}) + J') \<in> mult r")
   1.573     prefer 2
   1.574     apply force
   1.575    apply (simp (no_asm_use) add: union_assoc [symmetric] mult_def)
   1.576 @@ -661,8 +661,8 @@
   1.577    done
   1.578  
   1.579  theorem one_step_implies_mult:
   1.580 -  "trans r ==> J \\<noteq> {#} ==> \\<forall>k \\<in> set_of K. \\<exists>j \\<in> set_of J. (k, j) \\<in> r
   1.581 -    ==> (I + K, I + J) \\<in> mult r"
   1.582 +  "trans r ==> J \<noteq> {#} ==> \<forall>k \<in> set_of K. \<exists>j \<in> set_of J. (k, j) \<in> r
   1.583 +    ==> (I + K, I + J) \<in> mult r"
   1.584    apply (insert one_step_implies_mult_aux)
   1.585    apply blast
   1.586    done
   1.587 @@ -673,8 +673,8 @@
   1.588  instance multiset :: ("term") ord ..
   1.589  
   1.590  defs (overloaded)
   1.591 -  less_multiset_def: "M' < M == (M', M) \\<in> mult {(x', x). x' < x}"
   1.592 -  le_multiset_def: "M' <= M == M' = M \\<or> M' < (M::'a multiset)"
   1.593 +  less_multiset_def: "M' < M == (M', M) \<in> mult {(x', x). x' < x}"
   1.594 +  le_multiset_def: "M' <= M == M' = M \<or> M' < (M::'a multiset)"
   1.595  
   1.596  lemma trans_base_order: "trans {(x', x). x' < (x::'a::order)}"
   1.597    apply (unfold trans_def)
   1.598 @@ -686,12 +686,12 @@
   1.599  *}
   1.600  
   1.601  lemma mult_irrefl_aux:
   1.602 -    "finite A ==> (\\<forall>x \\<in> A. \\<exists>y \\<in> A. x < (y::'a::order)) --> A = {}"
   1.603 +    "finite A ==> (\<forall>x \<in> A. \<exists>y \<in> A. x < (y::'a::order)) --> A = {}"
   1.604    apply (erule finite_induct)
   1.605     apply (auto intro: order_less_trans)
   1.606    done
   1.607  
   1.608 -theorem mult_less_not_refl: "\\<not> M < (M::'a::order multiset)"
   1.609 +theorem mult_less_not_refl: "\<not> M < (M::'a::order multiset)"
   1.610    apply (unfold less_multiset_def)
   1.611    apply auto
   1.612    apply (drule trans_base_order [THEN mult_implies_one_step])
   1.613 @@ -715,7 +715,7 @@
   1.614  
   1.615  text {* Asymmetry. *}
   1.616  
   1.617 -theorem mult_less_not_sym: "M < N ==> \\<not> N < (M::'a::order multiset)"
   1.618 +theorem mult_less_not_sym: "M < N ==> \<not> N < (M::'a::order multiset)"
   1.619    apply auto
   1.620    apply (rule mult_less_not_refl [THEN notE])
   1.621    apply (erule mult_less_trans)
   1.622 @@ -723,7 +723,7 @@
   1.623    done
   1.624  
   1.625  theorem mult_less_asym:
   1.626 -    "M < N ==> (\\<not> P ==> N < (M::'a::order multiset)) ==> P"
   1.627 +    "M < N ==> (\<not> P ==> N < (M::'a::order multiset)) ==> P"
   1.628    apply (insert mult_less_not_sym)
   1.629    apply blast
   1.630    done
   1.631 @@ -749,7 +749,7 @@
   1.632    apply (blast intro: mult_less_trans)
   1.633    done
   1.634  
   1.635 -theorem mult_less_le: "M < N = (M <= N \\<and> M \\<noteq> (N::'a::order multiset))"
   1.636 +theorem mult_less_le: "M < N = (M <= N \<and> M \<noteq> (N::'a::order multiset))"
   1.637    apply (unfold le_multiset_def)
   1.638    apply auto
   1.639    done
   1.640 @@ -770,7 +770,7 @@
   1.641  subsubsection {* Monotonicity of multiset union *}
   1.642  
   1.643  theorem mult1_union:
   1.644 -    "(B, D) \\<in> mult1 r ==> trans r ==> (C + B, C + D) \\<in> mult1 r"
   1.645 +    "(B, D) \<in> mult1 r ==> trans r ==> (C + B, C + D) \<in> mult1 r"
   1.646    apply (unfold mult1_def)
   1.647    apply auto
   1.648    apply (rule_tac x = a in exI)
   1.649 @@ -806,7 +806,7 @@
   1.650    apply (unfold le_multiset_def less_multiset_def)
   1.651    apply (case_tac "M = {#}")
   1.652     prefer 2
   1.653 -   apply (subgoal_tac "({#} + {#}, {#} + M) \\<in> mult (Collect (split op <))")
   1.654 +   apply (subgoal_tac "({#} + {#}, {#} + M) \<in> mult (Collect (split op <))")
   1.655      prefer 2
   1.656      apply (rule one_step_implies_mult)
   1.657        apply (simp only: trans_def)