[STATEMENT]
lemma random_treap_fold:
  assumes "t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))"
  shows "rinss xs t A = distr (\<Pi>\<^sub>M x\<in>set xs. \<U> 0 1)
                              (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
                              (\<lambda>p. foldl (\<lambda>t x. ins x (p x) t) t xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rinss xs t A = distr (Pi\<^sub>M (set xs) (\<lambda>x. \<U> 0 1)) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>p. foldl (\<lambda>t x. ins x (p x) t) t xs)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. rinss xs t A = distr (Pi\<^sub>M (set xs) (\<lambda>x. \<U> 0 1)) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>p. foldl (\<lambda>t x. ins x (p x) t) t xs)
[PROOF STEP]
let ?U = "uniform_measure lborel {0::real..1}"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. rinss xs t A = distr (Pi\<^sub>M (set xs) (\<lambda>x. \<U> 0 1)) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>p. foldl (\<lambda>t x. ins x (p x) t) t xs)
[PROOF STEP]
have "set xs \<subseteq> space (count_space A)" "c \<in> set xs \<Longrightarrow> c \<in> space (count_space A)" for c
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set xs \<subseteq> space (count_space A) &&& (c \<in> set xs \<Longrightarrow> c \<in> space (count_space A))
[PROOF STEP]
using con_assms
[PROOF STATE]
proof (prove)
using this:
countable A
set xs \<subseteq> A
distinct xs

goal (1 subgoal):
 1. set xs \<subseteq> space (count_space A) &&& (c \<in> set xs \<Longrightarrow> c \<in> space (count_space A))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set xs \<subseteq> space (count_space A)
?c \<in> set xs \<Longrightarrow> ?c \<in> space (count_space A)

goal (1 subgoal):
 1. rinss xs t A = distr (Pi\<^sub>M (set xs) (\<lambda>x. \<U> 0 1)) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>p. foldl (\<lambda>t x. ins x (p x) t) t xs)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
set xs \<subseteq> space (count_space A)
?c \<in> set xs \<Longrightarrow> ?c \<in> space (count_space A)
[PROOF STEP]
have *[intro]: "(\<lambda>p. foldl (\<lambda>t x. ins x (p x) t) t xs) \<in>
    Pi\<^sub>M (set xs) (\<lambda>x. ?U) \<rightarrow>\<^sub>M tree_sigma (count_space A \<Otimes>\<^sub>M lborel)"
    if "t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))" for t
[PROOF STATE]
proof (prove)
using this:
set xs \<subseteq> space (count_space A)
?c \<in> set xs \<Longrightarrow> ?c \<in> space (count_space A)

goal (1 subgoal):
 1. (\<lambda>p. foldl (\<lambda>t x. ins x (p x) t) t xs) \<in> Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<rightarrow>\<^sub>M tree_sigma (count_space A \<Otimes>\<^sub>M lborel)
[PROOF STEP]
using that con_assms
[PROOF STATE]
proof (prove)
using this:
set xs \<subseteq> space (count_space A)
?c \<in> set xs \<Longrightarrow> ?c \<in> space (count_space A)
t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
countable A
set xs \<subseteq> A
distinct xs

goal (1 subgoal):
 1. (\<lambda>p. foldl (\<lambda>t x. ins x (p x) t) t xs) \<in> Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<rightarrow>\<^sub>M tree_sigma (count_space A \<Otimes>\<^sub>M lborel)
[PROOF STEP]
by measurable
[PROOF STATE]
proof (state)
this:
?t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) \<Longrightarrow> (\<lambda>p. foldl (\<lambda>t x. ins x (p x) t) ?t xs) \<in> Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<rightarrow>\<^sub>M tree_sigma (count_space A \<Otimes>\<^sub>M lborel)

goal (1 subgoal):
 1. rinss xs t A = distr (Pi\<^sub>M (set xs) (\<lambda>x. \<U> 0 1)) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>p. foldl (\<lambda>t x. ins x (p x) t) t xs)
[PROOF STEP]
have insR':
    "insR x t A = ?U \<bind> (\<lambda>u. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (ins x u t))"
    if "x \<in> A" "t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))" for t x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. insR x t A = uniform_measure lborel {0..1} \<bind> (\<lambda>u. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (ins x u t))
[PROOF STEP]
using con_assms assms that
[PROOF STATE]
proof (prove)
using this:
countable A
set xs \<subseteq> A
distinct xs
t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
x \<in> A
t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))

goal (1 subgoal):
 1. insR x t A = uniform_measure lborel {0..1} \<bind> (\<lambda>u. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (ins x u t))
[PROOF STEP]
by (auto simp add: bind_return_distr' \<U>_def)
[PROOF STATE]
proof (state)
this:
\<lbrakk>?x \<in> A; ?t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> insR ?x ?t A = uniform_measure lborel {0..1} \<bind> (\<lambda>u. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (ins ?x u ?t))

goal (1 subgoal):
 1. rinss xs t A = distr (Pi\<^sub>M (set xs) (\<lambda>x. \<U> 0 1)) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>p. foldl (\<lambda>t x. ins x (p x) t) t xs)
[PROOF STEP]
have "rinss xs t A = (\<Pi>\<^sub>M x\<in>set xs. ?U) \<bind>
     (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs))
[PROOF STEP]
using con_assms(2,3) assms
[PROOF STATE]
proof (prove)
using this:
set xs \<subseteq> A
distinct xs
t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))

goal (1 subgoal):
 1. rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs))
[PROOF STEP]
proof (induction xs arbitrary: t)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>t. \<lbrakk>set [] \<subseteq> A; distinct []; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss [] t A = Pi\<^sub>M (set []) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t []))
 2. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
set [] \<subseteq> A
distinct []
t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))

goal (2 subgoals):
 1. \<And>t. \<lbrakk>set [] \<subseteq> A; distinct []; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss [] t A = Pi\<^sub>M (set []) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t []))
 2. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
set [] \<subseteq> A
distinct []
t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
set [] \<subseteq> A
distinct []
t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))

goal (1 subgoal):
 1. rinss [] t A = Pi\<^sub>M (set []) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t []))
[PROOF STEP]
by (intro measure_eqI) (auto simp add: space_PiM_empty emeasure_distr bind_return_distr')
[PROOF STATE]
proof (state)
this:
rinss [] t A = Pi\<^sub>M (set []) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t []))

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
case (Cons x xs)
[PROOF STATE]
proof (state)
this:
\<lbrakk>set xs \<subseteq> A; distinct xs; ?t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs ?t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) ?t xs))
set (x # xs) \<subseteq> A
distinct (x # xs)
t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
note insR.simps[simp del]
[PROOF STATE]
proof (state)
this:
insR ?x ?t ?A = distr (\<U> 0 1) (tree_sigma (count_space ?A \<Otimes>\<^sub>M lborel)) (\<lambda>p. ins ?x p ?t)

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
let ?treap_sigma  = "tree_sigma (count_space A \<Otimes>\<^sub>M lborel)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
have [measurable]: "set xs \<subseteq> space (count_space A)" "x \<in> A"
                     "c \<in> A \<Longrightarrow> c \<in> space (count_space A)" for c
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set xs \<subseteq> space (count_space A) &&& x \<in> A &&& (c \<in> A \<Longrightarrow> c \<in> space (count_space A))
[PROOF STEP]
using Cons
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>set xs \<subseteq> A; distinct xs; ?t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs ?t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) ?t xs))
set (x # xs) \<subseteq> A
distinct (x # xs)
t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))

goal (1 subgoal):
 1. set xs \<subseteq> space (count_space A) &&& x \<in> A &&& (c \<in> A \<Longrightarrow> c \<in> space (count_space A))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set xs \<subseteq> space (count_space A)
x \<in> A
?c1 \<in> A \<Longrightarrow> ?c1 \<in> space (count_space A)

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
have [intro!]: "ins k p t \<in> space ?treap_sigma" if "t \<in> space ?treap_sigma" "k \<in> A"
    for k t and p::real
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ins k p t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
k \<in> A

goal (1 subgoal):
 1. ins k p t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
[PROOF STEP]
by (auto intro!: ins_trees simp add: space_tree_sigma space_pair_measure)
[PROOF STATE]
proof (state)
this:
\<lbrakk>?t1 \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)); ?k1 \<in> A\<rbrakk> \<Longrightarrow> ins ?k1 ?p1 ?t1 \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
have [measurable]: "Pi\<^sub>M (set xs) (\<lambda>x. ?U) \<in> space (prob_algebra (Pi\<^sub>M (set xs) (\<lambda>i. ?U)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<in> space (prob_algebra (Pi\<^sub>M (set xs) (\<lambda>i. uniform_measure lborel {0..1})))
[PROOF STEP]
unfolding space_prob_algebra
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<in> {N. sets N = sets (Pi\<^sub>M (set xs) (\<lambda>i. uniform_measure lborel {0..1})) \<and> prob_space N}
[PROOF STEP]
by (auto intro!: prob_space_uniform_measure prob_space_PiM)
[PROOF STATE]
proof (state)
this:
Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<in> space (prob_algebra (Pi\<^sub>M (set xs) (\<lambda>i. uniform_measure lborel {0..1})))

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
have [measurable]: "Pi\<^sub>M (set xs) (\<lambda>x. ?U) \<in> space (subprob_algebra (Pi\<^sub>M (set xs) (\<lambda>i. ?U)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<in> space (subprob_algebra (Pi\<^sub>M (set xs) (\<lambda>i. uniform_measure lborel {0..1})))
[PROOF STEP]
unfolding space_subprob_algebra
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<in> {M. subprob_space M \<and> sets M = sets (Pi\<^sub>M (set xs) (\<lambda>i. uniform_measure lborel {0..1}))}
[PROOF STEP]
by (auto intro!: prob_space_imp_subprob_space prob_space_uniform_measure prob_space_PiM)
[PROOF STATE]
proof (state)
this:
Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<in> space (subprob_algebra (Pi\<^sub>M (set xs) (\<lambda>i. uniform_measure lborel {0..1})))

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
have [measurable]: "(\<lambda>x. x) \<in> (?treap_sigma \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>i. ?U)) \<Otimes>\<^sub>M ?treap_sigma \<rightarrow>\<^sub>M
            (?treap_sigma \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>i. borel)) \<Otimes>\<^sub>M ?treap_sigma"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. x) \<in> (tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>i. uniform_measure lborel {0..1})) \<Otimes>\<^sub>M tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M (tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>i. borel)) \<Otimes>\<^sub>M tree_sigma (count_space A \<Otimes>\<^sub>M lborel)
[PROOF STEP]
by (auto intro!: measurable_ident_sets sets_pair_measure_cong sets_PiM_cong simp add: \<U>_def)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. x) \<in> (tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>i. uniform_measure lborel {0..1})) \<Otimes>\<^sub>M tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M (tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>i. borel)) \<Otimes>\<^sub>M tree_sigma (count_space A \<Otimes>\<^sub>M lborel)

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
have [simp]: "(\<lambda>w. Pi\<^sub>M (set xs) (\<lambda>x. ?U) \<bind>
        (\<lambda>p. return ?treap_sigma (foldl (\<lambda>t x. ins x (p x) t) w xs)))
        \<in> ?treap_sigma \<rightarrow>\<^sub>M subprob_algebra ?treap_sigma"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>w. Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) w xs))) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>w. Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) w xs))) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
[PROOF STEP]
have [measurable]: "c \<in> set xs \<Longrightarrow> c \<in> A" for c
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c \<in> set xs \<Longrightarrow> c \<in> A
[PROOF STEP]
using Cons
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>set xs \<subseteq> A; distinct xs; ?t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs ?t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) ?t xs))
set (x # xs) \<subseteq> A
distinct (x # xs)
t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))

goal (1 subgoal):
 1. c \<in> set xs \<Longrightarrow> c \<in> A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?c2 \<in> set xs \<Longrightarrow> ?c2 \<in> A

goal (1 subgoal):
 1. (\<lambda>w. Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) w xs))) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>w. Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) w xs))) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
[PROOF STEP]
using con_assms
[PROOF STATE]
proof (prove)
using this:
countable A
set xs \<subseteq> A
distinct xs

goal (1 subgoal):
 1. (\<lambda>w. Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) w xs))) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
[PROOF STEP]
by measurable
[PROOF STATE]
proof (state)
this:
(\<lambda>w. Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) w xs))) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<lambda>w. Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) w xs))) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
have [measurable]: "?U \<in> space (prob_algebra (?U))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. uniform_measure lborel {0..1} \<in> space (prob_algebra (uniform_measure lborel {0..1}))
[PROOF STEP]
by (simp add: prob_space_uniform_measure space_prob_algebra)
[PROOF STATE]
proof (state)
this:
uniform_measure lborel {0..1} \<in> space (prob_algebra (uniform_measure lborel {0..1}))

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
have [measurable, intro]: "(\<lambda>t. rinss xs t A) \<in> ?treap_sigma \<rightarrow>\<^sub>M subprob_algebra ?treap_sigma"
    if "set xs \<subseteq> A" for xs
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>t. rinss xs t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
set xs \<subseteq> A

goal (1 subgoal):
 1. (\<lambda>t. rinss xs t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
[PROOF STEP]
proof (induction xs)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. set [] \<subseteq> A \<Longrightarrow> (\<lambda>t. rinss [] t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
 2. \<And>a xs. \<lbrakk>set xs \<subseteq> A \<Longrightarrow> (\<lambda>t. rinss xs t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)); set (a # xs) \<subseteq> A\<rbrakk> \<Longrightarrow> (\<lambda>t. rinss (a # xs) t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
[PROOF STEP]
case (Cons x xs)
[PROOF STATE]
proof (state)
this:
set xs \<subseteq> A \<Longrightarrow> (\<lambda>t. rinss xs t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
set (x # xs) \<subseteq> A

goal (2 subgoals):
 1. set [] \<subseteq> A \<Longrightarrow> (\<lambda>t. rinss [] t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
 2. \<And>a xs. \<lbrakk>set xs \<subseteq> A \<Longrightarrow> (\<lambda>t. rinss xs t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)); set (a # xs) \<subseteq> A\<rbrakk> \<Longrightarrow> (\<lambda>t. rinss (a # xs) t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
set xs \<subseteq> A \<Longrightarrow> (\<lambda>t. rinss xs t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
set (x # xs) \<subseteq> A
[PROOF STEP]
have [measurable]: "x \<in> A" "set xs \<subseteq> A"
[PROOF STATE]
proof (prove)
using this:
set xs \<subseteq> A \<Longrightarrow> (\<lambda>t. rinss xs t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
set (x # xs) \<subseteq> A

goal (1 subgoal):
 1. x \<in> A &&& set xs \<subseteq> A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> A
set xs \<subseteq> A

goal (2 subgoals):
 1. set [] \<subseteq> A \<Longrightarrow> (\<lambda>t. rinss [] t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
 2. \<And>a xs. \<lbrakk>set xs \<subseteq> A \<Longrightarrow> (\<lambda>t. rinss xs t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)); set (a # xs) \<subseteq> A\<rbrakk> \<Longrightarrow> (\<lambda>t. rinss (a # xs) t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
[PROOF STEP]
have [measurable]: "(\<lambda>y. x) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<Otimes>\<^sub>M ?U \<rightarrow>\<^sub>M count_space A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>y. x) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<Otimes>\<^sub>M uniform_measure lborel {0..1} \<rightarrow>\<^sub>M count_space A
[PROOF STEP]
using Cons
[PROOF STATE]
proof (prove)
using this:
set xs \<subseteq> A \<Longrightarrow> (\<lambda>t. rinss xs t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
set (x # xs) \<subseteq> A

goal (1 subgoal):
 1. (\<lambda>y. x) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<Otimes>\<^sub>M uniform_measure lborel {0..1} \<rightarrow>\<^sub>M count_space A
[PROOF STEP]
by measurable
[PROOF STATE]
proof (state)
this:
(\<lambda>y. x) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<Otimes>\<^sub>M uniform_measure lborel {0..1} \<rightarrow>\<^sub>M count_space A

goal (2 subgoals):
 1. set [] \<subseteq> A \<Longrightarrow> (\<lambda>t. rinss [] t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
 2. \<And>a xs. \<lbrakk>set xs \<subseteq> A \<Longrightarrow> (\<lambda>t. rinss xs t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)); set (a # xs) \<subseteq> A\<rbrakk> \<Longrightarrow> (\<lambda>t. rinss (a # xs) t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
[PROOF STEP]
have [measurable]: "(\<lambda>x. x) \<in> ?treap_sigma \<Otimes>\<^sub>M ?U \<rightarrow>\<^sub>M ?treap_sigma \<Otimes>\<^sub>M borel"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. x) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<Otimes>\<^sub>M uniform_measure lborel {0..1} \<rightarrow>\<^sub>M tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<Otimes>\<^sub>M borel
[PROOF STEP]
unfolding \<U>_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. x) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<Otimes>\<^sub>M uniform_measure lborel {0..1} \<rightarrow>\<^sub>M tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<Otimes>\<^sub>M borel
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>x. x) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<Otimes>\<^sub>M uniform_measure lborel {0..1} \<rightarrow>\<^sub>M tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<Otimes>\<^sub>M borel

goal (2 subgoals):
 1. set [] \<subseteq> A \<Longrightarrow> (\<lambda>t. rinss [] t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
 2. \<And>a xs. \<lbrakk>set xs \<subseteq> A \<Longrightarrow> (\<lambda>t. rinss xs t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)); set (a # xs) \<subseteq> A\<rbrakk> \<Longrightarrow> (\<lambda>t. rinss (a # xs) t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
[PROOF STEP]
have [measurable]: "(\<lambda>t. distr (?U) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>p. ins x p t))
    \<in> ?treap_sigma \<rightarrow>\<^sub>M subprob_algebra ?treap_sigma"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>t. distr (uniform_measure lborel {0..1}) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>p. ins x p t)) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
[PROOF STEP]
using con_assms
[PROOF STATE]
proof (prove)
using this:
countable A
set xs \<subseteq> A
distinct xs

goal (1 subgoal):
 1. (\<lambda>t. distr (uniform_measure lborel {0..1}) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>p. ins x p t)) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
[PROOF STEP]
by (intro measurable_prob_algebraD) measurable
[PROOF STATE]
proof (state)
this:
(\<lambda>t. distr (uniform_measure lborel {0..1}) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>p. ins x p t)) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))

goal (2 subgoals):
 1. set [] \<subseteq> A \<Longrightarrow> (\<lambda>t. rinss [] t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
 2. \<And>a xs. \<lbrakk>set xs \<subseteq> A \<Longrightarrow> (\<lambda>t. rinss xs t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)); set (a # xs) \<subseteq> A\<rbrakk> \<Longrightarrow> (\<lambda>t. rinss (a # xs) t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
[PROOF STEP]
from Cons
[PROOF STATE]
proof (chain)
picking this:
set xs \<subseteq> A \<Longrightarrow> (\<lambda>t. rinss xs t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
set (x # xs) \<subseteq> A
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
set xs \<subseteq> A \<Longrightarrow> (\<lambda>t. rinss xs t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
set (x # xs) \<subseteq> A

goal (1 subgoal):
 1. (\<lambda>t. rinss (x # xs) t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
[PROOF STEP]
unfolding rinss.simps insR.simps \<U>_def
[PROOF STATE]
proof (prove)
using this:
set xs \<subseteq> A \<Longrightarrow> (\<lambda>t. rinss xs t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
set (x # xs) \<subseteq> A

goal (1 subgoal):
 1. (\<lambda>t. distr (uniform_measure lborel {0..1}) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>p. ins x p t) \<bind> (\<lambda>t. rinss xs t A)) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
[PROOF STEP]
by measurable
[PROOF STATE]
proof (state)
this:
(\<lambda>t. rinss (x # xs) t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))

goal (1 subgoal):
 1. set [] \<subseteq> A \<Longrightarrow> (\<lambda>t. rinss [] t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
[PROOF STEP]
qed auto
[PROOF STATE]
proof (state)
this:
set ?xs2 \<subseteq> A \<Longrightarrow> (\<lambda>t. rinss ?xs2 t A) \<in> tree_sigma (count_space A \<Otimes>\<^sub>M lborel) \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
have [intro]: "(\<lambda>u. return ?treap_sigma (ins x u t)) \<in> ?U \<rightarrow>\<^sub>M subprob_algebra ?treap_sigma"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>u. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (ins x u t)) \<in> uniform_measure lborel {0..1} \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
[PROOF STEP]
using con_assms Cons
[PROOF STATE]
proof (prove)
using this:
countable A
set xs \<subseteq> A
distinct xs
\<lbrakk>set xs \<subseteq> A; distinct xs; ?t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs ?t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) ?t xs))
set (x # xs) \<subseteq> A
distinct (x # xs)
t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))

goal (1 subgoal):
 1. (\<lambda>u. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (ins x u t)) \<in> uniform_measure lborel {0..1} \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
[PROOF STEP]
by measurable
[PROOF STATE]
proof (state)
this:
(\<lambda>u. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (ins x u t)) \<in> uniform_measure lborel {0..1} \<rightarrow>\<^sub>M subprob_algebra (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
have [simp]: "space (?U \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. ?U)) \<noteq> {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. space (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1})) \<noteq> {}
[PROOF STEP]
by (simp add: prob_space.not_empty prob_space_PiM prob_space_pair prob_space_uniform_measure)
[PROOF STATE]
proof (state)
this:
space (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1})) \<noteq> {}

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
from Cons
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>set xs \<subseteq> A; distinct xs; ?t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs ?t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) ?t xs))
set (x # xs) \<subseteq> A
distinct (x # xs)
t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
[PROOF STEP]
have "rinss (x # xs) t A = (?U \<bind>
                                       (\<lambda>u. return ?treap_sigma (ins x u t))) \<bind>
                                       (\<lambda>t. rinss xs t A)"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>set xs \<subseteq> A; distinct xs; ?t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs ?t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) ?t xs))
set (x # xs) \<subseteq> A
distinct (x # xs)
t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))

goal (1 subgoal):
 1. rinss (x # xs) t A = uniform_measure lborel {0..1} \<bind> (\<lambda>u. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (ins x u t)) \<bind> (\<lambda>t. rinss xs t A)
[PROOF STEP]
by (simp add: insR')
[PROOF STATE]
proof (state)
this:
rinss (x # xs) t A = uniform_measure lborel {0..1} \<bind> (\<lambda>u. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (ins x u t)) \<bind> (\<lambda>t. rinss xs t A)

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
rinss (x # xs) t A = uniform_measure lborel {0..1} \<bind> (\<lambda>u. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (ins x u t)) \<bind> (\<lambda>t. rinss xs t A)

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
have "\<dots> = ?U \<bind> (\<lambda>u. return ?treap_sigma (ins x u t) \<bind> (\<lambda>t. rinss xs t A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. uniform_measure lborel {0..1} \<bind> (\<lambda>u. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (ins x u t)) \<bind> (\<lambda>t. rinss xs t A) = uniform_measure lborel {0..1} \<bind> (\<lambda>u. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (ins x u t) \<bind> (\<lambda>t. rinss xs t A))
[PROOF STEP]
using con_assms Cons
[PROOF STATE]
proof (prove)
using this:
countable A
set xs \<subseteq> A
distinct xs
\<lbrakk>set xs \<subseteq> A; distinct xs; ?t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs ?t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) ?t xs))
set (x # xs) \<subseteq> A
distinct (x # xs)
t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))

goal (1 subgoal):
 1. uniform_measure lborel {0..1} \<bind> (\<lambda>u. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (ins x u t)) \<bind> (\<lambda>t. rinss xs t A) = uniform_measure lborel {0..1} \<bind> (\<lambda>u. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (ins x u t) \<bind> (\<lambda>t. rinss xs t A))
[PROOF STEP]
by (subst bind_assoc) auto
[PROOF STATE]
proof (state)
this:
uniform_measure lborel {0..1} \<bind> (\<lambda>u. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (ins x u t)) \<bind> (\<lambda>t. rinss xs t A) = uniform_measure lborel {0..1} \<bind> (\<lambda>u. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (ins x u t) \<bind> (\<lambda>t. rinss xs t A))

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
uniform_measure lborel {0..1} \<bind> (\<lambda>u. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (ins x u t)) \<bind> (\<lambda>t. rinss xs t A) = uniform_measure lborel {0..1} \<bind> (\<lambda>u. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (ins x u t) \<bind> (\<lambda>t. rinss xs t A))

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
have "\<dots> = ?U \<bind> (\<lambda>u. rinss xs (ins x u t) A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. uniform_measure lborel {0..1} \<bind> (\<lambda>u. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (ins x u t) \<bind> (\<lambda>t. rinss xs t A)) = uniform_measure lborel {0..1} \<bind> (\<lambda>u. rinss xs (ins x u t) A)
[PROOF STEP]
using con_assms Cons
[PROOF STATE]
proof (prove)
using this:
countable A
set xs \<subseteq> A
distinct xs
\<lbrakk>set xs \<subseteq> A; distinct xs; ?t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs ?t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) ?t xs))
set (x # xs) \<subseteq> A
distinct (x # xs)
t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))

goal (1 subgoal):
 1. uniform_measure lborel {0..1} \<bind> (\<lambda>u. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (ins x u t) \<bind> (\<lambda>t. rinss xs t A)) = uniform_measure lborel {0..1} \<bind> (\<lambda>u. rinss xs (ins x u t) A)
[PROOF STEP]
by (subst bind_return) auto
[PROOF STATE]
proof (state)
this:
uniform_measure lborel {0..1} \<bind> (\<lambda>u. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (ins x u t) \<bind> (\<lambda>t. rinss xs t A)) = uniform_measure lborel {0..1} \<bind> (\<lambda>u. rinss xs (ins x u t) A)

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
uniform_measure lborel {0..1} \<bind> (\<lambda>u. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (ins x u t) \<bind> (\<lambda>t. rinss xs t A)) = uniform_measure lborel {0..1} \<bind> (\<lambda>u. rinss xs (ins x u t) A)

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
have "\<dots> = ?U \<bind>
                 (\<lambda>u. Pi\<^sub>M (set xs) (\<lambda>x. ?U) \<bind>
                 (\<lambda>p. return ?treap_sigma (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. uniform_measure lborel {0..1} \<bind> (\<lambda>u. rinss xs (ins x u t) A) = uniform_measure lborel {0..1} \<bind> (\<lambda>u. Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs)))
[PROOF STEP]
using Cons
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>set xs \<subseteq> A; distinct xs; ?t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs ?t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) ?t xs))
set (x # xs) \<subseteq> A
distinct (x # xs)
t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))

goal (1 subgoal):
 1. uniform_measure lborel {0..1} \<bind> (\<lambda>u. rinss xs (ins x u t) A) = uniform_measure lborel {0..1} \<bind> (\<lambda>u. Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs)))
[PROOF STEP]
by (subst Cons) (auto simp add: treap_ins keys_ins)
[PROOF STATE]
proof (state)
this:
uniform_measure lborel {0..1} \<bind> (\<lambda>u. rinss xs (ins x u t) A) = uniform_measure lborel {0..1} \<bind> (\<lambda>u. Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs)))

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
uniform_measure lborel {0..1} \<bind> (\<lambda>u. rinss xs (ins x u t) A) = uniform_measure lborel {0..1} \<bind> (\<lambda>u. Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs)))

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
have "\<dots> = ?U \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. ?U) \<bind>
                  (\<lambda>(u,p). return ?treap_sigma (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. uniform_measure lborel {0..1} \<bind> (\<lambda>u. Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs))) = uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>(u, p). return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. uniform_measure lborel {0..1} \<bind> (\<lambda>u. Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs))) = uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>(u, p). return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs))
[PROOF STEP]
have [measurable]: "pair_prob_space (?U) (Pi\<^sub>M (set xs) (\<lambda>x. ?U))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pair_prob_space (uniform_measure lborel {0..1}) (Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}))
[PROOF STEP]
by (simp add: \<U>_def pair_prob_space_def pair_sigma_finite.intro prob_space_PiM
          prob_space_imp_sigma_finite prob_space_uniform_measure)
[PROOF STATE]
proof (state)
this:
pair_prob_space (uniform_measure lborel {0..1}) (Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}))

goal (1 subgoal):
 1. uniform_measure lborel {0..1} \<bind> (\<lambda>u. Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs))) = uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>(u, p). return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs))
[PROOF STEP]
note this[unfolded \<U>_def, measurable]
[PROOF STATE]
proof (state)
this:
pair_prob_space (uniform_measure lborel {0..1}) (Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}))

goal (1 subgoal):
 1. uniform_measure lborel {0..1} \<bind> (\<lambda>u. Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs))) = uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>(u, p). return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs))
[PROOF STEP]
have [measurable]: "c \<in> set xs \<Longrightarrow> c \<in> A" for c
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c \<in> set xs \<Longrightarrow> c \<in> A
[PROOF STEP]
using Cons
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>set xs \<subseteq> A; distinct xs; ?t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs ?t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) ?t xs))
set (x # xs) \<subseteq> A
distinct (x # xs)
t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))

goal (1 subgoal):
 1. c \<in> set xs \<Longrightarrow> c \<in> A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?c2 \<in> set xs \<Longrightarrow> ?c2 \<in> A

goal (1 subgoal):
 1. uniform_measure lborel {0..1} \<bind> (\<lambda>u. Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs))) = uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>(u, p). return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. uniform_measure lborel {0..1} \<bind> (\<lambda>u. Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs))) = uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>(u, p). return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs))
[PROOF STEP]
using con_assms Cons
[PROOF STATE]
proof (prove)
using this:
countable A
set xs \<subseteq> A
distinct xs
\<lbrakk>set xs \<subseteq> A; distinct xs; ?t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs ?t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) ?t xs))
set (x # xs) \<subseteq> A
distinct (x # xs)
t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))

goal (1 subgoal):
 1. uniform_measure lborel {0..1} \<bind> (\<lambda>u. Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs))) = uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>(u, p). return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs))
[PROOF STEP]
by (subst pair_prob_space.pair_measure_bind) measurable
[PROOF STATE]
proof (state)
this:
uniform_measure lborel {0..1} \<bind> (\<lambda>u. Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs))) = uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>(u, p). return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
uniform_measure lborel {0..1} \<bind> (\<lambda>u. Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs))) = uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>(u, p). return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs))

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
uniform_measure lborel {0..1} \<bind> (\<lambda>u. Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs))) = uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>(u, p). return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs))

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
have "\<dots> = distr (?U \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. ?U)) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))
                  (\<lambda>(u, f). foldl (\<lambda>t x. ins x (f x) t) (ins x u t) xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>(u, p). return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs)) = distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>(u, f). foldl (\<lambda>t x. ins x (f x) t) (ins x u t) xs)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>(u, p). return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs)) = distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>(u, f). foldl (\<lambda>t x. ins x (f x) t) (ins x u t) xs)
[PROOF STEP]
have [simp]: "c \<in> set xs \<Longrightarrow> c \<in> A" for c
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c \<in> set xs \<Longrightarrow> c \<in> A
[PROOF STEP]
using Cons
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>set xs \<subseteq> A; distinct xs; ?t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs ?t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) ?t xs))
set (x # xs) \<subseteq> A
distinct (x # xs)
t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))

goal (1 subgoal):
 1. c \<in> set xs \<Longrightarrow> c \<in> A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?c2 \<in> set xs \<Longrightarrow> ?c2 \<in> A

goal (1 subgoal):
 1. uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>(u, p). return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs)) = distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>(u, f). foldl (\<lambda>t x. ins x (f x) t) (ins x u t) xs)
[PROOF STEP]
have "(\<lambda>xa. foldl (\<lambda>t x. ins x (snd xa x) t) (ins x (fst xa) t) xs) =
          (\<lambda>(u, f). foldl (\<lambda>t x. ins x (f x) t) (ins x u t) xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>xa. foldl (\<lambda>t x. ins x (snd xa x) t) (ins x (fst xa) t) xs) = (\<lambda>(u, f). foldl (\<lambda>t x. ins x (f x) t) (ins x u t) xs)
[PROOF STEP]
by (auto simp add: case_prod_beta')
[PROOF STATE]
proof (state)
this:
(\<lambda>xa. foldl (\<lambda>t x. ins x (snd xa x) t) (ins x (fst xa) t) xs) = (\<lambda>(u, f). foldl (\<lambda>t x. ins x (f x) t) (ins x u t) xs)

goal (1 subgoal):
 1. uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>(u, p). return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs)) = distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>(u, f). foldl (\<lambda>t x. ins x (f x) t) (ins x u t) xs)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>xa. foldl (\<lambda>t x. ins x (snd xa x) t) (ins x (fst xa) t) xs) = (\<lambda>(u, f). foldl (\<lambda>t x. ins x (f x) t) (ins x u t) xs)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<lambda>xa. foldl (\<lambda>t x. ins x (snd xa x) t) (ins x (fst xa) t) xs) = (\<lambda>(u, f). foldl (\<lambda>t x. ins x (f x) t) (ins x u t) xs)

goal (1 subgoal):
 1. uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>(u, p). return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs)) = distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>(u, f). foldl (\<lambda>t x. ins x (f x) t) (ins x u t) xs)
[PROOF STEP]
using con_assms Cons
[PROOF STATE]
proof (prove)
using this:
(\<lambda>xa. foldl (\<lambda>t x. ins x (snd xa x) t) (ins x (fst xa) t) xs) = (\<lambda>(u, f). foldl (\<lambda>t x. ins x (f x) t) (ins x u t) xs)
countable A
set xs \<subseteq> A
distinct xs
\<lbrakk>set xs \<subseteq> A; distinct xs; ?t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs ?t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) ?t xs))
set (x # xs) \<subseteq> A
distinct (x # xs)
t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))

goal (1 subgoal):
 1. uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>(u, p). return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs)) = distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>(u, f). foldl (\<lambda>t x. ins x (f x) t) (ins x u t) xs)
[PROOF STEP]
by (subst case_prod_beta', subst bind_return_distr') measurable
[PROOF STATE]
proof (state)
this:
uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>(u, p). return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs)) = distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>(u, f). foldl (\<lambda>t x. ins x (f x) t) (ins x u t) xs)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>(u, p). return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs)) = distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>(u, f). foldl (\<lambda>t x. ins x (f x) t) (ins x u t) xs)

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>(u, p). return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x u t) xs)) = distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>(u, f). foldl (\<lambda>t x. ins x (f x) t) (ins x u t) xs)

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
have
    "\<dots> = distr (?U \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>i. ?U)) ?treap_sigma
          (\<lambda>f. foldl (\<lambda>t y. ins y (if y = x then fst f else snd f y) t) (ins x (fst f) t) xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>(u, f). foldl (\<lambda>t x. ins x (f x) t) (ins x u t) xs) = distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>i. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>f. foldl (\<lambda>t y. ins y (if y = x then fst f else snd f y) t) (ins x (fst f) t) xs)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>(u, f). foldl (\<lambda>t x. ins x (f x) t) (ins x u t) xs) = distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>i. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>f. foldl (\<lambda>t y. ins y (if y = x then fst f else snd f y) t) (ins x (fst f) t) xs)
[PROOF STEP]
have "foldl (\<lambda>t y. ins y (snd f y) t) (ins x (fst f) t) xs =
          foldl (\<lambda>t y. ins y (if y = x then fst f else snd f y) t) (ins x (fst f) t) xs" for f
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. foldl (\<lambda>t y. ins y (snd f y) t) (ins x (fst f) t) xs = foldl (\<lambda>t y. ins y (if y = x then fst f else snd f y) t) (ins x (fst f) t) xs
[PROOF STEP]
using Cons
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>set xs \<subseteq> A; distinct xs; ?t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs ?t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) ?t xs))
set (x # xs) \<subseteq> A
distinct (x # xs)
t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))

goal (1 subgoal):
 1. foldl (\<lambda>t y. ins y (snd f y) t) (ins x (fst f) t) xs = foldl (\<lambda>t y. ins y (if y = x then fst f else snd f y) t) (ins x (fst f) t) xs
[PROOF STEP]
by (intro foldl_cong) auto
[PROOF STATE]
proof (state)
this:
foldl (\<lambda>t y. ins y (snd ?f2 y) t) (ins x (fst ?f2) t) xs = foldl (\<lambda>t y. ins y (if y = x then fst ?f2 else snd ?f2 y) t) (ins x (fst ?f2) t) xs

goal (1 subgoal):
 1. distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>(u, f). foldl (\<lambda>t x. ins x (f x) t) (ins x u t) xs) = distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>i. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>f. foldl (\<lambda>t y. ins y (if y = x then fst f else snd f y) t) (ins x (fst f) t) xs)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
foldl (\<lambda>t y. ins y (snd ?f2 y) t) (ins x (fst ?f2) t) xs = foldl (\<lambda>t y. ins y (if y = x then fst ?f2 else snd ?f2 y) t) (ins x (fst ?f2) t) xs
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
foldl (\<lambda>t y. ins y (snd ?f2 y) t) (ins x (fst ?f2) t) xs = foldl (\<lambda>t y. ins y (if y = x then fst ?f2 else snd ?f2 y) t) (ins x (fst ?f2) t) xs

goal (1 subgoal):
 1. distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>(u, f). foldl (\<lambda>t x. ins x (f x) t) (ins x u t) xs) = distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>i. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>f. foldl (\<lambda>t y. ins y (if y = x then fst f else snd f y) t) (ins x (fst f) t) xs)
[PROOF STEP]
by (auto simp add: case_prod_beta')
[PROOF STATE]
proof (state)
this:
distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>(u, f). foldl (\<lambda>t x. ins x (f x) t) (ins x u t) xs) = distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>i. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>f. foldl (\<lambda>t y. ins y (if y = x then fst f else snd f y) t) (ins x (fst f) t) xs)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>(u, f). foldl (\<lambda>t x. ins x (f x) t) (ins x u t) xs) = distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>i. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>f. foldl (\<lambda>t y. ins y (if y = x then fst f else snd f y) t) (ins x (fst f) t) xs)

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>(u, f). foldl (\<lambda>t x. ins x (f x) t) (ins x u t) xs) = distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>i. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>f. foldl (\<lambda>t y. ins y (if y = x then fst f else snd f y) t) (ins x (fst f) t) xs)

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
have "\<dots> = distr (?U \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>i. ?U)) (Pi\<^sub>M (insert x (set xs)) (\<lambda>i. ?U))
                          (\<lambda>(r, f). f(x := r)) \<bind>
                          (\<lambda>p. return ?treap_sigma (foldl (\<lambda>t x. ins x (p x) t) (ins x (p x) t) xs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>i. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>f. foldl (\<lambda>t y. ins y (if y = x then fst f else snd f y) t) (ins x (fst f) t) xs) = distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>i. uniform_measure lborel {0..1})) (Pi\<^sub>M (insert x (set xs)) (\<lambda>i. uniform_measure lborel {0..1})) (\<lambda>(r, f). f(x := r)) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x (p x) t) xs))
[PROOF STEP]
using con_assms  Cons
[PROOF STATE]
proof (prove)
using this:
countable A
set xs \<subseteq> A
distinct xs
\<lbrakk>set xs \<subseteq> A; distinct xs; ?t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs ?t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) ?t xs))
set (x # xs) \<subseteq> A
distinct (x # xs)
t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))

goal (1 subgoal):
 1. distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>i. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>f. foldl (\<lambda>t y. ins y (if y = x then fst f else snd f y) t) (ins x (fst f) t) xs) = distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>i. uniform_measure lborel {0..1})) (Pi\<^sub>M (insert x (set xs)) (\<lambda>i. uniform_measure lborel {0..1})) (\<lambda>(r, f). f(x := r)) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x (p x) t) xs))
[PROOF STEP]
by (subst bind_distr_return) (measurable, auto simp add: case_prod_beta')
[PROOF STATE]
proof (state)
this:
distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>i. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>f. foldl (\<lambda>t y. ins y (if y = x then fst f else snd f y) t) (ins x (fst f) t) xs) = distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>i. uniform_measure lborel {0..1})) (Pi\<^sub>M (insert x (set xs)) (\<lambda>i. uniform_measure lborel {0..1})) (\<lambda>(r, f). f(x := r)) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x (p x) t) xs))

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>i. uniform_measure lborel {0..1})) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>f. foldl (\<lambda>t y. ins y (if y = x then fst f else snd f y) t) (ins x (fst f) t) xs) = distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>i. uniform_measure lborel {0..1})) (Pi\<^sub>M (insert x (set xs)) (\<lambda>i. uniform_measure lborel {0..1})) (\<lambda>(r, f). f(x := r)) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x (p x) t) xs))

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
have "\<dots> = Pi\<^sub>M (insert x (set xs)) (\<lambda>x. ?U) \<bind>
                  (\<lambda>p. return ?treap_sigma (foldl (\<lambda>t x. ins x (p x) t) (ins x (p x) t) xs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>i. uniform_measure lborel {0..1})) (Pi\<^sub>M (insert x (set xs)) (\<lambda>i. uniform_measure lborel {0..1})) (\<lambda>(r, f). f(x := r)) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x (p x) t) xs)) = Pi\<^sub>M (insert x (set xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x (p x) t) xs))
[PROOF STEP]
by (subst distr_pair_PiM_eq_PiM) (auto simp add: prob_space_uniform_measure)
[PROOF STATE]
proof (state)
this:
distr (uniform_measure lborel {0..1} \<Otimes>\<^sub>M Pi\<^sub>M (set xs) (\<lambda>i. uniform_measure lborel {0..1})) (Pi\<^sub>M (insert x (set xs)) (\<lambda>i. uniform_measure lborel {0..1})) (\<lambda>(r, f). f(x := r)) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x (p x) t) xs)) = Pi\<^sub>M (insert x (set xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x (p x) t) xs))

goal (1 subgoal):
 1. \<And>a xs t. \<lbrakk>\<And>t. \<lbrakk>set xs \<subseteq> A; distinct xs; t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs)); set (a # xs) \<subseteq> A; distinct (a # xs); t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))\<rbrakk> \<Longrightarrow> rinss (a # xs) t A = Pi\<^sub>M (set (a # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (a # xs)))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
rinss (x # xs) t A = Pi\<^sub>M (insert x (set xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x (p x) t) xs))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
rinss (x # xs) t A = Pi\<^sub>M (insert x (set xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) (ins x (p x) t) xs))

goal (1 subgoal):
 1. rinss (x # xs) t A = Pi\<^sub>M (set (x # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (x # xs)))
[PROOF STEP]
by (simp)
[PROOF STATE]
proof (state)
this:
rinss (x # xs) t A = Pi\<^sub>M (set (x # xs)) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t (x # xs)))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs))

goal (1 subgoal):
 1. rinss xs t A = distr (Pi\<^sub>M (set xs) (\<lambda>x. \<U> 0 1)) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>p. foldl (\<lambda>t x. ins x (p x) t) t xs)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs))

goal (1 subgoal):
 1. rinss xs t A = distr (Pi\<^sub>M (set xs) (\<lambda>x. \<U> 0 1)) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>p. foldl (\<lambda>t x. ins x (p x) t) t xs)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
rinss xs t A = Pi\<^sub>M (set xs) (\<lambda>x. uniform_measure lborel {0..1}) \<bind> (\<lambda>p. return (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (foldl (\<lambda>t x. ins x (p x) t) t xs))
t \<in> space (tree_sigma (count_space A \<Otimes>\<^sub>M lborel))

goal (1 subgoal):
 1. rinss xs t A = distr (Pi\<^sub>M (set xs) (\<lambda>x. \<U> 0 1)) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>p. foldl (\<lambda>t x. ins x (p x) t) t xs)
[PROOF STEP]
by (subst bind_return_distr'[symmetric]) (auto simp add: bind_return_distr')
[PROOF STATE]
proof (state)
this:
rinss xs t A = distr (Pi\<^sub>M (set xs) (\<lambda>x. \<U> 0 1)) (tree_sigma (count_space A \<Otimes>\<^sub>M lborel)) (\<lambda>p. foldl (\<lambda>t x. ins x (p x) t) t xs)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma size_pop_sub: "\<lbrakk>0 < size current; invar current; pop current = (x, current') \<rbrakk>
   \<Longrightarrow> size current' = size current - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < size current; invar current; Current.pop current = (x, current')\<rbrakk> \<Longrightarrow> size current' = size current - 1
[PROOF STEP]
by(induction current rule: pop.induct) auto


[STATEMENT]
lemma LIMSEQ_le_const: "X \<longlonglongrightarrow> x \<Longrightarrow> \<exists>N. \<forall>n\<ge>N. a \<le> X n \<Longrightarrow> a \<le> x"
  for a x :: "'a::linorder_topology"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>X \<longlonglongrightarrow> x; \<exists>N. \<forall>n\<ge>N. a \<le> X n\<rbrakk> \<Longrightarrow> a \<le> x
[PROOF STEP]
by (simp add: eventually_at_top_linorder tendsto_lowerbound)


[STATEMENT]
lemma trans_letter_less:
  assumes "trans r"
  shows "trans (letter_less r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trans (letter_less r)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
trans r

goal (1 subgoal):
 1. trans (letter_less r)
[PROOF STEP]
unfolding trans_def letter_less_def
[PROOF STATE]
proof (prove)
using this:
\<forall>x y z. (x, y) \<in> r \<longrightarrow> (y, z) \<in> r \<longrightarrow> (x, z) \<in> r

goal (1 subgoal):
 1. \<forall>x y z. (x, y) \<in> {(a, b). (snd a, snd b) \<in> r} \<longrightarrow> (y, z) \<in> {(a, b). (snd a, snd b) \<in> r} \<longrightarrow> (x, z) \<in> {(a, b). (snd a, snd b) \<in> r}
[PROOF STEP]
by fast


[STATEMENT]
lemma mset_less[code]: "xs \<subset># (ys :: 'a multiset) \<longleftrightarrow> xs \<subseteq># ys \<and> \<not> ys \<subseteq># xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (xs \<subset># ys) = (xs \<subseteq># ys \<and> \<not> ys \<subseteq># xs)
[PROOF STEP]
by (rule subset_mset.less_le_not_le)


[STATEMENT]
lemma fempty_fCollect_eq [simp]: "{||} = fCollect P \<longleftrightarrow> (\<forall>x. \<not> P x) \<or> infinite (Collect P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ({||} = fCollect P) = ((\<forall>x. \<not> P x) \<or> infinite (Collect P))
[PROOF STEP]
by auto