equal
deleted
inserted
replaced
82 by transfer_prover |
82 by transfer_prover |
83 |
83 |
84 definition map_filter :: "('a \<Rightarrow> bool) \<Rightarrow> ('a \<rightharpoonup> 'b) \<Rightarrow> ('a \<rightharpoonup> 'b)" where |
84 definition map_filter :: "('a \<Rightarrow> bool) \<Rightarrow> ('a \<rightharpoonup> 'b) \<Rightarrow> ('a \<rightharpoonup> 'b)" where |
85 "map_filter P m = (\<lambda>x. if P x then m x else None)" |
85 "map_filter P m = (\<lambda>x. if P x then m x else None)" |
86 |
86 |
87 lemma map_filter_map_of[simp]: "map_filter P (map_of m) = map_of [(k, _) \<leftarrow> m. P k]" |
87 lemma map_filter_map_of[simp]: "map_filter P (map_of m) = map_of (filter (\<lambda>(k, _). P k) m)" |
88 proof |
88 proof |
89 fix x |
89 fix x |
90 show "map_filter P (map_of m) x = map_of [(k, _) \<leftarrow> m. P k] x" |
90 show "map_filter P (map_of m) x = map_of (filter (\<lambda>(k, _). P k) m) x" |
91 by (induct m) (auto simp: map_filter_def) |
91 by (induct m) (auto simp: map_filter_def) |
92 qed |
92 qed |
93 |
93 |
94 lemma map_filter_transfer[transfer_rule]: |
94 lemma map_filter_transfer[transfer_rule]: |
95 "((=) ===> rel_map A ===> rel_map A) map_filter map_filter" |
95 "((=) ===> rel_map A ===> rel_map A) map_filter map_filter" |