17 |
17 |
18 syntax (xsymbols) |
18 syntax (xsymbols) |
19 "~=>" :: "[type, type] => type" (infixr "\<rightharpoonup>" 0) |
19 "~=>" :: "[type, type] => type" (infixr "\<rightharpoonup>" 0) |
20 |
20 |
21 abbreviation |
21 abbreviation |
22 empty :: "'a ~=> 'b" |
22 empty :: "'a ~=> 'b" where |
23 "empty == %x. None" |
23 "empty == %x. None" |
24 |
24 |
25 definition |
25 definition |
26 map_comp :: "('b ~=> 'c) => ('a ~=> 'b) => ('a ~=> 'c)" (infixl "o'_m" 55) |
26 map_comp :: "('b ~=> 'c) => ('a ~=> 'b) => ('a ~=> 'c)" (infixl "o'_m" 55) where |
27 "f o_m g = (\<lambda>k. case g k of None \<Rightarrow> None | Some v \<Rightarrow> f v)" |
27 "f o_m g = (\<lambda>k. case g k of None \<Rightarrow> None | Some v \<Rightarrow> f v)" |
28 |
28 |
29 notation (xsymbols) |
29 notation (xsymbols) |
30 map_comp (infixl "\<circ>\<^sub>m" 55) |
30 map_comp (infixl "\<circ>\<^sub>m" 55) |
31 |
31 |
32 definition |
32 definition |
33 map_add :: "('a ~=> 'b) => ('a ~=> 'b) => ('a ~=> 'b)" (infixl "++" 100) |
33 map_add :: "('a ~=> 'b) => ('a ~=> 'b) => ('a ~=> 'b)" (infixl "++" 100) where |
34 "m1 ++ m2 = (\<lambda>x. case m2 x of None => m1 x | Some y => Some y)" |
34 "m1 ++ m2 = (\<lambda>x. case m2 x of None => m1 x | Some y => Some y)" |
35 |
35 |
36 restrict_map :: "('a ~=> 'b) => 'a set => ('a ~=> 'b)" (infixl "|`" 110) |
36 definition |
|
37 restrict_map :: "('a ~=> 'b) => 'a set => ('a ~=> 'b)" (infixl "|`" 110) where |
37 "m|`A = (\<lambda>x. if x : A then m x else None)" |
38 "m|`A = (\<lambda>x. if x : A then m x else None)" |
38 |
39 |
39 notation (latex output) |
40 notation (latex output) |
40 restrict_map ("_\<restriction>\<^bsub>_\<^esub>" [111,110] 110) |
41 restrict_map ("_\<restriction>\<^bsub>_\<^esub>" [111,110] 110) |
41 |
42 |
42 definition |
43 definition |
43 dom :: "('a ~=> 'b) => 'a set" |
44 dom :: "('a ~=> 'b) => 'a set" where |
44 "dom m = {a. m a ~= None}" |
45 "dom m = {a. m a ~= None}" |
45 |
46 |
46 ran :: "('a ~=> 'b) => 'b set" |
47 definition |
|
48 ran :: "('a ~=> 'b) => 'b set" where |
47 "ran m = {b. EX a. m a = Some b}" |
49 "ran m = {b. EX a. m a = Some b}" |
48 |
50 |
49 map_le :: "('a ~=> 'b) => ('a ~=> 'b) => bool" (infix "\<subseteq>\<^sub>m" 50) |
51 definition |
|
52 map_le :: "('a ~=> 'b) => ('a ~=> 'b) => bool" (infix "\<subseteq>\<^sub>m" 50) where |
50 "(m\<^isub>1 \<subseteq>\<^sub>m m\<^isub>2) = (\<forall>a \<in> dom m\<^isub>1. m\<^isub>1 a = m\<^isub>2 a)" |
53 "(m\<^isub>1 \<subseteq>\<^sub>m m\<^isub>2) = (\<forall>a \<in> dom m\<^isub>1. m\<^isub>1 a = m\<^isub>2 a)" |
51 |
54 |
52 consts |
55 consts |
53 map_of :: "('a * 'b) list => 'a ~=> 'b" |
56 map_of :: "('a * 'b) list => 'a ~=> 'b" |
54 map_upds :: "('a ~=> 'b) => 'a list => 'b list => ('a ~=> 'b)" |
57 map_upds :: "('a ~=> 'b) => 'a list => 'b list => ('a ~=> 'b)" |