equal
deleted
inserted
replaced
38 |
38 |
39 |
39 |
40 text \<open> |
40 text \<open> |
41 A generic fold function that takes a function, an initial state, and a set |
41 A generic fold function that takes a function, an initial state, and a set |
42 and chooses a random order in which it then traverses the set in the same |
42 and chooses a random order in which it then traverses the set in the same |
43 fashion as a left-fold over a list. |
43 fashion as a left fold over a list. |
44 We first give a recursive definition. |
44 We first give a recursive definition. |
45 \<close> |
45 \<close> |
46 function fold_random_permutation :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a set \<Rightarrow> 'b pmf" where |
46 function fold_random_permutation :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a set \<Rightarrow> 'b pmf" where |
47 "fold_random_permutation f x {} = return_pmf x" |
47 "fold_random_permutation f x {} = return_pmf x" |
48 | "\<not>finite A \<Longrightarrow> fold_random_permutation f x A = return_pmf x" |
48 | "\<not>finite A \<Longrightarrow> fold_random_permutation f x A = return_pmf x" |