src/HOL/Map.thy
changeset 20800 69c82605efcf
parent 19947 29b376397cd5
child 21210 c17fd2df4e9e
     1.1 --- a/src/HOL/Map.thy	Sat Sep 30 21:39:22 2006 +0200
     1.2 +++ b/src/HOL/Map.thy	Sat Sep 30 21:39:24 2006 +0200
     1.3 @@ -12,35 +12,47 @@
     1.4  imports List
     1.5  begin
     1.6  
     1.7 -types ('a,'b) "~=>" = "'a => 'b option" (infixr 0)
     1.8 +types ('a,'b) "~=>" = "'a => 'b option"  (infixr 0)
     1.9  translations (type) "a ~=> b " <= (type) "a => b option"
    1.10  
    1.11  syntax (xsymbols)
    1.12 -  "~=>"     :: "[type, type] => type"    (infixr "\<rightharpoonup>" 0)
    1.13 +  "~=>" :: "[type, type] => type"  (infixr "\<rightharpoonup>" 0)
    1.14  
    1.15  abbreviation
    1.16 -  empty     ::  "'a ~=> 'b"
    1.17 +  empty :: "'a ~=> 'b"
    1.18    "empty == %x. None"
    1.19  
    1.20  definition
    1.21 -  map_comp :: "('b ~=> 'c)  => ('a ~=> 'b) => ('a ~=> 'c)" (infixl "o'_m" 55)
    1.22 -  "f o_m g  == (\<lambda>k. case g k of None \<Rightarrow> None | Some v \<Rightarrow> f v)"
    1.23 +  map_comp :: "('b ~=> 'c)  => ('a ~=> 'b) => ('a ~=> 'c)"  (infixl "o'_m" 55)
    1.24 +  "f o_m g = (\<lambda>k. case g k of None \<Rightarrow> None | Some v \<Rightarrow> f v)"
    1.25  
    1.26  const_syntax (xsymbols)
    1.27    map_comp  (infixl "\<circ>\<^sub>m" 55)
    1.28  
    1.29 -consts
    1.30 -map_add :: "('a ~=> 'b) => ('a ~=> 'b) => ('a ~=> 'b)" (infixl "++" 100)
    1.31 -restrict_map :: "('a ~=> 'b) => 'a set => ('a ~=> 'b)" (infixl "|`"  110)
    1.32 -dom	:: "('a ~=> 'b) => 'a set"
    1.33 -ran	:: "('a ~=> 'b) => 'b set"
    1.34 -map_of	:: "('a * 'b)list => 'a ~=> 'b"
    1.35 -map_upds:: "('a ~=> 'b) => 'a list => 'b list => ('a ~=> 'b)"
    1.36 -map_le  :: "('a ~=> 'b) => ('a ~=> 'b) => bool" (infix "\<subseteq>\<^sub>m" 50)
    1.37 +definition
    1.38 +  map_add :: "('a ~=> 'b) => ('a ~=> 'b) => ('a ~=> 'b)"  (infixl "++" 100)
    1.39 +  "m1 ++ m2 = (\<lambda>x. case m2 x of None => m1 x | Some y => Some y)"
    1.40 +
    1.41 +  restrict_map :: "('a ~=> 'b) => 'a set => ('a ~=> 'b)"  (infixl "|`"  110)
    1.42 +  "m|`A = (\<lambda>x. if x : A then m x else None)"
    1.43  
    1.44  const_syntax (latex output)
    1.45    restrict_map  ("_\<restriction>\<^bsub>_\<^esub>" [111,110] 110)
    1.46  
    1.47 +definition
    1.48 +  dom :: "('a ~=> 'b) => 'a set"
    1.49 +  "dom m = {a. m a ~= None}"
    1.50 +
    1.51 +  ran :: "('a ~=> 'b) => 'b set"
    1.52 +  "ran m = {b. EX a. m a = Some b}"
    1.53 +
    1.54 +  map_le :: "('a ~=> 'b) => ('a ~=> 'b) => bool"  (infix "\<subseteq>\<^sub>m" 50)
    1.55 +  "(m\<^isub>1 \<subseteq>\<^sub>m m\<^isub>2) = (\<forall>a \<in> dom m\<^isub>1. m\<^isub>1 a = m\<^isub>2 a)"
    1.56 +
    1.57 +consts
    1.58 +  map_of :: "('a * 'b) list => 'a ~=> 'b"
    1.59 +  map_upds :: "('a ~=> 'b) => 'a list => 'b list => ('a ~=> 'b)"
    1.60 +
    1.61  nonterminals
    1.62    maplets maplet
    1.63  
    1.64 @@ -64,503 +76,472 @@
    1.65    "_Map (_Maplets ms1 ms2)"     <= "_MapUpd (_Map ms1) ms2"
    1.66    "_Maplets ms1 (_Maplets ms2 ms3)" <= "_Maplets (_Maplets ms1 ms2) ms3"
    1.67  
    1.68 -defs
    1.69 -map_add_def:   "m1++m2 == %x. case m2 x of None => m1 x | Some y => Some y"
    1.70 -restrict_map_def: "m|`A == %x. if x : A then m x else None"
    1.71 -
    1.72 -map_upds_def: "m(xs [|->] ys) == m ++ map_of (rev(zip xs ys))"
    1.73 -
    1.74 -dom_def: "dom(m) == {a. m a ~= None}"
    1.75 -ran_def: "ran(m) == {b. EX a. m a = Some b}"
    1.76 -
    1.77 -map_le_def: "m\<^isub>1 \<subseteq>\<^sub>m m\<^isub>2  ==  ALL a : dom m\<^isub>1. m\<^isub>1 a = m\<^isub>2 a"
    1.78 -
    1.79  primrec
    1.80    "map_of [] = empty"
    1.81    "map_of (p#ps) = (map_of ps)(fst p |-> snd p)"
    1.82  
    1.83 +defs
    1.84 +  map_upds_def: "m(xs [|->] ys) == m ++ map_of (rev(zip xs ys))"
    1.85 +
    1.86  (* special purpose constants that should be defined somewhere else and
    1.87  whose syntax is a bit odd as well:
    1.88  
    1.89   "@chg_map" :: "('a ~=> 'b) => 'a => ('b => 'b) => ('a ~=> 'b)"
    1.90 -					  ("_/'(_/\<mapsto>\<lambda>_. _')"  [900,0,0,0] 900)
    1.91 +                                          ("_/'(_/\<mapsto>\<lambda>_. _')"  [900,0,0,0] 900)
    1.92    "m(x\<mapsto>\<lambda>y. f)" == "chg_map (\<lambda>y. f) x m"
    1.93  
    1.94 -map_upd_s::"('a ~=> 'b) => 'a set => 'b => 
    1.95 -	    ('a ~=> 'b)"			 ("_/'(_{|->}_/')" [900,0,0]900)
    1.96 -map_subst::"('a ~=> 'b) => 'b => 'b => 
    1.97 -	    ('a ~=> 'b)"			 ("_/'(_~>_/')"    [900,0,0]900)
    1.98 +map_upd_s::"('a ~=> 'b) => 'a set => 'b =>
    1.99 +            ('a ~=> 'b)"                         ("_/'(_{|->}_/')" [900,0,0]900)
   1.100 +map_subst::"('a ~=> 'b) => 'b => 'b =>
   1.101 +            ('a ~=> 'b)"                         ("_/'(_~>_/')"    [900,0,0]900)
   1.102  
   1.103  map_upd_s_def: "m(as{|->}b) == %x. if x : as then Some b else m x"
   1.104  map_subst_def: "m(a~>b)     == %x. if m x = Some a then Some b else m x"
   1.105  
   1.106    map_upd_s  :: "('a ~=> 'b) => 'a set => 'b => ('a ~=> 'b)"
   1.107 -				    		 ("_/'(_/{\<mapsto>}/_')" [900,0,0]900)
   1.108 -  map_subst :: "('a ~=> 'b) => 'b => 'b => 
   1.109 -	        ('a ~=> 'b)"			 ("_/'(_\<leadsto>_/')"    [900,0,0]900)
   1.110 +                                                 ("_/'(_/{\<mapsto>}/_')" [900,0,0]900)
   1.111 +  map_subst :: "('a ~=> 'b) => 'b => 'b =>
   1.112 +                ('a ~=> 'b)"                     ("_/'(_\<leadsto>_/')"    [900,0,0]900)
   1.113  
   1.114  
   1.115  subsection {* @{term [source] map_upd_s} *}
   1.116  
   1.117 -lemma map_upd_s_apply [simp]: 
   1.118 +lemma map_upd_s_apply [simp]:
   1.119    "(m(as{|->}b)) x = (if x : as then Some b else m x)"
   1.120  by (simp add: map_upd_s_def)
   1.121  
   1.122 -lemma map_subst_apply [simp]: 
   1.123 -  "(m(a~>b)) x = (if m x = Some a then Some b else m x)" 
   1.124 +lemma map_subst_apply [simp]:
   1.125 +  "(m(a~>b)) x = (if m x = Some a then Some b else m x)"
   1.126  by (simp add: map_subst_def)
   1.127  
   1.128  *)
   1.129  
   1.130 +
   1.131  subsection {* @{term [source] empty} *}
   1.132  
   1.133 -lemma empty_upd_none[simp]: "empty(x := None) = empty"
   1.134 -apply (rule ext)
   1.135 -apply (simp (no_asm))
   1.136 -done
   1.137 -
   1.138 +lemma empty_upd_none [simp]: "empty(x := None) = empty"
   1.139 +  by (rule ext) simp
   1.140  
   1.141  (* FIXME: what is this sum_case nonsense?? *)
   1.142  lemma sum_case_empty_empty[simp]: "sum_case empty empty = empty"
   1.143 -apply (rule ext)
   1.144 -apply (simp (no_asm) split add: sum.split)
   1.145 -done
   1.146 +  by (rule ext) (simp split: sum.split)
   1.147 +
   1.148  
   1.149  subsection {* @{term [source] map_upd} *}
   1.150  
   1.151  lemma map_upd_triv: "t k = Some x ==> t(k|->x) = t"
   1.152 -apply (rule ext)
   1.153 -apply (simp (no_asm_simp))
   1.154 -done
   1.155 +  by (rule ext) simp
   1.156  
   1.157 -lemma map_upd_nonempty[simp]: "t(k|->x) ~= empty"
   1.158 -apply safe
   1.159 -apply (drule_tac x = k in fun_cong)
   1.160 -apply (simp (no_asm_use))
   1.161 -done
   1.162 +lemma map_upd_nonempty [simp]: "t(k|->x) ~= empty"
   1.163 +proof
   1.164 +  assume "t(k \<mapsto> x) = empty"
   1.165 +  then have "(t(k \<mapsto> x)) k = None" by simp
   1.166 +  then show False by simp
   1.167 +qed
   1.168  
   1.169 -lemma map_upd_eqD1: "m(a\<mapsto>x) = n(a\<mapsto>y) \<Longrightarrow> x = y"
   1.170 -by (drule fun_cong [of _ _ a], auto)
   1.171 +lemma map_upd_eqD1:
   1.172 +  assumes "m(a\<mapsto>x) = n(a\<mapsto>y)"
   1.173 +  shows "x = y"
   1.174 +proof -
   1.175 +  from prems have "(m(a\<mapsto>x)) a = (n(a\<mapsto>y)) a" by simp
   1.176 +  then show ?thesis by simp
   1.177 +qed
   1.178  
   1.179 -lemma map_upd_Some_unfold: 
   1.180 -  "((m(a|->b)) x = Some y) = (x = a \<and> b = y \<or> x \<noteq> a \<and> m x = Some y)"
   1.181 -by auto
   1.182 +lemma map_upd_Some_unfold:
   1.183 +    "((m(a|->b)) x = Some y) = (x = a \<and> b = y \<or> x \<noteq> a \<and> m x = Some y)"
   1.184 +  by auto
   1.185  
   1.186 -lemma image_map_upd[simp]: "x \<notin> A \<Longrightarrow> m(x \<mapsto> y) ` A = m ` A"
   1.187 -by fastsimp
   1.188 +lemma image_map_upd [simp]: "x \<notin> A \<Longrightarrow> m(x \<mapsto> y) ` A = m ` A"
   1.189 +  by auto
   1.190  
   1.191  lemma finite_range_updI: "finite (range f) ==> finite (range (f(a|->b)))"
   1.192 -apply (unfold image_def)
   1.193 -apply (simp (no_asm_use) add: full_SetCompr_eq)
   1.194 -apply (rule finite_subset)
   1.195 -prefer 2 apply assumption
   1.196 -apply auto
   1.197 -done
   1.198 +  unfolding image_def
   1.199 +  apply (simp (no_asm_use) add: full_SetCompr_eq)
   1.200 +  apply (rule finite_subset)
   1.201 +   prefer 2 apply assumption
   1.202 +  apply auto
   1.203 +  done
   1.204  
   1.205  
   1.206  (* FIXME: what is this sum_case nonsense?? *)
   1.207  subsection {* @{term [source] sum_case} and @{term [source] empty}/@{term [source] map_upd} *}
   1.208  
   1.209 -lemma sum_case_map_upd_empty[simp]:
   1.210 - "sum_case (m(k|->y)) empty =  (sum_case m empty)(Inl k|->y)"
   1.211 -apply (rule ext)
   1.212 -apply (simp (no_asm) split add: sum.split)
   1.213 -done
   1.214 +lemma sum_case_map_upd_empty [simp]:
   1.215 +    "sum_case (m(k|->y)) empty = (sum_case m empty)(Inl k|->y)"
   1.216 +  by (rule ext) (simp split: sum.split)
   1.217  
   1.218 -lemma sum_case_empty_map_upd[simp]:
   1.219 - "sum_case empty (m(k|->y)) =  (sum_case empty m)(Inr k|->y)"
   1.220 -apply (rule ext)
   1.221 -apply (simp (no_asm) split add: sum.split)
   1.222 -done
   1.223 +lemma sum_case_empty_map_upd [simp]:
   1.224 +    "sum_case empty (m(k|->y)) = (sum_case empty m)(Inr k|->y)"
   1.225 +  by (rule ext) (simp split: sum.split)
   1.226  
   1.227 -lemma sum_case_map_upd_map_upd[simp]:
   1.228 - "sum_case (m1(k1|->y1)) (m2(k2|->y2)) = (sum_case (m1(k1|->y1)) m2)(Inr k2|->y2)"
   1.229 -apply (rule ext)
   1.230 -apply (simp (no_asm) split add: sum.split)
   1.231 -done
   1.232 +lemma sum_case_map_upd_map_upd [simp]:
   1.233 +    "sum_case (m1(k1|->y1)) (m2(k2|->y2)) = (sum_case (m1(k1|->y1)) m2)(Inr k2|->y2)"
   1.234 +  by (rule ext) (simp split: sum.split)
   1.235  
   1.236  
   1.237  subsection {* @{term [source] map_of} *}
   1.238  
   1.239  lemma map_of_eq_None_iff:
   1.240 - "(map_of xys x = None) = (x \<notin> fst ` (set xys))"
   1.241 -by (induct xys) simp_all
   1.242 +    "(map_of xys x = None) = (x \<notin> fst ` (set xys))"
   1.243 +  by (induct xys) simp_all
   1.244  
   1.245  lemma map_of_is_SomeD:
   1.246 - "map_of xys x = Some y \<Longrightarrow> (x,y) \<in> set xys"
   1.247 -apply(induct xys)
   1.248 - apply simp
   1.249 -apply(clarsimp split:if_splits)
   1.250 -done
   1.251 +    "map_of xys x = Some y \<Longrightarrow> (x,y) \<in> set xys"
   1.252 +  apply (induct xys)
   1.253 +   apply simp
   1.254 +  apply (clarsimp split: if_splits)
   1.255 +  done
   1.256  
   1.257 -lemma map_of_eq_Some_iff[simp]:
   1.258 - "distinct(map fst xys) \<Longrightarrow> (map_of xys x = Some y) = ((x,y) \<in> set xys)"
   1.259 -apply(induct xys)
   1.260 - apply(simp)
   1.261 -apply(auto simp:map_of_eq_None_iff[symmetric])
   1.262 -done
   1.263 +lemma map_of_eq_Some_iff [simp]:
   1.264 +    "distinct(map fst xys) \<Longrightarrow> (map_of xys x = Some y) = ((x,y) \<in> set xys)"
   1.265 +  apply (induct xys)
   1.266 +   apply simp
   1.267 +  apply (auto simp: map_of_eq_None_iff [symmetric])
   1.268 +  done
   1.269  
   1.270 -lemma Some_eq_map_of_iff[simp]:
   1.271 - "distinct(map fst xys) \<Longrightarrow> (Some y = map_of xys x) = ((x,y) \<in> set xys)"
   1.272 -by(auto simp del:map_of_eq_Some_iff simp add:map_of_eq_Some_iff[symmetric])
   1.273 +lemma Some_eq_map_of_iff [simp]:
   1.274 +    "distinct(map fst xys) \<Longrightarrow> (Some y = map_of xys x) = ((x,y) \<in> set xys)"
   1.275 +  by (auto simp del:map_of_eq_Some_iff simp add: map_of_eq_Some_iff [symmetric])
   1.276  
   1.277  lemma map_of_is_SomeI [simp]: "\<lbrakk> distinct(map fst xys); (x,y) \<in> set xys \<rbrakk>
   1.278 -  \<Longrightarrow> map_of xys x = Some y"
   1.279 -apply (induct xys)
   1.280 - apply simp
   1.281 -apply force
   1.282 -done
   1.283 +    \<Longrightarrow> map_of xys x = Some y"
   1.284 +  apply (induct xys)
   1.285 +   apply simp
   1.286 +  apply force
   1.287 +  done
   1.288  
   1.289 -lemma map_of_zip_is_None[simp]:
   1.290 -  "length xs = length ys \<Longrightarrow> (map_of (zip xs ys) x = None) = (x \<notin> set xs)"
   1.291 -by (induct rule:list_induct2, simp_all)
   1.292 +lemma map_of_zip_is_None [simp]:
   1.293 +    "length xs = length ys \<Longrightarrow> (map_of (zip xs ys) x = None) = (x \<notin> set xs)"
   1.294 +  by (induct rule: list_induct2) simp_all
   1.295  
   1.296  lemma finite_range_map_of: "finite (range (map_of xys))"
   1.297 -apply (induct xys)
   1.298 -apply  (simp_all (no_asm) add: image_constant)
   1.299 -apply (rule finite_subset)
   1.300 -prefer 2 apply assumption
   1.301 -apply auto
   1.302 -done
   1.303 +  apply (induct xys)
   1.304 +   apply (simp_all add: image_constant)
   1.305 +  apply (rule finite_subset)
   1.306 +   prefer 2 apply assumption
   1.307 +  apply auto
   1.308 +  done
   1.309  
   1.310 -lemma map_of_SomeD [rule_format]: "map_of xs k = Some y --> (k,y):set xs"
   1.311 -by (induct "xs", auto)
   1.312 +lemma map_of_SomeD: "map_of xs k = Some y \<Longrightarrow> (k, y) \<in> set xs"
   1.313 +  by (induct xs) (simp, atomize (full), auto)
   1.314  
   1.315 -lemma map_of_mapk_SomeI [rule_format]:
   1.316 -     "inj f ==> map_of t k = Some x -->  
   1.317 -        map_of (map (split (%k. Pair (f k))) t) (f k) = Some x"
   1.318 -apply (induct "t")
   1.319 -apply  (auto simp add: inj_eq)
   1.320 -done
   1.321 +lemma map_of_mapk_SomeI:
   1.322 +  assumes "inj f"
   1.323 +  shows "map_of t k = Some x ==>
   1.324 +    map_of (map (split (%k. Pair (f k))) t) (f k) = Some x"
   1.325 +  by (induct t) (auto simp add: `inj f` inj_eq)
   1.326  
   1.327 -lemma weak_map_of_SomeI [rule_format]:
   1.328 -     "(k, x) : set l --> (\<exists>x. map_of l k = Some x)"
   1.329 -by (induct "l", auto)
   1.330 +lemma weak_map_of_SomeI: "(k, x) : set l ==> \<exists>x. map_of l k = Some x"
   1.331 +  by (induct l) auto
   1.332  
   1.333 -lemma map_of_filter_in: 
   1.334 -"[| map_of xs k = Some z; P k z |] ==> map_of (filter (split P) xs) k = Some z"
   1.335 -apply (rule mp)
   1.336 -prefer 2 apply assumption
   1.337 -apply (erule thin_rl)
   1.338 -apply (induct "xs", auto)
   1.339 -done
   1.340 +lemma map_of_filter_in:
   1.341 +  assumes 1: "map_of xs k = Some z"
   1.342 +    and 2: "P k z"
   1.343 +  shows "map_of (filter (split P) xs) k = Some z"
   1.344 +  using 1 by (induct xs) (insert 2, auto)
   1.345  
   1.346  lemma map_of_map: "map_of (map (%(a,b). (a,f b)) xs) x = option_map f (map_of xs x)"
   1.347 -by (induct "xs", auto)
   1.348 +  by (induct xs) auto
   1.349  
   1.350  
   1.351  subsection {* @{term [source] option_map} related *}
   1.352  
   1.353 -lemma option_map_o_empty[simp]: "option_map f o empty = empty"
   1.354 -apply (rule ext)
   1.355 -apply (simp (no_asm))
   1.356 -done
   1.357 +lemma option_map_o_empty [simp]: "option_map f o empty = empty"
   1.358 +  by (rule ext) simp
   1.359  
   1.360 -lemma option_map_o_map_upd[simp]:
   1.361 - "option_map f o m(a|->b) = (option_map f o m)(a|->f b)"
   1.362 -apply (rule ext)
   1.363 -apply (simp (no_asm))
   1.364 -done
   1.365 +lemma option_map_o_map_upd [simp]:
   1.366 +    "option_map f o m(a|->b) = (option_map f o m)(a|->f b)"
   1.367 +  by (rule ext) simp
   1.368 +
   1.369  
   1.370  subsection {* @{term [source] map_comp} related *}
   1.371  
   1.372 -lemma map_comp_empty [simp]: 
   1.373 -  "m \<circ>\<^sub>m empty = empty"
   1.374 -  "empty \<circ>\<^sub>m m = empty"
   1.375 +lemma map_comp_empty [simp]:
   1.376 +    "m \<circ>\<^sub>m empty = empty"
   1.377 +    "empty \<circ>\<^sub>m m = empty"
   1.378    by (auto simp add: map_comp_def intro: ext split: option.splits)
   1.379  
   1.380 -lemma map_comp_simps [simp]: 
   1.381 -  "m2 k = None \<Longrightarrow> (m1 \<circ>\<^sub>m m2) k = None"
   1.382 -  "m2 k = Some k' \<Longrightarrow> (m1 \<circ>\<^sub>m m2) k = m1 k'" 
   1.383 +lemma map_comp_simps [simp]:
   1.384 +    "m2 k = None \<Longrightarrow> (m1 \<circ>\<^sub>m m2) k = None"
   1.385 +    "m2 k = Some k' \<Longrightarrow> (m1 \<circ>\<^sub>m m2) k = m1 k'"
   1.386    by (auto simp add: map_comp_def)
   1.387  
   1.388  lemma map_comp_Some_iff:
   1.389 -  "((m1 \<circ>\<^sub>m m2) k = Some v) = (\<exists>k'. m2 k = Some k' \<and> m1 k' = Some v)" 
   1.390 +    "((m1 \<circ>\<^sub>m m2) k = Some v) = (\<exists>k'. m2 k = Some k' \<and> m1 k' = Some v)"
   1.391    by (auto simp add: map_comp_def split: option.splits)
   1.392  
   1.393  lemma map_comp_None_iff:
   1.394 -  "((m1 \<circ>\<^sub>m m2) k = None) = (m2 k = None \<or> (\<exists>k'. m2 k = Some k' \<and> m1 k' = None)) " 
   1.395 +    "((m1 \<circ>\<^sub>m m2) k = None) = (m2 k = None \<or> (\<exists>k'. m2 k = Some k' \<and> m1 k' = None)) "
   1.396    by (auto simp add: map_comp_def split: option.splits)
   1.397  
   1.398 +
   1.399  subsection {* @{text "++"} *}
   1.400  
   1.401  lemma map_add_empty[simp]: "m ++ empty = m"
   1.402 -apply (unfold map_add_def)
   1.403 -apply (simp (no_asm))
   1.404 -done
   1.405 +  unfolding map_add_def by simp
   1.406  
   1.407  lemma empty_map_add[simp]: "empty ++ m = m"
   1.408 -apply (unfold map_add_def)
   1.409 -apply (rule ext)
   1.410 -apply (simp split add: option.split)
   1.411 -done
   1.412 +  unfolding map_add_def by (rule ext) (simp split: option.split)
   1.413  
   1.414  lemma map_add_assoc[simp]: "m1 ++ (m2 ++ m3) = (m1 ++ m2) ++ m3"
   1.415 -apply(rule ext)
   1.416 -apply(simp add: map_add_def split:option.split)
   1.417 -done
   1.418 +  unfolding map_add_def by (rule ext) (simp add: map_add_def split: option.split)
   1.419 +
   1.420 +lemma map_add_Some_iff:
   1.421 +    "((m ++ n) k = Some x) = (n k = Some x | n k = None & m k = Some x)"
   1.422 +  unfolding map_add_def by (simp split: option.split)
   1.423  
   1.424 -lemma map_add_Some_iff: 
   1.425 - "((m ++ n) k = Some x) = (n k = Some x | n k = None & m k = Some x)"
   1.426 -apply (unfold map_add_def)
   1.427 -apply (simp (no_asm) split add: option.split)
   1.428 -done
   1.429 +lemma map_add_SomeD [dest!]:
   1.430 +    "(m ++ n) k = Some x \<Longrightarrow> n k = Some x \<or> n k = None \<and> m k = Some x"
   1.431 +  by (rule map_add_Some_iff [THEN iffD1])
   1.432  
   1.433 -lemmas map_add_SomeD = map_add_Some_iff [THEN iffD1, standard]
   1.434 -declare map_add_SomeD [dest!]
   1.435 -
   1.436 -lemma map_add_find_right[simp]: "!!xx. n k = Some xx ==> (m ++ n) k = Some xx"
   1.437 -by (subst map_add_Some_iff, fast)
   1.438 +lemma map_add_find_right [simp]: "!!xx. n k = Some xx ==> (m ++ n) k = Some xx"
   1.439 +  by (subst map_add_Some_iff) fast
   1.440  
   1.441  lemma map_add_None [iff]: "((m ++ n) k = None) = (n k = None & m k = None)"
   1.442 -apply (unfold map_add_def)
   1.443 -apply (simp (no_asm) split add: option.split)
   1.444 -done
   1.445 +  unfolding map_add_def by (simp split: option.split)
   1.446  
   1.447  lemma map_add_upd[simp]: "f ++ g(x|->y) = (f ++ g)(x|->y)"
   1.448 -apply (unfold map_add_def)
   1.449 -apply (rule ext, auto)
   1.450 -done
   1.451 +  unfolding map_add_def by (rule ext) simp
   1.452  
   1.453  lemma map_add_upds[simp]: "m1 ++ (m2(xs[\<mapsto>]ys)) = (m1++m2)(xs[\<mapsto>]ys)"
   1.454 -by(simp add:map_upds_def)
   1.455 +  by (simp add: map_upds_def)
   1.456  
   1.457 -lemma map_of_append[simp]: "map_of (xs@ys) = map_of ys ++ map_of xs"
   1.458 -apply (unfold map_add_def)
   1.459 -apply (induct "xs")
   1.460 -apply (simp (no_asm))
   1.461 -apply (rule ext)
   1.462 -apply (simp (no_asm_simp) split add: option.split)
   1.463 -done
   1.464 +lemma map_of_append[simp]: "map_of (xs @ ys) = map_of ys ++ map_of xs"
   1.465 +  unfolding map_add_def
   1.466 +  apply (induct xs)
   1.467 +   apply simp
   1.468 +  apply (rule ext)
   1.469 +  apply (simp split add: option.split)
   1.470 +  done
   1.471  
   1.472 -declare fun_upd_apply [simp del]
   1.473  lemma finite_range_map_of_map_add:
   1.474 - "finite (range f) ==> finite (range (f ++ map_of l))"
   1.475 -apply (induct "l", auto)
   1.476 -apply (erule finite_range_updI)
   1.477 -done
   1.478 -declare fun_upd_apply [simp]
   1.479 +  "finite (range f) ==> finite (range (f ++ map_of l))"
   1.480 +  apply (induct l)
   1.481 +   apply (auto simp del: fun_upd_apply)
   1.482 +  apply (erule finite_range_updI)
   1.483 +  done
   1.484  
   1.485 -lemma inj_on_map_add_dom[iff]:
   1.486 - "inj_on (m ++ m') (dom m') = inj_on m' (dom m')"
   1.487 -by(fastsimp simp add:map_add_def dom_def inj_on_def split:option.splits)
   1.488 +lemma inj_on_map_add_dom [iff]:
   1.489 +    "inj_on (m ++ m') (dom m') = inj_on m' (dom m')"
   1.490 +  unfolding map_add_def dom_def inj_on_def
   1.491 +  by (fastsimp split: option.splits)
   1.492 +
   1.493  
   1.494  subsection {* @{term [source] restrict_map} *}
   1.495  
   1.496 -lemma restrict_map_to_empty[simp]: "m|`{} = empty"
   1.497 -by(simp add: restrict_map_def)
   1.498 +lemma restrict_map_to_empty [simp]: "m|`{} = empty"
   1.499 +  by (simp add: restrict_map_def)
   1.500  
   1.501 -lemma restrict_map_empty[simp]: "empty|`D = empty"
   1.502 -by(simp add: restrict_map_def)
   1.503 +lemma restrict_map_empty [simp]: "empty|`D = empty"
   1.504 +  by (simp add: restrict_map_def)
   1.505  
   1.506  lemma restrict_in [simp]: "x \<in> A \<Longrightarrow> (m|`A) x = m x"
   1.507 -by (auto simp: restrict_map_def)
   1.508 +  by (simp add: restrict_map_def)
   1.509  
   1.510  lemma restrict_out [simp]: "x \<notin> A \<Longrightarrow> (m|`A) x = None"
   1.511 -by (auto simp: restrict_map_def)
   1.512 +  by (simp add: restrict_map_def)
   1.513  
   1.514  lemma ran_restrictD: "y \<in> ran (m|`A) \<Longrightarrow> \<exists>x\<in>A. m x = Some y"
   1.515 -by (auto simp: restrict_map_def ran_def split: split_if_asm)
   1.516 +  by (auto simp: restrict_map_def ran_def split: split_if_asm)
   1.517  
   1.518  lemma dom_restrict [simp]: "dom (m|`A) = dom m \<inter> A"
   1.519 -by (auto simp: restrict_map_def dom_def split: split_if_asm)
   1.520 +  by (auto simp: restrict_map_def dom_def split: split_if_asm)
   1.521  
   1.522  lemma restrict_upd_same [simp]: "m(x\<mapsto>y)|`(-{x}) = m|`(-{x})"
   1.523 -by (rule ext, auto simp: restrict_map_def)
   1.524 +  by (rule ext) (auto simp: restrict_map_def)
   1.525  
   1.526  lemma restrict_restrict [simp]: "m|`A|`B = m|`(A\<inter>B)"
   1.527 -by (rule ext, auto simp: restrict_map_def)
   1.528 +  by (rule ext) (auto simp: restrict_map_def)
   1.529  
   1.530 -lemma restrict_fun_upd[simp]:
   1.531 - "m(x := y)|`D = (if x \<in> D then (m|`(D-{x}))(x := y) else m|`D)"
   1.532 -by(simp add: restrict_map_def expand_fun_eq)
   1.533 +lemma restrict_fun_upd [simp]:
   1.534 +    "m(x := y)|`D = (if x \<in> D then (m|`(D-{x}))(x := y) else m|`D)"
   1.535 +  by (simp add: restrict_map_def expand_fun_eq)
   1.536  
   1.537 -lemma fun_upd_None_restrict[simp]:
   1.538 -  "(m|`D)(x := None) = (if x:D then m|`(D - {x}) else m|`D)"
   1.539 -by(simp add: restrict_map_def expand_fun_eq)
   1.540 +lemma fun_upd_None_restrict [simp]:
   1.541 +    "(m|`D)(x := None) = (if x:D then m|`(D - {x}) else m|`D)"
   1.542 +  by (simp add: restrict_map_def expand_fun_eq)
   1.543  
   1.544 -lemma fun_upd_restrict:
   1.545 - "(m|`D)(x := y) = (m|`(D-{x}))(x := y)"
   1.546 -by(simp add: restrict_map_def expand_fun_eq)
   1.547 +lemma fun_upd_restrict: "(m|`D)(x := y) = (m|`(D-{x}))(x := y)"
   1.548 +  by (simp add: restrict_map_def expand_fun_eq)
   1.549  
   1.550 -lemma fun_upd_restrict_conv[simp]:
   1.551 - "x \<in> D \<Longrightarrow> (m|`D)(x := y) = (m|`(D-{x}))(x := y)"
   1.552 -by(simp add: restrict_map_def expand_fun_eq)
   1.553 +lemma fun_upd_restrict_conv [simp]:
   1.554 +    "x \<in> D \<Longrightarrow> (m|`D)(x := y) = (m|`(D-{x}))(x := y)"
   1.555 +  by (simp add: restrict_map_def expand_fun_eq)
   1.556  
   1.557  
   1.558  subsection {* @{term [source] map_upds} *}
   1.559  
   1.560 -lemma map_upds_Nil1[simp]: "m([] [|->] bs) = m"
   1.561 -by(simp add:map_upds_def)
   1.562 +lemma map_upds_Nil1 [simp]: "m([] [|->] bs) = m"
   1.563 +  by (simp add: map_upds_def)
   1.564  
   1.565 -lemma map_upds_Nil2[simp]: "m(as [|->] []) = m"
   1.566 -by(simp add:map_upds_def)
   1.567 +lemma map_upds_Nil2 [simp]: "m(as [|->] []) = m"
   1.568 +  by (simp add:map_upds_def)
   1.569 +
   1.570 +lemma map_upds_Cons [simp]: "m(a#as [|->] b#bs) = (m(a|->b))(as[|->]bs)"
   1.571 +  by (simp add:map_upds_def)
   1.572  
   1.573 -lemma map_upds_Cons[simp]: "m(a#as [|->] b#bs) = (m(a|->b))(as[|->]bs)"
   1.574 -by(simp add:map_upds_def)
   1.575 -
   1.576 -lemma map_upds_append1[simp]: "\<And>ys m. size xs < size ys \<Longrightarrow>
   1.577 -  m(xs@[x] [\<mapsto>] ys) = m(xs [\<mapsto>] ys)(x \<mapsto> ys!size xs)"
   1.578 -apply(induct xs)
   1.579 - apply(clarsimp simp add:neq_Nil_conv)
   1.580 -apply (case_tac ys, simp, simp)
   1.581 -done
   1.582 +lemma map_upds_append1 [simp]: "\<And>ys m. size xs < size ys \<Longrightarrow>
   1.583 +    m(xs@[x] [\<mapsto>] ys) = m(xs [\<mapsto>] ys)(x \<mapsto> ys!size xs)"
   1.584 +  apply(induct xs)
   1.585 +   apply (clarsimp simp add: neq_Nil_conv)
   1.586 +  apply (case_tac ys)
   1.587 +   apply simp
   1.588 +  apply simp
   1.589 +  done
   1.590  
   1.591 -lemma map_upds_list_update2_drop[simp]:
   1.592 - "\<And>m ys i. \<lbrakk>size xs \<le> i; i < size ys\<rbrakk>
   1.593 -     \<Longrightarrow> m(xs[\<mapsto>]ys[i:=y]) = m(xs[\<mapsto>]ys)"
   1.594 -apply (induct xs, simp)
   1.595 -apply (case_tac ys, simp)
   1.596 -apply(simp split:nat.split)
   1.597 -done
   1.598 +lemma map_upds_list_update2_drop [simp]:
   1.599 +  "\<lbrakk>size xs \<le> i; i < size ys\<rbrakk>
   1.600 +    \<Longrightarrow> m(xs[\<mapsto>]ys[i:=y]) = m(xs[\<mapsto>]ys)"
   1.601 +  apply (induct xs arbitrary: m ys i)
   1.602 +   apply simp
   1.603 +  apply (case_tac ys)
   1.604 +   apply simp
   1.605 +  apply (simp split: nat.split)
   1.606 +  done
   1.607  
   1.608 -lemma map_upd_upds_conv_if: "!!x y ys f.
   1.609 - (f(x|->y))(xs [|->] ys) =
   1.610 - (if x : set(take (length ys) xs) then f(xs [|->] ys)
   1.611 -                                  else (f(xs [|->] ys))(x|->y))"
   1.612 -apply (induct xs, simp)
   1.613 -apply(case_tac ys)
   1.614 - apply(auto split:split_if simp:fun_upd_twist)
   1.615 -done
   1.616 +lemma map_upd_upds_conv_if:
   1.617 +  "(f(x|->y))(xs [|->] ys) =
   1.618 +   (if x : set(take (length ys) xs) then f(xs [|->] ys)
   1.619 +                                    else (f(xs [|->] ys))(x|->y))"
   1.620 +  apply (induct xs arbitrary: x y ys f)
   1.621 +   apply simp
   1.622 +  apply (case_tac ys)
   1.623 +   apply (auto split: split_if simp: fun_upd_twist)
   1.624 +  done
   1.625  
   1.626  lemma map_upds_twist [simp]:
   1.627 - "a ~: set as ==> m(a|->b)(as[|->]bs) = m(as[|->]bs)(a|->b)"
   1.628 -apply(insert set_take_subset)
   1.629 -apply (fastsimp simp add: map_upd_upds_conv_if)
   1.630 -done
   1.631 +    "a ~: set as ==> m(a|->b)(as[|->]bs) = m(as[|->]bs)(a|->b)"
   1.632 +  using set_take_subset by (fastsimp simp add: map_upd_upds_conv_if)
   1.633  
   1.634 -lemma map_upds_apply_nontin[simp]:
   1.635 - "!!ys. x ~: set xs ==> (f(xs[|->]ys)) x = f x"
   1.636 -apply (induct xs, simp)
   1.637 -apply(case_tac ys)
   1.638 - apply(auto simp: map_upd_upds_conv_if)
   1.639 -done
   1.640 +lemma map_upds_apply_nontin [simp]:
   1.641 +    "x ~: set xs ==> (f(xs[|->]ys)) x = f x"
   1.642 +  apply (induct xs arbitrary: ys)
   1.643 +   apply simp
   1.644 +  apply (case_tac ys)
   1.645 +   apply (auto simp: map_upd_upds_conv_if)
   1.646 +  done
   1.647  
   1.648 -lemma fun_upds_append_drop[simp]:
   1.649 -  "!!m ys. size xs = size ys \<Longrightarrow> m(xs@zs[\<mapsto>]ys) = m(xs[\<mapsto>]ys)"
   1.650 -apply(induct xs)
   1.651 - apply (simp)
   1.652 -apply(case_tac ys)
   1.653 -apply simp_all
   1.654 -done
   1.655 +lemma fun_upds_append_drop [simp]:
   1.656 +    "size xs = size ys \<Longrightarrow> m(xs@zs[\<mapsto>]ys) = m(xs[\<mapsto>]ys)"
   1.657 +  apply (induct xs arbitrary: m ys)
   1.658 +   apply simp
   1.659 +  apply (case_tac ys)
   1.660 +   apply simp_all
   1.661 +  done
   1.662  
   1.663 -lemma fun_upds_append2_drop[simp]:
   1.664 -  "!!m ys. size xs = size ys \<Longrightarrow> m(xs[\<mapsto>]ys@zs) = m(xs[\<mapsto>]ys)"
   1.665 -apply(induct xs)
   1.666 - apply (simp)
   1.667 -apply(case_tac ys)
   1.668 -apply simp_all
   1.669 -done
   1.670 +lemma fun_upds_append2_drop [simp]:
   1.671 +    "size xs = size ys \<Longrightarrow> m(xs[\<mapsto>]ys@zs) = m(xs[\<mapsto>]ys)"
   1.672 +  apply (induct xs arbitrary: m ys)
   1.673 +   apply simp
   1.674 +  apply (case_tac ys)
   1.675 +   apply simp_all
   1.676 +  done
   1.677  
   1.678  
   1.679 -lemma restrict_map_upds[simp]: "!!m ys.
   1.680 - \<lbrakk> length xs = length ys; set xs \<subseteq> D \<rbrakk>
   1.681 - \<Longrightarrow> m(xs [\<mapsto>] ys)|`D = (m|`(D - set xs))(xs [\<mapsto>] ys)"
   1.682 -apply (induct xs, simp)
   1.683 -apply (case_tac ys, simp)
   1.684 -apply(simp add:Diff_insert[symmetric] insert_absorb)
   1.685 -apply(simp add: map_upd_upds_conv_if)
   1.686 -done
   1.687 +lemma restrict_map_upds[simp]:
   1.688 +  "\<lbrakk> length xs = length ys; set xs \<subseteq> D \<rbrakk>
   1.689 +    \<Longrightarrow> m(xs [\<mapsto>] ys)|`D = (m|`(D - set xs))(xs [\<mapsto>] ys)"
   1.690 +  apply (induct xs arbitrary: m ys)
   1.691 +   apply simp
   1.692 +  apply (case_tac ys)
   1.693 +   apply simp
   1.694 +  apply (simp add: Diff_insert [symmetric] insert_absorb)
   1.695 +  apply (simp add: map_upd_upds_conv_if)
   1.696 +  done
   1.697  
   1.698  
   1.699  subsection {* @{term [source] dom} *}
   1.700  
   1.701  lemma domI: "m a = Some b ==> a : dom m"
   1.702 -by (unfold dom_def, auto)
   1.703 +  unfolding dom_def by simp
   1.704  (* declare domI [intro]? *)
   1.705  
   1.706  lemma domD: "a : dom m ==> \<exists>b. m a = Some b"
   1.707 -apply (case_tac "m a") 
   1.708 -apply (auto simp add: dom_def) 
   1.709 -done
   1.710 +  by (cases "m a") (auto simp add: dom_def)
   1.711  
   1.712 -lemma domIff[iff]: "(a : dom m) = (m a ~= None)"
   1.713 -by (unfold dom_def, auto)
   1.714 -declare domIff [simp del]
   1.715 +lemma domIff [iff, simp del]: "(a : dom m) = (m a ~= None)"
   1.716 +  unfolding dom_def by simp
   1.717  
   1.718 -lemma dom_empty[simp]: "dom empty = {}"
   1.719 -apply (unfold dom_def)
   1.720 -apply (simp (no_asm))
   1.721 -done
   1.722 +lemma dom_empty [simp]: "dom empty = {}"
   1.723 +  unfolding dom_def by simp
   1.724  
   1.725 -lemma dom_fun_upd[simp]:
   1.726 - "dom(f(x := y)) = (if y=None then dom f - {x} else insert x (dom f))"
   1.727 -by (simp add:dom_def) blast
   1.728 +lemma dom_fun_upd [simp]:
   1.729 +    "dom(f(x := y)) = (if y=None then dom f - {x} else insert x (dom f))"
   1.730 +  unfolding dom_def by auto
   1.731  
   1.732  lemma dom_map_of: "dom(map_of xys) = {x. \<exists>y. (x,y) : set xys}"
   1.733 -apply(induct xys)
   1.734 -apply(auto simp del:fun_upd_apply)
   1.735 -done
   1.736 +  by (induct xys) (auto simp del: fun_upd_apply)
   1.737  
   1.738  lemma dom_map_of_conv_image_fst:
   1.739 -  "dom(map_of xys) = fst ` (set xys)"
   1.740 -by(force simp: dom_map_of)
   1.741 +    "dom(map_of xys) = fst ` (set xys)"
   1.742 +  unfolding dom_map_of by force
   1.743  
   1.744 -lemma dom_map_of_zip[simp]: "[| length xs = length ys; distinct xs |] ==>
   1.745 -  dom(map_of(zip xs ys)) = set xs"
   1.746 -by(induct rule: list_induct2, simp_all)
   1.747 +lemma dom_map_of_zip [simp]: "[| length xs = length ys; distinct xs |] ==>
   1.748 +    dom(map_of(zip xs ys)) = set xs"
   1.749 +  by (induct rule: list_induct2) simp_all
   1.750  
   1.751  lemma finite_dom_map_of: "finite (dom (map_of l))"
   1.752 -apply (unfold dom_def)
   1.753 -apply (induct "l")
   1.754 -apply (auto simp add: insert_Collect [symmetric])
   1.755 -done
   1.756 +  unfolding dom_def
   1.757 +  by (induct l) (auto simp add: insert_Collect [symmetric])
   1.758  
   1.759 -lemma dom_map_upds[simp]:
   1.760 - "!!m ys. dom(m(xs[|->]ys)) = set(take (length ys) xs) Un dom m"
   1.761 -apply (induct xs, simp)
   1.762 -apply (case_tac ys, auto)
   1.763 -done
   1.764 +lemma dom_map_upds [simp]:
   1.765 +    "dom(m(xs[|->]ys)) = set(take (length ys) xs) Un dom m"
   1.766 +  apply (induct xs arbitrary: m ys)
   1.767 +   apply simp
   1.768 +  apply (case_tac ys)
   1.769 +   apply auto
   1.770 +  done
   1.771  
   1.772 -lemma dom_map_add[simp]: "dom(m++n) = dom n Un dom m"
   1.773 -by (unfold dom_def, auto)
   1.774 +lemma dom_map_add [simp]: "dom(m++n) = dom n Un dom m"
   1.775 +  unfolding dom_def by auto
   1.776  
   1.777 -lemma dom_override_on[simp]:
   1.778 - "dom(override_on f g A) =
   1.779 - (dom f  - {a. a : A - dom g}) Un {a. a : A Int dom g}"
   1.780 -by(auto simp add: dom_def override_on_def)
   1.781 +lemma dom_override_on [simp]:
   1.782 +  "dom(override_on f g A) =
   1.783 +    (dom f  - {a. a : A - dom g}) Un {a. a : A Int dom g}"
   1.784 +  unfolding dom_def override_on_def by auto
   1.785  
   1.786  lemma map_add_comm: "dom m1 \<inter> dom m2 = {} \<Longrightarrow> m1++m2 = m2++m1"
   1.787 -apply(rule ext)
   1.788 -apply(force simp: map_add_def dom_def split:option.split) 
   1.789 -done
   1.790 +  by (rule ext) (force simp: map_add_def dom_def split: option.split)
   1.791 +
   1.792  
   1.793  subsection {* @{term [source] ran} *}
   1.794  
   1.795 -lemma ranI: "m a = Some b ==> b : ran m" 
   1.796 -by (auto simp add: ran_def)
   1.797 +lemma ranI: "m a = Some b ==> b : ran m"
   1.798 +  unfolding ran_def by auto
   1.799  (* declare ranI [intro]? *)
   1.800  
   1.801 -lemma ran_empty[simp]: "ran empty = {}"
   1.802 -apply (unfold ran_def)
   1.803 -apply (simp (no_asm))
   1.804 -done
   1.805 +lemma ran_empty [simp]: "ran empty = {}"
   1.806 +  unfolding ran_def by simp
   1.807  
   1.808 -lemma ran_map_upd[simp]: "m a = None ==> ran(m(a|->b)) = insert b (ran m)"
   1.809 -apply (unfold ran_def, auto)
   1.810 -apply (subgoal_tac "~ (aa = a) ")
   1.811 -apply auto
   1.812 -done
   1.813 +lemma ran_map_upd [simp]: "m a = None ==> ran(m(a|->b)) = insert b (ran m)"
   1.814 +  unfolding ran_def
   1.815 +  apply auto
   1.816 +  apply (subgoal_tac "aa ~= a")
   1.817 +   apply auto
   1.818 +  done
   1.819 +
   1.820  
   1.821  subsection {* @{text "map_le"} *}
   1.822  
   1.823  lemma map_le_empty [simp]: "empty \<subseteq>\<^sub>m g"
   1.824 -by(simp add:map_le_def)
   1.825 +  by (simp add: map_le_def)
   1.826  
   1.827  lemma upd_None_map_le [simp]: "f(x := None) \<subseteq>\<^sub>m f"
   1.828 -by(force simp add:map_le_def)
   1.829 +  by (force simp add: map_le_def)
   1.830  
   1.831  lemma map_le_upd[simp]: "f \<subseteq>\<^sub>m g ==> f(a := b) \<subseteq>\<^sub>m g(a := b)"
   1.832 -by(fastsimp simp add:map_le_def)
   1.833 +  by (fastsimp simp add: map_le_def)
   1.834  
   1.835  lemma map_le_imp_upd_le [simp]: "m1 \<subseteq>\<^sub>m m2 \<Longrightarrow> m1(x := None) \<subseteq>\<^sub>m m2(x \<mapsto> y)"
   1.836 -by(force simp add:map_le_def)
   1.837 +  by (force simp add: map_le_def)
   1.838  
   1.839 -lemma map_le_upds[simp]:
   1.840 - "!!f g bs. f \<subseteq>\<^sub>m g ==> f(as [|->] bs) \<subseteq>\<^sub>m g(as [|->] bs)"
   1.841 -apply (induct as, simp)
   1.842 -apply (case_tac bs, auto)
   1.843 -done
   1.844 +lemma map_le_upds [simp]:
   1.845 +    "f \<subseteq>\<^sub>m g ==> f(as [|->] bs) \<subseteq>\<^sub>m g(as [|->] bs)"
   1.846 +  apply (induct as arbitrary: f g bs)
   1.847 +   apply simp
   1.848 +  apply (case_tac bs)
   1.849 +   apply auto
   1.850 +  done
   1.851  
   1.852  lemma map_le_implies_dom_le: "(f \<subseteq>\<^sub>m g) \<Longrightarrow> (dom f \<subseteq> dom g)"
   1.853    by (fastsimp simp add: map_le_def dom_def)
   1.854 @@ -572,22 +553,22 @@
   1.855    by (auto simp add: map_le_def dom_def)
   1.856  
   1.857  lemma map_le_antisym: "\<lbrakk> f \<subseteq>\<^sub>m g; g \<subseteq>\<^sub>m f \<rbrakk> \<Longrightarrow> f = g"
   1.858 -  apply (unfold map_le_def)
   1.859 +  unfolding map_le_def
   1.860    apply (rule ext)
   1.861    apply (case_tac "x \<in> dom f", simp)
   1.862    apply (case_tac "x \<in> dom g", simp, fastsimp)
   1.863 -done
   1.864 +  done
   1.865  
   1.866  lemma map_le_map_add [simp]: "f \<subseteq>\<^sub>m (g ++ f)"
   1.867    by (fastsimp simp add: map_le_def)
   1.868  
   1.869  lemma map_le_iff_map_add_commute: "(f \<subseteq>\<^sub>m f ++ g) = (f++g = g++f)"
   1.870 -by(fastsimp simp add:map_add_def map_le_def expand_fun_eq split:option.splits)
   1.871 +  by (fastsimp simp add: map_add_def map_le_def expand_fun_eq split: option.splits)
   1.872  
   1.873  lemma map_add_le_mapE: "f++g \<subseteq>\<^sub>m h \<Longrightarrow> g \<subseteq>\<^sub>m h"
   1.874 -by (fastsimp simp add: map_le_def map_add_def dom_def)
   1.875 +  by (fastsimp simp add: map_le_def map_add_def dom_def)
   1.876  
   1.877  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.878 -by (clarsimp simp add: map_le_def map_add_def dom_def split:option.splits)
   1.879 +  by (clarsimp simp add: map_le_def map_add_def dom_def split: option.splits)
   1.880  
   1.881  end