src/HOL/Map.thy
changeset 24331 76f7a8c6e842
parent 22744 5cbe966d67a2
child 25483 65de74f62874
     1.1 --- a/src/HOL/Map.thy	Sun Aug 19 12:43:05 2007 +0200
     1.2 +++ b/src/HOL/Map.thy	Sun Aug 19 21:21:37 2007 +0200
     1.3 @@ -90,13 +90,13 @@
     1.4  subsection {* @{term [source] empty} *}
     1.5  
     1.6  lemma empty_upd_none [simp]: "empty(x := None) = empty"
     1.7 -  by (rule ext) simp
     1.8 +by (rule ext) simp
     1.9  
    1.10  
    1.11  subsection {* @{term [source] map_upd} *}
    1.12  
    1.13  lemma map_upd_triv: "t k = Some x ==> t(k|->x) = t"
    1.14 -  by (rule ext) simp
    1.15 +by (rule ext) simp
    1.16  
    1.17  lemma map_upd_nonempty [simp]: "t(k|->x) ~= empty"
    1.18  proof
    1.19 @@ -114,344 +114,338 @@
    1.20  qed
    1.21  
    1.22  lemma map_upd_Some_unfold:
    1.23 -    "((m(a|->b)) x = Some y) = (x = a \<and> b = y \<or> x \<noteq> a \<and> m x = Some y)"
    1.24 -  by auto
    1.25 +  "((m(a|->b)) x = Some y) = (x = a \<and> b = y \<or> x \<noteq> a \<and> m x = Some y)"
    1.26 +by auto
    1.27  
    1.28  lemma image_map_upd [simp]: "x \<notin> A \<Longrightarrow> m(x \<mapsto> y) ` A = m ` A"
    1.29 -  by auto
    1.30 +by auto
    1.31  
    1.32  lemma finite_range_updI: "finite (range f) ==> finite (range (f(a|->b)))"
    1.33 -  unfolding image_def
    1.34 -  apply (simp (no_asm_use) add: full_SetCompr_eq)
    1.35 -  apply (rule finite_subset)
    1.36 -   prefer 2 apply assumption
    1.37 -  apply auto
    1.38 -  done
    1.39 +unfolding image_def
    1.40 +apply (simp (no_asm_use) add:full_SetCompr_eq)
    1.41 +apply (rule finite_subset)
    1.42 + prefer 2 apply assumption
    1.43 +apply (auto)
    1.44 +done
    1.45  
    1.46  
    1.47  subsection {* @{term [source] map_of} *}
    1.48  
    1.49  lemma map_of_eq_None_iff:
    1.50 -    "(map_of xys x = None) = (x \<notin> fst ` (set xys))"
    1.51 -  by (induct xys) simp_all
    1.52 +  "(map_of xys x = None) = (x \<notin> fst ` (set xys))"
    1.53 +by (induct xys) simp_all
    1.54  
    1.55 -lemma map_of_is_SomeD:
    1.56 -    "map_of xys x = Some y \<Longrightarrow> (x,y) \<in> set xys"
    1.57 -  apply (induct xys)
    1.58 -   apply simp
    1.59 -  apply (clarsimp split: if_splits)
    1.60 -  done
    1.61 +lemma map_of_is_SomeD: "map_of xys x = Some y \<Longrightarrow> (x,y) \<in> set xys"
    1.62 +apply (induct xys)
    1.63 + apply simp
    1.64 +apply (clarsimp split: if_splits)
    1.65 +done
    1.66  
    1.67  lemma map_of_eq_Some_iff [simp]:
    1.68 -    "distinct(map fst xys) \<Longrightarrow> (map_of xys x = Some y) = ((x,y) \<in> set xys)"
    1.69 -  apply (induct xys)
    1.70 -   apply simp
    1.71 -  apply (auto simp: map_of_eq_None_iff [symmetric])
    1.72 -  done
    1.73 +  "distinct(map fst xys) \<Longrightarrow> (map_of xys x = Some y) = ((x,y) \<in> set xys)"
    1.74 +apply (induct xys)
    1.75 + apply simp
    1.76 +apply (auto simp: map_of_eq_None_iff [symmetric])
    1.77 +done
    1.78  
    1.79  lemma Some_eq_map_of_iff [simp]:
    1.80 -    "distinct(map fst xys) \<Longrightarrow> (Some y = map_of xys x) = ((x,y) \<in> set xys)"
    1.81 -  by (auto simp del:map_of_eq_Some_iff simp add: map_of_eq_Some_iff [symmetric])
    1.82 +  "distinct(map fst xys) \<Longrightarrow> (Some y = map_of xys x) = ((x,y) \<in> set xys)"
    1.83 +by (auto simp del:map_of_eq_Some_iff simp add: map_of_eq_Some_iff [symmetric])
    1.84  
    1.85  lemma map_of_is_SomeI [simp]: "\<lbrakk> distinct(map fst xys); (x,y) \<in> set xys \<rbrakk>
    1.86      \<Longrightarrow> map_of xys x = Some y"
    1.87 -  apply (induct xys)
    1.88 -   apply simp
    1.89 -  apply force
    1.90 -  done
    1.91 +apply (induct xys)
    1.92 + apply simp
    1.93 +apply force
    1.94 +done
    1.95  
    1.96  lemma map_of_zip_is_None [simp]:
    1.97 -    "length xs = length ys \<Longrightarrow> (map_of (zip xs ys) x = None) = (x \<notin> set xs)"
    1.98 -  by (induct rule: list_induct2) simp_all
    1.99 +  "length xs = length ys \<Longrightarrow> (map_of (zip xs ys) x = None) = (x \<notin> set xs)"
   1.100 +by (induct rule: list_induct2) simp_all
   1.101  
   1.102  lemma finite_range_map_of: "finite (range (map_of xys))"
   1.103 -  apply (induct xys)
   1.104 -   apply (simp_all add: image_constant)
   1.105 -  apply (rule finite_subset)
   1.106 -   prefer 2 apply assumption
   1.107 -  apply auto
   1.108 -  done
   1.109 +apply (induct xys)
   1.110 + apply (simp_all add: image_constant)
   1.111 +apply (rule finite_subset)
   1.112 + prefer 2 apply assumption
   1.113 +apply auto
   1.114 +done
   1.115  
   1.116  lemma map_of_SomeD: "map_of xs k = Some y \<Longrightarrow> (k, y) \<in> set xs"
   1.117 -  by (induct xs) (simp, atomize (full), auto)
   1.118 +by (induct xs) (simp, atomize (full), auto)
   1.119  
   1.120  lemma map_of_mapk_SomeI:
   1.121 -  assumes "inj f"
   1.122 -  shows "map_of t k = Some x ==>
   1.123 -    map_of (map (split (%k. Pair (f k))) t) (f k) = Some x"
   1.124 -  by (induct t) (auto simp add: `inj f` inj_eq)
   1.125 +  "inj f ==> map_of t k = Some x ==>
   1.126 +   map_of (map (split (%k. Pair (f k))) t) (f k) = Some x"
   1.127 +by (induct t) (auto simp add: inj_eq)
   1.128  
   1.129  lemma weak_map_of_SomeI: "(k, x) : set l ==> \<exists>x. map_of l k = Some x"
   1.130 -  by (induct l) auto
   1.131 +by (induct l) auto
   1.132  
   1.133  lemma map_of_filter_in:
   1.134 -  assumes 1: "map_of xs k = Some z"
   1.135 -    and 2: "P k z"
   1.136 -  shows "map_of (filter (split P) xs) k = Some z"
   1.137 -  using 1 by (induct xs) (insert 2, auto)
   1.138 +  "map_of xs k = Some z \<Longrightarrow> P k z \<Longrightarrow> map_of (filter (split P) xs) k = Some z"
   1.139 +by (induct xs) auto
   1.140  
   1.141  lemma map_of_map: "map_of (map (%(a,b). (a,f b)) xs) x = option_map f (map_of xs x)"
   1.142 -  by (induct xs) auto
   1.143 +by (induct xs) auto
   1.144  
   1.145  
   1.146  subsection {* @{term [source] option_map} related *}
   1.147  
   1.148  lemma option_map_o_empty [simp]: "option_map f o empty = empty"
   1.149 -  by (rule ext) simp
   1.150 +by (rule ext) simp
   1.151  
   1.152  lemma option_map_o_map_upd [simp]:
   1.153 -    "option_map f o m(a|->b) = (option_map f o m)(a|->f b)"
   1.154 -  by (rule ext) simp
   1.155 +  "option_map f o m(a|->b) = (option_map f o m)(a|->f b)"
   1.156 +by (rule ext) simp
   1.157  
   1.158  
   1.159  subsection {* @{term [source] map_comp} related *}
   1.160  
   1.161  lemma map_comp_empty [simp]:
   1.162 -    "m \<circ>\<^sub>m empty = empty"
   1.163 -    "empty \<circ>\<^sub>m m = empty"
   1.164 -  by (auto simp add: map_comp_def intro: ext split: option.splits)
   1.165 +  "m \<circ>\<^sub>m empty = empty"
   1.166 +  "empty \<circ>\<^sub>m m = empty"
   1.167 +by (auto simp add: map_comp_def intro: ext split: option.splits)
   1.168  
   1.169  lemma map_comp_simps [simp]:
   1.170 -    "m2 k = None \<Longrightarrow> (m1 \<circ>\<^sub>m m2) k = None"
   1.171 -    "m2 k = Some k' \<Longrightarrow> (m1 \<circ>\<^sub>m m2) k = m1 k'"
   1.172 -  by (auto simp add: map_comp_def)
   1.173 +  "m2 k = None \<Longrightarrow> (m1 \<circ>\<^sub>m m2) k = None"
   1.174 +  "m2 k = Some k' \<Longrightarrow> (m1 \<circ>\<^sub>m m2) k = m1 k'"
   1.175 +by (auto simp add: map_comp_def)
   1.176  
   1.177  lemma map_comp_Some_iff:
   1.178 -    "((m1 \<circ>\<^sub>m m2) k = Some v) = (\<exists>k'. m2 k = Some k' \<and> m1 k' = Some v)"
   1.179 -  by (auto simp add: map_comp_def split: option.splits)
   1.180 +  "((m1 \<circ>\<^sub>m m2) k = Some v) = (\<exists>k'. m2 k = Some k' \<and> m1 k' = Some v)"
   1.181 +by (auto simp add: map_comp_def split: option.splits)
   1.182  
   1.183  lemma map_comp_None_iff:
   1.184 -    "((m1 \<circ>\<^sub>m m2) k = None) = (m2 k = None \<or> (\<exists>k'. m2 k = Some k' \<and> m1 k' = None)) "
   1.185 -  by (auto simp add: map_comp_def split: option.splits)
   1.186 +  "((m1 \<circ>\<^sub>m m2) k = None) = (m2 k = None \<or> (\<exists>k'. m2 k = Some k' \<and> m1 k' = None)) "
   1.187 +by (auto simp add: map_comp_def split: option.splits)
   1.188  
   1.189  
   1.190  subsection {* @{text "++"} *}
   1.191  
   1.192  lemma map_add_empty[simp]: "m ++ empty = m"
   1.193 -  unfolding map_add_def by simp
   1.194 +by(simp add: map_add_def)
   1.195  
   1.196  lemma empty_map_add[simp]: "empty ++ m = m"
   1.197 -  unfolding map_add_def by (rule ext) (simp split: option.split)
   1.198 +by (rule ext) (simp add: map_add_def split: option.split)
   1.199  
   1.200  lemma map_add_assoc[simp]: "m1 ++ (m2 ++ m3) = (m1 ++ m2) ++ m3"
   1.201 -  unfolding map_add_def by (rule ext) (simp add: map_add_def split: option.split)
   1.202 +by (rule ext) (simp add: map_add_def split: option.split)
   1.203  
   1.204  lemma map_add_Some_iff:
   1.205 -    "((m ++ n) k = Some x) = (n k = Some x | n k = None & m k = Some x)"
   1.206 -  unfolding map_add_def by (simp split: option.split)
   1.207 +  "((m ++ n) k = Some x) = (n k = Some x | n k = None & m k = Some x)"
   1.208 +by (simp add: map_add_def split: option.split)
   1.209  
   1.210  lemma map_add_SomeD [dest!]:
   1.211 -    "(m ++ n) k = Some x \<Longrightarrow> n k = Some x \<or> n k = None \<and> m k = Some x"
   1.212 -  by (rule map_add_Some_iff [THEN iffD1])
   1.213 +  "(m ++ n) k = Some x \<Longrightarrow> n k = Some x \<or> n k = None \<and> m k = Some x"
   1.214 +by (rule map_add_Some_iff [THEN iffD1])
   1.215  
   1.216  lemma map_add_find_right [simp]: "!!xx. n k = Some xx ==> (m ++ n) k = Some xx"
   1.217 -  by (subst map_add_Some_iff) fast
   1.218 +by (subst map_add_Some_iff) fast
   1.219  
   1.220  lemma map_add_None [iff]: "((m ++ n) k = None) = (n k = None & m k = None)"
   1.221 -  unfolding map_add_def by (simp split: option.split)
   1.222 +by (simp add: map_add_def split: option.split)
   1.223  
   1.224  lemma map_add_upd[simp]: "f ++ g(x|->y) = (f ++ g)(x|->y)"
   1.225 -  unfolding map_add_def by (rule ext) simp
   1.226 +by (rule ext) (simp add: map_add_def)
   1.227  
   1.228  lemma map_add_upds[simp]: "m1 ++ (m2(xs[\<mapsto>]ys)) = (m1++m2)(xs[\<mapsto>]ys)"
   1.229 -  by (simp add: map_upds_def)
   1.230 +by (simp add: map_upds_def)
   1.231  
   1.232  lemma map_of_append[simp]: "map_of (xs @ ys) = map_of ys ++ map_of xs"
   1.233 -  unfolding map_add_def
   1.234 -  apply (induct xs)
   1.235 -   apply simp
   1.236 -  apply (rule ext)
   1.237 -  apply (simp split add: option.split)
   1.238 -  done
   1.239 +unfolding map_add_def
   1.240 +apply (induct xs)
   1.241 + apply simp
   1.242 +apply (rule ext)
   1.243 +apply (simp split add: option.split)
   1.244 +done
   1.245  
   1.246  lemma finite_range_map_of_map_add:
   1.247    "finite (range f) ==> finite (range (f ++ map_of l))"
   1.248 -  apply (induct l)
   1.249 -   apply (auto simp del: fun_upd_apply)
   1.250 -  apply (erule finite_range_updI)
   1.251 -  done
   1.252 +apply (induct l)
   1.253 + apply (auto simp del: fun_upd_apply)
   1.254 +apply (erule finite_range_updI)
   1.255 +done
   1.256  
   1.257  lemma inj_on_map_add_dom [iff]:
   1.258 -    "inj_on (m ++ m') (dom m') = inj_on m' (dom m')"
   1.259 -  unfolding map_add_def dom_def inj_on_def
   1.260 -  by (fastsimp split: option.splits)
   1.261 +  "inj_on (m ++ m') (dom m') = inj_on m' (dom m')"
   1.262 +by (fastsimp simp: map_add_def dom_def inj_on_def split: option.splits)
   1.263  
   1.264  
   1.265  subsection {* @{term [source] restrict_map} *}
   1.266  
   1.267  lemma restrict_map_to_empty [simp]: "m|`{} = empty"
   1.268 -  by (simp add: restrict_map_def)
   1.269 +by (simp add: restrict_map_def)
   1.270  
   1.271  lemma restrict_map_empty [simp]: "empty|`D = empty"
   1.272 -  by (simp add: restrict_map_def)
   1.273 +by (simp add: restrict_map_def)
   1.274  
   1.275  lemma restrict_in [simp]: "x \<in> A \<Longrightarrow> (m|`A) x = m x"
   1.276 -  by (simp add: restrict_map_def)
   1.277 +by (simp add: restrict_map_def)
   1.278  
   1.279  lemma restrict_out [simp]: "x \<notin> A \<Longrightarrow> (m|`A) x = None"
   1.280 -  by (simp add: restrict_map_def)
   1.281 +by (simp add: restrict_map_def)
   1.282  
   1.283  lemma ran_restrictD: "y \<in> ran (m|`A) \<Longrightarrow> \<exists>x\<in>A. m x = Some y"
   1.284 -  by (auto simp: restrict_map_def ran_def split: split_if_asm)
   1.285 +by (auto simp: restrict_map_def ran_def split: split_if_asm)
   1.286  
   1.287  lemma dom_restrict [simp]: "dom (m|`A) = dom m \<inter> A"
   1.288 -  by (auto simp: restrict_map_def dom_def split: split_if_asm)
   1.289 +by (auto simp: restrict_map_def dom_def split: split_if_asm)
   1.290  
   1.291  lemma restrict_upd_same [simp]: "m(x\<mapsto>y)|`(-{x}) = m|`(-{x})"
   1.292 -  by (rule ext) (auto simp: restrict_map_def)
   1.293 +by (rule ext) (auto simp: restrict_map_def)
   1.294  
   1.295  lemma restrict_restrict [simp]: "m|`A|`B = m|`(A\<inter>B)"
   1.296 -  by (rule ext) (auto simp: restrict_map_def)
   1.297 +by (rule ext) (auto simp: restrict_map_def)
   1.298  
   1.299  lemma restrict_fun_upd [simp]:
   1.300 -    "m(x := y)|`D = (if x \<in> D then (m|`(D-{x}))(x := y) else m|`D)"
   1.301 -  by (simp add: restrict_map_def expand_fun_eq)
   1.302 +  "m(x := y)|`D = (if x \<in> D then (m|`(D-{x}))(x := y) else m|`D)"
   1.303 +by (simp add: restrict_map_def expand_fun_eq)
   1.304  
   1.305  lemma fun_upd_None_restrict [simp]:
   1.306 -    "(m|`D)(x := None) = (if x:D then m|`(D - {x}) else m|`D)"
   1.307 -  by (simp add: restrict_map_def expand_fun_eq)
   1.308 +  "(m|`D)(x := None) = (if x:D then m|`(D - {x}) else m|`D)"
   1.309 +by (simp add: restrict_map_def expand_fun_eq)
   1.310  
   1.311  lemma fun_upd_restrict: "(m|`D)(x := y) = (m|`(D-{x}))(x := y)"
   1.312 -  by (simp add: restrict_map_def expand_fun_eq)
   1.313 +by (simp add: restrict_map_def expand_fun_eq)
   1.314  
   1.315  lemma fun_upd_restrict_conv [simp]:
   1.316 -    "x \<in> D \<Longrightarrow> (m|`D)(x := y) = (m|`(D-{x}))(x := y)"
   1.317 -  by (simp add: restrict_map_def expand_fun_eq)
   1.318 +  "x \<in> D \<Longrightarrow> (m|`D)(x := y) = (m|`(D-{x}))(x := y)"
   1.319 +by (simp add: restrict_map_def expand_fun_eq)
   1.320  
   1.321  
   1.322  subsection {* @{term [source] map_upds} *}
   1.323  
   1.324  lemma map_upds_Nil1 [simp]: "m([] [|->] bs) = m"
   1.325 -  by (simp add: map_upds_def)
   1.326 +by (simp add: map_upds_def)
   1.327  
   1.328  lemma map_upds_Nil2 [simp]: "m(as [|->] []) = m"
   1.329 -  by (simp add:map_upds_def)
   1.330 +by (simp add:map_upds_def)
   1.331  
   1.332  lemma map_upds_Cons [simp]: "m(a#as [|->] b#bs) = (m(a|->b))(as[|->]bs)"
   1.333 -  by (simp add:map_upds_def)
   1.334 +by (simp add:map_upds_def)
   1.335  
   1.336  lemma map_upds_append1 [simp]: "\<And>ys m. size xs < size ys \<Longrightarrow>
   1.337 -    m(xs@[x] [\<mapsto>] ys) = m(xs [\<mapsto>] ys)(x \<mapsto> ys!size xs)"
   1.338 -  apply(induct xs)
   1.339 -   apply (clarsimp simp add: neq_Nil_conv)
   1.340 -  apply (case_tac ys)
   1.341 -   apply simp
   1.342 -  apply simp
   1.343 -  done
   1.344 +  m(xs@[x] [\<mapsto>] ys) = m(xs [\<mapsto>] ys)(x \<mapsto> ys!size xs)"
   1.345 +apply(induct xs)
   1.346 + apply (clarsimp simp add: neq_Nil_conv)
   1.347 +apply (case_tac ys)
   1.348 + apply simp
   1.349 +apply simp
   1.350 +done
   1.351  
   1.352  lemma map_upds_list_update2_drop [simp]:
   1.353    "\<lbrakk>size xs \<le> i; i < size ys\<rbrakk>
   1.354      \<Longrightarrow> m(xs[\<mapsto>]ys[i:=y]) = m(xs[\<mapsto>]ys)"
   1.355 -  apply (induct xs arbitrary: m ys i)
   1.356 -   apply simp
   1.357 -  apply (case_tac ys)
   1.358 -   apply simp
   1.359 -  apply (simp split: nat.split)
   1.360 -  done
   1.361 +apply (induct xs arbitrary: m ys i)
   1.362 + apply simp
   1.363 +apply (case_tac ys)
   1.364 + apply simp
   1.365 +apply (simp split: nat.split)
   1.366 +done
   1.367  
   1.368  lemma map_upd_upds_conv_if:
   1.369    "(f(x|->y))(xs [|->] ys) =
   1.370     (if x : set(take (length ys) xs) then f(xs [|->] ys)
   1.371                                      else (f(xs [|->] ys))(x|->y))"
   1.372 -  apply (induct xs arbitrary: x y ys f)
   1.373 -   apply simp
   1.374 -  apply (case_tac ys)
   1.375 -   apply (auto split: split_if simp: fun_upd_twist)
   1.376 -  done
   1.377 +apply (induct xs arbitrary: x y ys f)
   1.378 + apply simp
   1.379 +apply (case_tac ys)
   1.380 + apply (auto split: split_if simp: fun_upd_twist)
   1.381 +done
   1.382  
   1.383  lemma map_upds_twist [simp]:
   1.384 -    "a ~: set as ==> m(a|->b)(as[|->]bs) = m(as[|->]bs)(a|->b)"
   1.385 -  using set_take_subset by (fastsimp simp add: map_upd_upds_conv_if)
   1.386 +  "a ~: set as ==> m(a|->b)(as[|->]bs) = m(as[|->]bs)(a|->b)"
   1.387 +using set_take_subset by (fastsimp simp add: map_upd_upds_conv_if)
   1.388  
   1.389  lemma map_upds_apply_nontin [simp]:
   1.390 -    "x ~: set xs ==> (f(xs[|->]ys)) x = f x"
   1.391 -  apply (induct xs arbitrary: ys)
   1.392 -   apply simp
   1.393 -  apply (case_tac ys)
   1.394 -   apply (auto simp: map_upd_upds_conv_if)
   1.395 -  done
   1.396 +  "x ~: set xs ==> (f(xs[|->]ys)) x = f x"
   1.397 +apply (induct xs arbitrary: ys)
   1.398 + apply simp
   1.399 +apply (case_tac ys)
   1.400 + apply (auto simp: map_upd_upds_conv_if)
   1.401 +done
   1.402  
   1.403  lemma fun_upds_append_drop [simp]:
   1.404 -    "size xs = size ys \<Longrightarrow> m(xs@zs[\<mapsto>]ys) = m(xs[\<mapsto>]ys)"
   1.405 -  apply (induct xs arbitrary: m ys)
   1.406 -   apply simp
   1.407 -  apply (case_tac ys)
   1.408 -   apply simp_all
   1.409 -  done
   1.410 +  "size xs = size ys \<Longrightarrow> m(xs@zs[\<mapsto>]ys) = m(xs[\<mapsto>]ys)"
   1.411 +apply (induct xs arbitrary: m ys)
   1.412 + apply simp
   1.413 +apply (case_tac ys)
   1.414 + apply simp_all
   1.415 +done
   1.416  
   1.417  lemma fun_upds_append2_drop [simp]:
   1.418 -    "size xs = size ys \<Longrightarrow> m(xs[\<mapsto>]ys@zs) = m(xs[\<mapsto>]ys)"
   1.419 -  apply (induct xs arbitrary: m ys)
   1.420 -   apply simp
   1.421 -  apply (case_tac ys)
   1.422 -   apply simp_all
   1.423 -  done
   1.424 +  "size xs = size ys \<Longrightarrow> m(xs[\<mapsto>]ys@zs) = m(xs[\<mapsto>]ys)"
   1.425 +apply (induct xs arbitrary: m ys)
   1.426 + apply simp
   1.427 +apply (case_tac ys)
   1.428 + apply simp_all
   1.429 +done
   1.430  
   1.431  
   1.432  lemma restrict_map_upds[simp]:
   1.433    "\<lbrakk> length xs = length ys; set xs \<subseteq> D \<rbrakk>
   1.434      \<Longrightarrow> m(xs [\<mapsto>] ys)|`D = (m|`(D - set xs))(xs [\<mapsto>] ys)"
   1.435 -  apply (induct xs arbitrary: m ys)
   1.436 -   apply simp
   1.437 -  apply (case_tac ys)
   1.438 -   apply simp
   1.439 -  apply (simp add: Diff_insert [symmetric] insert_absorb)
   1.440 -  apply (simp add: map_upd_upds_conv_if)
   1.441 -  done
   1.442 +apply (induct xs arbitrary: m ys)
   1.443 + apply simp
   1.444 +apply (case_tac ys)
   1.445 + apply simp
   1.446 +apply (simp add: Diff_insert [symmetric] insert_absorb)
   1.447 +apply (simp add: map_upd_upds_conv_if)
   1.448 +done
   1.449  
   1.450  
   1.451  subsection {* @{term [source] dom} *}
   1.452  
   1.453  lemma domI: "m a = Some b ==> a : dom m"
   1.454 -  unfolding dom_def by simp
   1.455 +by(simp add:dom_def)
   1.456  (* declare domI [intro]? *)
   1.457  
   1.458  lemma domD: "a : dom m ==> \<exists>b. m a = Some b"
   1.459 -  by (cases "m a") (auto simp add: dom_def)
   1.460 +by (cases "m a") (auto simp add: dom_def)
   1.461  
   1.462  lemma domIff [iff, simp del]: "(a : dom m) = (m a ~= None)"
   1.463 -  unfolding dom_def by simp
   1.464 +by(simp add:dom_def)
   1.465  
   1.466  lemma dom_empty [simp]: "dom empty = {}"
   1.467 -  unfolding dom_def by simp
   1.468 +by(simp add:dom_def)
   1.469  
   1.470  lemma dom_fun_upd [simp]:
   1.471 -    "dom(f(x := y)) = (if y=None then dom f - {x} else insert x (dom f))"
   1.472 -  unfolding dom_def by auto
   1.473 +  "dom(f(x := y)) = (if y=None then dom f - {x} else insert x (dom f))"
   1.474 +by(auto simp add:dom_def)
   1.475  
   1.476  lemma dom_map_of: "dom(map_of xys) = {x. \<exists>y. (x,y) : set xys}"
   1.477 -  by (induct xys) (auto simp del: fun_upd_apply)
   1.478 +by (induct xys) (auto simp del: fun_upd_apply)
   1.479  
   1.480  lemma dom_map_of_conv_image_fst:
   1.481 -    "dom(map_of xys) = fst ` (set xys)"
   1.482 -  unfolding dom_map_of by force
   1.483 +  "dom(map_of xys) = fst ` (set xys)"
   1.484 +by(force simp: dom_map_of)
   1.485  
   1.486  lemma dom_map_of_zip [simp]: "[| length xs = length ys; distinct xs |] ==>
   1.487 -    dom(map_of(zip xs ys)) = set xs"
   1.488 -  by (induct rule: list_induct2) simp_all
   1.489 +  dom(map_of(zip xs ys)) = set xs"
   1.490 +by (induct rule: list_induct2) simp_all
   1.491  
   1.492  lemma finite_dom_map_of: "finite (dom (map_of l))"
   1.493 -  unfolding dom_def
   1.494 -  by (induct l) (auto simp add: insert_Collect [symmetric])
   1.495 +by (induct l) (auto simp add: dom_def insert_Collect [symmetric])
   1.496  
   1.497  lemma dom_map_upds [simp]:
   1.498 -    "dom(m(xs[|->]ys)) = set(take (length ys) xs) Un dom m"
   1.499 -  apply (induct xs arbitrary: m ys)
   1.500 -   apply simp
   1.501 -  apply (case_tac ys)
   1.502 -   apply auto
   1.503 -  done
   1.504 +  "dom(m(xs[|->]ys)) = set(take (length ys) xs) Un dom m"
   1.505 +apply (induct xs arbitrary: m ys)
   1.506 + apply simp
   1.507 +apply (case_tac ys)
   1.508 + apply auto
   1.509 +done
   1.510  
   1.511  lemma dom_map_add [simp]: "dom(m++n) = dom n Un dom m"
   1.512 -  unfolding dom_def by auto
   1.513 +by(auto simp:dom_def)
   1.514  
   1.515  lemma dom_override_on [simp]:
   1.516    "dom(override_on f g A) =
   1.517      (dom f  - {a. a : A - dom g}) Un {a. a : A Int dom g}"
   1.518 -  unfolding dom_def override_on_def by auto
   1.519 +by(auto simp: dom_def override_on_def)
   1.520  
   1.521  lemma map_add_comm: "dom m1 \<inter> dom m2 = {} \<Longrightarrow> m1++m2 = m2++m1"
   1.522 -  by (rule ext) (force simp: map_add_def dom_def split: option.split)
   1.523 +by (rule ext) (force simp: map_add_def dom_def split: option.split)
   1.524  
   1.525  (* Due to John Matthews - could be rephrased with dom *)
   1.526  lemma finite_map_freshness:
   1.527 @@ -462,68 +456,68 @@
   1.528  subsection {* @{term [source] ran} *}
   1.529  
   1.530  lemma ranI: "m a = Some b ==> b : ran m"
   1.531 -  unfolding ran_def by auto
   1.532 +by(auto simp: ran_def)
   1.533  (* declare ranI [intro]? *)
   1.534  
   1.535  lemma ran_empty [simp]: "ran empty = {}"
   1.536 -  unfolding ran_def by simp
   1.537 +by(auto simp: ran_def)
   1.538  
   1.539  lemma ran_map_upd [simp]: "m a = None ==> ran(m(a|->b)) = insert b (ran m)"
   1.540 -  unfolding ran_def
   1.541 -  apply auto
   1.542 -  apply (subgoal_tac "aa ~= a")
   1.543 -   apply auto
   1.544 -  done
   1.545 +unfolding ran_def
   1.546 +apply auto
   1.547 +apply (subgoal_tac "aa ~= a")
   1.548 + apply auto
   1.549 +done
   1.550  
   1.551  
   1.552  subsection {* @{text "map_le"} *}
   1.553  
   1.554  lemma map_le_empty [simp]: "empty \<subseteq>\<^sub>m g"
   1.555 -  by (simp add: map_le_def)
   1.556 +by (simp add: map_le_def)
   1.557  
   1.558  lemma upd_None_map_le [simp]: "f(x := None) \<subseteq>\<^sub>m f"
   1.559 -  by (force simp add: map_le_def)
   1.560 +by (force simp add: map_le_def)
   1.561  
   1.562  lemma map_le_upd[simp]: "f \<subseteq>\<^sub>m g ==> f(a := b) \<subseteq>\<^sub>m g(a := b)"
   1.563 -  by (fastsimp simp add: map_le_def)
   1.564 +by (fastsimp simp add: map_le_def)
   1.565  
   1.566  lemma map_le_imp_upd_le [simp]: "m1 \<subseteq>\<^sub>m m2 \<Longrightarrow> m1(x := None) \<subseteq>\<^sub>m m2(x \<mapsto> y)"
   1.567 -  by (force simp add: map_le_def)
   1.568 +by (force simp add: map_le_def)
   1.569  
   1.570  lemma map_le_upds [simp]:
   1.571 -    "f \<subseteq>\<^sub>m g ==> f(as [|->] bs) \<subseteq>\<^sub>m g(as [|->] bs)"
   1.572 -  apply (induct as arbitrary: f g bs)
   1.573 -   apply simp
   1.574 -  apply (case_tac bs)
   1.575 -   apply auto
   1.576 -  done
   1.577 +  "f \<subseteq>\<^sub>m g ==> f(as [|->] bs) \<subseteq>\<^sub>m g(as [|->] bs)"
   1.578 +apply (induct as arbitrary: f g bs)
   1.579 + apply simp
   1.580 +apply (case_tac bs)
   1.581 + apply auto
   1.582 +done
   1.583  
   1.584  lemma map_le_implies_dom_le: "(f \<subseteq>\<^sub>m g) \<Longrightarrow> (dom f \<subseteq> dom g)"
   1.585 -  by (fastsimp simp add: map_le_def dom_def)
   1.586 +by (fastsimp simp add: map_le_def dom_def)
   1.587  
   1.588  lemma map_le_refl [simp]: "f \<subseteq>\<^sub>m f"
   1.589 -  by (simp add: map_le_def)
   1.590 +by (simp add: map_le_def)
   1.591  
   1.592  lemma map_le_trans[trans]: "\<lbrakk> m1 \<subseteq>\<^sub>m m2; m2 \<subseteq>\<^sub>m m3\<rbrakk> \<Longrightarrow> m1 \<subseteq>\<^sub>m m3"
   1.593 -  by (auto simp add: map_le_def dom_def)
   1.594 +by (auto simp add: map_le_def dom_def)
   1.595  
   1.596  lemma map_le_antisym: "\<lbrakk> f \<subseteq>\<^sub>m g; g \<subseteq>\<^sub>m f \<rbrakk> \<Longrightarrow> f = g"
   1.597 -  unfolding map_le_def
   1.598 -  apply (rule ext)
   1.599 -  apply (case_tac "x \<in> dom f", simp)
   1.600 -  apply (case_tac "x \<in> dom g", simp, fastsimp)
   1.601 -  done
   1.602 +unfolding map_le_def
   1.603 +apply (rule ext)
   1.604 +apply (case_tac "x \<in> dom f", simp)
   1.605 +apply (case_tac "x \<in> dom g", simp, fastsimp)
   1.606 +done
   1.607  
   1.608  lemma map_le_map_add [simp]: "f \<subseteq>\<^sub>m (g ++ f)"
   1.609 -  by (fastsimp simp add: map_le_def)
   1.610 +by (fastsimp simp add: map_le_def)
   1.611  
   1.612  lemma map_le_iff_map_add_commute: "(f \<subseteq>\<^sub>m f ++ g) = (f++g = g++f)"
   1.613 -  by (fastsimp simp add: map_add_def map_le_def expand_fun_eq split: option.splits)
   1.614 +by(fastsimp simp: map_add_def map_le_def expand_fun_eq split: option.splits)
   1.615  
   1.616  lemma map_add_le_mapE: "f++g \<subseteq>\<^sub>m h \<Longrightarrow> g \<subseteq>\<^sub>m h"
   1.617 -  by (fastsimp simp add: map_le_def map_add_def dom_def)
   1.618 +by (fastsimp simp add: map_le_def map_add_def dom_def)
   1.619  
   1.620  lemma map_add_le_mapI: "\<lbrakk> f \<subseteq>\<^sub>m h; g \<subseteq>\<^sub>m h; f \<subseteq>\<^sub>m f++g \<rbrakk> \<Longrightarrow> f++g \<subseteq>\<^sub>m h"
   1.621 -  by (clarsimp simp add: map_le_def map_add_def dom_def split: option.splits)
   1.622 +by (clarsimp simp add: map_le_def map_add_def dom_def split: option.splits)
   1.623  
   1.624  end