library theories for debugging and parallel computing using code generation towards Isabelle/ML
1 (* Author: Florian Haftmann, TU Muenchen *)
3 header {* Futures and parallel lists for code generated towards Isabelle/ML *}
9 subsection {* Futures *}
11 datatype 'a future = fork "unit \<Rightarrow> 'a"
13 primrec join :: "'a future \<Rightarrow> 'a" where
14 "join (fork f) = f ()"
16 lemma future_eqI [intro!]:
17 assumes "join f = join g"
19 using assms by (cases f, cases g) (simp add: ext)
30 code_reserved Eval Future future
33 subsection {* Parallel lists *}
35 definition map :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a list \<Rightarrow> 'b list" where
36 [simp]: "map = List.map"
38 definition forall :: "('a \<Rightarrow> bool) \<Rightarrow> 'a list \<Rightarrow> bool" where
41 lemma forall_all [simp]:
42 "forall P xs \<longleftrightarrow> (\<forall>x\<in>set xs. P x)"
43 by (simp add: forall_def list_all_iff)
45 definition exists :: "('a \<Rightarrow> bool) \<Rightarrow> 'a list \<Rightarrow> bool" where
48 lemma exists_ex [simp]:
49 "exists P xs \<longleftrightarrow> (\<exists>x\<in>set xs. P x)"
50 by (simp add: exists_def list_ex_iff)
53 (Eval "Par'_List.map")
56 (Eval "Par'_List.forall")
59 (Eval "Par'_List.exists")
61 code_reserved Eval Par_List
64 hide_const (open) fork join map exists forall