src/HOL/Map.thy
 changeset 60838 2d7eea27ceec parent 60758 d8d85a8172b5 child 60839 422ec7a3c18a
```     1.1 --- a/src/HOL/Map.thy	Thu Jul 30 21:56:19 2015 +0200
1.2 +++ b/src/HOL/Map.thy	Tue Aug 04 14:06:24 2015 +0200
1.3 @@ -2,7 +2,7 @@
1.4      Author:     Tobias Nipkow, based on a theory by David von Oheimb
1.6
1.7 -The datatype of `maps' (written ~=>); strongly resembles maps in VDM.
1.8 +The datatype of "maps"; strongly resembles maps in VDM.
1.9  *)
1.10
1.11  section \<open>Maps\<close>
1.12 @@ -11,43 +11,43 @@
1.13  imports List
1.14  begin
1.15
1.16 -type_synonym ('a,'b) "map" = "'a => 'b option" (infixr "~=>" 0)
1.17 +type_synonym ('a, 'b) "map" = "'a => 'b option" (infixr "~=>" 0)
1.18
1.19  type_notation (xsymbols)
1.20    "map" (infixr "\<rightharpoonup>" 0)
1.21
1.22  abbreviation
1.23 -  empty :: "'a ~=> 'b" where
1.24 +  empty :: "'a \<rightharpoonup> 'b" where
1.25    "empty == %x. None"
1.26
1.27  definition
1.28 -  map_comp :: "('b ~=> 'c) => ('a ~=> 'b) => ('a ~=> 'c)"  (infixl "o'_m" 55) where
1.29 +  map_comp :: "('b \<rightharpoonup> 'c) => ('a \<rightharpoonup> 'b) => ('a \<rightharpoonup> 'c)"  (infixl "o'_m" 55) where
1.30    "f o_m g = (\<lambda>k. case g k of None \<Rightarrow> None | Some v \<Rightarrow> f v)"
1.31
1.32  notation (xsymbols)
1.33    map_comp  (infixl "\<circ>\<^sub>m" 55)
1.34
1.35  definition
1.36 -  map_add :: "('a ~=> 'b) => ('a ~=> 'b) => ('a ~=> 'b)"  (infixl "++" 100) where
1.37 +  map_add :: "('a \<rightharpoonup> 'b) => ('a \<rightharpoonup> 'b) => ('a \<rightharpoonup> 'b)"  (infixl "++" 100) where
1.38    "m1 ++ m2 = (\<lambda>x. case m2 x of None => m1 x | Some y => Some y)"
1.39
1.40  definition
1.41 -  restrict_map :: "('a ~=> 'b) => 'a set => ('a ~=> 'b)"  (infixl "|`"  110) where
1.42 +  restrict_map :: "('a \<rightharpoonup> 'b) => 'a set => ('a \<rightharpoonup> 'b)"  (infixl "|`"  110) where
1.43    "m|`A = (\<lambda>x. if x : A then m x else None)"
1.44
1.45  notation (latex output)
1.46    restrict_map  ("_\<restriction>\<^bsub>_\<^esub>" [111,110] 110)
1.47
1.48  definition
1.49 -  dom :: "('a ~=> 'b) => 'a set" where
1.50 +  dom :: "('a \<rightharpoonup> 'b) => 'a set" where
1.51    "dom m = {a. m a ~= None}"
1.52
1.53  definition
1.54 -  ran :: "('a ~=> 'b) => 'b set" where
1.55 +  ran :: "('a \<rightharpoonup> 'b) => 'b set" where
1.56    "ran m = {b. EX a. m a = Some b}"
1.57
1.58  definition
1.59 -  map_le :: "('a ~=> 'b) => ('a ~=> 'b) => bool"  (infix "\<subseteq>\<^sub>m" 50) where
1.60 +  map_le :: "('a \<rightharpoonup> 'b) => ('a \<rightharpoonup> 'b) => bool"  (infix "\<subseteq>\<^sub>m" 50) where
1.61    "(m\<^sub>1 \<subseteq>\<^sub>m m\<^sub>2) = (\<forall>a \<in> dom m\<^sub>1. m\<^sub>1 a = m\<^sub>2 a)"
1.62
1.63  nonterminal maplets and maplet
1.64 @@ -57,8 +57,8 @@
1.65    "_maplets" :: "['a, 'a] => maplet"             ("_ /[|->]/ _")
1.66    ""         :: "maplet => maplets"             ("_")
1.67    "_Maplets" :: "[maplet, maplets] => maplets" ("_,/ _")
1.68 -  "_MapUpd"  :: "['a ~=> 'b, maplets] => 'a ~=> 'b" ("_/'(_')" [900,0]900)
1.69 -  "_Map"     :: "maplets => 'a ~=> 'b"            ("(1[_])")
1.70 +  "_MapUpd"  :: "['a \<rightharpoonup> 'b, maplets] => 'a \<rightharpoonup> 'b" ("_/'(_')" [900,0]900)
1.71 +  "_Map"     :: "maplets => 'a \<rightharpoonup> 'b"            ("(1[_])")
1.72
1.73  syntax (xsymbols)
1.74    "_maplet"  :: "['a, 'a] => maplet"             ("_ /\<mapsto>/ _")
1.75 @@ -97,10 +97,10 @@
1.76
1.77  subsection \<open>@{term [source] map_upd}\<close>
1.78
1.79 -lemma map_upd_triv: "t k = Some x ==> t(k|->x) = t"
1.80 +lemma map_upd_triv: "t k = Some x ==> t(k\<mapsto>x) = t"
1.81  by (rule ext) simp
1.82
1.83 -lemma map_upd_nonempty [simp]: "t(k|->x) ~= empty"
1.84 +lemma map_upd_nonempty [simp]: "t(k\<mapsto>x) ~= empty"
1.85  proof
1.86    assume "t(k \<mapsto> x) = empty"
1.87    then have "(t(k \<mapsto> x)) k = None" by simp
1.88 @@ -116,13 +116,13 @@
1.89  qed
1.90
1.91  lemma map_upd_Some_unfold:
1.92 -  "((m(a|->b)) x = Some y) = (x = a \<and> b = y \<or> x \<noteq> a \<and> m x = Some y)"
1.93 +  "((m(a\<mapsto>b)) x = Some y) = (x = a \<and> b = y \<or> x \<noteq> a \<and> m x = Some y)"
1.94  by auto
1.95
1.96  lemma image_map_upd [simp]: "x \<notin> A \<Longrightarrow> m(x \<mapsto> y) ` A = m ` A"
1.97  by auto
1.98
1.99 -lemma finite_range_updI: "finite (range f) ==> finite (range (f(a|->b)))"
1.100 +lemma finite_range_updI: "finite (range f) ==> finite (range (f(a\<mapsto>b)))"
1.101  unfolding image_def
1.103  apply (rule finite_subset)
1.104 @@ -260,7 +260,7 @@
1.105  by (rule ext) simp
1.106
1.107  lemma map_option_o_map_upd [simp]:
1.108 -  "map_option f o m(a|->b) = (map_option f o m)(a|->f b)"
1.109 +  "map_option f o m(a\<mapsto>b) = (map_option f o m)(a\<mapsto>f b)"
1.110  by (rule ext) simp
1.111
1.112
1.113 @@ -310,7 +310,7 @@
1.114  lemma map_add_None [iff]: "((m ++ n) k = None) = (n k = None & m k = None)"
1.116
1.117 -lemma map_add_upd[simp]: "f ++ g(x|->y) = (f ++ g)(x|->y)"
1.118 +lemma map_add_upd[simp]: "f ++ g(x\<mapsto>y) = (f ++ g)(x\<mapsto>y)"
1.120
1.121  lemma map_add_upds[simp]: "m1 ++ (m2(xs[\<mapsto>]ys)) = (m1++m2)(xs[\<mapsto>]ys)"
1.122 @@ -407,13 +407,13 @@
1.123
1.124  subsection \<open>@{term [source] map_upds}\<close>
1.125
1.126 -lemma map_upds_Nil1 [simp]: "m([] [|->] bs) = m"
1.127 +lemma map_upds_Nil1 [simp]: "m([] [\<mapsto>] bs) = m"
1.129
1.130 -lemma map_upds_Nil2 [simp]: "m(as [|->] []) = m"
1.131 +lemma map_upds_Nil2 [simp]: "m(as [\<mapsto>] []) = m"
1.133
1.134 -lemma map_upds_Cons [simp]: "m(a#as [|->] b#bs) = (m(a|->b))(as[|->]bs)"
1.135 +lemma map_upds_Cons [simp]: "m(a#as [\<mapsto>] b#bs) = (m(a\<mapsto>b))(as[\<mapsto>]bs)"
1.137
1.138  lemma map_upds_append1 [simp]: "\<And>ys m. size xs < size ys \<Longrightarrow>
1.139 @@ -435,9 +435,9 @@
1.140  done
1.141
1.142  lemma map_upd_upds_conv_if:
1.143 -  "(f(x|->y))(xs [|->] ys) =
1.144 -   (if x : set(take (length ys) xs) then f(xs [|->] ys)
1.145 -                                    else (f(xs [|->] ys))(x|->y))"
1.146 +  "(f(x\<mapsto>y))(xs [\<mapsto>] ys) =
1.147 +   (if x : set(take (length ys) xs) then f(xs [\<mapsto>] ys)
1.148 +                                    else (f(xs [\<mapsto>] ys))(x\<mapsto>y))"
1.149  apply (induct xs arbitrary: x y ys f)
1.150   apply simp
1.151  apply (case_tac ys)
1.152 @@ -445,11 +445,11 @@
1.153  done
1.154
1.155  lemma map_upds_twist [simp]:
1.156 -  "a ~: set as ==> m(a|->b)(as[|->]bs) = m(as[|->]bs)(a|->b)"
1.157 +  "a ~: set as ==> m(a\<mapsto>b)(as[\<mapsto>]bs) = m(as[\<mapsto>]bs)(a\<mapsto>b)"
1.158  using set_take_subset by (fastforce simp add: map_upd_upds_conv_if)
1.159
1.160  lemma map_upds_apply_nontin [simp]:
1.161 -  "x ~: set xs ==> (f(xs[|->]ys)) x = f x"
1.162 +  "x ~: set xs ==> (f(xs[\<mapsto>]ys)) x = f x"
1.163  apply (induct xs arbitrary: ys)
1.164   apply simp
1.165  apply (case_tac ys)
1.166 @@ -522,7 +522,7 @@
1.167  by (induct l) (auto simp add: dom_def insert_Collect [symmetric])
1.168
1.169  lemma dom_map_upds [simp]:
1.170 -  "dom(m(xs[|->]ys)) = set(take (length ys) xs) Un dom m"
1.171 +  "dom(m(xs[\<mapsto>]ys)) = set(take (length ys) xs) Un dom m"
1.172  apply (induct xs arbitrary: m ys)
1.173   apply simp
1.174  apply (case_tac ys)
1.175 @@ -621,7 +621,7 @@
1.176  lemma ran_empty [simp]: "ran empty = {}"
1.177  by(auto simp: ran_def)
1.178
1.179 -lemma ran_map_upd [simp]: "m a = None ==> ran(m(a|->b)) = insert b (ran m)"
1.180 +lemma ran_map_upd [simp]: "m a = None ==> ran(m(a\<mapsto>b)) = insert b (ran m)"
1.181  unfolding ran_def
1.182  apply auto
1.183  apply (subgoal_tac "aa ~= a")
1.184 @@ -659,7 +659,7 @@
1.185  by (force simp add: map_le_def)
1.186
1.187  lemma map_le_upds [simp]:
1.188 -  "f \<subseteq>\<^sub>m g ==> f(as [|->] bs) \<subseteq>\<^sub>m g(as [|->] bs)"
1.189 +  "f \<subseteq>\<^sub>m g ==> f(as [\<mapsto>] bs) \<subseteq>\<^sub>m g(as [\<mapsto>] bs)"
1.190  apply (induct as arbitrary: f g bs)
1.191   apply simp
1.192  apply (case_tac bs)
```