author | oheimb |
Thu, 14 May 1998 16:32:33 +0200 | |
changeset 4926 | 0fd0b3f3bc25 |
parent 4883 | c1aec06d1dca |
child 4990 | 25da60d0a20b |
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 |
||
9 |
goalw thy [empty_def] "empty k = None"; |
|
4423 | 10 |
by (Simp_tac 1); |
3981 | 11 |
qed "empty_def2"; |
12 |
Addsimps [empty_def2]; |
|
13 |
||
14 |
goalw thy [update_def] "(m[a|->b])x = (if x=a then Some b else m x)"; |
|
4423 | 15 |
by (Simp_tac 1); |
3981 | 16 |
qed "update_def2"; |
17 |
Addsimps [update_def2]; |
|
18 |
||
4526
6be35399125a
added update_same, update_other, update_triv, and map_of_SomeD
oheimb
parents:
4423
diff
changeset
|
19 |
qed_goal "update_same" thy "(t[k|->x]) k = Some x" |
6be35399125a
added update_same, update_other, update_triv, and map_of_SomeD
oheimb
parents:
4423
diff
changeset
|
20 |
(K [Simp_tac 1]); |
6be35399125a
added update_same, update_other, update_triv, and map_of_SomeD
oheimb
parents:
4423
diff
changeset
|
21 |
qed_goal "update_other" thy "!!X. l~=k ==> (t[k|->x]) l = t l" |
6be35399125a
added update_same, update_other, update_triv, and map_of_SomeD
oheimb
parents:
4423
diff
changeset
|
22 |
(K [Asm_simp_tac 1]); |
6be35399125a
added update_same, update_other, update_triv, and map_of_SomeD
oheimb
parents:
4423
diff
changeset
|
23 |
qed_goal "update_triv" thy "!!X. t k = Some x ==> t[k|->x] = t" |
4686 | 24 |
(K [rtac ext 1, Asm_simp_tac 1]); |
4526
6be35399125a
added update_same, update_other, update_triv, and map_of_SomeD
oheimb
parents:
4423
diff
changeset
|
25 |
(*Addsimps [update_same, update_other, update_triv];*) |
6be35399125a
added update_same, update_other, update_triv, and map_of_SomeD
oheimb
parents:
4423
diff
changeset
|
26 |
|
4926 | 27 |
qed_goal "option_map_o_update" thy |
28 |
"option_map f o m[a|->b] = (option_map f o m)[a|->f b]" |
|
29 |
(K [rtac ext 1,Auto_tac]); |
|
4883 | 30 |
|
3981 | 31 |
section "++"; |
32 |
||
33 |
goalw thy [override_def] "m ++ empty = m"; |
|
4423 | 34 |
by (Simp_tac 1); |
3981 | 35 |
qed "override_empty"; |
36 |
Addsimps [override_empty]; |
|
37 |
||
38 |
goalw thy [override_def] "empty ++ m = m"; |
|
4423 | 39 |
by (Simp_tac 1); |
40 |
by (rtac ext 1); |
|
41 |
by (split_tac [split_option_case] 1); |
|
42 |
by (Simp_tac 1); |
|
3981 | 43 |
qed "empty_override"; |
44 |
Addsimps [empty_override]; |
|
45 |
||
46 |
goalw thy [override_def] |
|
47 |
"((m ++ n) k = Some x) = (n k = Some x | n k = None & m k = Some x)"; |
|
4423 | 48 |
by (simp_tac (simpset() addsplits [split_option_case]) 1); |
3981 | 49 |
qed_spec_mp "override_Some_iff"; |
50 |
||
4926 | 51 |
bind_thm ("override_SomeD", standard(override_Some_iff RS iffD1)); |
3981 | 52 |
|
53 |
goalw thy [override_def] |
|
54 |
"((m ++ n) k = None) = (n k = None & m k = None)"; |
|
4423 | 55 |
by (simp_tac (simpset() addsplits [split_option_case]) 1); |
3981 | 56 |
qed "override_None"; |
57 |
AddIffs [override_None]; |
|
58 |
||
59 |
goalw thy [override_def] "map_of(xs@ys) = map_of ys ++ map_of xs"; |
|
4423 | 60 |
by (induct_tac "xs" 1); |
61 |
by (Simp_tac 1); |
|
62 |
by (rtac ext 1); |
|
4686 | 63 |
by (asm_simp_tac (simpset() addsplits [split_option_case]) 1); |
3981 | 64 |
qed "map_of_append"; |
65 |
Addsimps [map_of_append]; |
|
66 |
||
4526
6be35399125a
added update_same, update_other, update_triv, and map_of_SomeD
oheimb
parents:
4423
diff
changeset
|
67 |
goal thy "map_of xs k = Some y --> (k,y):set xs"; |
6be35399125a
added update_same, update_other, update_triv, and map_of_SomeD
oheimb
parents:
4423
diff
changeset
|
68 |
by (list.induct_tac "xs" 1); |
6be35399125a
added update_same, update_other, update_triv, and map_of_SomeD
oheimb
parents:
4423
diff
changeset
|
69 |
by (Simp_tac 1); |
4838 | 70 |
by (split_all_tac 1); |
4686 | 71 |
by (Asm_simp_tac 1); |
4526
6be35399125a
added update_same, update_other, update_triv, and map_of_SomeD
oheimb
parents:
4423
diff
changeset
|
72 |
qed_spec_mp "map_of_SomeD"; |
6be35399125a
added update_same, update_other, update_triv, and map_of_SomeD
oheimb
parents:
4423
diff
changeset
|
73 |
|
3981 | 74 |
section "dom"; |
75 |
||
76 |
goalw thy [dom_def] "dom empty = {}"; |
|
4423 | 77 |
by (Simp_tac 1); |
3981 | 78 |
qed "dom_empty"; |
79 |
Addsimps [dom_empty]; |
|
80 |
||
81 |
goalw thy [dom_def] "dom(m[a|->b]) = insert a (dom m)"; |
|
4686 | 82 |
by (Simp_tac 1); |
4423 | 83 |
by (Blast_tac 1); |
3981 | 84 |
qed "dom_update"; |
85 |
Addsimps [dom_update]; |
|
86 |
||
4883 | 87 |
qed_goalw "finite_dom_map_of" Map.thy [dom_def] "finite (dom (map_of l))" (K[ |
88 |
list.induct_tac "l" 1, |
|
89 |
ALLGOALS Simp_tac, |
|
90 |
stac (insert_Collect RS sym) 1, |
|
91 |
Asm_simp_tac 1]); |
|
92 |
||
3981 | 93 |
goalw thy [dom_def] "dom(m++n) = dom n Un dom m"; |
4423 | 94 |
by (Blast_tac 1); |
3981 | 95 |
qed "dom_override"; |
96 |
Addsimps [dom_override]; |
|
97 |
||
98 |
section "ran"; |
|
99 |
||
100 |
goalw thy [ran_def] "ran empty = {}"; |
|
4423 | 101 |
by (Simp_tac 1); |
3981 | 102 |
qed "ran_empty"; |
103 |
Addsimps [ran_empty]; |
|
4883 | 104 |
|
105 |
goalw thy [ran_def] "!!X. m a = None ==> ran(m[a|->b]) = insert b (ran m)"; |
|
106 |
by Auto_tac; |
|
107 |
by (subgoal_tac "~(aa = a)" 1); |
|
108 |
by Auto_tac; |
|
109 |
qed "ran_update"; |
|
110 |
Addsimps [ran_update]; |