author | nipkow |
Fri, 24 Jul 1998 17:18:15 +0200 | |
changeset 5195 | 277831ae7eac |
parent 5183 | 89f162de39cf |
child 5300 | 2b1ca524ace8 |
permissions | -rw-r--r-- |
3981 | 1 |
(* Title: HOL/Map.ML |
2 |
ID: $Id$ |
|
3 |
Author: Tobias Nipkow |
|
4 |
Copyright 1997 TU Muenchen |
|
5 |
||
6 |
Map lemmas |
|
7 |
*) |
|
8 |
||
5069 | 9 |
Goalw [empty_def] "empty k = None"; |
4423 | 10 |
by (Simp_tac 1); |
3981 | 11 |
qed "empty_def2"; |
12 |
Addsimps [empty_def2]; |
|
13 |
||
5195 | 14 |
Goalw [map_upd_def] "(m[a|->b])x = (if x=a then Some b else m x)"; |
4423 | 15 |
by (Simp_tac 1); |
5195 | 16 |
qed "map_upd_def2"; |
17 |
Addsimps [map_upd_def2]; |
|
3981 | 18 |
|
5195 | 19 |
qed_goal "map_upd_same" thy "(t[k|->x]) k = Some x" |
4526
6be35399125a
added update_same, update_other, update_triv, and map_of_SomeD
oheimb
parents:
4423
diff
changeset
|
20 |
(K [Simp_tac 1]); |
5195 | 21 |
qed_goal "map_upd_other" thy "!!X. l~=k ==> (t[k|->x]) l = t l" |
4526
6be35399125a
added update_same, update_other, update_triv, and map_of_SomeD
oheimb
parents:
4423
diff
changeset
|
22 |
(K [Asm_simp_tac 1]); |
5195 | 23 |
qed_goal "map_upd_triv" thy "!!X. t k = Some x ==> t[k|->x] = t" |
4686 | 24 |
(K [rtac ext 1, Asm_simp_tac 1]); |
5195 | 25 |
(*Addsimps [map_upd_same, map_upd_other, map_upd_triv];*) |
4526
6be35399125a
added update_same, update_other, update_triv, and map_of_SomeD
oheimb
parents:
4423
diff
changeset
|
26 |
|
4990 | 27 |
section "option_map"; |
28 |
||
29 |
qed_goal "option_map_o_empty" thy |
|
30 |
"option_map f o empty = empty" (K [rtac ext 1, Simp_tac 1]); |
|
31 |
||
5195 | 32 |
qed_goal "option_map_o_map_upd" thy |
4990 | 33 |
"option_map f o m[a|->b] = (option_map f o m)[a|->f b]" |
34 |
(K [rtac ext 1, Simp_tac 1]); |
|
5195 | 35 |
Addsimps[option_map_o_empty, option_map_o_map_upd]; |
4883 | 36 |
|
3981 | 37 |
section "++"; |
38 |
||
5069 | 39 |
Goalw [override_def] "m ++ empty = m"; |
4423 | 40 |
by (Simp_tac 1); |
3981 | 41 |
qed "override_empty"; |
42 |
Addsimps [override_empty]; |
|
43 |
||
5069 | 44 |
Goalw [override_def] "empty ++ m = m"; |
4423 | 45 |
by (Simp_tac 1); |
46 |
by (rtac ext 1); |
|
5183 | 47 |
by (split_tac [option.split] 1); |
4423 | 48 |
by (Simp_tac 1); |
3981 | 49 |
qed "empty_override"; |
50 |
Addsimps [empty_override]; |
|
51 |
||
5069 | 52 |
Goalw [override_def] |
3981 | 53 |
"((m ++ n) k = Some x) = (n k = Some x | n k = None & m k = Some x)"; |
5183 | 54 |
by (simp_tac (simpset() addsplits [option.split]) 1); |
3981 | 55 |
qed_spec_mp "override_Some_iff"; |
56 |
||
4926 | 57 |
bind_thm ("override_SomeD", standard(override_Some_iff RS iffD1)); |
3981 | 58 |
|
5069 | 59 |
Goalw [override_def] |
3981 | 60 |
"((m ++ n) k = None) = (n k = None & m k = None)"; |
5183 | 61 |
by (simp_tac (simpset() addsplits [option.split]) 1); |
3981 | 62 |
qed "override_None"; |
63 |
AddIffs [override_None]; |
|
64 |
||
5069 | 65 |
Goalw [override_def] "map_of(xs@ys) = map_of ys ++ map_of xs"; |
4423 | 66 |
by (induct_tac "xs" 1); |
67 |
by (Simp_tac 1); |
|
68 |
by (rtac ext 1); |
|
5183 | 69 |
by (asm_simp_tac (simpset() addsplits [option.split]) 1); |
3981 | 70 |
qed "map_of_append"; |
71 |
Addsimps [map_of_append]; |
|
72 |
||
5069 | 73 |
Goal "map_of xs k = Some y --> (k,y):set xs"; |
5183 | 74 |
by (induct_tac "xs" 1); |
4526
6be35399125a
added update_same, update_other, update_triv, and map_of_SomeD
oheimb
parents:
4423
diff
changeset
|
75 |
by (Simp_tac 1); |
4838 | 76 |
by (split_all_tac 1); |
4686 | 77 |
by (Asm_simp_tac 1); |
4526
6be35399125a
added update_same, update_other, update_triv, and map_of_SomeD
oheimb
parents:
4423
diff
changeset
|
78 |
qed_spec_mp "map_of_SomeD"; |
6be35399125a
added update_same, update_other, update_triv, and map_of_SomeD
oheimb
parents:
4423
diff
changeset
|
79 |
|
3981 | 80 |
section "dom"; |
81 |
||
5069 | 82 |
Goalw [dom_def] "dom empty = {}"; |
4423 | 83 |
by (Simp_tac 1); |
3981 | 84 |
qed "dom_empty"; |
85 |
Addsimps [dom_empty]; |
|
86 |
||
5069 | 87 |
Goalw [dom_def] "dom(m[a|->b]) = insert a (dom m)"; |
4686 | 88 |
by (Simp_tac 1); |
4423 | 89 |
by (Blast_tac 1); |
5195 | 90 |
qed "dom_map_upd"; |
91 |
Addsimps [dom_map_upd]; |
|
3981 | 92 |
|
4883 | 93 |
qed_goalw "finite_dom_map_of" Map.thy [dom_def] "finite (dom (map_of l))" (K[ |
5183 | 94 |
induct_tac "l" 1, |
4883 | 95 |
ALLGOALS Simp_tac, |
96 |
stac (insert_Collect RS sym) 1, |
|
97 |
Asm_simp_tac 1]); |
|
98 |
||
5069 | 99 |
Goalw [dom_def] "dom(m++n) = dom n Un dom m"; |
4423 | 100 |
by (Blast_tac 1); |
3981 | 101 |
qed "dom_override"; |
102 |
Addsimps [dom_override]; |
|
103 |
||
104 |
section "ran"; |
|
105 |
||
5069 | 106 |
Goalw [ran_def] "ran empty = {}"; |
4423 | 107 |
by (Simp_tac 1); |
3981 | 108 |
qed "ran_empty"; |
109 |
Addsimps [ran_empty]; |
|
4883 | 110 |
|
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5069
diff
changeset
|
111 |
Goalw [ran_def] "m a = None ==> ran(m[a|->b]) = insert b (ran m)"; |
4883 | 112 |
by Auto_tac; |
113 |
by (subgoal_tac "~(aa = a)" 1); |
|
114 |
by Auto_tac; |
|
5195 | 115 |
qed "ran_map_upd"; |
116 |
Addsimps [ran_map_upd]; |