src/HOL/Library/Mapping.thy
changeset 37091 1535aa1c943a
parent 37036 80dd92673fca
child 37299 6315d1bd8388
equal deleted inserted replaced
37090:d56e0b30ce5a 37091:1535aa1c943a
     3 header {* An abstract view on maps for code generation. *}
     3 header {* An abstract view on maps for code generation. *}
     4 
     4 
     5 theory Mapping
     5 theory Mapping
     6 imports Main
     6 imports Main
     7 begin
     7 begin
     8 
       
     9 lemma remove1_idem: (*FIXME move to List.thy*)
       
    10   assumes "x \<notin> set xs"
       
    11   shows "remove1 x xs = xs"
       
    12   using assms by (induct xs) simp_all
       
    13 
       
    14 lemma remove1_insort [simp]:
       
    15   "remove1 x (insort x xs) = xs"
       
    16   by (induct xs) simp_all
       
    17 
       
    18 lemma sorted_list_of_set_remove:
       
    19   assumes "finite A"
       
    20   shows "sorted_list_of_set (A - {x}) = remove1 x (sorted_list_of_set A)"
       
    21 proof (cases "x \<in> A")
       
    22   case False with assms have "x \<notin> set (sorted_list_of_set A)" by simp
       
    23   with False show ?thesis by (simp add: remove1_idem)
       
    24 next
       
    25   case True then obtain B where A: "A = insert x B" by (rule Set.set_insert)
       
    26   with assms show ?thesis by simp
       
    27 qed
       
    28 
       
    29 lemma sorted_list_of_set_range [simp]:
       
    30   "sorted_list_of_set {m..<n} = [m..<n]"
       
    31   by (rule sorted_distinct_set_unique) simp_all
       
    32 
     8 
    33 subsection {* Type definition and primitive operations *}
     9 subsection {* Type definition and primitive operations *}
    34 
    10 
    35 datatype ('a, 'b) mapping = Mapping "'a \<rightharpoonup> 'b"
    11 datatype ('a, 'b) mapping = Mapping "'a \<rightharpoonup> 'b"
    36 
    12