equal
deleted
inserted
replaced
185 |
185 |
186 definition if_randompred :: "bool \<Rightarrow> unit randompred" |
186 definition if_randompred :: "bool \<Rightarrow> unit randompred" |
187 where |
187 where |
188 "if_randompred b = (if b then single () else empty)" |
188 "if_randompred b = (if b then single () else empty)" |
189 |
189 |
|
190 definition iterate_upto :: "(code_numeral => 'a) => code_numeral => code_numeral => 'a randompred" |
|
191 where |
|
192 "iterate_upto f n m = Pair (Code_Numeral.iterate_upto f n m)" |
|
193 |
190 definition not_randompred :: "unit randompred \<Rightarrow> unit randompred" |
194 definition not_randompred :: "unit randompred \<Rightarrow> unit randompred" |
191 where |
195 where |
192 "not_randompred P = (\<lambda>s. let |
196 "not_randompred P = (\<lambda>s. let |
193 (P', s') = P s |
197 (P', s') = P s |
194 in if Predicate.eval P' () then (Orderings.bot, s') else (Predicate.single (), s'))" |
198 in if Predicate.eval P' () then (Orderings.bot, s') else (Predicate.single (), s'))" |
197 where "Random g = scomp g (Pair o (Predicate.single o fst))" |
201 where "Random g = scomp g (Pair o (Predicate.single o fst))" |
198 |
202 |
199 definition map :: "('a \<Rightarrow> 'b) \<Rightarrow> ('a randompred \<Rightarrow> 'b randompred)" |
203 definition map :: "('a \<Rightarrow> 'b) \<Rightarrow> ('a randompred \<Rightarrow> 'b randompred)" |
200 where "map f P = bind P (single o f)" |
204 where "map f P = bind P (single o f)" |
201 |
205 |
202 hide (open) fact iter'.simps iter_def empty_def single_def bind_def union_def if_randompred_def not_randompred_def Random_def map_def |
206 hide (open) fact iter'.simps iter_def empty_def single_def bind_def union_def if_randompred_def iterate_upto_def not_randompred_def Random_def map_def |
203 hide (open) type randompred |
207 hide (open) type randompred |
204 hide (open) const random collapse beyond random_fun_aux random_fun_lift |
208 hide (open) const random collapse beyond random_fun_aux random_fun_lift |
205 iter' iter empty single bind union if_randompred not_randompred Random map |
209 iter' iter empty single bind union if_randompred iterate_upto not_randompred Random map |
206 |
210 |
207 end |
211 end |