[STATEMENT]
lemma (in infinite_cts_filtration) F_n_integral_pos:
  fixes f::"bool stream\<Rightarrow>real"
  assumes "f\<in> borel_measurable (F n)"
  and "\<forall>w. 0 \<le> f w"
  shows "has_bochner_integral M f
    (\<Sum> w\<in> range (pseudo_proj_True n). (measure M ((pseudo_proj_True n) -`{w} \<inter> space M)) *   (f w))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. has_bochner_integral M f (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. has_bochner_integral M f (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)
[PROOF STEP]
have "integral\<^sup>N M f = (\<Sum> w\<in> range (pseudo_proj_True n). (emeasure M ((pseudo_proj_True n) -`{w} \<inter> space M)) *   (f w))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (f x) \<partial>M = (\<Sum>w\<in>range (pseudo_proj_True n). emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f \<in> borel_measurable (F n)
\<forall>w. 0 \<le> f w

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (f x) \<partial>M = (\<Sum>w\<in>range (pseudo_proj_True n). emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w))
[PROOF STEP]
by (simp add: F_n_nn_integral_pos)
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. ennreal (f x) \<partial>M = (\<Sum>w\<in>range (pseudo_proj_True n). emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w))

goal (1 subgoal):
 1. has_bochner_integral M f (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)
[PROOF STEP]
have "integral\<^sup>L M f = enn2real (integral\<^sup>N M f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. expectation f = enn2real (\<integral>\<^sup>+ x. ennreal (f x) \<partial>M)
[PROOF STEP]
proof (rule integral_eq_nn_integral)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. random_variable borel f
 2. AE x in M. 0 \<le> f x
[PROOF STEP]
show "AE x in M. 0\<le> f x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. AE x in M. 0 \<le> f x
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f \<in> borel_measurable (F n)
\<forall>w. 0 \<le> f w

goal (1 subgoal):
 1. AE x in M. 0 \<le> f x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
AE x in M. 0 \<le> f x

goal (1 subgoal):
 1. random_variable borel f
[PROOF STEP]
show "random_variable borel f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. random_variable borel f
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f \<in> borel_measurable (F n)
\<forall>w. 0 \<le> f w

goal (1 subgoal):
 1. random_variable borel f
[PROOF STEP]
using measurable_from_subalg nat_filtration_subalgebra natural_filtration
[PROOF STATE]
proof (prove)
using this:
f \<in> borel_measurable (F n)
\<forall>w. 0 \<le> f w
\<lbrakk>subalgebra ?M ?F; ?f \<in> ?F \<rightarrow>\<^sub>M ?N\<rbrakk> \<Longrightarrow> ?f \<in> ?M \<rightarrow>\<^sub>M ?N
subalgebra M (nat_filtration ?n)
F = nat_filtration

goal (1 subgoal):
 1. random_variable borel f
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
random_variable borel f

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
expectation f = enn2real (\<integral>\<^sup>+ x. ennreal (f x) \<partial>M)

goal (1 subgoal):
 1. has_bochner_integral M f (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
expectation f = enn2real (\<integral>\<^sup>+ x. ennreal (f x) \<partial>M)

goal (1 subgoal):
 1. has_bochner_integral M f (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)
[PROOF STEP]
have "... = enn2real (\<Sum> w\<in> range (pseudo_proj_True n). (emeasure M ((pseudo_proj_True n) -`{w} \<inter> space M)) *   (f w))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. enn2real (\<integral>\<^sup>+ x. ennreal (f x) \<partial>M) = enn2real (\<Sum>w\<in>range (pseudo_proj_True n). emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f \<in> borel_measurable (F n)
\<forall>w. 0 \<le> f w

goal (1 subgoal):
 1. enn2real (\<integral>\<^sup>+ x. ennreal (f x) \<partial>M) = enn2real (\<Sum>w\<in>range (pseudo_proj_True n). emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w))
[PROOF STEP]
by (simp add: F_n_nn_integral_pos)
[PROOF STATE]
proof (state)
this:
enn2real (\<integral>\<^sup>+ x. ennreal (f x) \<partial>M) = enn2real (\<Sum>w\<in>range (pseudo_proj_True n). emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w))

goal (1 subgoal):
 1. has_bochner_integral M f (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
enn2real (\<integral>\<^sup>+ x. ennreal (f x) \<partial>M) = enn2real (\<Sum>w\<in>range (pseudo_proj_True n). emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w))

goal (1 subgoal):
 1. has_bochner_integral M f (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)
[PROOF STEP]
have "... = (\<Sum> w\<in> range (pseudo_proj_True n). enn2real ((emeasure M ((pseudo_proj_True n) -`{w} \<inter> space M)) *   (f w)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. enn2real (\<Sum>w\<in>range (pseudo_proj_True n). emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w)) = (\<Sum>w\<in>range (pseudo_proj_True n). enn2real (emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w)))
[PROOF STEP]
proof (rule enn2real_sum)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. finite (range (pseudo_proj_True n))
 2. \<And>w. w \<in> range (pseudo_proj_True n) \<Longrightarrow> emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w) < \<top>
[PROOF STEP]
show "finite (range (pseudo_proj_True n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (range (pseudo_proj_True n))
[PROOF STEP]
by (simp add: pseudo_proj_True_finite_image)
[PROOF STATE]
proof (state)
this:
finite (range (pseudo_proj_True n))

goal (1 subgoal):
 1. \<And>w. w \<in> range (pseudo_proj_True n) \<Longrightarrow> emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w) < \<top>
[PROOF STEP]
show "\<And>w. w \<in> range (pseudo_proj_True n) \<Longrightarrow> emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w) < \<top>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>w. w \<in> range (pseudo_proj_True n) \<Longrightarrow> emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w) < \<top>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>w. w \<in> range (pseudo_proj_True n) \<Longrightarrow> emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w) < \<top>
[PROOF STEP]
fix w
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>w. w \<in> range (pseudo_proj_True n) \<Longrightarrow> emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w) < \<top>
[PROOF STEP]
assume "w\<in> range (pseudo_proj_True n)"
[PROOF STATE]
proof (state)
this:
w \<in> range (pseudo_proj_True n)

goal (1 subgoal):
 1. \<And>w. w \<in> range (pseudo_proj_True n) \<Longrightarrow> emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w) < \<top>
[PROOF STEP]
show "emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w) < \<top>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w) < \<top>
[PROOF STEP]
by (simp add: emeasure_eq_measure ennreal_mult_less_top)
[PROOF STATE]
proof (state)
this:
emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w) < \<top>

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?w1 \<in> range (pseudo_proj_True n) \<Longrightarrow> emeasure M (pseudo_proj_True n -` {?w1} \<inter> space M) * ennreal (f ?w1) < \<top>

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
enn2real (\<Sum>w\<in>range (pseudo_proj_True n). emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w)) = (\<Sum>w\<in>range (pseudo_proj_True n). enn2real (emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w)))

goal (1 subgoal):
 1. has_bochner_integral M f (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
enn2real (\<Sum>w\<in>range (pseudo_proj_True n). emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w)) = (\<Sum>w\<in>range (pseudo_proj_True n). enn2real (emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w)))

goal (1 subgoal):
 1. has_bochner_integral M f (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)
[PROOF STEP]
have "... = (\<Sum> w\<in> range (pseudo_proj_True n).  ((measure M ((pseudo_proj_True n) -`{w} \<inter> space M)) *   (f w)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>w\<in>range (pseudo_proj_True n). enn2real (emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w))) = (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)
[PROOF STEP]
by (simp add: Sigma_Algebra.measure_def assms(2) enn2real_mult)
[PROOF STATE]
proof (state)
this:
(\<Sum>w\<in>range (pseudo_proj_True n). enn2real (emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w))) = (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)

goal (1 subgoal):
 1. has_bochner_integral M f (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
expectation f = (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)
[PROOF STEP]
have "integral\<^sup>L M f =(\<Sum> w\<in> range (pseudo_proj_True n).  ((measure M ((pseudo_proj_True n) -`{w} \<inter> space M)) *   (f w)))"
[PROOF STATE]
proof (prove)
using this:
expectation f = (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)

goal (1 subgoal):
 1. expectation f = (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
expectation f = (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)

goal (1 subgoal):
 1. has_bochner_integral M f (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
expectation f = (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)

goal (1 subgoal):
 1. has_bochner_integral M f (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)
[PROOF STEP]
have "integrable M f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integrable M f
[PROOF STEP]
proof (rule integrableI_nn_integral_finite)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. random_variable borel f
 2. AE x in M. 0 \<le> f x
 3. \<integral>\<^sup>+ x. ennreal (f x) \<partial>M = ennreal ?x
[PROOF STEP]
show "random_variable borel f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. random_variable borel f
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f \<in> borel_measurable (F n)
\<forall>w. 0 \<le> f w

goal (1 subgoal):
 1. random_variable borel f
[PROOF STEP]
using measurable_from_subalg nat_filtration_subalgebra natural_filtration
[PROOF STATE]
proof (prove)
using this:
f \<in> borel_measurable (F n)
\<forall>w. 0 \<le> f w
\<lbrakk>subalgebra ?M ?F; ?f \<in> ?F \<rightarrow>\<^sub>M ?N\<rbrakk> \<Longrightarrow> ?f \<in> ?M \<rightarrow>\<^sub>M ?N
subalgebra M (nat_filtration ?n)
F = nat_filtration

goal (1 subgoal):
 1. random_variable borel f
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
random_variable borel f

goal (2 subgoals):
 1. AE x in M. 0 \<le> f x
 2. \<integral>\<^sup>+ x. ennreal (f x) \<partial>M = ennreal ?x
[PROOF STEP]
show "AE x in M. 0 \<le> f x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. AE x in M. 0 \<le> f x
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f \<in> borel_measurable (F n)
\<forall>w. 0 \<le> f w

goal (1 subgoal):
 1. AE x in M. 0 \<le> f x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
AE x in M. 0 \<le> f x

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (f x) \<partial>M = ennreal ?x
[PROOF STEP]
have "(\<integral>\<^sup>+ x. ennreal (f x) \<partial>M) = (\<Sum> w\<in> range (pseudo_proj_True n). (emeasure M ((pseudo_proj_True n) -`{w} \<inter> space M)) *   (f w))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (f x) \<partial>M = (\<Sum>w\<in>range (pseudo_proj_True n). emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f \<in> borel_measurable (F n)
\<forall>w. 0 \<le> f w

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (f x) \<partial>M = (\<Sum>w\<in>range (pseudo_proj_True n). emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w))
[PROOF STEP]
by (simp add: F_n_nn_integral_pos)
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. ennreal (f x) \<partial>M = (\<Sum>w\<in>range (pseudo_proj_True n). emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w))

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (f x) \<partial>M = ennreal ?x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. ennreal (f x) \<partial>M = (\<Sum>w\<in>range (pseudo_proj_True n). emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w))

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (f x) \<partial>M = ennreal ?x
[PROOF STEP]
have "... = (\<Sum> w\<in> range (pseudo_proj_True n). ennreal (measure M ((pseudo_proj_True n) -`{w} \<inter> space M) *   (f w)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>w\<in>range (pseudo_proj_True n). emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w)) = (\<Sum>w\<in>range (pseudo_proj_True n). ennreal (prob (pseudo_proj_True n -` {w} \<inter> space M) * f w))
[PROOF STEP]
proof (rule sum.cong, simp)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> range (pseudo_proj_True n) \<Longrightarrow> emeasure M (pseudo_proj_True n -` {x} \<inter> space M) * ennreal (f x) = ennreal (prob (pseudo_proj_True n -` {x} \<inter> space M) * f x)
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> range (pseudo_proj_True n) \<Longrightarrow> emeasure M (pseudo_proj_True n -` {x} \<inter> space M) * ennreal (f x) = ennreal (prob (pseudo_proj_True n -` {x} \<inter> space M) * f x)
[PROOF STEP]
assume "x\<in> range (pseudo_proj_True n)"
[PROOF STATE]
proof (state)
this:
x \<in> range (pseudo_proj_True n)

goal (1 subgoal):
 1. \<And>x. x \<in> range (pseudo_proj_True n) \<Longrightarrow> emeasure M (pseudo_proj_True n -` {x} \<inter> space M) * ennreal (f x) = ennreal (prob (pseudo_proj_True n -` {x} \<inter> space M) * f x)
[PROOF STEP]
thus "emeasure M (pseudo_proj_True n -` {x} \<inter> space M) * ennreal (f x) =
         ennreal (prob (pseudo_proj_True n -` {x} \<inter> space M) * f x)"
[PROOF STATE]
proof (prove)
using this:
x \<in> range (pseudo_proj_True n)

goal (1 subgoal):
 1. emeasure M (pseudo_proj_True n -` {x} \<inter> space M) * ennreal (f x) = ennreal (prob (pseudo_proj_True n -` {x} \<inter> space M) * f x)
[PROOF STEP]
using assms(2) emeasure_eq_measure ennreal_mult''
[PROOF STATE]
proof (prove)
using this:
x \<in> range (pseudo_proj_True n)
\<forall>w. 0 \<le> f w
emeasure M ?A = ennreal (prob ?A)
0 \<le> ?b \<Longrightarrow> ennreal (?a * ?b) = ennreal ?a * ennreal ?b

goal (1 subgoal):
 1. emeasure M (pseudo_proj_True n -` {x} \<inter> space M) * ennreal (f x) = ennreal (prob (pseudo_proj_True n -` {x} \<inter> space M) * f x)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
emeasure M (pseudo_proj_True n -` {x} \<inter> space M) * ennreal (f x) = ennreal (prob (pseudo_proj_True n -` {x} \<inter> space M) * f x)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>w\<in>range (pseudo_proj_True n). emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w)) = (\<Sum>w\<in>range (pseudo_proj_True n). ennreal (prob (pseudo_proj_True n -` {w} \<inter> space M) * f w))

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (f x) \<partial>M = ennreal ?x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>w\<in>range (pseudo_proj_True n). emeasure M (pseudo_proj_True n -` {w} \<inter> space M) * ennreal (f w)) = (\<Sum>w\<in>range (pseudo_proj_True n). ennreal (prob (pseudo_proj_True n -` {w} \<inter> space M) * f w))

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (f x) \<partial>M = ennreal ?x
[PROOF STEP]
have "... = ennreal (\<Sum> w\<in> range (pseudo_proj_True n). (measure M ((pseudo_proj_True n) -`{w} \<inter> space M) *   (f w)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>w\<in>range (pseudo_proj_True n). ennreal (prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)) = ennreal (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)
[PROOF STEP]
proof (rule ennreal_sum)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. finite (range (pseudo_proj_True n))
 2. \<And>w. 0 \<le> prob (pseudo_proj_True n -` {w} \<inter> space M) * f w
[PROOF STEP]
show "finite (range (pseudo_proj_True n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (range (pseudo_proj_True n))
[PROOF STEP]
by (simp add: pseudo_proj_True_finite_image)
[PROOF STATE]
proof (state)
this:
finite (range (pseudo_proj_True n))

goal (1 subgoal):
 1. \<And>w. 0 \<le> prob (pseudo_proj_True n -` {w} \<inter> space M) * f w
[PROOF STEP]
show "\<And>w. 0 \<le> prob (pseudo_proj_True n -` {w} \<inter> space M) * f w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>w. 0 \<le> prob (pseudo_proj_True n -` {w} \<inter> space M) * f w
[PROOF STEP]
using assms(2) measure_nonneg zero_le_mult_iff
[PROOF STATE]
proof (prove)
using this:
\<forall>w. 0 \<le> f w
0 \<le> Sigma_Algebra.measure ?M ?A
((0::?'a) \<le> ?a * ?b) = ((0::?'a) \<le> ?a \<and> (0::?'a) \<le> ?b \<or> ?a \<le> (0::?'a) \<and> ?b \<le> (0::?'a))

goal (1 subgoal):
 1. \<And>w. 0 \<le> prob (pseudo_proj_True n -` {w} \<inter> space M) * f w
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
0 \<le> prob (pseudo_proj_True n -` {?w1} \<inter> space M) * f ?w1

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>w\<in>range (pseudo_proj_True n). ennreal (prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)) = ennreal (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (f x) \<partial>M = ennreal ?x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<integral>\<^sup>+ x. ennreal (f x) \<partial>M = ennreal (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)
[PROOF STEP]
show "(\<integral>\<^sup>+ x. ennreal (f x) \<partial>M) =
      ennreal (\<Sum> w\<in> range (pseudo_proj_True n). (measure M ((pseudo_proj_True n) -`{w} \<inter> space M) *   (f w)))"
[PROOF STATE]
proof (prove)
using this:
\<integral>\<^sup>+ x. ennreal (f x) \<partial>M = ennreal (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (f x) \<partial>M = ennreal (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. ennreal (f x) \<partial>M = ennreal (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
integrable M f

goal (1 subgoal):
 1. has_bochner_integral M f (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
expectation f = (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)
integrable M f
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
expectation f = (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)
integrable M f

goal (1 subgoal):
 1. has_bochner_integral M f (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)
[PROOF STEP]
using has_bochner_integral_iff
[PROOF STATE]
proof (prove)
using this:
expectation f = (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)
integrable M f
has_bochner_integral ?M ?f ?x = (integrable ?M ?f \<and> integral\<^sup>L ?M ?f = ?x)

goal (1 subgoal):
 1. has_bochner_integral M f (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
has_bochner_integral M f (\<Sum>w\<in>range (pseudo_proj_True n). prob (pseudo_proj_True n -` {w} \<inter> space M) * f w)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ex_refinement_thm:
     "[| strict_ex_prop X;
         \<forall>H. F ok H & G ok H & F\<squnion>H \<in> welldef \<inter> X --> G\<squnion>H \<in> welldef |]
      ==> (G refines F wrt X) = (G iso_refines F wrt X)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>strict_ex_prop X; \<forall>H. F ok H \<and> G ok H \<and> F \<squnion> H \<in> welldef \<inter> X \<longrightarrow> G \<squnion> H \<in> welldef\<rbrakk> \<Longrightarrow> (G refines F wrt X) = (G iso_refines F wrt X)
[PROOF STEP]
apply (rule_tac x = SKIP in allE, assumption)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>strict_ex_prop X; \<forall>H. F ok H \<and> G ok H \<and> F \<squnion> H \<in> welldef \<inter> X \<longrightarrow> G \<squnion> H \<in> welldef; F ok \<bottom> \<and> G ok \<bottom> \<and> F \<squnion> \<bottom> \<in> welldef \<inter> X \<longrightarrow> G \<squnion> \<bottom> \<in> welldef\<rbrakk> \<Longrightarrow> (G refines F wrt X) = (G iso_refines F wrt X)
[PROOF STEP]
apply (simp add: refines_def iso_refines_def strict_ex_refine_lemma_v)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma ffilter_fBall: "(\<forall>x |\<in>| xs. P x) = (ffilter P xs = xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fBall xs P = (ffilter P xs = xs)
[PROOF STEP]
by auto


[STATEMENT]
lemma measurable_convergent[measurable (raw)]:
  fixes f :: "nat \<Rightarrow> 'a \<Rightarrow> 'b::{complete_linorder, second_countable_topology, linorder_topology}"
  assumes [measurable]: "\<And>i. f i \<in> borel_measurable M"
  shows "Measurable.pred M (\<lambda>x. convergent (\<lambda>i. f i x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Measurable.pred M (\<lambda>x. convergent (\<lambda>i. f i x))
[PROOF STEP]
unfolding convergent_ereal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Measurable.pred M (\<lambda>x. limsup (\<lambda>i. f i x) = liminf (\<lambda>i. f i x))
[PROOF STEP]
by measurable


[STATEMENT]
lemma merge0_inv:
  "\<forall>I I'. oneone I \<and> oneone I' \<longrightarrow> compat I' I \<longrightarrow> oneone (merge0 I' I)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>I I'. oneone I \<and> oneone I' \<longrightarrow> PlaneGraphIso.compat I' I \<longrightarrow> oneone (merge0 I' I)
[PROOF STEP]
apply(auto simp add:merge0_def distinct_map compat_def split_def)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>I I'. \<lbrakk>inj_on fst (set I); distinct I; inj_on snd (set I); inj_on fst (set I'); distinct I'; inj_on snd (set I'); \<forall>x\<in>set I'. \<forall>xa\<in>set I. (fst x = fst xa) = (snd x = snd xa)\<rbrakk> \<Longrightarrow> inj_on fst {x \<in> set I'. fst x \<notin> fst ` set I}
 2. \<And>I I'. \<lbrakk>inj_on fst (set I); distinct I; inj_on snd (set I); inj_on fst (set I'); distinct I'; inj_on snd (set I'); \<forall>x\<in>set I'. \<forall>xa\<in>set I. (fst x = fst xa) = (snd x = snd xa)\<rbrakk> \<Longrightarrow> inj_on snd {x \<in> set I'. fst x \<notin> fst ` set I}
[PROOF STEP]
apply(blast intro:subset_inj_on)+
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma remainderexplemma: "(y mod (a::nat) = z mod a) \<Longrightarrow> (x*y) mod a = (x*z) mod a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y mod a = z mod a \<Longrightarrow> x * y mod a = x * z mod a
[PROOF STEP]
by (rule mod_mult_cong [OF refl])


[STATEMENT]
lemma not_simple_elim:
  assumes "\<not>simple S"
  shows "(\<exists>A B ts. S = A@Send ts#B \<and> (\<nexists>x. ts = [Var x]) \<and> simple A) \<or>
         (\<exists>A B a t t'. S = A@Equality a t t'#B \<and> simple A) \<or>
         (\<exists>A B X F. S = A@Inequality X F#B \<and> (\<nexists>\<I>. ineq_model \<I> X F) \<and> simple A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<exists>A B ts. S = A @ send\<langle>ts\<rangle>\<^sub>s\<^sub>t # B \<and> (\<nexists>x. ts = [Var x]) \<and> simple A) \<or> (\<exists>A B a t t'. S = A @ \<langle>a: t \<doteq> t'\<rangle>\<^sub>s\<^sub>t # B \<and> simple A) \<or> (\<exists>A B X F. S = A @ \<forall>X\<langle>\<or>\<noteq>: F\<rangle>\<^sub>s\<^sub>t # B \<and> (\<nexists>\<I>. ineq_model \<I> X F) \<and> simple A)
[PROOF STEP]
by (metis assms not_list_all_elim not_simple\<^sub>s\<^sub>t\<^sub>p_elim simple_def)


[STATEMENT]
lemma stable_nat: "stable |UNIV::nat set|"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. stable |UNIV|
[PROOF STEP]
using stable_natLeq card_of_nat stable_ordIso
[PROOF STATE]
proof (prove)
using this:
stable natLeq
|UNIV| =o natLeq
?r =o ?r' \<Longrightarrow> stable ?r = stable ?r'

goal (1 subgoal):
 1. stable |UNIV|
[PROOF STEP]
by auto


[STATEMENT]
lemma filter_mset_sum_list: "filter_mset P (sum_list xs) = sum_list (map (filter_mset P) xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. filter_mset P (sum_list xs) = sum_list (map (filter_mset P) xs)
[PROOF STEP]
by (induction xs) simp_all


[STATEMENT]
lemma integral_trans:
  "proper (fst cf) \<Longrightarrow>
    (\<integral>x. f x \<partial>trans cf) = (\<Sum>i<brn (fst cf). wt (fst cf) (snd cf) i * f (cont_eff cf i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proper (fst cf) \<Longrightarrow> measure_pmf.expectation (local.trans cf) f = (\<Sum>i<brn (fst cf). wt (fst cf) (snd cf) i * f (cont_eff cf i))
[PROOF STEP]
unfolding trans_def map_pmf_rep_eq
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proper (fst cf) \<Longrightarrow> integral\<^sup>L (distr (measure_pmf (wt_pmf cf)) (count_space UNIV) (\<lambda>i. if proper (fst cf) then cont_eff cf i else cf)) f = (\<Sum>i<brn (fst cf). wt (fst cf) (snd cf) i * f (cont_eff cf i))
[PROOF STEP]
apply (simp add: integral_distr)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proper (fst cf) \<Longrightarrow> measure_pmf.expectation (wt_pmf cf) (\<lambda>x. f (cont_eff cf x)) = (\<Sum>i<brn (fst cf). wt (fst cf) (snd cf) i * f (cont_eff cf i))
[PROOF STEP]
apply (subst integral_measure_pmf[of "{..< brn (fst cf)}"])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. proper (fst cf) \<Longrightarrow> finite {..<brn (fst cf)}
 2. \<And>a. \<lbrakk>proper (fst cf); a \<in> set_pmf (wt_pmf cf); f (cont_eff cf a) \<noteq> 0\<rbrakk> \<Longrightarrow> a \<in> {..<brn (fst cf)}
 3. proper (fst cf) \<Longrightarrow> (\<Sum>a<brn (fst cf). pmf (wt_pmf cf) a *\<^sub>R f (cont_eff cf a)) = (\<Sum>i<brn (fst cf). wt (fst cf) (snd cf) i * f (cont_eff cf i))
[PROOF STEP]
apply (auto simp: set_pmf_wt mult_ac wt_pmf.rep_eq split: prod.split)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma conga_right_comm:
  assumes "A B C CongA D E F"
  shows "A B C CongA F E D"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A B C CongA F E D
[PROOF STEP]
by (metis Tarski_neutral_dimensionless.conga_diff45 Tarski_neutral_dimensionless.conga_sym Tarski_neutral_dimensionless.conga_trans Tarski_neutral_dimensionless_axioms assms conga_diff56 conga_pseudo_refl)


[STATEMENT]
lemma is_poincare_line_not_trough_zero_not_trough_infty [simp]:
  assumes "is_poincare_line l"
  assumes "0\<^sub>h \<notin> circline_set l"
  shows "\<infinity>\<^sub>h \<notin> circline_set l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<infinity>\<^sub>h \<notin> circline_set l
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
is_poincare_line l
0\<^sub>h \<notin> circline_set l

goal (1 subgoal):
 1. \<infinity>\<^sub>h \<notin> circline_set l
[PROOF STEP]
using is_poincare_line_inverse_point[OF assms(1), of "\<infinity>\<^sub>h"]
[PROOF STATE]
proof (prove)
using this:
is_poincare_line l
0\<^sub>h \<notin> circline_set l
\<infinity>\<^sub>h \<in> circline_set l \<Longrightarrow> inversion \<infinity>\<^sub>h \<in> circline_set l

goal (1 subgoal):
 1. \<infinity>\<^sub>h \<notin> circline_set l
[PROOF STEP]
by auto


[STATEMENT]
lemma (in complete_measure) fmeasurable_measure_inner_outer:
   "(S \<in> fmeasurable M \<and> m = measure M S) \<longleftrightarrow>
      (\<forall>e>0. \<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - e < measure M T) \<and>
      (\<forall>e>0. \<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> measure M U < m + e)"
    (is "?lhs = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (S \<in> fmeasurable M \<and> m = Sigma_Algebra.measure M S) = ((\<forall>e>0. \<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - e < Sigma_Algebra.measure M T) \<and> (\<forall>e>0. \<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> Sigma_Algebra.measure M U < m + e))
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. S \<in> fmeasurable M \<and> m = Sigma_Algebra.measure M S \<Longrightarrow> (\<forall>e>0. \<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - e < Sigma_Algebra.measure M T) \<and> (\<forall>e>0. \<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> Sigma_Algebra.measure M U < m + e)
 2. (\<forall>e>0. \<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - e < Sigma_Algebra.measure M T) \<and> (\<forall>e>0. \<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> Sigma_Algebra.measure M U < m + e) \<Longrightarrow> S \<in> fmeasurable M \<and> m = Sigma_Algebra.measure M S
[PROOF STEP]
assume RHS: ?rhs
[PROOF STATE]
proof (state)
this:
(\<forall>e>0. \<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - e < Sigma_Algebra.measure M T) \<and> (\<forall>e>0. \<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> Sigma_Algebra.measure M U < m + e)

goal (2 subgoals):
 1. S \<in> fmeasurable M \<and> m = Sigma_Algebra.measure M S \<Longrightarrow> (\<forall>e>0. \<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - e < Sigma_Algebra.measure M T) \<and> (\<forall>e>0. \<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> Sigma_Algebra.measure M U < m + e)
 2. (\<forall>e>0. \<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - e < Sigma_Algebra.measure M T) \<and> (\<forall>e>0. \<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> Sigma_Algebra.measure M U < m + e) \<Longrightarrow> S \<in> fmeasurable M \<and> m = Sigma_Algebra.measure M S
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<forall>e>0. \<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - e < Sigma_Algebra.measure M T) \<and> (\<forall>e>0. \<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> Sigma_Algebra.measure M U < m + e)
[PROOF STEP]
have T: "\<And>e. 0 < e \<longrightarrow> (\<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - e < measure M T)"
        and U: "\<And>e. 0 < e \<longrightarrow> (\<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> measure M U < m + e)"
[PROOF STATE]
proof (prove)
using this:
(\<forall>e>0. \<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - e < Sigma_Algebra.measure M T) \<and> (\<forall>e>0. \<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> Sigma_Algebra.measure M U < m + e)

goal (1 subgoal):
 1. (\<And>e. 0 < e \<longrightarrow> (\<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - e < Sigma_Algebra.measure M T)) &&& (\<And>e. 0 < e \<longrightarrow> (\<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> Sigma_Algebra.measure M U < m + e))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < ?e \<longrightarrow> (\<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - ?e < Sigma_Algebra.measure M T)
0 < ?e \<longrightarrow> (\<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> Sigma_Algebra.measure M U < m + ?e)

goal (2 subgoals):
 1. S \<in> fmeasurable M \<and> m = Sigma_Algebra.measure M S \<Longrightarrow> (\<forall>e>0. \<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - e < Sigma_Algebra.measure M T) \<and> (\<forall>e>0. \<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> Sigma_Algebra.measure M U < m + e)
 2. (\<forall>e>0. \<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - e < Sigma_Algebra.measure M T) \<and> (\<forall>e>0. \<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> Sigma_Algebra.measure M U < m + e) \<Longrightarrow> S \<in> fmeasurable M \<and> m = Sigma_Algebra.measure M S
[PROOF STEP]
have "S \<in> fmeasurable M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S \<in> fmeasurable M
[PROOF STEP]
proof (subst fmeasurable_inner_outer, safe)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>e. 0 < e \<Longrightarrow> \<exists>T\<in>fmeasurable M. \<exists>U\<in>fmeasurable M. T \<subseteq> S \<and> S \<subseteq> U \<and> \<bar>Sigma_Algebra.measure M T - Sigma_Algebra.measure M U\<bar> < e
[PROOF STEP]
fix e::real
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>e. 0 < e \<Longrightarrow> \<exists>T\<in>fmeasurable M. \<exists>U\<in>fmeasurable M. T \<subseteq> S \<and> S \<subseteq> U \<and> \<bar>Sigma_Algebra.measure M T - Sigma_Algebra.measure M U\<bar> < e
[PROOF STEP]
assume "0 < e"
[PROOF STATE]
proof (state)
this:
0 < e

goal (1 subgoal):
 1. \<And>e. 0 < e \<Longrightarrow> \<exists>T\<in>fmeasurable M. \<exists>U\<in>fmeasurable M. T \<subseteq> S \<and> S \<subseteq> U \<and> \<bar>Sigma_Algebra.measure M T - Sigma_Algebra.measure M U\<bar> < e
[PROOF STEP]
with RHS
[PROOF STATE]
proof (chain)
picking this:
(\<forall>e>0. \<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - e < Sigma_Algebra.measure M T) \<and> (\<forall>e>0. \<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> Sigma_Algebra.measure M U < m + e)
0 < e
[PROOF STEP]
obtain T U where T: "T \<in> fmeasurable M" "T \<subseteq> S" "m - e/2 < measure M T"
                          and U: "U \<in> fmeasurable M" "S \<subseteq> U" "measure M U < m + e/2"
[PROOF STATE]
proof (prove)
using this:
(\<forall>e>0. \<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - e < Sigma_Algebra.measure M T) \<and> (\<forall>e>0. \<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> Sigma_Algebra.measure M U < m + e)
0 < e

goal (1 subgoal):
 1. (\<And>T U. \<lbrakk>T \<in> fmeasurable M; T \<subseteq> S; m - e / 2 < Sigma_Algebra.measure M T; U \<in> fmeasurable M; S \<subseteq> U; Sigma_Algebra.measure M U < m + e / 2\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (meson half_gt_zero)+
[PROOF STATE]
proof (state)
this:
T \<in> fmeasurable M
T \<subseteq> S
m - e / 2 < Sigma_Algebra.measure M T
U \<in> fmeasurable M
S \<subseteq> U
Sigma_Algebra.measure M U < m + e / 2

goal (1 subgoal):
 1. \<And>e. 0 < e \<Longrightarrow> \<exists>T\<in>fmeasurable M. \<exists>U\<in>fmeasurable M. T \<subseteq> S \<and> S \<subseteq> U \<and> \<bar>Sigma_Algebra.measure M T - Sigma_Algebra.measure M U\<bar> < e
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
T \<in> fmeasurable M
T \<subseteq> S
m - e / 2 < Sigma_Algebra.measure M T
U \<in> fmeasurable M
S \<subseteq> U
Sigma_Algebra.measure M U < m + e / 2

goal (1 subgoal):
 1. \<And>e. 0 < e \<Longrightarrow> \<exists>T\<in>fmeasurable M. \<exists>U\<in>fmeasurable M. T \<subseteq> S \<and> S \<subseteq> U \<and> \<bar>Sigma_Algebra.measure M T - Sigma_Algebra.measure M U\<bar> < e
[PROOF STEP]
have "measure M U - measure M T < (m + e/2) - (m - e/2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Sigma_Algebra.measure M U - Sigma_Algebra.measure M T < m + e / 2 - (m - e / 2)
[PROOF STEP]
by (intro diff_strict_mono) fact+
[PROOF STATE]
proof (state)
this:
Sigma_Algebra.measure M U - Sigma_Algebra.measure M T < m + e / 2 - (m - e / 2)

goal (1 subgoal):
 1. \<And>e. 0 < e \<Longrightarrow> \<exists>T\<in>fmeasurable M. \<exists>U\<in>fmeasurable M. T \<subseteq> S \<and> S \<subseteq> U \<and> \<bar>Sigma_Algebra.measure M T - Sigma_Algebra.measure M U\<bar> < e
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
Sigma_Algebra.measure M U - Sigma_Algebra.measure M T < m + e / 2 - (m - e / 2)

goal (1 subgoal):
 1. \<And>e. 0 < e \<Longrightarrow> \<exists>T\<in>fmeasurable M. \<exists>U\<in>fmeasurable M. T \<subseteq> S \<and> S \<subseteq> U \<and> \<bar>Sigma_Algebra.measure M T - Sigma_Algebra.measure M U\<bar> < e
[PROOF STEP]
have "measure M T \<le> measure M U"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Sigma_Algebra.measure M T \<le> Sigma_Algebra.measure M U
[PROOF STEP]
using T U
[PROOF STATE]
proof (prove)
using this:
T \<in> fmeasurable M
T \<subseteq> S
m - e / 2 < Sigma_Algebra.measure M T
U \<in> fmeasurable M
S \<subseteq> U
Sigma_Algebra.measure M U < m + e / 2

goal (1 subgoal):
 1. Sigma_Algebra.measure M T \<le> Sigma_Algebra.measure M U
[PROOF STEP]
by (intro measure_mono_fmeasurable) auto
[PROOF STATE]
proof (state)
this:
Sigma_Algebra.measure M T \<le> Sigma_Algebra.measure M U

goal (1 subgoal):
 1. \<And>e. 0 < e \<Longrightarrow> \<exists>T\<in>fmeasurable M. \<exists>U\<in>fmeasurable M. T \<subseteq> S \<and> S \<subseteq> U \<and> \<bar>Sigma_Algebra.measure M T - Sigma_Algebra.measure M U\<bar> < e
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
T \<in> fmeasurable M
T \<subseteq> S
m - e / 2 < Sigma_Algebra.measure M T
U \<in> fmeasurable M
S \<subseteq> U
Sigma_Algebra.measure M U < m + e / 2
Sigma_Algebra.measure M U - Sigma_Algebra.measure M T < m + e / 2 - (m - e / 2)
Sigma_Algebra.measure M T \<le> Sigma_Algebra.measure M U
[PROOF STEP]
show "\<exists>T\<in>fmeasurable M. \<exists>U\<in>fmeasurable M. T \<subseteq> S \<and> S \<subseteq> U \<and> \<bar>measure M T - measure M U\<bar> < e"
[PROOF STATE]
proof (prove)
using this:
T \<in> fmeasurable M
T \<subseteq> S
m - e / 2 < Sigma_Algebra.measure M T
U \<in> fmeasurable M
S \<subseteq> U
Sigma_Algebra.measure M U < m + e / 2
Sigma_Algebra.measure M U - Sigma_Algebra.measure M T < m + e / 2 - (m - e / 2)
Sigma_Algebra.measure M T \<le> Sigma_Algebra.measure M U

goal (1 subgoal):
 1. \<exists>T\<in>fmeasurable M. \<exists>U\<in>fmeasurable M. T \<subseteq> S \<and> S \<subseteq> U \<and> \<bar>Sigma_Algebra.measure M T - Sigma_Algebra.measure M U\<bar> < e
[PROOF STEP]
apply (rule_tac bexI[OF _ \<open>T \<in> fmeasurable M\<close>])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>T \<in> fmeasurable M; T \<subseteq> S; m - e / 2 < Sigma_Algebra.measure M T; U \<in> fmeasurable M; S \<subseteq> U; Sigma_Algebra.measure M U < m + e / 2; Sigma_Algebra.measure M U - Sigma_Algebra.measure M T < m + e / 2 - (m - e / 2); Sigma_Algebra.measure M T \<le> Sigma_Algebra.measure M U\<rbrakk> \<Longrightarrow> \<exists>U\<in>fmeasurable M. T \<subseteq> S \<and> S \<subseteq> U \<and> \<bar>Sigma_Algebra.measure M T - Sigma_Algebra.measure M U\<bar> < e
[PROOF STEP]
apply (rule_tac bexI[OF _ \<open>U \<in> fmeasurable M\<close>])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>T \<in> fmeasurable M; T \<subseteq> S; m - e / 2 < Sigma_Algebra.measure M T; U \<in> fmeasurable M; S \<subseteq> U; Sigma_Algebra.measure M U < m + e / 2; Sigma_Algebra.measure M U - Sigma_Algebra.measure M T < m + e / 2 - (m - e / 2); Sigma_Algebra.measure M T \<le> Sigma_Algebra.measure M U\<rbrakk> \<Longrightarrow> T \<subseteq> S \<and> S \<subseteq> U \<and> \<bar>Sigma_Algebra.measure M T - Sigma_Algebra.measure M U\<bar> < e
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>T\<in>fmeasurable M. \<exists>U\<in>fmeasurable M. T \<subseteq> S \<and> S \<subseteq> U \<and> \<bar>Sigma_Algebra.measure M T - Sigma_Algebra.measure M U\<bar> < e

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
S \<in> fmeasurable M

goal (2 subgoals):
 1. S \<in> fmeasurable M \<and> m = Sigma_Algebra.measure M S \<Longrightarrow> (\<forall>e>0. \<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - e < Sigma_Algebra.measure M T) \<and> (\<forall>e>0. \<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> Sigma_Algebra.measure M U < m + e)
 2. (\<forall>e>0. \<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - e < Sigma_Algebra.measure M T) \<and> (\<forall>e>0. \<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> Sigma_Algebra.measure M U < m + e) \<Longrightarrow> S \<in> fmeasurable M \<and> m = Sigma_Algebra.measure M S
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
S \<in> fmeasurable M

goal (2 subgoals):
 1. S \<in> fmeasurable M \<and> m = Sigma_Algebra.measure M S \<Longrightarrow> (\<forall>e>0. \<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - e < Sigma_Algebra.measure M T) \<and> (\<forall>e>0. \<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> Sigma_Algebra.measure M U < m + e)
 2. (\<forall>e>0. \<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - e < Sigma_Algebra.measure M T) \<and> (\<forall>e>0. \<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> Sigma_Algebra.measure M U < m + e) \<Longrightarrow> S \<in> fmeasurable M \<and> m = Sigma_Algebra.measure M S
[PROOF STEP]
have "m = measure M S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m = Sigma_Algebra.measure M S
[PROOF STEP]
using \<open>S \<in> fmeasurable M\<close> U[of "measure M S - m"] T[of "m - measure M S"]
[PROOF STATE]
proof (prove)
using this:
S \<in> fmeasurable M
0 < Sigma_Algebra.measure M S - m \<longrightarrow> (\<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> Sigma_Algebra.measure M U < m + (Sigma_Algebra.measure M S - m))
0 < m - Sigma_Algebra.measure M S \<longrightarrow> (\<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - (m - Sigma_Algebra.measure M S) < Sigma_Algebra.measure M T)

goal (1 subgoal):
 1. m = Sigma_Algebra.measure M S
[PROOF STEP]
by (cases m "measure M S" rule: linorder_cases)
       (auto simp: not_le[symmetric] measure_mono_fmeasurable)
[PROOF STATE]
proof (state)
this:
m = Sigma_Algebra.measure M S

goal (2 subgoals):
 1. S \<in> fmeasurable M \<and> m = Sigma_Algebra.measure M S \<Longrightarrow> (\<forall>e>0. \<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - e < Sigma_Algebra.measure M T) \<and> (\<forall>e>0. \<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> Sigma_Algebra.measure M U < m + e)
 2. (\<forall>e>0. \<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - e < Sigma_Algebra.measure M T) \<and> (\<forall>e>0. \<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> Sigma_Algebra.measure M U < m + e) \<Longrightarrow> S \<in> fmeasurable M \<and> m = Sigma_Algebra.measure M S
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
S \<in> fmeasurable M
m = Sigma_Algebra.measure M S
[PROOF STEP]
show ?lhs
[PROOF STATE]
proof (prove)
using this:
S \<in> fmeasurable M
m = Sigma_Algebra.measure M S

goal (1 subgoal):
 1. S \<in> fmeasurable M \<and> m = Sigma_Algebra.measure M S
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
S \<in> fmeasurable M \<and> m = Sigma_Algebra.measure M S

goal (1 subgoal):
 1. S \<in> fmeasurable M \<and> m = Sigma_Algebra.measure M S \<Longrightarrow> (\<forall>e>0. \<exists>T\<in>fmeasurable M. T \<subseteq> S \<and> m - e < Sigma_Algebra.measure M T) \<and> (\<forall>e>0. \<exists>U\<in>fmeasurable M. S \<subseteq> U \<and> Sigma_Algebra.measure M U < m + e)
[PROOF STEP]
qed (auto intro!: bexI[of _ S])


[STATEMENT]
lemma Fvars_fm_simps[simp]:
  "Fvars (x IN y) = Fvars x \<union> Fvars y"
  "Fvars (x EQ y) = Fvars x \<union> Fvars y"
  "Fvars (A OR B) = Fvars A \<union> Fvars B"
  "Fvars (A AND B) = Fvars A \<union> Fvars B"
  "Fvars (A IMP B) = Fvars A \<union> Fvars B"
  "Fvars Fls = {}"
  "Fvars (Neg A) = Fvars A"
  "Fvars (Ex a A) = Fvars A - {a}"
  "Fvars (All a A) = Fvars A - {a}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((Fvars (x IN y) = Fvars x \<union> Fvars y &&& Fvars (x EQ y) = Fvars x \<union> Fvars y) &&& Fvars (A OR B) = Fvars A \<union> Fvars B &&& Fvars (A AND B) = Fvars A \<union> Fvars B) &&& (Fvars (A IMP B) = Fvars A \<union> Fvars B &&& Fvars Fls = {}) &&& Fvars (Neg A) = Fvars A &&& Fvars (SyntaxN.Ex a A) = Fvars A - {a} &&& Fvars (SyntaxN.All a A) = Fvars A - {a}
[PROOF STEP]
by (auto simp: Fvars_def fresh_at_base(2))


[STATEMENT]
lemma val_ineq_cancel_leq:
  assumes "a \<in> nonzero Q\<^sub>p"
  assumes "b \<in> carrier Q\<^sub>p"
  assumes "c \<in> carrier Q\<^sub>p"
  assumes "val (a \<otimes> b) \<le> val (a \<otimes> c)"
  shows "val b \<le> val c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. val b \<le> val c
[PROOF STEP]
using Units_eq_nonzero assms(1) assms(2) assms(3) assms(4) times_cfs_val_mono
[PROOF STATE]
proof (prove)
using this:
Units Q\<^sub>p = nonzero Q\<^sub>p
a \<in> nonzero Q\<^sub>p
b \<in> carrier Q\<^sub>p
c \<in> carrier Q\<^sub>p
val (a \<otimes> b) \<le> val (a \<otimes> c)
\<lbrakk>?u \<in> Units Q\<^sub>p; ?a \<in> carrier Q\<^sub>p; ?b \<in> carrier Q\<^sub>p; val (?u \<otimes> ?a) \<le> val (?u \<otimes> ?b)\<rbrakk> \<Longrightarrow> val ?a \<le> val ?b

goal (1 subgoal):
 1. val b \<le> val c
[PROOF STEP]
by blast


[STATEMENT]
lemma Ball_True: "(\<forall>x\<in>X. True) \<longleftrightarrow> True"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x\<in>X. True) = True
[PROOF STEP]
by auto


[STATEMENT]
lemma non_empty_exist_elt [backward]: "U \<noteq> {} \<Longrightarrow> \<exists>x. x \<in> U"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. U \<noteq> {} \<Longrightarrow> \<exists>x. x \<in> U
[PROOF STEP]
by blast


[STATEMENT]
lemma le_int_of_integer: "(x \<le> y) = (int_of_integer x \<le> int_of_integer y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x \<le> y) = (int_of_integer x \<le> int_of_integer y)
[PROOF STEP]
by (rule less_eq_integer.rep_eq)


[STATEMENT]
theorem invpst_mkNode[simp]: "invpst (mkNode c l a r) \<longleftrightarrow> invpst l \<and> invpst r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invpst (mkNode c l a r) = (invpst l \<and> invpst r)
[PROOF STEP]
apply (cases l rule: invpst.cases;
       cases r rule: invpst.cases;
       simp add: mkNode_def min_kp_def)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>la x uu_ mkp ra. \<lbrakk>l = \<langle>\<rangle>; r = \<langle>la, (x, uu_, mkp), ra\<rangle>\<rbrakk> \<Longrightarrow> (invpst la \<and> invpst ra \<and> is_min2 mkp (insert x (Tree2.set_tree la \<union> Tree2.set_tree ra)) \<and> is_min2 (min2 a mkp) (insert a (insert x (Tree2.set_tree la \<union> Tree2.set_tree ra)))) = (invpst la \<and> invpst ra \<and> is_min2 mkp (insert x (Tree2.set_tree la \<union> Tree2.set_tree ra)))
 2. \<And>la x uu_ mkp ra. \<lbrakk>l = \<langle>la, (x, uu_, mkp), ra\<rangle>; r = \<langle>\<rangle>\<rbrakk> \<Longrightarrow> (invpst la \<and> invpst ra \<and> is_min2 mkp (insert x (Tree2.set_tree la \<union> Tree2.set_tree ra)) \<and> is_min2 (min2 a mkp) (insert x (insert a (Tree2.set_tree la \<union> Tree2.set_tree ra)))) = (invpst la \<and> invpst ra \<and> is_min2 mkp (insert x (Tree2.set_tree la \<union> Tree2.set_tree ra)))
 3. \<And>la x uu_ mkp ra laa xa uua_ mkpa raa. \<lbrakk>l = \<langle>la, (x, uu_, mkp), ra\<rangle>; r = \<langle>laa, (xa, uua_, mkpa), raa\<rangle>\<rbrakk> \<Longrightarrow> (invpst la \<and> invpst ra \<and> is_min2 mkp (insert x (Tree2.set_tree la \<union> Tree2.set_tree ra)) \<and> invpst laa \<and> invpst raa \<and> is_min2 mkpa (insert xa (Tree2.set_tree laa \<union> Tree2.set_tree raa)) \<and> is_min2 (min2 a (min2 mkp mkpa)) (insert x (insert a (insert xa (Tree2.set_tree la \<union> (Tree2.set_tree ra \<union> (Tree2.set_tree laa \<union> Tree2.set_tree raa))))))) = (invpst la \<and> invpst ra \<and> is_min2 mkp (insert x (Tree2.set_tree la \<union> Tree2.set_tree ra)) \<and> invpst laa \<and> invpst raa \<and> is_min2 mkpa (insert xa (Tree2.set_tree laa \<union> Tree2.set_tree raa)))
[PROOF STEP]
subgoal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>l = \<langle>\<rangle>; r = \<langle>la_, (x_, uu_, mkp_), ra_\<rangle>\<rbrakk> \<Longrightarrow> (invpst la_ \<and> invpst ra_ \<and> is_min2 mkp_ (insert x_ (Tree2.set_tree la_ \<union> Tree2.set_tree ra_)) \<and> is_min2 (min2 a mkp_) (insert a (insert x_ (Tree2.set_tree la_ \<union> Tree2.set_tree ra_)))) = (invpst la_ \<and> invpst ra_ \<and> is_min2 mkp_ (insert x_ (Tree2.set_tree la_ \<union> Tree2.set_tree ra_)))
[PROOF STEP]
using is_min2_min2_insI
[PROOF STATE]
proof (prove)
using this:
is_min2 ?y ?ys \<Longrightarrow> is_min2 (min2 ?x ?y) (insert ?x ?ys)

goal (1 subgoal):
 1. \<lbrakk>l = \<langle>\<rangle>; r = \<langle>la_, (x_, uu_, mkp_), ra_\<rangle>\<rbrakk> \<Longrightarrow> (invpst la_ \<and> invpst ra_ \<and> is_min2 mkp_ (insert x_ (Tree2.set_tree la_ \<union> Tree2.set_tree ra_)) \<and> is_min2 (min2 a mkp_) (insert a (insert x_ (Tree2.set_tree la_ \<union> Tree2.set_tree ra_)))) = (invpst la_ \<and> invpst ra_ \<and> is_min2 mkp_ (insert x_ (Tree2.set_tree la_ \<union> Tree2.set_tree ra_)))
[PROOF STEP]
by blast
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>la x uu_ mkp ra. \<lbrakk>l = \<langle>la, (x, uu_, mkp), ra\<rangle>; r = \<langle>\<rangle>\<rbrakk> \<Longrightarrow> (invpst la \<and> invpst ra \<and> is_min2 mkp (insert x (Tree2.set_tree la \<union> Tree2.set_tree ra)) \<and> is_min2 (min2 a mkp) (insert x (insert a (Tree2.set_tree la \<union> Tree2.set_tree ra)))) = (invpst la \<and> invpst ra \<and> is_min2 mkp (insert x (Tree2.set_tree la \<union> Tree2.set_tree ra)))
 2. \<And>la x uu_ mkp ra laa xa uua_ mkpa raa. \<lbrakk>l = \<langle>la, (x, uu_, mkp), ra\<rangle>; r = \<langle>laa, (xa, uua_, mkpa), raa\<rangle>\<rbrakk> \<Longrightarrow> (invpst la \<and> invpst ra \<and> is_min2 mkp (insert x (Tree2.set_tree la \<union> Tree2.set_tree ra)) \<and> invpst laa \<and> invpst raa \<and> is_min2 mkpa (insert xa (Tree2.set_tree laa \<union> Tree2.set_tree raa)) \<and> is_min2 (min2 a (min2 mkp mkpa)) (insert x (insert a (insert xa (Tree2.set_tree la \<union> (Tree2.set_tree ra \<union> (Tree2.set_tree laa \<union> Tree2.set_tree raa))))))) = (invpst la \<and> invpst ra \<and> is_min2 mkp (insert x (Tree2.set_tree la \<union> Tree2.set_tree ra)) \<and> invpst laa \<and> invpst raa \<and> is_min2 mkpa (insert xa (Tree2.set_tree laa \<union> Tree2.set_tree raa)))
[PROOF STEP]
subgoal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>l = \<langle>la_, (x_, uu_, mkp_), ra_\<rangle>; r = \<langle>\<rangle>\<rbrakk> \<Longrightarrow> (invpst la_ \<and> invpst ra_ \<and> is_min2 mkp_ (insert x_ (Tree2.set_tree la_ \<union> Tree2.set_tree ra_)) \<and> is_min2 (min2 a mkp_) (insert x_ (insert a (Tree2.set_tree la_ \<union> Tree2.set_tree ra_)))) = (invpst la_ \<and> invpst ra_ \<and> is_min2 mkp_ (insert x_ (Tree2.set_tree la_ \<union> Tree2.set_tree ra_)))
[PROOF STEP]
by (auto intro!: is_min2_min2_insI simp: insert_commute)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>la x uu_ mkp ra laa xa uua_ mkpa raa. \<lbrakk>l = \<langle>la, (x, uu_, mkp), ra\<rangle>; r = \<langle>laa, (xa, uua_, mkpa), raa\<rangle>\<rbrakk> \<Longrightarrow> (invpst la \<and> invpst ra \<and> is_min2 mkp (insert x (Tree2.set_tree la \<union> Tree2.set_tree ra)) \<and> invpst laa \<and> invpst raa \<and> is_min2 mkpa (insert xa (Tree2.set_tree laa \<union> Tree2.set_tree raa)) \<and> is_min2 (min2 a (min2 mkp mkpa)) (insert x (insert a (insert xa (Tree2.set_tree la \<union> (Tree2.set_tree ra \<union> (Tree2.set_tree laa \<union> Tree2.set_tree raa))))))) = (invpst la \<and> invpst ra \<and> is_min2 mkp (insert x (Tree2.set_tree la \<union> Tree2.set_tree ra)) \<and> invpst laa \<and> invpst raa \<and> is_min2 mkpa (insert xa (Tree2.set_tree laa \<union> Tree2.set_tree raa)))
[PROOF STEP]
subgoal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>l = \<langle>la_, (x_, uu_, mkp_), ra_\<rangle>; r = \<langle>laa_, (xa_, uua_, mkpa_), raa_\<rangle>\<rbrakk> \<Longrightarrow> (invpst la_ \<and> invpst ra_ \<and> is_min2 mkp_ (insert x_ (Tree2.set_tree la_ \<union> Tree2.set_tree ra_)) \<and> invpst laa_ \<and> invpst raa_ \<and> is_min2 mkpa_ (insert xa_ (Tree2.set_tree laa_ \<union> Tree2.set_tree raa_)) \<and> is_min2 (min2 a (min2 mkp_ mkpa_)) (insert x_ (insert a (insert xa_ (Tree2.set_tree la_ \<union> (Tree2.set_tree ra_ \<union> (Tree2.set_tree laa_ \<union> Tree2.set_tree raa_))))))) = (invpst la_ \<and> invpst ra_ \<and> is_min2 mkp_ (insert x_ (Tree2.set_tree la_ \<union> Tree2.set_tree ra_)) \<and> invpst laa_ \<and> invpst raa_ \<and> is_min2 mkpa_ (insert xa_ (Tree2.set_tree laa_ \<union> Tree2.set_tree raa_)))
[PROOF STEP]
by (smt Un_insert_left Un_insert_right is_min2_mergeI is_min2_min2_insI
                sup_assoc)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma eucl_ivals[measurable]:
  fixes a b :: "'a::ordered_euclidean_space"
  shows "{x. x <e a} \<in> sets borel"
    and "{x. a <e x} \<in> sets borel"
    and "{..a} \<in> sets borel"
    and "{a..} \<in> sets borel"
    and "{a..b} \<in> sets borel"
    and  "{x. a <e x \<and> x \<le> b} \<in> sets borel"
    and "{x. a \<le> x \<and>  x <e b} \<in> sets borel"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ({x. x <e a} \<in> sets borel &&& {x. a <e x} \<in> sets borel &&& {..a} \<in> sets borel) &&& ({a..} \<in> sets borel &&& {a..b} \<in> sets borel) &&& {x. a <e x \<and> x \<le> b} \<in> sets borel &&& {x. a \<le> x \<and> x <e b} \<in> sets borel
[PROOF STEP]
unfolding box_oc box_co
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ({x. x <e a} \<in> sets borel &&& {x. a <e x} \<in> sets borel &&& {..a} \<in> sets borel) &&& ({a..} \<in> sets borel &&& {a..b} \<in> sets borel) &&& Collect ((<e) a) \<inter> {..b} \<in> sets borel &&& {a..} \<inter> {x. x <e b} \<in> sets borel
[PROOF STEP]
by (auto intro: borel_open borel_closed)


[STATEMENT]
lemma multiply_by_add_tc: "VARS m s a b
  [a=A \<and> b=B]
  m := 0; s := 0;
  WHILE m\<noteq>a
  INV {s=m*b \<and> a=A \<and> b=B \<and> m\<le>a}
  VAR {a-m}
  DO s := s+b; m := m+(1::nat) OD
  [s = A*B]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [a = A \<and> b = B]
m := 0; s := 0; WHILE m \<noteq> a INV {s = m * b \<and> a = A \<and> b = B \<and> m \<le> a}  VAR {a - m}
DO s := s + b; m := m + 1 OD
[s = A * B]
[PROOF STEP]
apply vcg_tc_simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>m. m \<le> A \<and> m \<noteq> A \<Longrightarrow> A - Suc m < A - m
[PROOF STEP]
by auto


[STATEMENT]
lemma single_addition_neg:"\<lbrakk>commute_bpp f (aug_pm_set z i {(a::'a)});
      assoc_bpp (aug_pm_set z i {a}) f; ipp_cond1 {a} i; ipp_cond2 z {a} i f;
      ipp_cond3 z i; inv_ipp z i f {a}; commute_bpp f (aug_pm_set z i {a});
      zeroA z i f {a} z; (n::int) < 0; (m::int) < 0 \<rbrakk> \<Longrightarrow>
           (n\<Odot>a\<^bsub>f,i,z\<^esub>) \<^sub>f+ (m\<Odot>a\<^bsub>f,i,z\<^esub>) = (n + m)\<Odot>a\<^bsub>f,i,z\<^esub>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>commute_bpp f (aug_pm_set z i {a}); assoc_bpp (aug_pm_set z i {a}) f; ipp_cond1 {a} i; ipp_cond2 z {a} i f; ipp_cond3 z i; inv_ipp z i f {a}; commute_bpp f (aug_pm_set z i {a}); zeroA z i f {a} z; n < 0; m < 0\<rbrakk> \<Longrightarrow> n\<Odot>a\<^bsub>f,i,z\<^esub> \<^sub>f+ m\<Odot>a\<^bsub>f,i,z\<^esub> = (n + m)\<Odot>a\<^bsub>f,i,z\<^esub>
[PROOF STEP]
apply (simp add:fg_elem_single_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>assoc_bpp (aug_pm_set z i {a}) f; ipp_cond1 {a} i; ipp_cond2 z {a} i f; ipp_cond3 z i; inv_ipp z i f {a}; commute_bpp f (aug_pm_set z i {a}); zeroA z i f {a} z; n < 0; m < 0\<rbrakk> \<Longrightarrow> (THE x. x \<in> add_set f {\<^sub>i- a} (nat (- n - 1))) \<^sub>f+ (THE x. x \<in> add_set f {\<^sub>i- a} (nat (- m - 1))) = (THE x. x \<in> add_set f {\<^sub>i- a} (nat (- n - m - 1)))
[PROOF STEP]
apply (simp del:add_set_Suc add:aug_pm_aug_pm_minus)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>assoc_bpp (aug_pm_set z i {\<^sub>i- a}) f; ipp_cond1 {a} i; ipp_cond2 z {a} i f; ipp_cond3 z i; inv_ipp z i f {a}; commute_bpp f (aug_pm_set z i {\<^sub>i- a}); zeroA z i f {a} z; n < 0; m < 0\<rbrakk> \<Longrightarrow> (THE x. x \<in> add_set f {\<^sub>i- a} (nat (- n - 1))) \<^sub>f+ (THE x. x \<in> add_set f {\<^sub>i- a} (nat (- m - 1))) = (THE x. x \<in> add_set f {\<^sub>i- a} (nat (- n - m - 1)))
[PROOF STEP]
apply (frule ipp_cond1_minus[of "a" "i"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>assoc_bpp (aug_pm_set z i {\<^sub>i- a}) f; ipp_cond1 {a} i; ipp_cond2 z {a} i f; ipp_cond3 z i; inv_ipp z i f {a}; commute_bpp f (aug_pm_set z i {\<^sub>i- a}); zeroA z i f {a} z; n < 0; m < 0; ipp_cond1 {\<^sub>i- a} i\<rbrakk> \<Longrightarrow> (THE x. x \<in> add_set f {\<^sub>i- a} (nat (- n - 1))) \<^sub>f+ (THE x. x \<in> add_set f {\<^sub>i- a} (nat (- m - 1))) = (THE x. x \<in> add_set f {\<^sub>i- a} (nat (- n - m - 1)))
[PROOF STEP]
apply (frule ipp_cond2_minus[of "a" "i" "z" "f"], assumption+)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>assoc_bpp (aug_pm_set z i {\<^sub>i- a}) f; ipp_cond1 {a} i; ipp_cond2 z {a} i f; ipp_cond3 z i; inv_ipp z i f {a}; commute_bpp f (aug_pm_set z i {\<^sub>i- a}); zeroA z i f {a} z; n < 0; m < 0; ipp_cond1 {\<^sub>i- a} i; ipp_cond2 z {\<^sub>i- a} i f\<rbrakk> \<Longrightarrow> (THE x. x \<in> add_set f {\<^sub>i- a} (nat (- n - 1))) \<^sub>f+ (THE x. x \<in> add_set f {\<^sub>i- a} (nat (- m - 1))) = (THE x. x \<in> add_set f {\<^sub>i- a} (nat (- n - m - 1)))
[PROOF STEP]
apply (frule inv_ipp_minus[of "a" "i" "z" "f"], assumption+)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>assoc_bpp (aug_pm_set z i {\<^sub>i- a}) f; ipp_cond1 {a} i; ipp_cond2 z {a} i f; ipp_cond3 z i; inv_ipp z i f {a}; commute_bpp f (aug_pm_set z i {\<^sub>i- a}); zeroA z i f {a} z; n < 0; m < 0; ipp_cond1 {\<^sub>i- a} i; ipp_cond2 z {\<^sub>i- a} i f; inv_ipp z i f {\<^sub>i- a}\<rbrakk> \<Longrightarrow> (THE x. x \<in> add_set f {\<^sub>i- a} (nat (- n - 1))) \<^sub>f+ (THE x. x \<in> add_set f {\<^sub>i- a} (nat (- m - 1))) = (THE x. x \<in> add_set f {\<^sub>i- a} (nat (- n - m - 1)))
[PROOF STEP]
apply (frule zeroA_minus[of "a" "i" "z" "f" "z"], assumption+)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>assoc_bpp (aug_pm_set z i {\<^sub>i- a}) f; ipp_cond1 {a} i; ipp_cond2 z {a} i f; ipp_cond3 z i; inv_ipp z i f {a}; commute_bpp f (aug_pm_set z i {\<^sub>i- a}); zeroA z i f {a} z; n < 0; m < 0; ipp_cond1 {\<^sub>i- a} i; ipp_cond2 z {\<^sub>i- a} i f; inv_ipp z i f {\<^sub>i- a}; zeroA z i f {\<^sub>i- a} z\<rbrakk> \<Longrightarrow> (THE x. x \<in> add_set f {\<^sub>i- a} (nat (- n - 1))) \<^sub>f+ (THE x. x \<in> add_set f {\<^sub>i- a} (nat (- m - 1))) = (THE x. x \<in> add_set f {\<^sub>i- a} (nat (- n - m - 1)))
[PROOF STEP]
apply (frule single_addition_posTr [of f z i "\<^sub>i- a" "- n" "- m"], assumption+)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<lbrakk>assoc_bpp (aug_pm_set z i {\<^sub>i- a}) f; ipp_cond1 {a} i; ipp_cond2 z {a} i f; ipp_cond3 z i; inv_ipp z i f {a}; commute_bpp f (aug_pm_set z i {\<^sub>i- a}); zeroA z i f {a} z; n < 0; m < 0; ipp_cond1 {\<^sub>i- a} i; ipp_cond2 z {\<^sub>i- a} i f; inv_ipp z i f {\<^sub>i- a}; zeroA z i f {\<^sub>i- a} z\<rbrakk> \<Longrightarrow> 0 < - n
 2. \<lbrakk>assoc_bpp (aug_pm_set z i {\<^sub>i- a}) f; ipp_cond1 {a} i; ipp_cond2 z {a} i f; ipp_cond3 z i; inv_ipp z i f {a}; commute_bpp f (aug_pm_set z i {\<^sub>i- a}); zeroA z i f {a} z; n < 0; m < 0; ipp_cond1 {\<^sub>i- a} i; ipp_cond2 z {\<^sub>i- a} i f; inv_ipp z i f {\<^sub>i- a}; zeroA z i f {\<^sub>i- a} z\<rbrakk> \<Longrightarrow> 0 < - m
 3. \<lbrakk>assoc_bpp (aug_pm_set z i {\<^sub>i- a}) f; ipp_cond1 {a} i; ipp_cond2 z {a} i f; ipp_cond3 z i; inv_ipp z i f {a}; commute_bpp f (aug_pm_set z i {\<^sub>i- a}); zeroA z i f {a} z; n < 0; m < 0; ipp_cond1 {\<^sub>i- a} i; ipp_cond2 z {\<^sub>i- a} i f; inv_ipp z i f {\<^sub>i- a}; zeroA z i f {\<^sub>i- a} z; (THE x. x \<in> add_set f {\<^sub>i- a} (nat (- n - 1))) \<^sub>f+ (THE x. x \<in> add_set f {\<^sub>i- a} (nat (- m - 1))) = (THE x. x \<in> add_set f {\<^sub>i- a} (nat (- n + - m - 1)))\<rbrakk> \<Longrightarrow> (THE x. x \<in> add_set f {\<^sub>i- a} (nat (- n - 1))) \<^sub>f+ (THE x. x \<in> add_set f {\<^sub>i- a} (nat (- m - 1))) = (THE x. x \<in> add_set f {\<^sub>i- a} (nat (- n - m - 1)))
[PROOF STEP]
apply simp+
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma "(x::real) > 1 \<and> y > 1 \<longrightarrow> x * y > x + y - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 < x \<and> 1 < y \<longrightarrow> x + y - 1 < x * y
[PROOF STEP]
by (sos "((((A<0 * A<1) * R<1) + ((A<=0 * R<1) * (R<1 * [1]^2))))")


[STATEMENT]
lemma (in cring)
  assumes "x \<in> carrier R" "y \<in> carrier R"
  shows "(x \<ominus> y) [^] (2::nat) = x [^] (2::nat) \<oplus> y [^] (2::nat) \<ominus> \<guillemotleft>2\<guillemotright> \<otimes> x \<otimes> y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x \<ominus> y) [^] 2 = x [^] 2 \<oplus> y [^] 2 \<ominus> \<guillemotleft>2\<guillemotright> \<otimes> x \<otimes> y
[PROOF STEP]
by ring


[STATEMENT]
lemma max_less:"2 ^ 31 < (9223372039002259455::int)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 ^ 31 < 9223372039002259455
[PROOF STEP]
by auto


[STATEMENT]
lemma DeMoivre: "(cos z + \<i> * sin z) ^ n = cos(n * z) + \<i> * sin(n * z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cos z + \<i> * sin z) ^ n = cos (of_nat n * z) + \<i> * sin (of_nat n * z)
[PROOF STEP]
by (metis exp_Euler [symmetric] exp_of_nat_mult mult.left_commute)


[STATEMENT]
lemma p_gt_1: "p > 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 < p
[PROOF STEP]
using p_ge_18
[PROOF STATE]
proof (prove)
using this:
18 \<le> p

goal (1 subgoal):
 1. 1 < p
[PROOF STEP]
by simp


[STATEMENT]
lemma setops\<^sub>l\<^sub>s\<^sub>s\<^sub>t_suffix_subset:
  "setops\<^sub>l\<^sub>s\<^sub>s\<^sub>t B \<subseteq> setops\<^sub>l\<^sub>s\<^sub>s\<^sub>t (A@B)"
  "setops\<^sub>l\<^sub>s\<^sub>s\<^sub>t (proj n B) \<subseteq> setops\<^sub>l\<^sub>s\<^sub>s\<^sub>t (proj n (A@B))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. setops\<^sub>l\<^sub>s\<^sub>s\<^sub>t B \<subseteq> setops\<^sub>l\<^sub>s\<^sub>s\<^sub>t (A @ B) &&& setops\<^sub>l\<^sub>s\<^sub>s\<^sub>t (proj n B) \<subseteq> setops\<^sub>l\<^sub>s\<^sub>s\<^sub>t (proj n (A @ B))
[PROOF STEP]
unfolding proj_def setops\<^sub>l\<^sub>s\<^sub>s\<^sub>t_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Union> (setops\<^sub>l\<^sub>s\<^sub>s\<^sub>t\<^sub>p ` set B) \<subseteq> \<Union> (setops\<^sub>l\<^sub>s\<^sub>s\<^sub>t\<^sub>p ` set (A @ B)) &&& \<Union> (setops\<^sub>l\<^sub>s\<^sub>s\<^sub>t\<^sub>p ` set (filter (\<lambda>s. has_LabelN n s \<or> has_LabelS s) B)) \<subseteq> \<Union> (setops\<^sub>l\<^sub>s\<^sub>s\<^sub>t\<^sub>p ` set (filter (\<lambda>s. has_LabelN n s \<or> has_LabelS s) (A @ B)))
[PROOF STEP]
by auto


[STATEMENT]
lemma count_space_PiM_finite:
  fixes B :: "'a \<Rightarrow> 'b set"
  assumes "finite A" "\<And>i. countable (B i)"
  shows   "PiM A (\<lambda>i. count_space (B i)) = count_space (PiE A B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Pi\<^sub>M A (\<lambda>i. count_space (B i)) = count_space (Pi\<^sub>E A B)
[PROOF STEP]
proof (rule measure_eqI_countable')
[PROOF STATE]
proof (state)
goal (6 subgoals):
 1. space (Pi\<^sub>M A (\<lambda>i. count_space (B i))) = ?A
 2. space (count_space (Pi\<^sub>E A B)) = ?A
 3. \<And>x. x \<in> ?A \<Longrightarrow> {x} \<in> sets (Pi\<^sub>M A (\<lambda>i. count_space (B i)))
 4. \<And>x. x \<in> ?A \<Longrightarrow> {x} \<in> sets (count_space (Pi\<^sub>E A B))
 5. countable ?A
 6. \<And>a. a \<in> ?A \<Longrightarrow> emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {a} = emeasure (count_space (Pi\<^sub>E A B)) {a}
[PROOF STEP]
show "space (PiM A (\<lambda>i. count_space (B i))) = PiE A B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. space (Pi\<^sub>M A (\<lambda>i. count_space (B i))) = Pi\<^sub>E A B
[PROOF STEP]
by (simp add: space_PiM)
[PROOF STATE]
proof (state)
this:
space (Pi\<^sub>M A (\<lambda>i. count_space (B i))) = Pi\<^sub>E A B

goal (5 subgoals):
 1. space (count_space (Pi\<^sub>E A B)) = Pi\<^sub>E A B
 2. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (Pi\<^sub>M A (\<lambda>i. count_space (B i)))
 3. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (count_space (Pi\<^sub>E A B))
 4. countable (Pi\<^sub>E A B)
 5. \<And>a. a \<in> Pi\<^sub>E A B \<Longrightarrow> emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {a} = emeasure (count_space (Pi\<^sub>E A B)) {a}
[PROOF STEP]
show "space (count_space (PiE A B)) = PiE A B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. space (count_space (Pi\<^sub>E A B)) = Pi\<^sub>E A B
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
space (count_space (Pi\<^sub>E A B)) = Pi\<^sub>E A B

goal (4 subgoals):
 1. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (Pi\<^sub>M A (\<lambda>i. count_space (B i)))
 2. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (count_space (Pi\<^sub>E A B))
 3. countable (Pi\<^sub>E A B)
 4. \<And>a. a \<in> Pi\<^sub>E A B \<Longrightarrow> emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {a} = emeasure (count_space (Pi\<^sub>E A B)) {a}
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (Pi\<^sub>M A (\<lambda>i. count_space (B i)))
 2. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (count_space (Pi\<^sub>E A B))
 3. countable (Pi\<^sub>E A B)
 4. \<And>a. a \<in> Pi\<^sub>E A B \<Longrightarrow> emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {a} = emeasure (count_space (Pi\<^sub>E A B)) {a}
[PROOF STEP]
fix f
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (Pi\<^sub>M A (\<lambda>i. count_space (B i)))
 2. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (count_space (Pi\<^sub>E A B))
 3. countable (Pi\<^sub>E A B)
 4. \<And>a. a \<in> Pi\<^sub>E A B \<Longrightarrow> emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {a} = emeasure (count_space (Pi\<^sub>E A B)) {a}
[PROOF STEP]
assume f: "f \<in> PiE A B"
[PROOF STATE]
proof (state)
this:
f \<in> Pi\<^sub>E A B

goal (4 subgoals):
 1. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (Pi\<^sub>M A (\<lambda>i. count_space (B i)))
 2. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (count_space (Pi\<^sub>E A B))
 3. countable (Pi\<^sub>E A B)
 4. \<And>a. a \<in> Pi\<^sub>E A B \<Longrightarrow> emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {a} = emeasure (count_space (Pi\<^sub>E A B)) {a}
[PROOF STEP]
hence "PiE A (\<lambda>x. {f x}) \<in> sets (Pi\<^sub>M A (\<lambda>i. count_space (B i)))"
[PROOF STATE]
proof (prove)
using this:
f \<in> Pi\<^sub>E A B

goal (1 subgoal):
 1. (\<Pi>\<^sub>E x\<in>A. {f x}) \<in> sets (Pi\<^sub>M A (\<lambda>i. count_space (B i)))
[PROOF STEP]
by (intro sets_PiM_I_finite assms) auto
[PROOF STATE]
proof (state)
this:
(\<Pi>\<^sub>E x\<in>A. {f x}) \<in> sets (Pi\<^sub>M A (\<lambda>i. count_space (B i)))

goal (4 subgoals):
 1. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (Pi\<^sub>M A (\<lambda>i. count_space (B i)))
 2. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (count_space (Pi\<^sub>E A B))
 3. countable (Pi\<^sub>E A B)
 4. \<And>a. a \<in> Pi\<^sub>E A B \<Longrightarrow> emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {a} = emeasure (count_space (Pi\<^sub>E A B)) {a}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Pi>\<^sub>E x\<in>A. {f x}) \<in> sets (Pi\<^sub>M A (\<lambda>i. count_space (B i)))

goal (4 subgoals):
 1. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (Pi\<^sub>M A (\<lambda>i. count_space (B i)))
 2. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (count_space (Pi\<^sub>E A B))
 3. countable (Pi\<^sub>E A B)
 4. \<And>a. a \<in> Pi\<^sub>E A B \<Longrightarrow> emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {a} = emeasure (count_space (Pi\<^sub>E A B)) {a}
[PROOF STEP]
from f
[PROOF STATE]
proof (chain)
picking this:
f \<in> Pi\<^sub>E A B
[PROOF STEP]
have "PiE A (\<lambda>x. {f x}) = {f}"
[PROOF STATE]
proof (prove)
using this:
f \<in> Pi\<^sub>E A B

goal (1 subgoal):
 1. (\<Pi>\<^sub>E x\<in>A. {f x}) = {f}
[PROOF STEP]
by (intro PiE_singleton) (auto simp: PiE_def)
[PROOF STATE]
proof (state)
this:
(\<Pi>\<^sub>E x\<in>A. {f x}) = {f}

goal (4 subgoals):
 1. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (Pi\<^sub>M A (\<lambda>i. count_space (B i)))
 2. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (count_space (Pi\<^sub>E A B))
 3. countable (Pi\<^sub>E A B)
 4. \<And>a. a \<in> Pi\<^sub>E A B \<Longrightarrow> emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {a} = emeasure (count_space (Pi\<^sub>E A B)) {a}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
{f} \<in> sets (Pi\<^sub>M A (\<lambda>i. count_space (B i)))
[PROOF STEP]
show "{f} \<in> sets (Pi\<^sub>M A (\<lambda>i. count_space (B i)))"
[PROOF STATE]
proof (prove)
using this:
{f} \<in> sets (Pi\<^sub>M A (\<lambda>i. count_space (B i)))

goal (1 subgoal):
 1. {f} \<in> sets (Pi\<^sub>M A (\<lambda>i. count_space (B i)))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
{f} \<in> sets (Pi\<^sub>M A (\<lambda>i. count_space (B i)))

goal (3 subgoals):
 1. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (count_space (Pi\<^sub>E A B))
 2. countable (Pi\<^sub>E A B)
 3. \<And>a. a \<in> Pi\<^sub>E A B \<Longrightarrow> emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {a} = emeasure (count_space (Pi\<^sub>E A B)) {a}
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (count_space (Pi\<^sub>E A B))
 2. countable (Pi\<^sub>E A B)
 3. \<And>a. a \<in> Pi\<^sub>E A B \<Longrightarrow> emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {a} = emeasure (count_space (Pi\<^sub>E A B)) {a}
[PROOF STEP]
interpret product_sigma_finite "(\<lambda>i. count_space (B i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. product_sigma_finite (\<lambda>i. count_space (B i))
[PROOF STEP]
by (intro product_sigma_finite.intro sigma_finite_measure_count_space_countable assms)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (count_space (Pi\<^sub>E A B))
 2. countable (Pi\<^sub>E A B)
 3. \<And>a. a \<in> Pi\<^sub>E A B \<Longrightarrow> emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {a} = emeasure (count_space (Pi\<^sub>E A B)) {a}
[PROOF STEP]
thm sigma_finite_measure_count_space
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (count_space (Pi\<^sub>E A B))
 2. countable (Pi\<^sub>E A B)
 3. \<And>a. a \<in> Pi\<^sub>E A B \<Longrightarrow> emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {a} = emeasure (count_space (Pi\<^sub>E A B)) {a}
[PROOF STEP]
fix f
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (count_space (Pi\<^sub>E A B))
 2. countable (Pi\<^sub>E A B)
 3. \<And>a. a \<in> Pi\<^sub>E A B \<Longrightarrow> emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {a} = emeasure (count_space (Pi\<^sub>E A B)) {a}
[PROOF STEP]
assume f: "f \<in> PiE A B"
[PROOF STATE]
proof (state)
this:
f \<in> Pi\<^sub>E A B

goal (3 subgoals):
 1. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (count_space (Pi\<^sub>E A B))
 2. countable (Pi\<^sub>E A B)
 3. \<And>a. a \<in> Pi\<^sub>E A B \<Longrightarrow> emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {a} = emeasure (count_space (Pi\<^sub>E A B)) {a}
[PROOF STEP]
hence "{f} = PiE A (\<lambda>x. {f x})"
[PROOF STATE]
proof (prove)
using this:
f \<in> Pi\<^sub>E A B

goal (1 subgoal):
 1. {f} = (\<Pi>\<^sub>E x\<in>A. {f x})
[PROOF STEP]
by (intro PiE_singleton [symmetric]) (auto simp: PiE_def)
[PROOF STATE]
proof (state)
this:
{f} = (\<Pi>\<^sub>E x\<in>A. {f x})

goal (3 subgoals):
 1. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (count_space (Pi\<^sub>E A B))
 2. countable (Pi\<^sub>E A B)
 3. \<And>a. a \<in> Pi\<^sub>E A B \<Longrightarrow> emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {a} = emeasure (count_space (Pi\<^sub>E A B)) {a}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
{f} = (\<Pi>\<^sub>E x\<in>A. {f x})

goal (3 subgoals):
 1. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (count_space (Pi\<^sub>E A B))
 2. countable (Pi\<^sub>E A B)
 3. \<And>a. a \<in> Pi\<^sub>E A B \<Longrightarrow> emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {a} = emeasure (count_space (Pi\<^sub>E A B)) {a}
[PROOF STEP]
have "emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) \<dots> =
               (\<Prod>i\<in>A. emeasure (count_space (B i)) {f i})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) (\<Pi>\<^sub>E x\<in>A. {f x}) = (\<Prod>i\<in>A. emeasure (count_space (B i)) {f i})
[PROOF STEP]
using f assms
[PROOF STATE]
proof (prove)
using this:
f \<in> Pi\<^sub>E A B
finite A
countable (B ?i)

goal (1 subgoal):
 1. emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) (\<Pi>\<^sub>E x\<in>A. {f x}) = (\<Prod>i\<in>A. emeasure (count_space (B i)) {f i})
[PROOF STEP]
by (subst emeasure_PiM) auto
[PROOF STATE]
proof (state)
this:
emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) (\<Pi>\<^sub>E x\<in>A. {f x}) = (\<Prod>i\<in>A. emeasure (count_space (B i)) {f i})

goal (3 subgoals):
 1. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (count_space (Pi\<^sub>E A B))
 2. countable (Pi\<^sub>E A B)
 3. \<And>a. a \<in> Pi\<^sub>E A B \<Longrightarrow> emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {a} = emeasure (count_space (Pi\<^sub>E A B)) {a}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) (\<Pi>\<^sub>E x\<in>A. {f x}) = (\<Prod>i\<in>A. emeasure (count_space (B i)) {f i})

goal (3 subgoals):
 1. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (count_space (Pi\<^sub>E A B))
 2. countable (Pi\<^sub>E A B)
 3. \<And>a. a \<in> Pi\<^sub>E A B \<Longrightarrow> emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {a} = emeasure (count_space (Pi\<^sub>E A B)) {a}
[PROOF STEP]
have "\<dots> = (\<Prod>i\<in>A. 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>i\<in>A. emeasure (count_space (B i)) {f i}) = (\<Prod>i\<in>A. 1)
[PROOF STEP]
by (intro prod.cong refl, subst emeasure_count_space_finite) (use f in auto)
[PROOF STATE]
proof (state)
this:
(\<Prod>i\<in>A. emeasure (count_space (B i)) {f i}) = (\<Prod>i\<in>A. 1)

goal (3 subgoals):
 1. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (count_space (Pi\<^sub>E A B))
 2. countable (Pi\<^sub>E A B)
 3. \<And>a. a \<in> Pi\<^sub>E A B \<Longrightarrow> emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {a} = emeasure (count_space (Pi\<^sub>E A B)) {a}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Prod>i\<in>A. emeasure (count_space (B i)) {f i}) = (\<Prod>i\<in>A. 1)

goal (3 subgoals):
 1. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (count_space (Pi\<^sub>E A B))
 2. countable (Pi\<^sub>E A B)
 3. \<And>a. a \<in> Pi\<^sub>E A B \<Longrightarrow> emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {a} = emeasure (count_space (Pi\<^sub>E A B)) {a}
[PROOF STEP]
have "\<dots> = emeasure (count_space (PiE A B)) {f}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>i\<in>A. 1) = emeasure (count_space (Pi\<^sub>E A B)) {f}
[PROOF STEP]
using f
[PROOF STATE]
proof (prove)
using this:
f \<in> Pi\<^sub>E A B

goal (1 subgoal):
 1. (\<Prod>i\<in>A. 1) = emeasure (count_space (Pi\<^sub>E A B)) {f}
[PROOF STEP]
by (subst emeasure_count_space_finite) auto
[PROOF STATE]
proof (state)
this:
(\<Prod>i\<in>A. 1) = emeasure (count_space (Pi\<^sub>E A B)) {f}

goal (3 subgoals):
 1. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (count_space (Pi\<^sub>E A B))
 2. countable (Pi\<^sub>E A B)
 3. \<And>a. a \<in> Pi\<^sub>E A B \<Longrightarrow> emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {a} = emeasure (count_space (Pi\<^sub>E A B)) {a}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {f} = emeasure (count_space (Pi\<^sub>E A B)) {f}
[PROOF STEP]
show "emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {f} =
                  emeasure (count_space (Pi\<^sub>E A B)) {f}"
[PROOF STATE]
proof (prove)
using this:
emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {f} = emeasure (count_space (Pi\<^sub>E A B)) {f}

goal (1 subgoal):
 1. emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {f} = emeasure (count_space (Pi\<^sub>E A B)) {f}
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
emeasure (Pi\<^sub>M A (\<lambda>i. count_space (B i))) {f} = emeasure (count_space (Pi\<^sub>E A B)) {f}

goal (2 subgoals):
 1. \<And>x. x \<in> Pi\<^sub>E A B \<Longrightarrow> {x} \<in> sets (count_space (Pi\<^sub>E A B))
 2. countable (Pi\<^sub>E A B)
[PROOF STEP]
qed (simp_all add: countable_PiE assms)


[STATEMENT]
lemma [code abstract]:
  "integer_of_natural (m * n) = integer_of_natural m * integer_of_natural n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integer_of_natural (m * n) = integer_of_natural m * integer_of_natural n
[PROOF STEP]
by transfer simp


[STATEMENT]
lemma n0: "n > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < n
[PROOF STEP]
using d0 dn
[PROOF STATE]
proof (prove)
using this:
0 < d
d \<le> n

goal (1 subgoal):
 1. 0 < n
[PROOF STEP]
by auto


[STATEMENT]
lemma boffa_aux2:
  "conway_assm1 x \<Longrightarrow>
  \<Sum>{x\<^bsub>i\<^esub>\<cdot>x\<^bsub>j \<^esub>| i j. i \<in> UNIV \<and> j \<in> UNIV} \<le> \<Sum>{x\<^bsub>i\<cdot>j\<^esub> | i j. i \<in> UNIV \<and> j \<in> UNIV}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. conway_assm1 x \<Longrightarrow> \<Sum> {x\<^bsub>i\<^esub> \<cdot> x\<^bsub>j\<^esub> |i j. i \<in> UNIV \<and> j \<in> UNIV} \<le> \<Sum> {x\<^bsub>i \<cdot> j\<^esub> |i j. i \<in> UNIV \<and> j \<in> UNIV}
[PROOF STEP]
unfolding conway_assm1_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i j. x\<^bsub>i\<^esub> \<cdot> x\<^bsub>j\<^esub> \<le> x\<^bsub>i \<cdot> j\<^esub> \<Longrightarrow> \<Sum> {x\<^bsub>i\<^esub> \<cdot> x\<^bsub>j\<^esub> |i j. i \<in> UNIV \<and> j \<in> UNIV} \<le> \<Sum> {x\<^bsub>i \<cdot> j\<^esub> |i j. i \<in> UNIV \<and> j \<in> UNIV}
[PROOF STEP]
using [[simproc add: finite_Collect]]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i j. x\<^bsub>i\<^esub> \<cdot> x\<^bsub>j\<^esub> \<le> x\<^bsub>i \<cdot> j\<^esub> \<Longrightarrow> \<Sum> {x\<^bsub>i\<^esub> \<cdot> x\<^bsub>j\<^esub> |i j. i \<in> UNIV \<and> j \<in> UNIV} \<le> \<Sum> {x\<^bsub>i \<cdot> j\<^esub> |i j. i \<in> UNIV \<and> j \<in> UNIV}
[PROOF STEP]
by force


[STATEMENT]
lemma gen_boolean_algebra_generators:
  assumes "\<And>b. b \<in> B \<Longrightarrow> b \<subseteq> S"
  assumes "b \<in> B"
  shows "b \<in> gen_boolean_algebra S B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b \<in> gen_boolean_algebra S B
[PROOF STEP]
unfolding gen_boolean_algebra.simps[of b]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b = S \<or> (\<exists>A. b = A \<inter> S \<and> A \<in> B) \<or> (\<exists>A C. b = A \<union> C \<and> A \<in> gen_boolean_algebra S B \<and> C \<in> gen_boolean_algebra S B) \<or> (\<exists>A. b = S - A \<and> A \<in> gen_boolean_algebra S B)
[PROOF STEP]
using assms(1)[of b] assms(2)
[PROOF STATE]
proof (prove)
using this:
b \<in> B \<Longrightarrow> b \<subseteq> S
b \<in> B

goal (1 subgoal):
 1. b = S \<or> (\<exists>A. b = A \<inter> S \<and> A \<in> B) \<or> (\<exists>A C. b = A \<union> C \<and> A \<in> gen_boolean_algebra S B \<and> C \<in> gen_boolean_algebra S B) \<or> (\<exists>A. b = S - A \<and> A \<in> gen_boolean_algebra S B)
[PROOF STEP]
by blast


[STATEMENT]
lemma partially_ordered_set_cong:
  assumes r: "\<And>a b. a \<in> A \<Longrightarrow> b \<in> A \<Longrightarrow> r a b \<longleftrightarrow> r' a b"
  shows "partially_ordered_set A r \<longleftrightarrow> partially_ordered_set A r'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. partially_ordered_set A r = partially_ordered_set A r'
[PROOF STEP]
by (simp add: partially_ordered_set_def r cong: reflexive_cong antisymmetric_cong transitive_cong)


[STATEMENT]
lemma mono_mult2_s:
  assumes "ns \<subseteq> ns'" "s \<subseteq> s'" shows "mult2_s ns s \<subseteq> mult2_s ns' s'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mult2_s ns s \<subseteq> mult2_s ns' s'
[PROOF STEP]
using mono_multpw[OF assms(1)] mono_mult[OF assms(2)]
[PROOF STATE]
proof (prove)
using this:
multpw ns \<subseteq> multpw ns'
mult s \<subseteq> mult s'

goal (1 subgoal):
 1. mult2_s ns s \<subseteq> mult2_s ns' s'
[PROOF STEP]
unfolding mult2_s_def
[PROOF STATE]
proof (prove)
using this:
multpw ns \<subseteq> multpw ns'
mult s \<subseteq> mult s'

goal (1 subgoal):
 1. multpw ns O mult s \<subseteq> multpw ns' O mult s'
[PROOF STEP]
by auto


[STATEMENT]
lemma list_all2_in_setE: "list_all2 P xs ys \<Longrightarrow> x \<in> set xs \<Longrightarrow> (\<And>y. y \<in> set ys \<Longrightarrow> P x y \<Longrightarrow> Q) \<Longrightarrow> Q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>list_all2 P xs ys; x \<in> set xs; \<And>y. \<lbrakk>y \<in> set ys; P x y\<rbrakk> \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q
[PROOF STEP]
by (fastforce simp: list_all2_iff set_zip in_set_conv_nth)


[STATEMENT]
lemma poly_pseudo_mod:
  assumes "poly q x=0" "q\<noteq>0"
  shows "poly (pseudo_mod p q) x = (lead_coeff q ^ (Suc (degree p) - degree q)) * poly p x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly (pseudo_mod p q) x = lead_coeff q ^ (Suc (degree p) - degree q) * poly p x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. poly (pseudo_mod p q) x = lead_coeff q ^ (Suc (degree p) - degree q) * poly p x
[PROOF STEP]
define a where "a=coeff q (degree q) ^ (Suc (degree p) - degree q)"
[PROOF STATE]
proof (state)
this:
a = lead_coeff q ^ (Suc (degree p) - degree q)

goal (1 subgoal):
 1. poly (pseudo_mod p q) x = lead_coeff q ^ (Suc (degree p) - degree q) * poly p x
[PROOF STEP]
obtain f r where fr:"pseudo_divmod p q = (f, r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>f r. pseudo_divmod p q = (f, r) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
pseudo_divmod p q = (f, r)

goal (1 subgoal):
 1. poly (pseudo_mod p q) x = lead_coeff q ^ (Suc (degree p) - degree q) * poly p x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
pseudo_divmod p q = (f, r)
[PROOF STEP]
have "smult a p = q * f + r" "r = 0 \<or> degree r < degree q"
[PROOF STATE]
proof (prove)
using this:
pseudo_divmod p q = (f, r)

goal (1 subgoal):
 1. smult a p = q * f + r &&& r = 0 \<or> degree r < degree q
[PROOF STEP]
using pseudo_divmod[OF \<open>q\<noteq>0\<close>]
[PROOF STATE]
proof (prove)
using this:
pseudo_divmod p q = (f, r)
pseudo_divmod ?f q = (?q, ?r) \<Longrightarrow> smult (lead_coeff q ^ (Suc (degree ?f) - degree q)) ?f = q * ?q + ?r
pseudo_divmod ?f q = (?q, ?r) \<Longrightarrow> ?r = 0 \<or> degree ?r < degree q

goal (1 subgoal):
 1. smult a p = q * f + r &&& r = 0 \<or> degree r < degree q
[PROOF STEP]
unfolding a_def
[PROOF STATE]
proof (prove)
using this:
pseudo_divmod p q = (f, r)
pseudo_divmod ?f q = (?q, ?r) \<Longrightarrow> smult (lead_coeff q ^ (Suc (degree ?f) - degree q)) ?f = q * ?q + ?r
pseudo_divmod ?f q = (?q, ?r) \<Longrightarrow> ?r = 0 \<or> degree ?r < degree q

goal (1 subgoal):
 1. smult (lead_coeff q ^ (Suc (degree p) - degree q)) p = q * f + r &&& r = 0 \<or> degree r < degree q
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
smult a p = q * f + r
r = 0 \<or> degree r < degree q

goal (1 subgoal):
 1. poly (pseudo_mod p q) x = lead_coeff q ^ (Suc (degree p) - degree q) * poly p x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
smult a p = q * f + r
r = 0 \<or> degree r < degree q
[PROOF STEP]
have "poly (q*f+r) x = poly (smult a p) x"
[PROOF STATE]
proof (prove)
using this:
smult a p = q * f + r
r = 0 \<or> degree r < degree q

goal (1 subgoal):
 1. poly (q * f + r) x = poly (smult a p) x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
poly (q * f + r) x = poly (smult a p) x

goal (1 subgoal):
 1. poly (pseudo_mod p q) x = lead_coeff q ^ (Suc (degree p) - degree q) * poly p x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
poly (q * f + r) x = poly (smult a p) x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
poly (q * f + r) x = poly (smult a p) x

goal (1 subgoal):
 1. poly (pseudo_mod p q) x = lead_coeff q ^ (Suc (degree p) - degree q) * poly p x
[PROOF STEP]
using assms(1) fr
[PROOF STATE]
proof (prove)
using this:
poly (q * f + r) x = poly (smult a p) x
poly q x = (0::'a)
pseudo_divmod p q = (f, r)

goal (1 subgoal):
 1. poly (pseudo_mod p q) x = lead_coeff q ^ (Suc (degree p) - degree q) * poly p x
[PROOF STEP]
unfolding pseudo_mod_def a_def
[PROOF STATE]
proof (prove)
using this:
poly (q * f + r) x = poly (smult (lead_coeff q ^ (Suc (degree p) - degree q)) p) x
poly q x = (0::'a)
pseudo_divmod p q = (f, r)

goal (1 subgoal):
 1. poly (snd (pseudo_divmod p q)) x = lead_coeff q ^ (Suc (degree p) - degree q) * poly p x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
poly (pseudo_mod p q) x = lead_coeff q ^ (Suc (degree p) - degree q) * poly p x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in Worder) ord_isom_Pre2:"\<lbrakk>Worder E; a \<in> carrier D; ExPre D a;
       ord_isom D E f\<rbrakk> \<Longrightarrow> f (Pre D a) = Pre E (f a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Worder E; a \<in> carrier D; ExPre D a; ord_isom D E f\<rbrakk> \<Longrightarrow> f (Pre D a) = Pre E (f a)
[PROOF STEP]
apply (frule_tac E = E and a = a and f = f in ord_isom_Pre1, assumption+,
       frule_tac a = a in Pre_element, assumption+, (erule conjE)+)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Worder E; a \<in> carrier D; ExPre D a; ord_isom D E f; ExPre E (f a); Pre D a \<in> carrier D; Pre D a \<prec> a; \<not> (\<exists>y\<in>carrier D. Pre D a \<prec> y \<and> y \<prec> a)\<rbrakk> \<Longrightarrow> f (Pre D a) = Pre E (f a)
[PROOF STEP]
apply (frule Worder.Order[of "E"],
        frule  ord_isom_mem[of "E" "f" "a"], assumption+,
        frule  ord_isom_mem[of "E" "f" "Pre D a"], assumption+,
        simp add:ord_isom_less[of "E" "f" "Pre D a" "a"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Worder E; a \<in> carrier D; ExPre D a; ord_isom D E f; ExPre E (f a); Pre D a \<in> carrier D; f (Pre D a) \<prec>\<^bsub>E\<^esub> f a; \<forall>y\<in>carrier D. Pre D a \<prec> y \<longrightarrow> \<not> y \<prec> a; Order E; f a \<in> carrier E; f (Pre D a) \<in> carrier E\<rbrakk> \<Longrightarrow> f (Pre D a) = Pre E (f a)
[PROOF STEP]
apply (simp add:ord_isom_convert[of E f "Pre D a" a])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Worder E; a \<in> carrier D; ExPre D a; ord_isom D E f; ExPre E (f a); Pre D a \<in> carrier D; f (Pre D a) \<prec>\<^bsub>E\<^esub> f a; \<forall>z\<in>carrier E. f (Pre D a) \<prec>\<^bsub>E\<^esub> z \<longrightarrow> \<not> z \<prec>\<^bsub>E\<^esub> f a; Order E; f a \<in> carrier E; f (Pre D a) \<in> carrier E\<rbrakk> \<Longrightarrow> f (Pre D a) = Pre E (f a)
[PROOF STEP]
apply (rule Worder.UniquePre[THEN sym, of "E" "f a" "f (Pre D a)"],
        assumption+, simp)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma balance_left_inv2_app:
  assumes "inv2 lt" "inv2 rt" "bheight lt + 1 = bheight rt" "color_of rt = B"
  shows "inv2 (balance_left lt k v rt)"
        "bheight (balance_left lt k v rt) = bheight rt"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inv2 (balance_left lt k v rt) &&& bheight (balance_left lt k v rt) = bheight rt
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
inv2 lt
inv2 rt
bheight lt + 1 = bheight rt
color_of rt = B

goal (1 subgoal):
 1. inv2 (balance_left lt k v rt) &&& bheight (balance_left lt k v rt) = bheight rt
[PROOF STEP]
by (induct lt k v rt rule: balance_left.induct) (auto simp add: balance_inv2 balance_bheight)+


[STATEMENT]
lemma norm_\<P>\<^sub>L_le_one: "norm (\<P>\<^sub>L d) \<le> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (\<P>\<^sub>L d) \<le> 1
[PROOF STEP]
using norm_\<P>\<^sub>L_le norm_\<P>\<^sub>1
[PROOF STATE]
proof (prove)
using this:
norm (\<P>\<^sub>L ?d) \<le> norm (\<P>\<^sub>1 (mk_dec_det ?d))
norm (\<P>\<^sub>1 ?d) = 1

goal (1 subgoal):
 1. norm (\<P>\<^sub>L d) \<le> 1
[PROOF STEP]
by auto


[STATEMENT]
lemma nth_delete_index:
  "i < length xs \<Longrightarrow> n < length xs \<Longrightarrow>
     delete_index n xs ! i = (if i < n then xs ! i else xs ! Suc i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>i < length xs; n < length xs\<rbrakk> \<Longrightarrow> delete_index n xs ! i = (if i < n then xs ! i else xs ! Suc i)
[PROOF STEP]
by (auto simp: delete_index_altdef nth_append min_def)


[STATEMENT]
lemma nth_append_take:
  assumes "i \<le> length xs" shows "(take i xs @ y#ys)!i = y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (take i xs @ y # ys) ! i = y
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (take i xs @ y # ys) ! i = y
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
i \<le> length xs
[PROOF STEP]
have a: "length(take i xs) = i"
[PROOF STATE]
proof (prove)
using this:
i \<le> length xs

goal (1 subgoal):
 1. length (take i xs) = i
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
length (take i xs) = i

goal (1 subgoal):
 1. (take i xs @ y # ys) ! i = y
[PROOF STEP]
have "(take i xs @ y#ys)!(length(take i xs)) = y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (take i xs @ y # ys) ! length (take i xs) = y
[PROOF STEP]
by (rule nth_append_length)
[PROOF STATE]
proof (state)
this:
(take i xs @ y # ys) ! length (take i xs) = y

goal (1 subgoal):
 1. (take i xs @ y # ys) ! i = y
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(take i xs @ y # ys) ! length (take i xs) = y

goal (1 subgoal):
 1. (take i xs @ y # ys) ! i = y
[PROOF STEP]
unfolding a
[PROOF STATE]
proof (prove)
using this:
(take i xs @ y # ys) ! i = y

goal (1 subgoal):
 1. (take i xs @ y # ys) ! i = y
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(take i xs @ y # ys) ! i = y

goal:
No subgoals!
[PROOF STEP]
qed