src/HOL/Probability/Random_Permutations.thy
changeset 63132 8230358fab88
parent 63124 6a17bcddd6c2
child 63133 feea9cf343d9
equal deleted inserted replaced
63131:76cb6c6bd7b8 63132:8230358fab88
    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"