equal
deleted
inserted
replaced
15 |
15 |
16 fun map_of :: "('a*'b)list \<Rightarrow> 'a \<Rightarrow> 'b option" where |
16 fun map_of :: "('a*'b)list \<Rightarrow> 'a \<Rightarrow> 'b option" where |
17 "map_of [] = (\<lambda>a. None)" | |
17 "map_of [] = (\<lambda>a. None)" | |
18 "map_of ((x,y)#ps) = (\<lambda>a. if x=a then Some y else map_of ps a)" |
18 "map_of ((x,y)#ps) = (\<lambda>a. if x=a then Some y else map_of ps a)" |
19 |
19 |
20 text \<open>Updating into an association list:\<close> |
20 text \<open>Updating an association list:\<close> |
21 |
21 |
22 fun upd_list :: "'a::linorder \<Rightarrow> 'b \<Rightarrow> ('a*'b) list \<Rightarrow> ('a*'b) list" where |
22 fun upd_list :: "'a::linorder \<Rightarrow> 'b \<Rightarrow> ('a*'b) list \<Rightarrow> ('a*'b) list" where |
23 "upd_list a b [] = [(a,b)]" | |
23 "upd_list a b [] = [(a,b)]" | |
24 "upd_list a b ((x,y)#ps) = |
24 "upd_list a b ((x,y)#ps) = |
25 (if a < x then (a,b)#(x,y)#ps else |
25 (if a < x then (a,b)#(x,y)#ps else |
56 lemma map_of_sorted_snoc: "sorted (map fst ps @ [a]) \<Longrightarrow> a \<le> x \<Longrightarrow> |
56 lemma map_of_sorted_snoc: "sorted (map fst ps @ [a]) \<Longrightarrow> a \<le> x \<Longrightarrow> |
57 map_of ps x = None" |
57 map_of ps x = None" |
58 by (meson le_less_trans map_of_None2 not_less sorted_snoc_iff) |
58 by (meson le_less_trans map_of_None2 not_less sorted_snoc_iff) |
59 |
59 |
60 lemmas map_of_sorteds = map_of_sorted_Cons map_of_sorted_snoc |
60 lemmas map_of_sorteds = map_of_sorted_Cons map_of_sorted_snoc |
|
61 lemmas map_of_simps = sorted_lems map_of_append map_of_sorteds |
61 |
62 |
62 |
63 |
63 subsection \<open>Lemmas for @{const upd_list}\<close> |
64 subsection \<open>Lemmas for @{const upd_list}\<close> |
64 |
65 |
65 lemma sorted_upd_list: "sorted1 ps \<Longrightarrow> sorted1 (upd_list a b ps)" |
66 lemma sorted_upd_list: "sorted1 ps \<Longrightarrow> sorted1 (upd_list a b ps)" |
134 by (induction xs) (auto simp: sorted_Cons_iff del_list_sorted4) |
135 by (induction xs) (auto simp: sorted_Cons_iff del_list_sorted4) |
135 |
136 |
136 lemmas del_list_sorted = |
137 lemmas del_list_sorted = |
137 del_list_sorted1 del_list_sorted2 del_list_sorted3 del_list_sorted4 del_list_sorted5 |
138 del_list_sorted1 del_list_sorted2 del_list_sorted3 del_list_sorted4 del_list_sorted5 |
138 |
139 |
|
140 lemmas del_list_simps = sorted_lems del_list_sorted |
|
141 |
139 end |
142 end |