src/HOL/Library/Mapping.thy
changeset 49973 e84baadd4963
parent 49939 eb8b434158c8
child 49975 faf4afed009f
equal deleted inserted replaced
49972:f11f8905d9fd 49973:e84baadd4963
    68 
    68 
    69 definition map_default :: "'a \<Rightarrow> 'b \<Rightarrow> ('b \<Rightarrow> 'b) \<Rightarrow> ('a, 'b) mapping \<Rightarrow> ('a, 'b) mapping" where
    69 definition map_default :: "'a \<Rightarrow> 'b \<Rightarrow> ('b \<Rightarrow> 'b) \<Rightarrow> ('a, 'b) mapping \<Rightarrow> ('a, 'b) mapping" where
    70   "map_default k v f m = map_entry k f (default k v m)" 
    70   "map_default k v f m = map_entry k f (default k v m)" 
    71 
    71 
    72 subsection {* Properties *}
    72 subsection {* Properties *}
       
    73 
       
    74 lemma lookup_update: "lookup (update k v m) k = Some v" 
       
    75   by transfer simp
       
    76 
       
    77 lemma lookup_update_neq: "k \<noteq> k' \<Longrightarrow> lookup (update k v m) k' = lookup m k'" 
       
    78   by transfer simp
       
    79 
       
    80 lemma lookup_empty: "lookup empty k = None" 
       
    81   by transfer simp
    73 
    82 
    74 lemma keys_is_none_rep [code_unfold]:
    83 lemma keys_is_none_rep [code_unfold]:
    75   "k \<in> keys m \<longleftrightarrow> \<not> (Option.is_none (lookup m k))"
    84   "k \<in> keys m \<longleftrightarrow> \<not> (Option.is_none (lookup m k))"
    76   by transfer (auto simp add: is_none_def)
    85   by transfer (auto simp add: is_none_def)
    77 
    86