src/HOL/Probability/Random_Permutations.thy
changeset 63134 aa573306a9cd
parent 63133 feea9cf343d9
child 63194 0b7bdb75f451
equal deleted inserted replaced
63133:feea9cf343d9 63134:aa573306a9cd
    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"