src/HOL/Map.ML
author nipkow
Sat, 07 Mar 1998 16:29:29 +0100
changeset 4686 74a12e86b20b
parent 4526 6be35399125a
child 4838 196100237656
permissions -rw-r--r--
Removed `addsplits [expand_if]'
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3981
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
     1
(*  Title:      HOL/Map.ML
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
     2
    ID:         $Id$
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
     3
    Author:     Tobias Nipkow
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
     4
    Copyright   1997 TU Muenchen
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
     5
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
     6
Map lemmas
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
     7
*)
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
     8
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
     9
goalw thy [empty_def] "empty k = None";
4423
a129b817b58a expandshort;
wenzelm
parents: 4089
diff changeset
    10
by (Simp_tac 1);
3981
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    11
qed "empty_def2";
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    12
Addsimps [empty_def2];
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    13
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    14
goalw thy [update_def] "(m[a|->b])x = (if x=a then Some b else m x)";
4423
a129b817b58a expandshort;
wenzelm
parents: 4089
diff changeset
    15
by (Simp_tac 1);
3981
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    16
qed "update_def2";
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    17
Addsimps [update_def2];
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    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
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4526
diff changeset
    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
3981
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    27
section "++";
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    28
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    29
goalw thy [override_def] "m ++ empty = m";
4423
a129b817b58a expandshort;
wenzelm
parents: 4089
diff changeset
    30
by (Simp_tac 1);
3981
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    31
qed "override_empty";
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    32
Addsimps [override_empty];
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    33
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    34
goalw thy [override_def] "empty ++ m = m";
4423
a129b817b58a expandshort;
wenzelm
parents: 4089
diff changeset
    35
by (Simp_tac 1);
a129b817b58a expandshort;
wenzelm
parents: 4089
diff changeset
    36
by (rtac ext 1);
a129b817b58a expandshort;
wenzelm
parents: 4089
diff changeset
    37
by (split_tac [split_option_case] 1);
a129b817b58a expandshort;
wenzelm
parents: 4089
diff changeset
    38
by (Simp_tac 1);
3981
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    39
qed "empty_override";
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    40
Addsimps [empty_override];
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    41
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    42
goalw thy [override_def]
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    43
 "((m ++ n) k = Some x) = (n k = Some x | n k = None & m k = Some x)";
4423
a129b817b58a expandshort;
wenzelm
parents: 4089
diff changeset
    44
by (simp_tac (simpset() addsplits [split_option_case]) 1);
3981
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    45
qed_spec_mp "override_Some_iff";
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    46
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    47
bind_thm("override_SomeD", standard(override_Some_iff RS iffD1));
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    48
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    49
goalw thy [override_def]
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    50
 "((m ++ n) k = None) = (n k = None & m k = None)";
4423
a129b817b58a expandshort;
wenzelm
parents: 4089
diff changeset
    51
by (simp_tac (simpset() addsplits [split_option_case]) 1);
3981
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    52
qed "override_None";
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    53
AddIffs [override_None];
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    54
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    55
goalw thy [override_def] "map_of(xs@ys) = map_of ys ++ map_of xs";
4423
a129b817b58a expandshort;
wenzelm
parents: 4089
diff changeset
    56
by (induct_tac "xs" 1);
a129b817b58a expandshort;
wenzelm
parents: 4089
diff changeset
    57
by (Simp_tac 1);
a129b817b58a expandshort;
wenzelm
parents: 4089
diff changeset
    58
by (rtac ext 1);
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4526
diff changeset
    59
by (asm_simp_tac (simpset() addsplits [split_option_case]) 1);
3981
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    60
qed "map_of_append";
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    61
Addsimps [map_of_append];
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    62
4526
6be35399125a added update_same, update_other, update_triv, and map_of_SomeD
oheimb
parents: 4423
diff changeset
    63
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
    64
by (list.induct_tac "xs" 1);
6be35399125a added update_same, update_other, update_triv, and map_of_SomeD
oheimb
parents: 4423
diff changeset
    65
by  (Simp_tac 1);
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4526
diff changeset
    66
by (Asm_simp_tac 1);
4526
6be35399125a added update_same, update_other, update_triv, and map_of_SomeD
oheimb
parents: 4423
diff changeset
    67
by (split_all_tac 1);
6be35399125a added update_same, update_other, update_triv, and map_of_SomeD
oheimb
parents: 4423
diff changeset
    68
by (Simp_tac 1);
6be35399125a added update_same, update_other, update_triv, and map_of_SomeD
oheimb
parents: 4423
diff changeset
    69
qed_spec_mp "map_of_SomeD";
6be35399125a added update_same, update_other, update_triv, and map_of_SomeD
oheimb
parents: 4423
diff changeset
    70
3981
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    71
section "dom";
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    72
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    73
goalw thy [dom_def] "dom empty = {}";
4423
a129b817b58a expandshort;
wenzelm
parents: 4089
diff changeset
    74
by (Simp_tac 1);
3981
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    75
qed "dom_empty";
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    76
Addsimps [dom_empty];
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    77
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    78
goalw thy [dom_def] "dom(m[a|->b]) = insert a (dom m)";
4686
74a12e86b20b Removed `addsplits [expand_if]'
nipkow
parents: 4526
diff changeset
    79
by (Simp_tac 1);
4423
a129b817b58a expandshort;
wenzelm
parents: 4089
diff changeset
    80
by (Blast_tac 1);
3981
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    81
qed "dom_update";
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    82
Addsimps [dom_update];
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    83
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    84
goalw thy [dom_def] "dom(m++n) = dom n Un dom m";
4423
a129b817b58a expandshort;
wenzelm
parents: 4089
diff changeset
    85
by (Blast_tac 1);
3981
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    86
qed "dom_override";
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    87
Addsimps [dom_override];
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    88
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    89
section "ran";
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    90
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    91
goalw thy [ran_def] "ran empty = {}";
4423
a129b817b58a expandshort;
wenzelm
parents: 4089
diff changeset
    92
by (Simp_tac 1);
3981
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    93
qed "ran_empty";
b4f93a8da835 Added the new theory Map.
nipkow
parents:
diff changeset
    94
Addsimps [ran_empty];