equal
deleted
inserted
replaced
48 flip :: "('a \<Rightarrow> 'b \<Rightarrow> 'c) \<Rightarrow> 'b \<Rightarrow> 'a \<Rightarrow> 'c" where |
48 flip :: "('a \<Rightarrow> 'b \<Rightarrow> 'c) \<Rightarrow> 'b \<Rightarrow> 'a \<Rightarrow> 'c" where |
49 "flip f a b = f b a" |
49 "flip f a b = f b a" |
50 |
50 |
51 definition |
51 definition |
52 member :: "'a list \<Rightarrow> 'a \<Rightarrow> bool" where |
52 member :: "'a list \<Rightarrow> 'a \<Rightarrow> bool" where |
53 "member xs x = (x \<in> set xs)" |
53 "member xs x \<longleftrightarrow> x \<in> set xs" |
54 |
54 |
55 definition |
55 definition |
56 insertl :: "'a \<Rightarrow> 'a list \<Rightarrow> 'a list" where |
56 insertl :: "'a \<Rightarrow> 'a list \<Rightarrow> 'a list" where |
57 "insertl x xs = (if member xs x then xs else x#xs)" |
57 "insertl x xs = (if member xs x then xs else x#xs)" |
58 |
58 |
59 lemma |
59 lemma |
60 [code target: List]: "member [] y = False" |
60 [code target: List]: "member [] y \<longleftrightarrow> False" |
61 and [code target: List]: "member (x#xs) y = (y = x \<or> member xs y)" |
61 and [code target: List]: "member (x#xs) y \<longleftrightarrow> y = x \<or> member xs y" |
62 unfolding member_def by (induct xs) simp_all |
62 unfolding member_def by (induct xs) simp_all |
63 |
63 |
64 fun |
64 fun |
65 drop_first :: "('a \<Rightarrow> bool) \<Rightarrow> 'a list \<Rightarrow> 'a list" where |
65 drop_first :: "('a \<Rightarrow> bool) \<Rightarrow> 'a list \<Rightarrow> 'a list" where |
66 "drop_first f [] = []" |
66 "drop_first f [] = []" |
170 |
170 |
171 |
171 |
172 section {* Isomorphism proofs *} |
172 section {* Isomorphism proofs *} |
173 |
173 |
174 lemma iso_member: |
174 lemma iso_member: |
175 "member xs x = (x \<in> set xs)" |
175 "member xs x \<longleftrightarrow> x \<in> set xs" |
176 unfolding member_def mem_iff .. |
176 unfolding member_def mem_iff .. |
177 |
177 |
178 lemma iso_insert: |
178 lemma iso_insert: |
179 "set (insertl x xs) = insert x (set xs)" |
179 "set (insertl x xs) = insert x (set xs)" |
180 unfolding insertl_def iso_member by (simp add: Set.insert_absorb) |
180 unfolding insertl_def iso_member by (simp add: Set.insert_absorb) |
313 UNION \<equiv> map_union |
313 UNION \<equiv> map_union |
314 INTER \<equiv> map_inter |
314 INTER \<equiv> map_inter |
315 Ball \<equiv> Blall |
315 Ball \<equiv> Blall |
316 Bex \<equiv> Blex |
316 Bex \<equiv> Blex |
317 filter_set \<equiv> filter |
317 filter_set \<equiv> filter |
318 |
|
319 code_gen "{}" insert "op \<union>" "op \<inter>" "op - \<Colon> 'a set \<Rightarrow> 'a set \<Rightarrow> 'a set" |
|
320 image Union Inter UNION INTER Ball Bex filter_set (SML -) |
|
321 |
318 |
322 |
319 |
323 subsection {* type serializations *} |
320 subsection {* type serializations *} |
324 |
321 |
325 types_code |
322 types_code |