equal
deleted
inserted
replaced
96 primrec |
96 primrec |
97 "map_of [] = empty" |
97 "map_of [] = empty" |
98 "map_of (p#ps) = (map_of ps)(fst p |-> snd p)" |
98 "map_of (p#ps) = (map_of ps)(fst p |-> snd p)" |
99 |
99 |
100 |
100 |
101 subsection {* @{term empty} *} |
101 subsection {* @{term [source] empty} *} |
102 |
102 |
103 lemma empty_upd_none[simp]: "empty(x := None) = empty" |
103 lemma empty_upd_none[simp]: "empty(x := None) = empty" |
104 apply (rule ext) |
104 apply (rule ext) |
105 apply (simp (no_asm)) |
105 apply (simp (no_asm)) |
106 done |
106 done |
110 lemma sum_case_empty_empty[simp]: "sum_case empty empty = empty" |
110 lemma sum_case_empty_empty[simp]: "sum_case empty empty = empty" |
111 apply (rule ext) |
111 apply (rule ext) |
112 apply (simp (no_asm) split add: sum.split) |
112 apply (simp (no_asm) split add: sum.split) |
113 done |
113 done |
114 |
114 |
115 subsection {* @{term map_upd} *} |
115 subsection {* @{term [source] map_upd} *} |
116 |
116 |
117 lemma map_upd_triv: "t k = Some x ==> t(k|->x) = t" |
117 lemma map_upd_triv: "t k = Some x ==> t(k|->x) = t" |
118 apply (rule ext) |
118 apply (rule ext) |
119 apply (simp (no_asm_simp)) |
119 apply (simp (no_asm_simp)) |
120 done |
120 done |
143 apply auto |
143 apply auto |
144 done |
144 done |
145 |
145 |
146 |
146 |
147 (* FIXME: what is this sum_case nonsense?? *) |
147 (* FIXME: what is this sum_case nonsense?? *) |
148 subsection {* @{term sum_case} and @{term empty}/@{term map_upd} *} |
148 subsection {* @{term [source] sum_case} and @{term [source] empty}/@{term [source] map_upd} *} |
149 |
149 |
150 lemma sum_case_map_upd_empty[simp]: |
150 lemma sum_case_map_upd_empty[simp]: |
151 "sum_case (m(k|->y)) empty = (sum_case m empty)(Inl k|->y)" |
151 "sum_case (m(k|->y)) empty = (sum_case m empty)(Inl k|->y)" |
152 apply (rule ext) |
152 apply (rule ext) |
153 apply (simp (no_asm) split add: sum.split) |
153 apply (simp (no_asm) split add: sum.split) |
164 apply (rule ext) |
164 apply (rule ext) |
165 apply (simp (no_asm) split add: sum.split) |
165 apply (simp (no_asm) split add: sum.split) |
166 done |
166 done |
167 |
167 |
168 |
168 |
169 subsection {* @{term chg_map} *} |
169 subsection {* @{term [source] chg_map} *} |
170 |
170 |
171 lemma chg_map_new[simp]: "m a = None ==> chg_map f a m = m" |
171 lemma chg_map_new[simp]: "m a = None ==> chg_map f a m = m" |
172 by (unfold chg_map_def, auto) |
172 by (unfold chg_map_def, auto) |
173 |
173 |
174 lemma chg_map_upd[simp]: "m a = Some b ==> chg_map f a m = m(a|->f b)" |
174 lemma chg_map_upd[simp]: "m a = Some b ==> chg_map f a m = m(a|->f b)" |
176 |
176 |
177 lemma chg_map_other [simp]: "a \<noteq> b \<Longrightarrow> chg_map f a m b = m b" |
177 lemma chg_map_other [simp]: "a \<noteq> b \<Longrightarrow> chg_map f a m b = m b" |
178 by (auto simp: chg_map_def split add: option.split) |
178 by (auto simp: chg_map_def split add: option.split) |
179 |
179 |
180 |
180 |
181 subsection {* @{term map_of} *} |
181 subsection {* @{term [source] map_of} *} |
182 |
182 |
183 lemma map_of_eq_None_iff: |
183 lemma map_of_eq_None_iff: |
184 "(map_of xys x = None) = (x \<notin> fst ` (set xys))" |
184 "(map_of xys x = None) = (x \<notin> fst ` (set xys))" |
185 by (induct xys) simp_all |
185 by (induct xys) simp_all |
186 |
186 |
245 |
245 |
246 lemma map_of_map: "map_of (map (%(a,b). (a,f b)) xs) x = option_map f (map_of xs x)" |
246 lemma map_of_map: "map_of (map (%(a,b). (a,f b)) xs) x = option_map f (map_of xs x)" |
247 by (induct "xs", auto) |
247 by (induct "xs", auto) |
248 |
248 |
249 |
249 |
250 subsection {* @{term option_map} related *} |
250 subsection {* @{term [source] option_map} related *} |
251 |
251 |
252 lemma option_map_o_empty[simp]: "option_map f o empty = empty" |
252 lemma option_map_o_empty[simp]: "option_map f o empty = empty" |
253 apply (rule ext) |
253 apply (rule ext) |
254 apply (simp (no_asm)) |
254 apply (simp (no_asm)) |
255 done |
255 done |
258 "option_map f o m(a|->b) = (option_map f o m)(a|->f b)" |
258 "option_map f o m(a|->b) = (option_map f o m)(a|->f b)" |
259 apply (rule ext) |
259 apply (rule ext) |
260 apply (simp (no_asm)) |
260 apply (simp (no_asm)) |
261 done |
261 done |
262 |
262 |
263 subsection {* @{term map_comp} related *} |
263 subsection {* @{term [source] map_comp} related *} |
264 |
264 |
265 lemma map_comp_empty [simp]: |
265 lemma map_comp_empty [simp]: |
266 "m \<circ>\<^sub>m empty = empty" |
266 "m \<circ>\<^sub>m empty = empty" |
267 "empty \<circ>\<^sub>m m = empty" |
267 "empty \<circ>\<^sub>m m = empty" |
268 by (auto simp add: map_comp_def intro: ext split: option.splits) |
268 by (auto simp add: map_comp_def intro: ext split: option.splits) |
341 |
341 |
342 lemma inj_on_map_add_dom[iff]: |
342 lemma inj_on_map_add_dom[iff]: |
343 "inj_on (m ++ m') (dom m') = inj_on m' (dom m')" |
343 "inj_on (m ++ m') (dom m') = inj_on m' (dom m')" |
344 by(fastsimp simp add:map_add_def dom_def inj_on_def split:option.splits) |
344 by(fastsimp simp add:map_add_def dom_def inj_on_def split:option.splits) |
345 |
345 |
346 subsection {* @{term restrict_map} *} |
346 subsection {* @{term [source] restrict_map} *} |
347 |
347 |
348 lemma restrict_map_to_empty[simp]: "m|`{} = empty" |
348 lemma restrict_map_to_empty[simp]: "m|`{} = empty" |
349 by(simp add: restrict_map_def) |
349 by(simp add: restrict_map_def) |
350 |
350 |
351 lemma restrict_map_empty[simp]: "empty|`D = empty" |
351 lemma restrict_map_empty[simp]: "empty|`D = empty" |
384 lemma fun_upd_restrict_conv[simp]: |
384 lemma fun_upd_restrict_conv[simp]: |
385 "x \<in> D \<Longrightarrow> (m|`D)(x := y) = (m|`(D-{x}))(x := y)" |
385 "x \<in> D \<Longrightarrow> (m|`D)(x := y) = (m|`(D-{x}))(x := y)" |
386 by(simp add: restrict_map_def expand_fun_eq) |
386 by(simp add: restrict_map_def expand_fun_eq) |
387 |
387 |
388 |
388 |
389 subsection {* @{term map_upds} *} |
389 subsection {* @{term [source] map_upds} *} |
390 |
390 |
391 lemma map_upds_Nil1[simp]: "m([] [|->] bs) = m" |
391 lemma map_upds_Nil1[simp]: "m([] [|->] bs) = m" |
392 by(simp add:map_upds_def) |
392 by(simp add:map_upds_def) |
393 |
393 |
394 lemma map_upds_Nil2[simp]: "m(as [|->] []) = m" |
394 lemma map_upds_Nil2[simp]: "m(as [|->] []) = m" |
459 apply(simp add:Diff_insert[symmetric] insert_absorb) |
459 apply(simp add:Diff_insert[symmetric] insert_absorb) |
460 apply(simp add: map_upd_upds_conv_if) |
460 apply(simp add: map_upd_upds_conv_if) |
461 done |
461 done |
462 |
462 |
463 |
463 |
464 subsection {* @{term map_upd_s} *} |
464 subsection {* @{term [source] map_upd_s} *} |
465 |
465 |
466 lemma map_upd_s_apply [simp]: |
466 lemma map_upd_s_apply [simp]: |
467 "(m(as{|->}b)) x = (if x : as then Some b else m x)" |
467 "(m(as{|->}b)) x = (if x : as then Some b else m x)" |
468 by (simp add: map_upd_s_def) |
468 by (simp add: map_upd_s_def) |
469 |
469 |
470 lemma map_subst_apply [simp]: |
470 lemma map_subst_apply [simp]: |
471 "(m(a~>b)) x = (if m x = Some a then Some b else m x)" |
471 "(m(a~>b)) x = (if m x = Some a then Some b else m x)" |
472 by (simp add: map_subst_def) |
472 by (simp add: map_subst_def) |
473 |
473 |
474 subsection {* @{term dom} *} |
474 subsection {* @{term [source] dom} *} |
475 |
475 |
476 lemma domI: "m a = Some b ==> a : dom m" |
476 lemma domI: "m a = Some b ==> a : dom m" |
477 by (unfold dom_def, auto) |
477 by (unfold dom_def, auto) |
478 (* declare domI [intro]? *) |
478 (* declare domI [intro]? *) |
479 |
479 |
529 lemma map_add_comm: "dom m1 \<inter> dom m2 = {} \<Longrightarrow> m1++m2 = m2++m1" |
529 lemma map_add_comm: "dom m1 \<inter> dom m2 = {} \<Longrightarrow> m1++m2 = m2++m1" |
530 apply(rule ext) |
530 apply(rule ext) |
531 apply(fastsimp simp:map_add_def split:option.split) |
531 apply(fastsimp simp:map_add_def split:option.split) |
532 done |
532 done |
533 |
533 |
534 subsection {* @{term ran} *} |
534 subsection {* @{term [source] ran} *} |
535 |
535 |
536 lemma ranI: "m a = Some b ==> b : ran m" |
536 lemma ranI: "m a = Some b ==> b : ran m" |
537 by (auto simp add: ran_def) |
537 by (auto simp add: ran_def) |
538 (* declare ranI [intro]? *) |
538 (* declare ranI [intro]? *) |
539 |
539 |