equal
deleted
inserted
replaced
23 qualified primrec update :: "'key \<Rightarrow> 'val \<Rightarrow> ('key \<times> 'val) list \<Rightarrow> ('key \<times> 'val) list" |
23 qualified primrec update :: "'key \<Rightarrow> 'val \<Rightarrow> ('key \<times> 'val) list \<Rightarrow> ('key \<times> 'val) list" |
24 where |
24 where |
25 "update k v [] = [(k, v)]" |
25 "update k v [] = [(k, v)]" |
26 | "update k v (p # ps) = (if fst p = k then (k, v) # ps else p # update k v ps)" |
26 | "update k v (p # ps) = (if fst p = k then (k, v) # ps else p # update k v ps)" |
27 |
27 |
28 lemma update_conv': "map_of (update k v al) = (map_of al)(k\<mapsto>v)" |
28 lemma update_conv': "map_of (update k v al) = (map_of al)(k\<mapsto>v)" |
29 by (induct al) (auto simp add: fun_eq_iff) |
29 by (induct al) (auto simp add: fun_eq_iff) |
30 |
30 |
31 corollary update_conv: "map_of (update k v al) k' = ((map_of al)(k\<mapsto>v)) k'" |
31 corollary update_conv: "map_of (update k v al) k' = ((map_of al)(k\<mapsto>v)) k'" |
32 by (simp add: update_conv') |
32 by (simp add: update_conv') |
33 |
33 |