[STATEMENT]
theorem lower_by_complete_lattice:
    assumes "complete_lattice \<Y>" "x \<in> carrier \<X>"
    shows "\<pi>\<^sup>*(x) = \<Sqinter>\<^bsub>\<Y>\<^esub> { y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>*(y) }"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<pi>\<^sup>* x = \<Sqinter>\<^bsub>\<Y>\<^esub>{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<pi>\<^sup>* x = \<Sqinter>\<^bsub>\<Y>\<^esub>{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y}
[PROOF STEP]
interpret Y: complete_lattice \<Y>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. complete_lattice \<Y>
[PROOF STEP]
by (simp add: assms)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<pi>\<^sup>* x = \<Sqinter>\<^bsub>\<Y>\<^esub>{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<pi>\<^sup>* x = \<Sqinter>\<^bsub>\<Y>\<^esub>{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y}
[PROOF STEP]
proof (rule Y.le_antisym)
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. \<pi>\<^sup>* x \<sqsubseteq>\<^bsub>\<Y>\<^esub> \<Sqinter>\<^bsub>\<Y>\<^esub>{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y}
 2. \<Sqinter>\<^bsub>\<Y>\<^esub>{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y} \<sqsubseteq>\<^bsub>\<Y>\<^esub> \<pi>\<^sup>* x
 3. \<pi>\<^sup>* x \<in> carrier \<Y>
 4. \<Sqinter>\<^bsub>\<Y>\<^esub>{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y} \<in> carrier \<Y>
[PROOF STEP]
show x: "\<pi>\<^sup>* x \<in> carrier \<Y>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<pi>\<^sup>* x \<in> carrier \<Y>
[PROOF STEP]
using assms(2) lower_closure
[PROOF STATE]
proof (prove)
using this:
x \<in> carrier \<X>
\<pi>\<^sup>* \<in> carrier \<X> \<rightarrow> carrier \<Y>

goal (1 subgoal):
 1. \<pi>\<^sup>* x \<in> carrier \<Y>
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<pi>\<^sup>* x \<in> carrier \<Y>

goal (3 subgoals):
 1. \<pi>\<^sup>* x \<sqsubseteq>\<^bsub>\<Y>\<^esub> \<Sqinter>\<^bsub>\<Y>\<^esub>{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y}
 2. \<Sqinter>\<^bsub>\<Y>\<^esub>{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y} \<sqsubseteq>\<^bsub>\<Y>\<^esub> \<pi>\<^sup>* x
 3. \<Sqinter>\<^bsub>\<Y>\<^esub>{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y} \<in> carrier \<Y>
[PROOF STEP]
show "\<pi>\<^sup>* x \<sqsubseteq>\<^bsub>\<Y>\<^esub> \<Sqinter>\<^bsub>\<Y>\<^esub>{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<pi>\<^sup>* x \<sqsubseteq>\<^bsub>\<Y>\<^esub> \<Sqinter>\<^bsub>\<Y>\<^esub>{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y}
[PROOF STEP]
proof (rule Y.weak.inf_greatest)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. {y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y} \<subseteq> carrier \<Y>
 2. \<pi>\<^sup>* x \<in> carrier \<Y>
 3. \<And>xa. xa \<in> {y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y} \<Longrightarrow> \<pi>\<^sup>* x \<sqsubseteq>\<^bsub>\<Y>\<^esub> xa
[PROOF STEP]
show "{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y} \<subseteq> carrier \<Y>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y} \<subseteq> carrier \<Y>
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y} \<subseteq> carrier \<Y>

goal (2 subgoals):
 1. \<pi>\<^sup>* x \<in> carrier \<Y>
 2. \<And>xa. xa \<in> {y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y} \<Longrightarrow> \<pi>\<^sup>* x \<sqsubseteq>\<^bsub>\<Y>\<^esub> xa
[PROOF STEP]
show "\<pi>\<^sup>* x \<in> carrier \<Y>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<pi>\<^sup>* x \<in> carrier \<Y>
[PROOF STEP]
by (fact x)
[PROOF STATE]
proof (state)
this:
\<pi>\<^sup>* x \<in> carrier \<Y>

goal (1 subgoal):
 1. \<And>xa. xa \<in> {y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y} \<Longrightarrow> \<pi>\<^sup>* x \<sqsubseteq>\<^bsub>\<Y>\<^esub> xa
[PROOF STEP]
fix z
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>xa. xa \<in> {y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y} \<Longrightarrow> \<pi>\<^sup>* x \<sqsubseteq>\<^bsub>\<Y>\<^esub> xa
[PROOF STEP]
assume "z \<in> {y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y}"
[PROOF STATE]
proof (state)
this:
z \<in> {y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y}

goal (1 subgoal):
 1. \<And>xa. xa \<in> {y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y} \<Longrightarrow> \<pi>\<^sup>* x \<sqsubseteq>\<^bsub>\<Y>\<^esub> xa
[PROOF STEP]
thus "\<pi>\<^sup>* x \<sqsubseteq>\<^bsub>\<Y>\<^esub> z"
[PROOF STATE]
proof (prove)
using this:
z \<in> {y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y}

goal (1 subgoal):
 1. \<pi>\<^sup>* x \<sqsubseteq>\<^bsub>\<Y>\<^esub> z
[PROOF STEP]
using assms(2) left
[PROOF STATE]
proof (prove)
using this:
z \<in> {y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y}
x \<in> carrier \<X>
\<lbrakk>?x \<in> carrier \<X>; ?y \<in> carrier \<Y>; ?x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* ?y\<rbrakk> \<Longrightarrow> \<pi>\<^sup>* ?x \<sqsubseteq>\<^bsub>\<Y>\<^esub> ?y

goal (1 subgoal):
 1. \<pi>\<^sup>* x \<sqsubseteq>\<^bsub>\<Y>\<^esub> z
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<pi>\<^sup>* x \<sqsubseteq>\<^bsub>\<Y>\<^esub> z

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<pi>\<^sup>* x \<sqsubseteq>\<^bsub>\<Y>\<^esub> \<Sqinter>\<^bsub>\<Y>\<^esub>{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y}

goal (2 subgoals):
 1. \<Sqinter>\<^bsub>\<Y>\<^esub>{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y} \<sqsubseteq>\<^bsub>\<Y>\<^esub> \<pi>\<^sup>* x
 2. \<Sqinter>\<^bsub>\<Y>\<^esub>{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y} \<in> carrier \<Y>
[PROOF STEP]
show "\<Sqinter>\<^bsub>\<Y>\<^esub>{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y} \<sqsubseteq>\<^bsub>\<Y>\<^esub> \<pi>\<^sup>* x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Sqinter>\<^bsub>\<Y>\<^esub>{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y} \<sqsubseteq>\<^bsub>\<Y>\<^esub> \<pi>\<^sup>* x
[PROOF STEP]
proof (rule Y.weak.inf_lower)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. {y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y} \<subseteq> carrier \<Y>
 2. \<pi>\<^sup>* x \<in> {y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y}
[PROOF STEP]
show "{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y} \<subseteq> carrier \<Y>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y} \<subseteq> carrier \<Y>
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y} \<subseteq> carrier \<Y>

goal (1 subgoal):
 1. \<pi>\<^sup>* x \<in> {y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y}
[PROOF STEP]
show "\<pi>\<^sup>* x \<in> {y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<pi>\<^sup>* x \<in> {y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y}
[PROOF STEP]
proof (auto)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<pi>\<^sup>* x \<in> carrier \<Y>
 2. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* (\<pi>\<^sup>* x)
[PROOF STEP]
show "\<pi>\<^sup>* x \<in> carrier \<Y>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<pi>\<^sup>* x \<in> carrier \<Y>
[PROOF STEP]
by (fact x)
[PROOF STATE]
proof (state)
this:
\<pi>\<^sup>* x \<in> carrier \<Y>

goal (1 subgoal):
 1. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* (\<pi>\<^sup>* x)
[PROOF STEP]
show "x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* (\<pi>\<^sup>* x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* (\<pi>\<^sup>* x)
[PROOF STEP]
using assms(2) inflation
[PROOF STATE]
proof (prove)
using this:
x \<in> carrier \<X>
?x \<in> carrier \<X> \<Longrightarrow> ?x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* (\<pi>\<^sup>* ?x)

goal (1 subgoal):
 1. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* (\<pi>\<^sup>* x)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* (\<pi>\<^sup>* x)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<pi>\<^sup>* x \<in> {y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<Sqinter>\<^bsub>\<Y>\<^esub>{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y} \<sqsubseteq>\<^bsub>\<Y>\<^esub> \<pi>\<^sup>* x

goal (1 subgoal):
 1. \<Sqinter>\<^bsub>\<Y>\<^esub>{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y} \<in> carrier \<Y>
[PROOF STEP]
show "\<Sqinter>\<^bsub>\<Y>\<^esub>{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y} \<in> carrier \<Y>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Sqinter>\<^bsub>\<Y>\<^esub>{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y} \<in> carrier \<Y>
[PROOF STEP]
by (auto intro: Y.weak.inf_closed)
[PROOF STATE]
proof (state)
this:
\<Sqinter>\<^bsub>\<Y>\<^esub>{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y} \<in> carrier \<Y>

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<pi>\<^sup>* x = \<Sqinter>\<^bsub>\<Y>\<^esub>{y \<in> carrier \<Y>. x \<sqsubseteq>\<^bsub>\<X>\<^esub> \<pi>\<^sub>* y}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma bilinear_continuous_compose:
  fixes h :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space \<Rightarrow> 'c::real_normed_vector"
  assumes "continuous F f" "continuous F g" "bilinear h"
  shows "continuous F (\<lambda>x. h (f x) (g x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous F (\<lambda>x. h (f x) (g x))
[PROOF STEP]
using assms bilinear_conv_bounded_bilinear bounded_bilinear.continuous
[PROOF STATE]
proof (prove)
using this:
continuous F f
continuous F g
bilinear h
bilinear ?h = bounded_bilinear ?h
\<lbrakk>bounded_bilinear ?prod; continuous ?F ?f; continuous ?F ?g\<rbrakk> \<Longrightarrow> continuous ?F (\<lambda>x. ?prod (?f x) (?g x))

goal (1 subgoal):
 1. continuous F (\<lambda>x. h (f x) (g x))
[PROOF STEP]
by blast


[STATEMENT]
lemma ordinal_of_nat_le [simp]:
"(ordinal_of_nat x \<le> ordinal_of_nat y) = (x \<le> y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (ordinal_of_nat x \<le> ordinal_of_nat y) = (x \<le> y)
[PROOF STEP]
by (rule strict_mono_cancel_le[OF strict_mono_ordinal_of_nat])


[STATEMENT]
lemma finprod_Suc [simp]:
  "f \<in> {..Suc n} \<rightarrow> carrier G \<Longrightarrow>
   finprod G f {..Suc n} = (f (Suc n) \<otimes> finprod G f {..n})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f \<in> {..Suc n} \<rightarrow> carrier G \<Longrightarrow> finprod G f {..Suc n} = f (Suc n) \<otimes> finprod G f {..n}
[PROOF STEP]
by (simp add: Pi_def atMost_Suc)


[STATEMENT]
lemma quotient_of_denom_add_dvd:
  "snd (quotient_of (x + y)) dvd snd (quotient_of x) * snd (quotient_of y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. snd (quotient_of (x + y)) dvd snd (quotient_of x) * snd (quotient_of y)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. snd (quotient_of (x + y)) dvd snd (quotient_of x) * snd (quotient_of y)
[PROOF STEP]
define a b where "a = fst (quotient_of x)" and "b = snd (quotient_of x)"
[PROOF STATE]
proof (state)
this:
a = fst (quotient_of x)
b = snd (quotient_of x)

goal (1 subgoal):
 1. snd (quotient_of (x + y)) dvd snd (quotient_of x) * snd (quotient_of y)
[PROOF STEP]
define c d where "c = fst (quotient_of y)" and "d = snd (quotient_of y)"
[PROOF STATE]
proof (state)
this:
c = fst (quotient_of y)
d = snd (quotient_of y)

goal (1 subgoal):
 1. snd (quotient_of (x + y)) dvd snd (quotient_of x) * snd (quotient_of y)
[PROOF STEP]
have "b > 0" "d > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < b &&& 0 < d
[PROOF STEP]
by (auto simp: b_def d_def quotient_of_denom_pos')
[PROOF STATE]
proof (state)
this:
0 < b
0 < d

goal (1 subgoal):
 1. snd (quotient_of (x + y)) dvd snd (quotient_of x) * snd (quotient_of y)
[PROOF STEP]
have xy: "x = rat_of_int a / rat_of_int b" "y = rat_of_int c / rat_of_int d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x = rat_of_int a / rat_of_int b &&& y = rat_of_int c / rat_of_int d
[PROOF STEP]
unfolding a_def b_def c_def d_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x = rat_of_int (fst (quotient_of x)) / rat_of_int (snd (quotient_of x)) &&& y = rat_of_int (fst (quotient_of y)) / rat_of_int (snd (quotient_of y))
[PROOF STEP]
by (simp_all add: quotient_of_div)
[PROOF STATE]
proof (state)
this:
x = rat_of_int a / rat_of_int b
y = rat_of_int c / rat_of_int d

goal (1 subgoal):
 1. snd (quotient_of (x + y)) dvd snd (quotient_of x) * snd (quotient_of y)
[PROOF STEP]
show "snd (quotient_of (x + y)) dvd b * d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. snd (quotient_of (x + y)) dvd b * d
[PROOF STEP]
proof (rule rat_eq_quotientD)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x + y = rat_of_int ?a / rat_of_int (b * d)
 2. b * d \<noteq> 0
[PROOF STEP]
show "x + y = rat_of_int (a * d + c * b) / rat_of_int (b * d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x + y = rat_of_int (a * d + c * b) / rat_of_int (b * d)
[PROOF STEP]
using \<open>b > 0\<close> \<open>d > 0\<close>
[PROOF STATE]
proof (prove)
using this:
0 < b
0 < d

goal (1 subgoal):
 1. x + y = rat_of_int (a * d + c * b) / rat_of_int (b * d)
[PROOF STEP]
by (simp add: field_simps xy)
[PROOF STATE]
proof (state)
this:
x + y = rat_of_int (a * d + c * b) / rat_of_int (b * d)

goal (1 subgoal):
 1. b * d \<noteq> 0
[PROOF STEP]
qed (use \<open>b > 0\<close> \<open>d > 0\<close> in auto)
[PROOF STATE]
proof (state)
this:
snd (quotient_of (x + y)) dvd b * d

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sgn_minus: "sgn (- x) = - sgn x"
  for x :: "'a::real_normed_vector"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sgn (- x) = - sgn x
[PROOF STEP]
by (simp add: sgn_div_norm)


[STATEMENT]
lemma euler_criterion_int:
  assumes "prime p" and "2 < p"
  shows "[Legendre a p = a^((nat p-1) div 2)] (mod p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [Legendre a p = a ^ ((nat p - 1) div 2)] (mod p)
[PROOF STEP]
using euler_criterion assms prime_int_nat_transfer
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>prime ?p; 2 < ?p\<rbrakk> \<Longrightarrow> [Legendre ?a (int ?p) = ?a ^ ((?p - 1) div 2)] (mod int ?p)
prime p
2 < p
prime ?k = (0 \<le> ?k \<and> prime (nat ?k))

goal (1 subgoal):
 1. [Legendre a p = a ^ ((nat p - 1) div 2)] (mod p)
[PROOF STEP]
by (metis int_nat_eq nat_numeral prime_gt_0_int zless_nat_conj)


[STATEMENT]
lemma bernoulli_stream_pref_prob:
  fixes x
  assumes "M =bernoulli_stream p"
and "0 \<le> p" and "p \<le> 1"
  shows "n\<ge> Suc 0\<Longrightarrow> emeasure M {w\<in> space M. (stake n w = stake n x)} = (\<Prod>i\<in>{0..n-1}. prob_component p x i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc 0 \<le> n \<Longrightarrow> emeasure M {w \<in> space M. stake n w = stake n x} = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Suc 0 \<le> n \<Longrightarrow> emeasure M {w \<in> space M. stake n w = stake n x} = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
have "prob_space M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prob_space M
[PROOF STEP]
by (simp add: assms bernoulli_stream_def prob_space.prob_space_stream_space prob_space_measure_pmf)
[PROOF STATE]
proof (state)
this:
prob_space M

goal (1 subgoal):
 1. Suc 0 \<le> n \<Longrightarrow> emeasure M {w \<in> space M. stake n w = stake n x} = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
fix n::nat
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Suc 0 \<le> n \<Longrightarrow> emeasure M {w \<in> space M. stake n w = stake n x} = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
assume "n\<ge> Suc 0"
[PROOF STATE]
proof (state)
this:
Suc 0 \<le> n

goal (1 subgoal):
 1. Suc 0 \<le> n \<Longrightarrow> emeasure M {w \<in> space M. stake n w = stake n x} = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
define S where "S = {w\<in> space M. (stake n w = stake n x)}"
[PROOF STATE]
proof (state)
this:
S = {w \<in> space M. stake n w = stake n x}

goal (1 subgoal):
 1. Suc 0 \<le> n \<Longrightarrow> emeasure M {w \<in> space M. stake n w = stake n x} = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
have s: "S \<in> sets M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S \<in> sets M
[PROOF STEP]
unfolding S_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {w \<in> space M. stake n w = stake n x} \<in> sets M
[PROOF STEP]
by (simp add: assms stake_preimage_measurable \<open>Suc 0 \<le> n\<close>)
[PROOF STATE]
proof (state)
this:
S \<in> sets M

goal (1 subgoal):
 1. Suc 0 \<le> n \<Longrightarrow> emeasure M {w \<in> space M. stake n w = stake n x} = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
define PM where  "PM = (\<lambda>i::nat. (measure_pmf (bernoulli_pmf p)))"
[PROOF STATE]
proof (state)
this:
PM = (\<lambda>i. measure_pmf (bernoulli_pmf p))

goal (1 subgoal):
 1. Suc 0 \<le> n \<Longrightarrow> emeasure M {w \<in> space M. stake n w = stake n x} = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
have isps: "product_prob_space PM"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. product_prob_space PM
[PROOF STEP]
unfolding PM_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. product_prob_space (\<lambda>i. measure_pmf (bernoulli_pmf p))
[PROOF STEP]
by unfold_locales
[PROOF STATE]
proof (state)
this:
product_prob_space PM

goal (1 subgoal):
 1. Suc 0 \<le> n \<Longrightarrow> emeasure M {w \<in> space M. stake n w = stake n x} = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
define Z where "Z = {X::nat\<Rightarrow>bool. \<forall>i. 0 \<le> i \<and> i \<le> n-1 \<longrightarrow> X i = snth x i}"
[PROOF STATE]
proof (state)
this:
Z = {X. \<forall>i. 0 \<le> i \<and> i \<le> n - 1 \<longrightarrow> X i = x !! i}

goal (1 subgoal):
 1. Suc 0 \<le> n \<Longrightarrow> emeasure M {w \<in> space M. stake n w = stake n x} = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
let ?wPM = "Pi\<^sub>M UNIV PM"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Suc 0 \<le> n \<Longrightarrow> emeasure M {w \<in> space M. stake n w = stake n x} = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
define imgSbs where "imgSbs = prod_emb UNIV PM {0..n-1} (Pi\<^sub>E {0..n-1} (\<lambda>i::nat. {snth x i}))"
[PROOF STATE]
proof (state)
this:
imgSbs = prod_emb UNIV PM {0..n - 1} (\<Pi>\<^sub>E i\<in>{0..n - 1}. {x !! i})

goal (1 subgoal):
 1. Suc 0 \<le> n \<Longrightarrow> emeasure M {w \<in> space M. stake n w = stake n x} = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
have "space ?wPM = UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. space (Pi\<^sub>M UNIV PM) = UNIV
[PROOF STEP]
using space_PiM
[PROOF STATE]
proof (prove)
using this:
space (Pi\<^sub>M ?I ?M) = (\<Pi>\<^sub>E i\<in>?I. space (?M i))

goal (1 subgoal):
 1. space (Pi\<^sub>M UNIV PM) = UNIV
[PROOF STEP]
unfolding PM_def
[PROOF STATE]
proof (prove)
using this:
space (Pi\<^sub>M ?I ?M) = (\<Pi>\<^sub>E i\<in>?I. space (?M i))

goal (1 subgoal):
 1. space (Pi\<^sub>M UNIV (\<lambda>i. measure_pmf (bernoulli_pmf p))) = UNIV
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
space (Pi\<^sub>M UNIV PM) = UNIV

goal (1 subgoal):
 1. Suc 0 \<le> n \<Longrightarrow> emeasure M {w \<in> space M. stake n w = stake n x} = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
hence "(to_stream -` S \<inter> (space ?wPM)) = to_stream -` S"
[PROOF STATE]
proof (prove)
using this:
space (Pi\<^sub>M UNIV PM) = UNIV

goal (1 subgoal):
 1. to_stream -` S \<inter> space (Pi\<^sub>M UNIV PM) = to_stream -` S
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
to_stream -` S \<inter> space (Pi\<^sub>M UNIV PM) = to_stream -` S

goal (1 subgoal):
 1. Suc 0 \<le> n \<Longrightarrow> emeasure M {w \<in> space M. stake n w = stake n x} = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
to_stream -` S \<inter> space (Pi\<^sub>M UNIV PM) = to_stream -` S

goal (1 subgoal):
 1. Suc 0 \<le> n \<Longrightarrow> emeasure M {w \<in> space M. stake n w = stake n x} = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
have "... =  Z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. to_stream -` S = Z
[PROOF STEP]
using stake_as_fct \<open>Suc 0 \<le> n\<close> assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>Suc 0 \<le> ?n; ?M = bernoulli_stream ?p\<rbrakk> \<Longrightarrow> to_stream -` {w \<in> space ?M. stake ?n w = stake ?n ?x} = {X. \<forall>i. 0 \<le> i \<and> i \<le> ?n - 1 \<longrightarrow> X i = ?x !! i}
Suc 0 \<le> n
M = bernoulli_stream p
0 \<le> p
p \<le> 1

goal (1 subgoal):
 1. to_stream -` S = Z
[PROOF STEP]
unfolding Z_def S_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>Suc 0 \<le> ?n; ?M = bernoulli_stream ?p\<rbrakk> \<Longrightarrow> to_stream -` {w \<in> space ?M. stake ?n w = stake ?n ?x} = {X. \<forall>i. 0 \<le> i \<and> i \<le> ?n - 1 \<longrightarrow> X i = ?x !! i}
Suc 0 \<le> n
M = bernoulli_stream p
0 \<le> p
p \<le> 1

goal (1 subgoal):
 1. to_stream -` {w \<in> space M. stake n w = stake n x} = {X. \<forall>i. 0 \<le> i \<and> i \<le> n - 1 \<longrightarrow> X i = x !! i}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
to_stream -` S = Z

goal (1 subgoal):
 1. Suc 0 \<le> n \<Longrightarrow> emeasure M {w \<in> space M. stake n w = stake n x} = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
to_stream -` S = Z

goal (1 subgoal):
 1. Suc 0 \<le> n \<Longrightarrow> emeasure M {w \<in> space M. stake n w = stake n x} = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
have "... = imgSbs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Z = imgSbs
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Z \<subseteq> imgSbs
 2. imgSbs \<subseteq> Z
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Z \<subseteq> imgSbs
 2. imgSbs \<subseteq> Z
[PROOF STEP]
fix X
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Z \<subseteq> imgSbs
 2. imgSbs \<subseteq> Z
[PROOF STEP]
assume "X \<in> imgSbs"
[PROOF STATE]
proof (state)
this:
X \<in> imgSbs

goal (2 subgoals):
 1. Z \<subseteq> imgSbs
 2. imgSbs \<subseteq> Z
[PROOF STEP]
hence "restrict X {0..n-1} \<in> (Pi\<^sub>E {0..n-1} (\<lambda>i::nat. {snth x i}))"
[PROOF STATE]
proof (prove)
using this:
X \<in> imgSbs

goal (1 subgoal):
 1. restrict X {0..n - 1} \<in> (\<Pi>\<^sub>E i\<in>{0..n - 1}. {x !! i})
[PROOF STEP]
using prod_emb_iff[of X]
[PROOF STATE]
proof (prove)
using this:
X \<in> imgSbs
(X \<in> prod_emb ?I ?M ?K ?X) = (X \<in> extensional ?I \<and> restrict X ?K \<in> ?X \<and> (\<forall>i\<in>?I. X i \<in> space (?M i)))

goal (1 subgoal):
 1. restrict X {0..n - 1} \<in> (\<Pi>\<^sub>E i\<in>{0..n - 1}. {x !! i})
[PROOF STEP]
unfolding imgSbs_def
[PROOF STATE]
proof (prove)
using this:
X \<in> prod_emb UNIV PM {0..n - 1} (\<Pi>\<^sub>E i\<in>{0..n - 1}. {x !! i})
(X \<in> prod_emb ?I ?M ?K ?X) = (X \<in> extensional ?I \<and> restrict X ?K \<in> ?X \<and> (\<forall>i\<in>?I. X i \<in> space (?M i)))

goal (1 subgoal):
 1. restrict X {0..n - 1} \<in> (\<Pi>\<^sub>E i\<in>{0..n - 1}. {x !! i})
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
restrict X {0..n - 1} \<in> (\<Pi>\<^sub>E i\<in>{0..n - 1}. {x !! i})

goal (2 subgoals):
 1. Z \<subseteq> imgSbs
 2. imgSbs \<subseteq> Z
[PROOF STEP]
hence "\<forall>i. 0 \<le> i \<and> i \<le> n-1 \<longrightarrow> X i = snth x i"
[PROOF STATE]
proof (prove)
using this:
restrict X {0..n - 1} \<in> (\<Pi>\<^sub>E i\<in>{0..n - 1}. {x !! i})

goal (1 subgoal):
 1. \<forall>i. 0 \<le> i \<and> i \<le> n - 1 \<longrightarrow> X i = x !! i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>i. 0 \<le> i \<and> i \<le> n - 1 \<longrightarrow> X i = x !! i

goal (2 subgoals):
 1. Z \<subseteq> imgSbs
 2. imgSbs \<subseteq> Z
[PROOF STEP]
hence "X \<in> Z"
[PROOF STATE]
proof (prove)
using this:
\<forall>i. 0 \<le> i \<and> i \<le> n - 1 \<longrightarrow> X i = x !! i

goal (1 subgoal):
 1. X \<in> Z
[PROOF STEP]
unfolding Z_def
[PROOF STATE]
proof (prove)
using this:
\<forall>i. 0 \<le> i \<and> i \<le> n - 1 \<longrightarrow> X i = x !! i

goal (1 subgoal):
 1. X \<in> {X. \<forall>i. 0 \<le> i \<and> i \<le> n - 1 \<longrightarrow> X i = x !! i}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
X \<in> Z

goal (2 subgoals):
 1. Z \<subseteq> imgSbs
 2. imgSbs \<subseteq> Z
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?X2 \<in> imgSbs \<Longrightarrow> ?X2 \<in> Z

goal (2 subgoals):
 1. Z \<subseteq> imgSbs
 2. imgSbs \<subseteq> Z
[PROOF STEP]
thus "imgSbs \<subseteq> Z"
[PROOF STATE]
proof (prove)
using this:
?X2 \<in> imgSbs \<Longrightarrow> ?X2 \<in> Z

goal (1 subgoal):
 1. imgSbs \<subseteq> Z
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
imgSbs \<subseteq> Z

goal (1 subgoal):
 1. Z \<subseteq> imgSbs
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
imgSbs \<subseteq> Z

goal (1 subgoal):
 1. Z \<subseteq> imgSbs
[PROOF STEP]
fix X
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Z \<subseteq> imgSbs
[PROOF STEP]
assume "X \<in> Z"
[PROOF STATE]
proof (state)
this:
X \<in> Z

goal (1 subgoal):
 1. Z \<subseteq> imgSbs
[PROOF STEP]
hence "\<forall>i. 0 \<le> i \<and> i \<le> n-1 \<longrightarrow> X i = snth x i"
[PROOF STATE]
proof (prove)
using this:
X \<in> Z

goal (1 subgoal):
 1. \<forall>i. 0 \<le> i \<and> i \<le> n - 1 \<longrightarrow> X i = x !! i
[PROOF STEP]
unfolding Z_def
[PROOF STATE]
proof (prove)
using this:
X \<in> {X. \<forall>i. 0 \<le> i \<and> i \<le> n - 1 \<longrightarrow> X i = x !! i}

goal (1 subgoal):
 1. \<forall>i. 0 \<le> i \<and> i \<le> n - 1 \<longrightarrow> X i = x !! i
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<forall>i. 0 \<le> i \<and> i \<le> n - 1 \<longrightarrow> X i = x !! i

goal (1 subgoal):
 1. Z \<subseteq> imgSbs
[PROOF STEP]
hence "restrict X {0..n-1} \<in> (Pi\<^sub>E {0..n-1} (\<lambda>i::nat. {snth x i}))"
[PROOF STATE]
proof (prove)
using this:
\<forall>i. 0 \<le> i \<and> i \<le> n - 1 \<longrightarrow> X i = x !! i

goal (1 subgoal):
 1. restrict X {0..n - 1} \<in> (\<Pi>\<^sub>E i\<in>{0..n - 1}. {x !! i})
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
restrict X {0..n - 1} \<in> (\<Pi>\<^sub>E i\<in>{0..n - 1}. {x !! i})

goal (1 subgoal):
 1. Z \<subseteq> imgSbs
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
restrict X {0..n - 1} \<in> (\<Pi>\<^sub>E i\<in>{0..n - 1}. {x !! i})

goal (1 subgoal):
 1. Z \<subseteq> imgSbs
[PROOF STEP]
have "X \<in> extensional UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. X \<in> extensional UNIV
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
X \<in> extensional UNIV

goal (1 subgoal):
 1. Z \<subseteq> imgSbs
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
X \<in> extensional UNIV

goal (1 subgoal):
 1. Z \<subseteq> imgSbs
[PROOF STEP]
have "\<forall>i \<in> UNIV. X i \<in> space (PM i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i\<in>UNIV. X i \<in> space (PM i)
[PROOF STEP]
unfolding PM_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i\<in>UNIV. X i \<in> space (measure_pmf (bernoulli_pmf p))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>i\<in>UNIV. X i \<in> space (PM i)

goal (1 subgoal):
 1. Z \<subseteq> imgSbs
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
restrict X {0..n - 1} \<in> (\<Pi>\<^sub>E i\<in>{0..n - 1}. {x !! i})
X \<in> extensional UNIV
\<forall>i\<in>UNIV. X i \<in> space (PM i)
[PROOF STEP]
have "X \<in> imgSbs"
[PROOF STATE]
proof (prove)
using this:
restrict X {0..n - 1} \<in> (\<Pi>\<^sub>E i\<in>{0..n - 1}. {x !! i})
X \<in> extensional UNIV
\<forall>i\<in>UNIV. X i \<in> space (PM i)

goal (1 subgoal):
 1. X \<in> imgSbs
[PROOF STEP]
using prod_emb_iff[of X]
[PROOF STATE]
proof (prove)
using this:
restrict X {0..n - 1} \<in> (\<Pi>\<^sub>E i\<in>{0..n - 1}. {x !! i})
X \<in> extensional UNIV
\<forall>i\<in>UNIV. X i \<in> space (PM i)
(X \<in> prod_emb ?I ?M ?K ?X) = (X \<in> extensional ?I \<and> restrict X ?K \<in> ?X \<and> (\<forall>i\<in>?I. X i \<in> space (?M i)))

goal (1 subgoal):
 1. X \<in> imgSbs
[PROOF STEP]
unfolding imgSbs_def
[PROOF STATE]
proof (prove)
using this:
restrict X {0..n - 1} \<in> (\<Pi>\<^sub>E i\<in>{0..n - 1}. {x !! i})
X \<in> extensional UNIV
\<forall>i\<in>UNIV. X i \<in> space (PM i)
(X \<in> prod_emb ?I ?M ?K ?X) = (X \<in> extensional ?I \<and> restrict X ?K \<in> ?X \<and> (\<forall>i\<in>?I. X i \<in> space (?M i)))

goal (1 subgoal):
 1. X \<in> prod_emb UNIV PM {0..n - 1} (\<Pi>\<^sub>E i\<in>{0..n - 1}. {x !! i})
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
X \<in> imgSbs

goal (1 subgoal):
 1. Z \<subseteq> imgSbs
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?X2 \<in> Z \<Longrightarrow> ?X2 \<in> imgSbs

goal (1 subgoal):
 1. Z \<subseteq> imgSbs
[PROOF STEP]
thus "Z \<subseteq> imgSbs"
[PROOF STATE]
proof (prove)
using this:
?X2 \<in> Z \<Longrightarrow> ?X2 \<in> imgSbs

goal (1 subgoal):
 1. Z \<subseteq> imgSbs
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Z \<subseteq> imgSbs

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Z = imgSbs

goal (1 subgoal):
 1. Suc 0 \<le> n \<Longrightarrow> emeasure M {w \<in> space M. stake n w = stake n x} = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
to_stream -` S \<inter> space (Pi\<^sub>M UNIV PM) = imgSbs
[PROOF STEP]
have inteq: "(to_stream -` S \<inter> (space ?wPM)) = imgSbs"
[PROOF STATE]
proof (prove)
using this:
to_stream -` S \<inter> space (Pi\<^sub>M UNIV PM) = imgSbs

goal (1 subgoal):
 1. to_stream -` S \<inter> space (Pi\<^sub>M UNIV PM) = imgSbs
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
to_stream -` S \<inter> space (Pi\<^sub>M UNIV PM) = imgSbs

goal (1 subgoal):
 1. Suc 0 \<le> n \<Longrightarrow> emeasure M {w \<in> space M. stake n w = stake n x} = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
have "emeasure M S = emeasure ?wPM (to_stream -` S \<inter> (space ?wPM))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. emeasure M S = emeasure (Pi\<^sub>M UNIV PM) (to_stream -` S \<inter> space (Pi\<^sub>M UNIV PM))
[PROOF STEP]
using  emeasure_distr[of "to_stream" ?wPM "M" S] measurable_to_stream[of "(measure_pmf (bernoulli_pmf p))"] s assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>to_stream \<in> Pi\<^sub>M UNIV PM \<rightarrow>\<^sub>M M; S \<in> sets M\<rbrakk> \<Longrightarrow> emeasure (distr (Pi\<^sub>M UNIV PM) M to_stream) S = emeasure (Pi\<^sub>M UNIV PM) (to_stream -` S \<inter> space (Pi\<^sub>M UNIV PM))
to_stream \<in> Pi\<^sub>M UNIV (\<lambda>i. measure_pmf (bernoulli_pmf p)) \<rightarrow>\<^sub>M stream_space (measure_pmf (bernoulli_pmf p))
S \<in> sets M
M = bernoulli_stream p
0 \<le> p
p \<le> 1

goal (1 subgoal):
 1. emeasure M S = emeasure (Pi\<^sub>M UNIV PM) (to_stream -` S \<inter> space (Pi\<^sub>M UNIV PM))
[PROOF STEP]
unfolding bernoulli_stream_def stream_space_def PM_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>to_stream \<in> Pi\<^sub>M UNIV (\<lambda>i. measure_pmf (bernoulli_pmf p)) \<rightarrow>\<^sub>M M; S \<in> sets M\<rbrakk> \<Longrightarrow> emeasure (distr (Pi\<^sub>M UNIV (\<lambda>i. measure_pmf (bernoulli_pmf p))) M to_stream) S = emeasure (Pi\<^sub>M UNIV (\<lambda>i. measure_pmf (bernoulli_pmf p))) (to_stream -` S \<inter> space (Pi\<^sub>M UNIV (\<lambda>i. measure_pmf (bernoulli_pmf p))))
to_stream \<in> Pi\<^sub>M UNIV (\<lambda>i. measure_pmf (bernoulli_pmf p)) \<rightarrow>\<^sub>M distr (Pi\<^sub>M UNIV (\<lambda>i. measure_pmf (bernoulli_pmf p))) (vimage_algebra (streams (space (measure_pmf (bernoulli_pmf p)))) (!!) (Pi\<^sub>M UNIV (\<lambda>i. measure_pmf (bernoulli_pmf p)))) to_stream
S \<in> sets M
M = distr (Pi\<^sub>M UNIV (\<lambda>i. measure_pmf (bernoulli_pmf p))) (vimage_algebra (streams (space (measure_pmf (bernoulli_pmf p)))) (!!) (Pi\<^sub>M UNIV (\<lambda>i. measure_pmf (bernoulli_pmf p)))) to_stream
0 \<le> p
p \<le> 1

goal (1 subgoal):
 1. emeasure M S = emeasure (Pi\<^sub>M UNIV (\<lambda>i. measure_pmf (bernoulli_pmf p))) (to_stream -` S \<inter> space (Pi\<^sub>M UNIV (\<lambda>i. measure_pmf (bernoulli_pmf p))))
[PROOF STEP]
by (simp add: emeasure_distr)
[PROOF STATE]
proof (state)
this:
emeasure M S = emeasure (Pi\<^sub>M UNIV PM) (to_stream -` S \<inter> space (Pi\<^sub>M UNIV PM))

goal (1 subgoal):
 1. Suc 0 \<le> n \<Longrightarrow> emeasure M {w \<in> space M. stake n w = stake n x} = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
emeasure M S = emeasure (Pi\<^sub>M UNIV PM) (to_stream -` S \<inter> space (Pi\<^sub>M UNIV PM))

goal (1 subgoal):
 1. Suc 0 \<le> n \<Longrightarrow> emeasure M {w \<in> space M. stake n w = stake n x} = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
have "... = emeasure ?wPM imgSbs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. emeasure (Pi\<^sub>M UNIV PM) (to_stream -` S \<inter> space (Pi\<^sub>M UNIV PM)) = emeasure (Pi\<^sub>M UNIV PM) imgSbs
[PROOF STEP]
using inteq
[PROOF STATE]
proof (prove)
using this:
to_stream -` S \<inter> space (Pi\<^sub>M UNIV PM) = imgSbs

goal (1 subgoal):
 1. emeasure (Pi\<^sub>M UNIV PM) (to_stream -` S \<inter> space (Pi\<^sub>M UNIV PM)) = emeasure (Pi\<^sub>M UNIV PM) imgSbs
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
emeasure (Pi\<^sub>M UNIV PM) (to_stream -` S \<inter> space (Pi\<^sub>M UNIV PM)) = emeasure (Pi\<^sub>M UNIV PM) imgSbs

goal (1 subgoal):
 1. Suc 0 \<le> n \<Longrightarrow> emeasure M {w \<in> space M. stake n w = stake n x} = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
emeasure (Pi\<^sub>M UNIV PM) (to_stream -` S \<inter> space (Pi\<^sub>M UNIV PM)) = emeasure (Pi\<^sub>M UNIV PM) imgSbs

goal (1 subgoal):
 1. Suc 0 \<le> n \<Longrightarrow> emeasure M {w \<in> space M. stake n w = stake n x} = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
have "... = (\<Prod>i\<in>{0..n-1}. emeasure (PM i) ((\<lambda>m::nat. {snth x m}) i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. emeasure (Pi\<^sub>M UNIV PM) imgSbs = (\<Prod>i = 0..n - 1. emeasure (PM i) {x !! i})
[PROOF STEP]
using isps
[PROOF STATE]
proof (prove)
using this:
product_prob_space PM

goal (1 subgoal):
 1. emeasure (Pi\<^sub>M UNIV PM) imgSbs = (\<Prod>i = 0..n - 1. emeasure (PM i) {x !! i})
[PROOF STEP]
unfolding imgSbs_def PM_def
[PROOF STATE]
proof (prove)
using this:
product_prob_space (\<lambda>i. measure_pmf (bernoulli_pmf p))

goal (1 subgoal):
 1. emeasure (Pi\<^sub>M UNIV (\<lambda>i. measure_pmf (bernoulli_pmf p))) (prod_emb UNIV (\<lambda>i. measure_pmf (bernoulli_pmf p)) {0..n - 1} (\<Pi>\<^sub>E i\<in>{0..n - 1}. {x !! i})) = (\<Prod>i = 0..n - 1. emeasure (measure_pmf (bernoulli_pmf p)) {x !! i})
[PROOF STEP]
by (auto simp add:product_prob_space.emeasure_PiM_emb)
[PROOF STATE]
proof (state)
this:
emeasure (Pi\<^sub>M UNIV PM) imgSbs = (\<Prod>i = 0..n - 1. emeasure (PM i) {x !! i})

goal (1 subgoal):
 1. Suc 0 \<le> n \<Longrightarrow> emeasure M {w \<in> space M. stake n w = stake n x} = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
emeasure (Pi\<^sub>M UNIV PM) imgSbs = (\<Prod>i = 0..n - 1. emeasure (PM i) {x !! i})

goal (1 subgoal):
 1. Suc 0 \<le> n \<Longrightarrow> emeasure M {w \<in> space M. stake n w = stake n x} = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
have "... = (\<Prod>i\<in>{0..n-1}. prob_component p x i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>i = 0..n - 1. emeasure (PM i) {x !! i}) = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
using prob_component_measure
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 \<le> ?p; ?p \<le> 1\<rbrakk> \<Longrightarrow> emeasure (measure_pmf (bernoulli_pmf ?p)) {?x !! ?i} = ennreal (prob_component ?p ?x ?i)

goal (1 subgoal):
 1. (\<Prod>i = 0..n - 1. emeasure (PM i) {x !! i}) = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
unfolding PM_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 \<le> ?p; ?p \<le> 1\<rbrakk> \<Longrightarrow> emeasure (measure_pmf (bernoulli_pmf ?p)) {?x !! ?i} = ennreal (prob_component ?p ?x ?i)

goal (1 subgoal):
 1. (\<Prod>i = 0..n - 1. emeasure (measure_pmf (bernoulli_pmf p)) {x !! i}) = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>p x i. \<lbrakk>0 \<le> p; p \<le> 1\<rbrakk> \<Longrightarrow> emeasure (measure_pmf (bernoulli_pmf p)) {x !! i} = ennreal (prob_component p x i)) \<Longrightarrow> (\<Prod>i = 0..n - 1. emeasure (measure_pmf (bernoulli_pmf p)) {x !! i}) = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
have f1: "\<forall>N f. (\<exists>n. (n::nat) \<in> N \<and> \<not> 0 \<le> f n) \<or> (\<Prod>n\<in>N. ennreal (f n)) = ennreal (prod f N)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>N f. (\<exists>n. n \<in> N \<and> \<not> 0 \<le> f n) \<or> (\<Prod>n\<in>N. ennreal (f n)) = ennreal (prod f N)
[PROOF STEP]
by (metis (no_types) prod_ennreal)
[PROOF STATE]
proof (state)
this:
\<forall>N f. (\<exists>n. n \<in> N \<and> \<not> 0 \<le> f n) \<or> (\<Prod>n\<in>N. ennreal (f n)) = ennreal (prod f N)

goal (1 subgoal):
 1. (\<And>p x i. \<lbrakk>0 \<le> p; p \<le> 1\<rbrakk> \<Longrightarrow> emeasure (measure_pmf (bernoulli_pmf p)) {x !! i} = ennreal (prob_component p x i)) \<Longrightarrow> (\<Prod>i = 0..n - 1. emeasure (measure_pmf (bernoulli_pmf p)) {x !! i}) = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
obtain nn :: "(nat \<Rightarrow> real) \<Rightarrow> nat set \<Rightarrow> nat" where
          f2: "\<forall>x0 x1. (\<exists>v2. v2 \<in> x1 \<and> \<not> 0 \<le> x0 v2) = (nn x0 x1 \<in> x1 \<and> \<not> 0 \<le> x0 (nn x0 x1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>nn. \<forall>x0 x1. (\<exists>v2. v2 \<in> x1 \<and> \<not> 0 \<le> x0 v2) = (nn x0 x1 \<in> x1 \<and> \<not> 0 \<le> x0 (nn x0 x1)) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by moura
[PROOF STATE]
proof (state)
this:
\<forall>x0 x1. (\<exists>v2. v2 \<in> x1 \<and> \<not> 0 \<le> x0 v2) = (nn x0 x1 \<in> x1 \<and> \<not> 0 \<le> x0 (nn x0 x1))

goal (1 subgoal):
 1. (\<And>p x i. \<lbrakk>0 \<le> p; p \<le> 1\<rbrakk> \<Longrightarrow> emeasure (measure_pmf (bernoulli_pmf p)) {x !! i} = ennreal (prob_component p x i)) \<Longrightarrow> (\<Prod>i = 0..n - 1. emeasure (measure_pmf (bernoulli_pmf p)) {x !! i}) = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
have f3: "\<forall>s n. if s !! n then prob_component p s n = p else p + prob_component p s n = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>s n. if s !! n then prob_component p s n = p else p + prob_component p s n = 1
[PROOF STEP]
by (simp add: prob_component_def)
[PROOF STATE]
proof (state)
this:
\<forall>s n. if s !! n then prob_component p s n = p else p + prob_component p s n = 1

goal (1 subgoal):
 1. (\<And>p x i. \<lbrakk>0 \<le> p; p \<le> 1\<rbrakk> \<Longrightarrow> emeasure (measure_pmf (bernoulli_pmf p)) {x !! i} = ennreal (prob_component p x i)) \<Longrightarrow> (\<Prod>i = 0..n - 1. emeasure (measure_pmf (bernoulli_pmf p)) {x !! i}) = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
\<forall>s n. if s !! n then prob_component p s n = p else p + prob_component p s n = 1

goal (1 subgoal):
 1. (\<And>p x i. \<lbrakk>0 \<le> p; p \<le> 1\<rbrakk> \<Longrightarrow> emeasure (measure_pmf (bernoulli_pmf p)) {x !! i} = ennreal (prob_component p x i)) \<Longrightarrow> (\<Prod>i = 0..n - 1. emeasure (measure_pmf (bernoulli_pmf p)) {x !! i}) = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
assume "prob_component p x (nn (prob_component p x) {0..n - 1}) \<noteq> p"
[PROOF STATE]
proof (state)
this:
prob_component p x (nn (prob_component p x) {0..n - 1}) \<noteq> p

goal (1 subgoal):
 1. (\<And>p x i. \<lbrakk>0 \<le> p; p \<le> 1\<rbrakk> \<Longrightarrow> emeasure (measure_pmf (bernoulli_pmf p)) {x !! i} = ennreal (prob_component p x i)) \<Longrightarrow> (\<Prod>i = 0..n - 1. emeasure (measure_pmf (bernoulli_pmf p)) {x !! i}) = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
prob_component p x (nn (prob_component p x) {0..n - 1}) \<noteq> p
[PROOF STEP]
have "p + prob_component p x (nn (prob_component p x) {0..n - 1}) = 1"
[PROOF STATE]
proof (prove)
using this:
prob_component p x (nn (prob_component p x) {0..n - 1}) \<noteq> p

goal (1 subgoal):
 1. p + prob_component p x (nn (prob_component p x) {0..n - 1}) = 1
[PROOF STEP]
using f3
[PROOF STATE]
proof (prove)
using this:
prob_component p x (nn (prob_component p x) {0..n - 1}) \<noteq> p
\<forall>s n. if s !! n then prob_component p s n = p else p + prob_component p s n = 1

goal (1 subgoal):
 1. p + prob_component p x (nn (prob_component p x) {0..n - 1}) = 1
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
p + prob_component p x (nn (prob_component p x) {0..n - 1}) = 1

goal (1 subgoal):
 1. (\<And>p x i. \<lbrakk>0 \<le> p; p \<le> 1\<rbrakk> \<Longrightarrow> emeasure (measure_pmf (bernoulli_pmf p)) {x !! i} = ennreal (prob_component p x i)) \<Longrightarrow> (\<Prod>i = 0..n - 1. emeasure (measure_pmf (bernoulli_pmf p)) {x !! i}) = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
p + prob_component p x (nn (prob_component p x) {0..n - 1}) = 1
[PROOF STEP]
have "nn (prob_component p x) {0..n - 1} \<notin> {0..n - 1} \<or> 0 \<le> prob_component p x (nn (prob_component p x) {0..n - 1})"
[PROOF STATE]
proof (prove)
using this:
p + prob_component p x (nn (prob_component p x) {0..n - 1}) = 1

goal (1 subgoal):
 1. nn (prob_component p x) {0..n - 1} \<notin> {0..n - 1} \<or> 0 \<le> prob_component p x (nn (prob_component p x) {0..n - 1})
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
p + prob_component p x (nn (prob_component p x) {0..n - 1}) = 1
M = bernoulli_stream p
0 \<le> p
p \<le> 1

goal (1 subgoal):
 1. nn (prob_component p x) {0..n - 1} \<notin> {0..n - 1} \<or> 0 \<le> prob_component p x (nn (prob_component p x) {0..n - 1})
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
nn (prob_component p x) {0..n - 1} \<notin> {0..n - 1} \<or> 0 \<le> prob_component p x (nn (prob_component p x) {0..n - 1})

goal (1 subgoal):
 1. (\<And>p x i. \<lbrakk>0 \<le> p; p \<le> 1\<rbrakk> \<Longrightarrow> emeasure (measure_pmf (bernoulli_pmf p)) {x !! i} = ennreal (prob_component p x i)) \<Longrightarrow> (\<Prod>i = 0..n - 1. emeasure (measure_pmf (bernoulli_pmf p)) {x !! i}) = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
prob_component p x (nn (prob_component p x) {0..n - 1}) \<noteq> p \<Longrightarrow> nn (prob_component p x) {0..n - 1} \<notin> {0..n - 1} \<or> 0 \<le> prob_component p x (nn (prob_component p x) {0..n - 1})

goal (1 subgoal):
 1. (\<And>p x i. \<lbrakk>0 \<le> p; p \<le> 1\<rbrakk> \<Longrightarrow> emeasure (measure_pmf (bernoulli_pmf p)) {x !! i} = ennreal (prob_component p x i)) \<Longrightarrow> (\<Prod>i = 0..n - 1. emeasure (measure_pmf (bernoulli_pmf p)) {x !! i}) = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
prob_component p x (nn (prob_component p x) {0..n - 1}) \<noteq> p \<Longrightarrow> nn (prob_component p x) {0..n - 1} \<notin> {0..n - 1} \<or> 0 \<le> prob_component p x (nn (prob_component p x) {0..n - 1})
[PROOF STEP]
have "nn (prob_component p x) {0..n - 1} \<notin> {0..n - 1} \<or> 0 \<le> prob_component p x (nn (prob_component  p x) {0..n - 1})"
[PROOF STATE]
proof (prove)
using this:
prob_component p x (nn (prob_component p x) {0..n - 1}) \<noteq> p \<Longrightarrow> nn (prob_component p x) {0..n - 1} \<notin> {0..n - 1} \<or> 0 \<le> prob_component p x (nn (prob_component p x) {0..n - 1})

goal (1 subgoal):
 1. nn (prob_component p x) {0..n - 1} \<notin> {0..n - 1} \<or> 0 \<le> prob_component p x (nn (prob_component p x) {0..n - 1})
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
prob_component p x (nn (prob_component p x) {0..n - 1}) \<noteq> p \<Longrightarrow> nn (prob_component p x) {0..n - 1} \<notin> {0..n - 1} \<or> 0 \<le> prob_component p x (nn (prob_component p x) {0..n - 1})
M = bernoulli_stream p
0 \<le> p
p \<le> 1

goal (1 subgoal):
 1. nn (prob_component p x) {0..n - 1} \<notin> {0..n - 1} \<or> 0 \<le> prob_component p x (nn (prob_component p x) {0..n - 1})
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
nn (prob_component p x) {0..n - 1} \<notin> {0..n - 1} \<or> 0 \<le> prob_component p x (nn (prob_component p x) {0..n - 1})

goal (1 subgoal):
 1. (\<And>p x i. \<lbrakk>0 \<le> p; p \<le> 1\<rbrakk> \<Longrightarrow> emeasure (measure_pmf (bernoulli_pmf p)) {x !! i} = ennreal (prob_component p x i)) \<Longrightarrow> (\<Prod>i = 0..n - 1. emeasure (measure_pmf (bernoulli_pmf p)) {x !! i}) = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
nn (prob_component p x) {0..n - 1} \<notin> {0..n - 1} \<or> 0 \<le> prob_component p x (nn (prob_component p x) {0..n - 1})
[PROOF STEP]
have "(\<Prod>n = 0..n - 1. ennreal (prob_component p x n)) = ennreal (prod (prob_component p x) {0..n - 1})"
[PROOF STATE]
proof (prove)
using this:
nn (prob_component p x) {0..n - 1} \<notin> {0..n - 1} \<or> 0 \<le> prob_component p x (nn (prob_component p x) {0..n - 1})

goal (1 subgoal):
 1. (\<Prod>n = 0..n - 1. ennreal (prob_component p x n)) = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
using f2 f1
[PROOF STATE]
proof (prove)
using this:
nn (prob_component p x) {0..n - 1} \<notin> {0..n - 1} \<or> 0 \<le> prob_component p x (nn (prob_component p x) {0..n - 1})
\<forall>x0 x1. (\<exists>v2. v2 \<in> x1 \<and> \<not> 0 \<le> x0 v2) = (nn x0 x1 \<in> x1 \<and> \<not> 0 \<le> x0 (nn x0 x1))
\<forall>N f. (\<exists>n. n \<in> N \<and> \<not> 0 \<le> f n) \<or> (\<Prod>n\<in>N. ennreal (f n)) = ennreal (prod f N)

goal (1 subgoal):
 1. (\<Prod>n = 0..n - 1. ennreal (prob_component p x n)) = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
by meson
[PROOF STATE]
proof (state)
this:
(\<Prod>n = 0..n - 1. ennreal (prob_component p x n)) = ennreal (prod (prob_component p x) {0..n - 1})

goal (1 subgoal):
 1. (\<And>p x i. \<lbrakk>0 \<le> p; p \<le> 1\<rbrakk> \<Longrightarrow> emeasure (measure_pmf (bernoulli_pmf p)) {x !! i} = ennreal (prob_component p x i)) \<Longrightarrow> (\<Prod>i = 0..n - 1. emeasure (measure_pmf (bernoulli_pmf p)) {x !! i}) = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<Prod>n = 0..n - 1. ennreal (prob_component p x n)) = ennreal (prod (prob_component p x) {0..n - 1})

goal (1 subgoal):
 1. (\<And>p x i. \<lbrakk>0 \<le> p; p \<le> 1\<rbrakk> \<Longrightarrow> emeasure (measure_pmf (bernoulli_pmf p)) {x !! i} = ennreal (prob_component p x i)) \<Longrightarrow> (\<Prod>i = 0..n - 1. emeasure (measure_pmf (bernoulli_pmf p)) {x !! i}) = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
have "(\<Prod>n = 0..n - 1. ennreal (prob_component p x n)) =
      (\<Prod>n = 0..n - 1. emeasure (measure_pmf (bernoulli_pmf p)) {x !! n})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>n = 0..n - 1. ennreal (prob_component p x n)) = (\<Prod>n = 0..n - 1. emeasure (measure_pmf (bernoulli_pmf p)) {x !! n})
[PROOF STEP]
using prob_component_measure[of p x]
       assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 \<le> p; p \<le> 1\<rbrakk> \<Longrightarrow> emeasure (measure_pmf (bernoulli_pmf p)) {x !! ?i} = ennreal (prob_component p x ?i)
M = bernoulli_stream p
0 \<le> p
p \<le> 1

goal (1 subgoal):
 1. (\<Prod>n = 0..n - 1. ennreal (prob_component p x n)) = (\<Prod>n = 0..n - 1. emeasure (measure_pmf (bernoulli_pmf p)) {x !! n})
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Prod>n = 0..n - 1. ennreal (prob_component p x n)) = (\<Prod>n = 0..n - 1. emeasure (measure_pmf (bernoulli_pmf p)) {x !! n})

goal (1 subgoal):
 1. (\<And>p x i. \<lbrakk>0 \<le> p; p \<le> 1\<rbrakk> \<Longrightarrow> emeasure (measure_pmf (bernoulli_pmf p)) {x !! i} = ennreal (prob_component p x i)) \<Longrightarrow> (\<Prod>i = 0..n - 1. emeasure (measure_pmf (bernoulli_pmf p)) {x !! i}) = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<Prod>n = 0..n - 1. ennreal (prob_component p x n)) = ennreal (prod (prob_component p x) {0..n - 1})
(\<Prod>n = 0..n - 1. ennreal (prob_component p x n)) = (\<Prod>n = 0..n - 1. emeasure (measure_pmf (bernoulli_pmf p)) {x !! n})
[PROOF STEP]
show "(\<Prod>n = 0..n - 1. emeasure (measure_pmf (bernoulli_pmf p)) {x !! n}) = ennreal (prod (prob_component p x) {0..n - 1})"
[PROOF STATE]
proof (prove)
using this:
(\<Prod>n = 0..n - 1. ennreal (prob_component p x n)) = ennreal (prod (prob_component p x) {0..n - 1})
(\<Prod>n = 0..n - 1. ennreal (prob_component p x n)) = (\<Prod>n = 0..n - 1. emeasure (measure_pmf (bernoulli_pmf p)) {x !! n})

goal (1 subgoal):
 1. (\<Prod>n = 0..n - 1. emeasure (measure_pmf (bernoulli_pmf p)) {x !! n}) = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
using prob_component_measure[of p x]
[PROOF STATE]
proof (prove)
using this:
(\<Prod>n = 0..n - 1. ennreal (prob_component p x n)) = ennreal (prod (prob_component p x) {0..n - 1})
(\<Prod>n = 0..n - 1. ennreal (prob_component p x n)) = (\<Prod>n = 0..n - 1. emeasure (measure_pmf (bernoulli_pmf p)) {x !! n})
\<lbrakk>0 \<le> p; p \<le> 1\<rbrakk> \<Longrightarrow> emeasure (measure_pmf (bernoulli_pmf p)) {x !! ?i} = ennreal (prob_component p x ?i)

goal (1 subgoal):
 1. (\<Prod>n = 0..n - 1. emeasure (measure_pmf (bernoulli_pmf p)) {x !! n}) = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Prod>n = 0..n - 1. emeasure (measure_pmf (bernoulli_pmf p)) {x !! n}) = ennreal (prod (prob_component p x) {0..n - 1})

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Prod>i = 0..n - 1. emeasure (PM i) {x !! i}) = ennreal (prod (prob_component p x) {0..n - 1})

goal (1 subgoal):
 1. Suc 0 \<le> n \<Longrightarrow> emeasure M {w \<in> space M. stake n w = stake n x} = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
emeasure M S = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
show "emeasure M S = (\<Prod>i\<in>{0..n-1}. prob_component p x i)"
[PROOF STATE]
proof (prove)
using this:
emeasure M S = ennreal (prod (prob_component p x) {0..n - 1})

goal (1 subgoal):
 1. emeasure M S = ennreal (prod (prob_component p x) {0..n - 1})
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
emeasure M S = ennreal (prod (prob_component p x) {0..n - 1})

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma lm032:
  assumes "finite A"
  shows "sum f A = sum f (A \<inter> B) + sum f (A - B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f A = sum f (A \<inter> B) + sum f (A - B)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite A

goal (1 subgoal):
 1. sum f A = sum f (A \<inter> B) + sum f (A - B)
[PROOF STEP]
by (metis DiffD2 Int_iff Un_Diff_Int Un_commute finite_Un sum.union_inter_neutral)


[STATEMENT]
lemma arctan_le_iff: "arctan x \<le> arctan y \<longleftrightarrow> x \<le> y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (arctan x \<le> arctan y) = (x \<le> y)
[PROOF STEP]
by (simp only: not_less [symmetric] arctan_less_iff)


[STATEMENT]
lemma kuratowski_card:
  assumes "kuratowski (X :: 'a::topological_space set)"
  shows "card {f. CK_nf_pos (f::'a set \<Rightarrow> 'a set)} = 7"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {f. CK_nf_pos f} = 7
[PROOF STEP]
using CK_nf_pos_lattice[where 'a='a] kuratowski_neqs[OF assms] assms
[PROOF STATE]
proof (prove)
using this:
I \<le> id
id \<le> K
I \<le> I \<circ> K \<circ> I
I \<circ> K \<circ> I \<le> I \<circ> K
I \<circ> K \<circ> I \<le> K \<circ> I
I \<circ> K \<le> K \<circ> I \<circ> K
K \<circ> I \<le> K \<circ> I \<circ> K
K \<circ> I \<circ> K \<le> K
I \<noteq> I \<circ> K \<circ> I
I \<circ> K \<circ> I \<noteq> K \<circ> I
I \<circ> K \<circ> I \<noteq> I \<circ> K
I \<circ> K \<noteq> K \<circ> I \<circ> K
K \<circ> I \<noteq> K \<circ> I \<circ> K
K \<circ> I \<circ> K \<noteq> K
I \<circ> K \<noteq> K \<circ> I
I \<noteq> id
K \<noteq> id
I \<circ> K \<circ> I \<noteq> id
K \<circ> I \<circ> K \<noteq> id
kuratowski X

goal (1 subgoal):
 1. card {f. CK_nf_pos f} = 7
[PROOF STEP]
unfolding kuratowski_def extremally_disconnected_def open_unresolvable_def
[PROOF STATE]
proof (prove)
using this:
I \<le> id
id \<le> K
I \<le> I \<circ> K \<circ> I
I \<circ> K \<circ> I \<le> I \<circ> K
I \<circ> K \<circ> I \<le> K \<circ> I
I \<circ> K \<le> K \<circ> I \<circ> K
K \<circ> I \<le> K \<circ> I \<circ> K
K \<circ> I \<circ> K \<le> K
I \<noteq> I \<circ> K \<circ> I
I \<circ> K \<circ> I \<noteq> K \<circ> I
I \<circ> K \<circ> I \<noteq> I \<circ> K
I \<circ> K \<noteq> K \<circ> I \<circ> K
K \<circ> I \<noteq> K \<circ> I \<circ> K
K \<circ> I \<circ> K \<noteq> K
I \<circ> K \<noteq> K \<circ> I
I \<noteq> id
K \<noteq> id
I \<circ> K \<circ> I \<noteq> id
K \<circ> I \<circ> K \<noteq> id
K \<circ> I \<circ> K \<noteq> I \<circ> K \<and> K \<circ> I \<circ> K \<noteq> K \<circ> I

goal (1 subgoal):
 1. card {f. CK_nf_pos f} = 7
[PROOF STEP]
by (subst CK_nf_pos_set) (subst card_insert_disjoint; (auto)[1])+


[STATEMENT]
lemma injective_mult_closed:
  "injective x \<Longrightarrow> injective y \<Longrightarrow> injective (x * y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>injective x; injective y\<rbrakk> \<Longrightarrow> injective (x * y)
[PROOF STEP]
by (metis injective_conv_univalent conv_dist_comp univalent_mult_closed)


[STATEMENT]
lemma Poly_snoc: "Poly (xs @ [x]) = Poly xs + monom x (length xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Poly (xs @ [x]) = Poly xs + monom x (length xs)
[PROOF STEP]
by (induct xs) (simp_all add: monom_0 monom_Suc)


[STATEMENT]
lemma ccINF_greatest: "countable A \<Longrightarrow> (\<And>i. i \<in> A \<Longrightarrow> u \<le> f i) \<Longrightarrow> u \<le> (INF i \<in> A. f i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>countable A; \<And>i. i \<in> A \<Longrightarrow> u \<le> f i\<rbrakk> \<Longrightarrow> u \<le> Inf (f ` A)
[PROOF STEP]
using ccInf_greatest [of "f ` A"]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>countable (f ` A); \<And>x. x \<in> f ` A \<Longrightarrow> ?z \<le> x\<rbrakk> \<Longrightarrow> ?z \<le> Inf (f ` A)

goal (1 subgoal):
 1. \<lbrakk>countable A; \<And>i. i \<in> A \<Longrightarrow> u \<le> f i\<rbrakk> \<Longrightarrow> u \<le> Inf (f ` A)
[PROOF STEP]
by auto


[STATEMENT]
lemma length_wcmpser0_7:"\<lbrakk>Group G; w_cmpser G (Suc (Suc n)) f\<rbrakk> \<Longrightarrow>
                     card {i. i \<le> n \<and> Qw_cmpser G f i \<cong> E} \<le> Suc n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Group G; w_cmpser G (Suc (Suc n)) f\<rbrakk> \<Longrightarrow> card {i. i \<le> n \<and> Qw_cmpser G f i \<cong> E} \<le> Suc n
[PROOF STEP]
apply (insert finite_Collect_le_nat [of "n"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Group G; w_cmpser G (Suc (Suc n)) f; finite {na. na \<le> n}\<rbrakk> \<Longrightarrow> card {i. i \<le> n \<and> Qw_cmpser G f i \<cong> E} \<le> Suc n
[PROOF STEP]
apply (subgoal_tac "{i. i \<le> n \<and> Qw_cmpser G f i \<cong> E} \<subseteq> {i. i \<le> n}")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>Group G; w_cmpser G (Suc (Suc n)) f; finite {na. na \<le> n}; {i. i \<le> n \<and> Qw_cmpser G f i \<cong> E} \<subseteq> {i. i \<le> n}\<rbrakk> \<Longrightarrow> card {i. i \<le> n \<and> Qw_cmpser G f i \<cong> E} \<le> Suc n
 2. \<lbrakk>Group G; w_cmpser G (Suc (Suc n)) f; finite {na. na \<le> n}\<rbrakk> \<Longrightarrow> {i. i \<le> n \<and> Qw_cmpser G f i \<cong> E} \<subseteq> {i. i \<le> n}
[PROOF STEP]
apply (frule card_mono [of "{i. i \<le> n}" "{i. i \<le> n \<and> Qw_cmpser G f i \<cong> E}"])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<lbrakk>Group G; w_cmpser G (Suc (Suc n)) f; finite {na. na \<le> n}; {i. i \<le> n \<and> Qw_cmpser G f i \<cong> E} \<subseteq> {i. i \<le> n}\<rbrakk> \<Longrightarrow> {i. i \<le> n \<and> Qw_cmpser G f i \<cong> E} \<subseteq> {i. i \<le> n}
 2. \<lbrakk>Group G; w_cmpser G (Suc (Suc n)) f; finite {na. na \<le> n}; {i. i \<le> n \<and> Qw_cmpser G f i \<cong> E} \<subseteq> {i. i \<le> n}; card {i. i \<le> n \<and> Qw_cmpser G f i \<cong> E} \<le> card {i. i \<le> n}\<rbrakk> \<Longrightarrow> card {i. i \<le> n \<and> Qw_cmpser G f i \<cong> E} \<le> Suc n
 3. \<lbrakk>Group G; w_cmpser G (Suc (Suc n)) f; finite {na. na \<le> n}\<rbrakk> \<Longrightarrow> {i. i \<le> n \<and> Qw_cmpser G f i \<cong> E} \<subseteq> {i. i \<le> n}
[PROOF STEP]
apply (assumption, simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Group G; w_cmpser G (Suc (Suc n)) f; finite {na. na \<le> n}\<rbrakk> \<Longrightarrow> {i. i \<le> n \<and> Qw_cmpser G f i \<cong> E} \<subseteq> {i. i \<le> n}
[PROOF STEP]
apply (rule subsetI, simp add:CollectI)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma coprime_add_mult_iff1 [simp]:
     "coprime (n + k * m) (m::'a::semiring_gcd) = coprime n m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coprime (n + k * m) m = coprime n m
[PROOF STEP]
by (simp add: coprime_iff_gcd_eq_1 gcd.commute gcd_add_mult_commute)


[STATEMENT]
lemma rbtreeify_gD:
  "\<lbrakk> rbtreeify_g n kvs = (t, kvs'); n \<le> Suc (length kvs) \<rbrakk>
  \<Longrightarrow> entries t = take (n - 1) kvs \<and> kvs' = drop (n - 1) kvs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>rbtreeify_g n kvs = (t, kvs'); n \<le> Suc (length kvs)\<rbrakk> \<Longrightarrow> entries t = take (n - 1) kvs \<and> kvs' = drop (n - 1) kvs
[PROOF STEP]
using rbtreeify_g_conv_drop[of n kvs] entries_rbtreeify_g[of n kvs]
[PROOF STATE]
proof (prove)
using this:
n \<le> Suc (length kvs) \<Longrightarrow> snd (rbtreeify_g n kvs) = drop (n - 1) kvs
n \<le> Suc (length kvs) \<Longrightarrow> entries (fst (rbtreeify_g n kvs)) = take (n - 1) kvs

goal (1 subgoal):
 1. \<lbrakk>rbtreeify_g n kvs = (t, kvs'); n \<le> Suc (length kvs)\<rbrakk> \<Longrightarrow> entries t = take (n - 1) kvs \<and> kvs' = drop (n - 1) kvs
[PROOF STEP]
by simp


[STATEMENT]
lemma union_subseteq_weaken: "\<lbrakk>A \<union> B \<subseteq> C; \<lbrakk>A \<subseteq> C; B \<subseteq> C\<rbrakk> \<Longrightarrow> P \<rbrakk> \<Longrightarrow> P"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A \<union> B \<subseteq> C; \<lbrakk>A \<subseteq> C; B \<subseteq> C\<rbrakk> \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P
[PROOF STEP]
by blast


[STATEMENT]
lemma subgroup_UNIV: "subgroup (UNIV)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. subgroup UNIV
[PROOF STEP]
unfolding subgroup_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0::'a) \<in> UNIV \<and> (\<forall>a\<in>UNIV. \<forall>b\<in>UNIV. a + b \<in> UNIV) \<and> (\<forall>a\<in>UNIV. - a \<in> UNIV)
[PROOF STEP]
by auto


[STATEMENT]
lemma conv_std_normal_density:
  "(\<lambda>x. \<integral>\<^sup>+y. ennreal (std_normal_density (x - y) * std_normal_density y) \<partial>lborel) =
  (normal_density 0 (sqrt 2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. \<integral>\<^sup>+ y. ennreal (std_normal_density (x - y) * std_normal_density y) \<partial>lborel) = (\<lambda>x. ennreal (normal_density 0 (sqrt 2) x))
[PROOF STEP]
by (subst conv_normal_density_zero_mean) simp_all


[STATEMENT]
lemma signs_are_cols: "\<forall>i < (length signs). col (alt_matrix_A signs subsets) i  = vec (length subsets) (\<lambda>j. z (subsets ! j) (signs ! i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i<length signs. col (alt_matrix_A signs subsets) i = vec (length subsets) (\<lambda>j. z (subsets ! j) (signs ! i))
[PROOF STEP]
unfolding col_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i<length signs. vec (dim_row (alt_matrix_A signs subsets)) (\<lambda>ia. alt_matrix_A signs subsets $$ (ia, i)) = vec (length subsets) (\<lambda>j. z (subsets ! j) (signs ! i))
[PROOF STEP]
unfolding alt_matrix_A_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i<length signs. vec (dim_row (mat (length subsets) (length signs) (\<lambda>(i, j). z (subsets ! i) (signs ! j)))) (\<lambda>ia. mat (length subsets) (length signs) (\<lambda>(i, j). z (subsets ! i) (signs ! j)) $$ (ia, i)) = vec (length subsets) (\<lambda>j. z (subsets ! j) (signs ! i))
[PROOF STEP]
by auto


[STATEMENT]
lemma prv_exi_commute:
assumes [simp]: "x \<in> var" "y \<in> var" "\<phi> \<in> fmla"
shows "prv (imp (exi x (exi y \<phi>)) (exi y (exi x \<phi>)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prv (imp (exi x (exi y \<phi>)) (exi y (exi x \<phi>)))
[PROOF STEP]
apply(rule nprv_prvI, auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nprv {} (imp (exi x (exi y \<phi>)) (exi y (exi x \<phi>)))
[PROOF STEP]
apply(rule nprv_impI, auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nprv {exi x (exi y \<phi>)} (exi y (exi x \<phi>))
[PROOF STEP]
by (rule nprv_exi_commute, auto)


[STATEMENT]
lemma "\<exists>(x::'a::linordered_field) y z w.
  min (5 * x + 3 * z) (17 * w) + 5 * \<bar>y - 8 * x + z\<bar> \<le> max y (7 * z - x + w)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>x y z w. min ((5::'a) * x + (3::'a) * z) ((17::'a) * w) + (5::'a) * \<bar>y - (8::'a) * x + z\<bar> \<le> max y ((7::'a) * z - x + w)
[PROOF STEP]
by ferrack


[STATEMENT]
lemma plus_mono: "x\<^sub>1 \<ge> (x\<^sub>2 :: 'a :: ordered_ab_semigroup) \<Longrightarrow>
  y\<^sub>1 \<ge> y\<^sub>2 \<Longrightarrow> x\<^sub>1 + y\<^sub>1 \<ge> x\<^sub>2 + y\<^sub>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x\<^sub>2 \<le> x\<^sub>1; y\<^sub>2 \<le> y\<^sub>1\<rbrakk> \<Longrightarrow> x\<^sub>2 + y\<^sub>2 \<le> x\<^sub>1 + y\<^sub>1
[PROOF STEP]
using ge_trans[OF plus_left_mono[of x\<^sub>2 x\<^sub>1] plus_right_mono[of y\<^sub>2 y\<^sub>1]]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>x\<^sub>2 \<le> x\<^sub>1; y\<^sub>2 \<le> y\<^sub>1\<rbrakk> \<Longrightarrow> x\<^sub>2 + y\<^sub>2 \<le> x\<^sub>1 + y\<^sub>1

goal (1 subgoal):
 1. \<lbrakk>x\<^sub>2 \<le> x\<^sub>1; y\<^sub>2 \<le> y\<^sub>1\<rbrakk> \<Longrightarrow> x\<^sub>2 + y\<^sub>2 \<le> x\<^sub>1 + y\<^sub>1
[PROOF STEP]
.


[STATEMENT]
lemma deformation_retraction_relative_homology_group_isomorphisms:
   "\<lbrakk>retraction_maps X Y r s; r ` U \<subseteq> V; s ` V \<subseteq> U; homotopic_with (\<lambda>h. h ` U \<subseteq> U) X X (s \<circ> r) id\<rbrakk>
    \<Longrightarrow> group_isomorphisms (relative_homology_group p X U) (relative_homology_group p Y V)
             (hom_induced p X U Y V r) (hom_induced p Y V X U s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>retraction_maps X Y r s; r ` U \<subseteq> V; s ` V \<subseteq> U; homotopic_with (\<lambda>h. h ` U \<subseteq> U) X X (s \<circ> r) id\<rbrakk> \<Longrightarrow> group_isomorphisms (relative_homology_group p X U) (relative_homology_group p Y V) (hom_induced p X U Y V r) (hom_induced p Y V X U s)
[PROOF STEP]
apply (simp add: retraction_maps_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>continuous_map X Y r \<and> continuous_map Y X s \<and> (\<forall>x\<in>topspace Y. r (s x) = x); r ` U \<subseteq> V; s ` V \<subseteq> U; homotopic_with (\<lambda>h. h ` U \<subseteq> U) X X (s \<circ> r) id\<rbrakk> \<Longrightarrow> group_isomorphisms (relative_homology_group p X U) (relative_homology_group p Y V) (hom_induced p X U Y V r) (hom_induced p Y V X U s)
[PROOF STEP]
apply (rule homotopy_equivalence_relative_homology_group_isomorphisms)
[PROOF STATE]
proof (prove)
goal (6 subgoals):
 1. \<lbrakk>continuous_map X Y r \<and> continuous_map Y X s \<and> (\<forall>x\<in>topspace Y. r (s x) = x); r ` U \<subseteq> V; s ` V \<subseteq> U; homotopic_with (\<lambda>h. h ` U \<subseteq> U) X X (s \<circ> r) id\<rbrakk> \<Longrightarrow> continuous_map X Y r
 2. \<lbrakk>continuous_map X Y r \<and> continuous_map Y X s \<and> (\<forall>x\<in>topspace Y. r (s x) = x); r ` U \<subseteq> V; s ` V \<subseteq> U; homotopic_with (\<lambda>h. h ` U \<subseteq> U) X X (s \<circ> r) id\<rbrakk> \<Longrightarrow> r ` U \<subseteq> V
 3. \<lbrakk>continuous_map X Y r \<and> continuous_map Y X s \<and> (\<forall>x\<in>topspace Y. r (s x) = x); r ` U \<subseteq> V; s ` V \<subseteq> U; homotopic_with (\<lambda>h. h ` U \<subseteq> U) X X (s \<circ> r) id\<rbrakk> \<Longrightarrow> continuous_map Y X s
 4. \<lbrakk>continuous_map X Y r \<and> continuous_map Y X s \<and> (\<forall>x\<in>topspace Y. r (s x) = x); r ` U \<subseteq> V; s ` V \<subseteq> U; homotopic_with (\<lambda>h. h ` U \<subseteq> U) X X (s \<circ> r) id\<rbrakk> \<Longrightarrow> s ` V \<subseteq> U
 5. \<lbrakk>continuous_map X Y r \<and> continuous_map Y X s \<and> (\<forall>x\<in>topspace Y. r (s x) = x); r ` U \<subseteq> V; s ` V \<subseteq> U; homotopic_with (\<lambda>h. h ` U \<subseteq> U) X X (s \<circ> r) id\<rbrakk> \<Longrightarrow> homotopic_with (\<lambda>h. h ` U \<subseteq> U) X X (s \<circ> r) id
 6. \<lbrakk>continuous_map X Y r \<and> continuous_map Y X s \<and> (\<forall>x\<in>topspace Y. r (s x) = x); r ` U \<subseteq> V; s ` V \<subseteq> U; homotopic_with (\<lambda>h. h ` U \<subseteq> U) X X (s \<circ> r) id\<rbrakk> \<Longrightarrow> homotopic_with (\<lambda>k. k ` V \<subseteq> V) Y Y (r \<circ> s) id
[PROOF STEP]
apply (auto simp: image_subset_iff continuous_map_compose homotopic_with_equal)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma is_map_subset: "is_map N \<Longrightarrow> M \<subseteq> N \<Longrightarrow> is_map M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>is_map N; M \<subseteq> N\<rbrakk> \<Longrightarrow> is_map M
[PROOF STEP]
unfolding is_map_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>(a\<^sub>1, b\<^sub>1)\<in>N. \<forall>(a\<^sub>2, b\<^sub>2)\<in>N. a\<^sub>1 = a\<^sub>2 \<longrightarrow> b\<^sub>1 = b\<^sub>2; M \<subseteq> N\<rbrakk> \<Longrightarrow> \<forall>(a\<^sub>1, b\<^sub>1)\<in>M. \<forall>(a\<^sub>2, b\<^sub>2)\<in>M. a\<^sub>1 = a\<^sub>2 \<longrightarrow> b\<^sub>1 = b\<^sub>2
[PROOF STEP]
by blast


[STATEMENT]
lemma RSpan_add_closed :
  assumes "set ms \<subseteq> M" "n \<in> RSpan ms" "n' \<in> RSpan ms"
  shows   "n + n' \<in> RSpan ms"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n + n' \<in> RSpan ms
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n + n' \<in> RSpan ms
[PROOF STEP]
from assms (2,3)
[PROOF STATE]
proof (chain)
picking this:
n \<in> RSpan ms
n' \<in> RSpan ms
[PROOF STEP]
obtain rs ss
    where rs: "set rs \<subseteq> R" "length rs = length ms" "n = rs \<bullet>\<cdot> ms"
    and   ss: "set ss \<subseteq> R" "length ss = length ms" "n' = ss \<bullet>\<cdot> ms"
[PROOF STATE]
proof (prove)
using this:
n \<in> RSpan ms
n' \<in> RSpan ms

goal (1 subgoal):
 1. (\<And>rs ss. \<lbrakk>set rs \<subseteq> R; length rs = length ms; n = rs \<bullet>\<cdot> ms; set ss \<subseteq> R; length ss = length ms; n' = ss \<bullet>\<cdot> ms\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using RSpanD_lincomb
[PROOF STATE]
proof (prove)
using this:
n \<in> RSpan ms
n' \<in> RSpan ms
RSpan ?ms = {rs \<bullet>\<cdot> ?ms |rs. set rs \<subseteq> R \<and> length rs = length ?ms}

goal (1 subgoal):
 1. (\<And>rs ss. \<lbrakk>set rs \<subseteq> R; length rs = length ms; n = rs \<bullet>\<cdot> ms; set ss \<subseteq> R; length ss = length ms; n' = ss \<bullet>\<cdot> ms\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set rs \<subseteq> R
length rs = length ms
n = rs \<bullet>\<cdot> ms
set ss \<subseteq> R
length ss = length ms
n' = ss \<bullet>\<cdot> ms

goal (1 subgoal):
 1. n + n' \<in> RSpan ms
[PROOF STEP]
with assms(1)
[PROOF STATE]
proof (chain)
picking this:
set ms \<subseteq> M
set rs \<subseteq> R
length rs = length ms
n = rs \<bullet>\<cdot> ms
set ss \<subseteq> R
length ss = length ms
n' = ss \<bullet>\<cdot> ms
[PROOF STEP]
have "n + n' = [r + s. (r,s)\<leftarrow>zip rs ss] \<bullet>\<cdot> ms"
[PROOF STATE]
proof (prove)
using this:
set ms \<subseteq> M
set rs \<subseteq> R
length rs = length ms
n = rs \<bullet>\<cdot> ms
set ss \<subseteq> R
length ss = length ms
n' = ss \<bullet>\<cdot> ms

goal (1 subgoal):
 1. n + n' = map2 (+) rs ss \<bullet>\<cdot> ms
[PROOF STEP]
using lincomb_sum_left
[PROOF STATE]
proof (prove)
using this:
set ms \<subseteq> M
set rs \<subseteq> R
length rs = length ms
n = rs \<bullet>\<cdot> ms
set ss \<subseteq> R
length ss = length ms
n' = ss \<bullet>\<cdot> ms
\<lbrakk>set ?rs \<subseteq> R; set ?ss \<subseteq> R; set ?ms \<subseteq> M; length ?rs \<le> length ?ss\<rbrakk> \<Longrightarrow> map2 (+) ?rs ?ss \<bullet>\<cdot> ?ms = ?rs \<bullet>\<cdot> ?ms + take (length ?rs) ?ss \<bullet>\<cdot> ?ms

goal (1 subgoal):
 1. n + n' = map2 (+) rs ss \<bullet>\<cdot> ms
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
n + n' = map2 (+) rs ss \<bullet>\<cdot> ms

goal (1 subgoal):
 1. n + n' \<in> RSpan ms
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
n + n' = map2 (+) rs ss \<bullet>\<cdot> ms

goal (1 subgoal):
 1. n + n' \<in> RSpan ms
[PROOF STEP]
from rs(1) ss(1)
[PROOF STATE]
proof (chain)
picking this:
set rs \<subseteq> R
set ss \<subseteq> R
[PROOF STEP]
have "set [r + s. (r,s)\<leftarrow>zip rs ss] \<subseteq> R"
[PROOF STATE]
proof (prove)
using this:
set rs \<subseteq> R
set ss \<subseteq> R

goal (1 subgoal):
 1. set (map2 (+) rs ss) \<subseteq> R
[PROOF STEP]
using set_zip_leftD[of _ _ rs ss] set_zip_rightD[of _ _ rs ss]
          R_scalars.add_closed R_scalars.zip_add_closed
[PROOF STATE]
proof (prove)
using this:
set rs \<subseteq> R
set ss \<subseteq> R
(?x, ?y) \<in> set (zip rs ss) \<Longrightarrow> ?x \<in> set rs
(?x, ?y) \<in> set (zip rs ss) \<Longrightarrow> ?y \<in> set ss
\<lbrakk>?g \<in> R; ?h \<in> R\<rbrakk> \<Longrightarrow> ?g + ?h \<in> R
\<lbrakk>set ?as \<subseteq> R; set ?bs \<subseteq> R\<rbrakk> \<Longrightarrow> set (map2 (+) ?as ?bs) \<subseteq> R

goal (1 subgoal):
 1. set (map2 (+) rs ss) \<subseteq> R
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
set (map2 (+) rs ss) \<subseteq> R

goal (1 subgoal):
 1. n + n' \<in> RSpan ms
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
n + n' = map2 (+) rs ss \<bullet>\<cdot> ms
set (map2 (+) rs ss) \<subseteq> R
[PROOF STEP]
show "n + n' \<in> RSpan ms"
[PROOF STATE]
proof (prove)
using this:
n + n' = map2 (+) rs ss \<bullet>\<cdot> ms
set (map2 (+) rs ss) \<subseteq> R

goal (1 subgoal):
 1. n + n' \<in> RSpan ms
[PROOF STEP]
using assms(1) RSpanI_lincomb_arb_len_coeffs
[PROOF STATE]
proof (prove)
using this:
n + n' = map2 (+) rs ss \<bullet>\<cdot> ms
set (map2 (+) rs ss) \<subseteq> R
set ms \<subseteq> M
\<lbrakk>set ?rs \<subseteq> R; set ?ms \<subseteq> M\<rbrakk> \<Longrightarrow> ?rs \<bullet>\<cdot> ?ms \<in> RSpan ?ms

goal (1 subgoal):
 1. n + n' \<in> RSpan ms
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
n + n' \<in> RSpan ms

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Nfunc_iNJTr:"\<lbrakk>inj_on g {i. i \<le> (n::nat)}; i \<le> n; j \<le> n; i < j \<rbrakk> \<Longrightarrow> g i \<noteq> g j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>inj_on g {i. i \<le> n}; i \<le> n; j \<le> n; i < j\<rbrakk> \<Longrightarrow> g i \<noteq> g j
[PROOF STEP]
apply (unfold inj_on_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>x\<in>{i. i \<le> n}. \<forall>y\<in>{i. i \<le> n}. g x = g y \<longrightarrow> x = y; i \<le> n; j \<le> n; i < j\<rbrakk> \<Longrightarrow> g i \<noteq> g j
[PROOF STEP]
apply (simp add:CollectI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>x\<le>n. \<forall>y\<le>n. g x = g y \<longrightarrow> x = y; j \<le> n; i < j\<rbrakk> \<Longrightarrow> g i \<noteq> g j
[PROOF STEP]
apply (rule contrapos_pp, simp+)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>x\<le>n. \<forall>y\<le>n. g x = g y \<longrightarrow> x = y; j \<le> n; i < j; g i = g j\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
apply (frule_tac a = i in forall_spec)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>\<forall>x\<le>n. \<forall>y\<le>n. g x = g y \<longrightarrow> x = y; j \<le> n; i < j; g i = g j\<rbrakk> \<Longrightarrow> i \<le> n
 2. \<lbrakk>\<forall>x\<le>n. \<forall>y\<le>n. g x = g y \<longrightarrow> x = y; j \<le> n; i < j; g i = g j; \<forall>y\<le>n. g i = g y \<longrightarrow> i = y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
apply (frule_tac x = i and y = j and z = n in less_le_trans, assumption+,
       simp add:less_imp_le,
       thin_tac "\<forall>x\<le>n. \<forall>y\<le>n. g x = g y \<longrightarrow> x = y",
       rotate_tac -1,
       frule_tac a = j in forall_spec, assumption,
       thin_tac "\<forall>y\<le>n. g i = g y \<longrightarrow> i = y")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>j \<le> n; i < j; g i = g j; g i = g j \<longrightarrow> i = j\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma poly_card_roots_leq:
  "card {x::real. x \<le> a \<and> poly p x = 0} = count_roots_below p a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {x. x \<le> a \<and> poly p x = 0} = count_roots_below p a
[PROOF STEP]
using count_roots_below_correct
[PROOF STATE]
proof (prove)
using this:
count_roots_below ?p ?a = card {x. x \<le> ?a \<and> poly ?p x = 0}

goal (1 subgoal):
 1. card {x. x \<le> a \<and> poly p x = 0} = count_roots_below p a
[PROOF STEP]
by simp


[STATEMENT]
theorem n_sequence_enum_correct:
  "set (n_sequence_enum xs n) = n_sequences (set xs) n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (n_sequence_enum xs n) = n_sequences (set xs) n
[PROOF STEP]
proof standard
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. set (n_sequence_enum xs n) \<subseteq> n_sequences (set xs) n
 2. n_sequences (set xs) n \<subseteq> set (n_sequence_enum xs n)
[PROOF STEP]
show "set (n_sequence_enum xs n) \<subseteq> n_sequences (set xs) n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (n_sequence_enum xs n) \<subseteq> n_sequences (set xs) n
[PROOF STEP]
unfolding n_sequences_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (n_sequence_enum xs n) \<subseteq> {xsa. set xsa \<subseteq> set xs \<and> length xsa = n}
[PROOF STEP]
by (induct n) auto+
[PROOF STATE]
proof (state)
this:
set (n_sequence_enum xs n) \<subseteq> n_sequences (set xs) n

goal (1 subgoal):
 1. n_sequences (set xs) n \<subseteq> set (n_sequence_enum xs n)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n_sequences (set xs) n \<subseteq> set (n_sequence_enum xs n)
[PROOF STEP]
show "n_sequences (set xs) n \<subseteq> set (n_sequence_enum xs n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n_sequences (set xs) n \<subseteq> set (n_sequence_enum xs n)
[PROOF STEP]
proof(induct n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n_sequences (set xs) 0 \<subseteq> set (n_sequence_enum xs 0)
 2. \<And>n. n_sequences (set xs) n \<subseteq> set (n_sequence_enum xs n) \<Longrightarrow> n_sequences (set xs) (Suc n) \<subseteq> set (n_sequence_enum xs (Suc n))
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. n_sequences (set xs) 0 \<subseteq> set (n_sequence_enum xs 0)
 2. \<And>n. n_sequences (set xs) n \<subseteq> set (n_sequence_enum xs n) \<Longrightarrow> n_sequences (set xs) (Suc n) \<subseteq> set (n_sequence_enum xs (Suc n))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n_sequences (set xs) 0 \<subseteq> set (n_sequence_enum xs 0)
[PROOF STEP]
unfolding n_sequences_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {xsa. set xsa \<subseteq> set xs \<and> length xsa = 0} \<subseteq> set (n_sequence_enum xs 0)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
n_sequences (set xs) 0 \<subseteq> set (n_sequence_enum xs 0)

goal (1 subgoal):
 1. \<And>n. n_sequences (set xs) n \<subseteq> set (n_sequence_enum xs n) \<Longrightarrow> n_sequences (set xs) (Suc n) \<subseteq> set (n_sequence_enum xs (Suc n))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. n_sequences (set xs) n \<subseteq> set (n_sequence_enum xs n) \<Longrightarrow> n_sequences (set xs) (Suc n) \<subseteq> set (n_sequence_enum xs (Suc n))
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
n_sequences (set xs) n \<subseteq> set (n_sequence_enum xs n)

goal (1 subgoal):
 1. \<And>n. n_sequences (set xs) n \<subseteq> set (n_sequence_enum xs n) \<Longrightarrow> n_sequences (set xs) (Suc n) \<subseteq> set (n_sequence_enum xs (Suc n))
[PROOF STEP]
have "\<lbrakk>n_sequences (set xs) n \<subseteq> set (n_sequence_enum xs n); set x \<subseteq> set xs; length x = Suc n\<rbrakk>
      \<Longrightarrow> \<exists>xa\<in>set xs. x \<in> (#) xa ` set (n_sequence_enum xs n)" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>n_sequences (set xs) n \<subseteq> set (n_sequence_enum xs n); set x \<subseteq> set xs; length x = Suc n\<rbrakk> \<Longrightarrow> \<exists>xa\<in>set xs. x \<in> (#) xa ` set (n_sequence_enum xs n)
[PROOF STEP]
unfolding n_sequences_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>{xsa. set xsa \<subseteq> set xs \<and> length xsa = n} \<subseteq> set (n_sequence_enum xs n); set x \<subseteq> set xs; length x = Suc n\<rbrakk> \<Longrightarrow> \<exists>xa\<in>set xs. x \<in> (#) xa ` set (n_sequence_enum xs n)
[PROOF STEP]
by (cases x) auto
[PROOF STATE]
proof (state)
this:
\<lbrakk>n_sequences (set xs) n \<subseteq> set (n_sequence_enum xs n); set ?x \<subseteq> set xs; length ?x = Suc n\<rbrakk> \<Longrightarrow> \<exists>xa\<in>set xs. ?x \<in> (#) xa ` set (n_sequence_enum xs n)

goal (1 subgoal):
 1. \<And>n. n_sequences (set xs) n \<subseteq> set (n_sequence_enum xs n) \<Longrightarrow> n_sequences (set xs) (Suc n) \<subseteq> set (n_sequence_enum xs (Suc n))
[PROOF STEP]
from this Suc
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>n_sequences (set xs) n \<subseteq> set (n_sequence_enum xs n); set ?x \<subseteq> set xs; length ?x = Suc n\<rbrakk> \<Longrightarrow> \<exists>xa\<in>set xs. ?x \<in> (#) xa ` set (n_sequence_enum xs n)
n_sequences (set xs) n \<subseteq> set (n_sequence_enum xs n)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>n_sequences (set xs) n \<subseteq> set (n_sequence_enum xs n); set ?x \<subseteq> set xs; length ?x = Suc n\<rbrakk> \<Longrightarrow> \<exists>xa\<in>set xs. ?x \<in> (#) xa ` set (n_sequence_enum xs n)
n_sequences (set xs) n \<subseteq> set (n_sequence_enum xs n)

goal (1 subgoal):
 1. n_sequences (set xs) (Suc n) \<subseteq> set (n_sequence_enum xs (Suc n))
[PROOF STEP]
unfolding n_sequences_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>{xsa. set xsa \<subseteq> set xs \<and> length xsa = n} \<subseteq> set (n_sequence_enum xs n); set ?x \<subseteq> set xs; length ?x = Suc n\<rbrakk> \<Longrightarrow> \<exists>xa\<in>set xs. ?x \<in> (#) xa ` set (n_sequence_enum xs n)
{xsa. set xsa \<subseteq> set xs \<and> length xsa = n} \<subseteq> set (n_sequence_enum xs n)

goal (1 subgoal):
 1. {xsa. set xsa \<subseteq> set xs \<and> length xsa = Suc n} \<subseteq> set (n_sequence_enum xs (Suc n))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
n_sequences (set xs) (Suc n) \<subseteq> set (n_sequence_enum xs (Suc n))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
n_sequences (set xs) n \<subseteq> set (n_sequence_enum xs n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma bernoulli_in_Rats: "bernoulli n \<in> \<rat>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bernoulli n \<in> \<rat>
[PROOF STEP]
proof (induction n rule: less_induct)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. (\<And>y. y < x \<Longrightarrow> bernoulli y \<in> \<rat>) \<Longrightarrow> bernoulli x \<in> \<rat>
[PROOF STEP]
case (less n)
[PROOF STATE]
proof (state)
this:
?y < n \<Longrightarrow> bernoulli ?y \<in> \<rat>

goal (1 subgoal):
 1. \<And>x. (\<And>y. y < x \<Longrightarrow> bernoulli y \<in> \<rat>) \<Longrightarrow> bernoulli x \<in> \<rat>
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
?y < n \<Longrightarrow> bernoulli ?y \<in> \<rat>

goal (1 subgoal):
 1. bernoulli n \<in> \<rat>
[PROOF STEP]
by (cases n) (auto simp: bernoulli_Suc intro!: Rats_sum Rats_divide)
[PROOF STATE]
proof (state)
this:
bernoulli n \<in> \<rat>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma i_nom_eff: "(1 + $i^{m}/m)^m = 1 + i" if "m \<noteq> 0" for m::nat
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (1 + $i^{m} / real m) ^ m = 1 + i
[PROOF STEP]
unfolding i_nom_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (1 + real m * ((1 + i) .^ (1 / real m) - 1) / real m) ^ m = 1 + i
[PROOF STEP]
using less_imp_neq v_futr_pos that
[PROOF STATE]
proof (prove)
using this:
?x < ?y \<Longrightarrow> ?x \<noteq> ?y
0 < 1 + i
m \<noteq> 0

goal (1 subgoal):
 1. (1 + real m * ((1 + i) .^ (1 / real m) - 1) / real m) ^ m = 1 + i
[PROOF STEP]
apply (simp, subst powr_realpow[THEN sym], simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<And>x y. x < y \<Longrightarrow> x \<noteq> y; 0 < 1 + i; 0 < m; \<And>x y. x < y \<Longrightarrow> x \<noteq> y; 0 < 1 + i; m \<noteq> 0\<rbrakk> \<Longrightarrow> ((1 + i) .^ (1 / real m)) .^ real m = 1 + i
[PROOF STEP]
by (subst powr_powr, simp)


[STATEMENT]
lemma norm_summable_imp_summable_on:
  fixes f :: "nat \<Rightarrow> 'a :: banach"
  assumes "summable (\<lambda>n. norm (f n))"
  shows   "f summable_on UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f summable_on UNIV
[PROOF STEP]
using norm_summable_imp_has_sum[OF assms, of "suminf f"] assms
[PROOF STATE]
proof (prove)
using this:
f sums suminf f \<Longrightarrow> has_sum f UNIV (suminf f)
summable (\<lambda>n. norm (f n))

goal (1 subgoal):
 1. f summable_on UNIV
[PROOF STEP]
by (auto simp: sums_iff summable_on_def dest: summable_norm_cancel)


[STATEMENT]
lemma real_ivl_eqs:
  assumes "0 < r"
  shows "ball x r = {x-r<--< x+r}"         and "{x-r<--< x+r} = {x-r<..< x+r}"
    and "ball (r / 2) (r / 2) = {0<--<r}"  and "{0<--<r} = {0<..<r}"
    and "ball 0 r = {-r<--<r}"             and "{-r<--<r} = {-r<..<r}"
    and "cball x r = {x-r--x+r}"           and "{x-r--x+r} = {x-r..x+r}"
    and "cball (r / 2) (r / 2) = {0--r}"   and "{0--r} = {0..r}"
    and "cball 0 r = {-r--r}"              and "{-r--r} = {-r..r}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((ball x r = {x - r<--<x + r} &&& {x - r<--<x + r} = {x - r<..<x + r} &&& ball (r / 2) (r / 2) = {0<--<r}) &&& {0<--<r} = {0<..<r} &&& ball 0 r = {- r<--<r} &&& {- r<--<r} = {- r<..<r}) &&& (cball x r = {x - r--x + r} &&& {x - r--x + r} = {x - r..x + r} &&& cball (r / 2) (r / 2) = {0--r}) &&& {0--r} = {0..r} &&& cball 0 r = {- r--r} &&& {- r--r} = {- r..r}
[PROOF STEP]
unfolding open_segment_eq_real_ivl closed_segment_eq_real_ivl
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((ball x r = (if x - r \<le> x + r then {x - r<..<x + r} else {x + r<..<x - r}) &&& (if x - r \<le> x + r then {x - r<..<x + r} else {x + r<..<x - r}) = {x - r<..<x + r} &&& ball (r / 2) (r / 2) = (if 0 \<le> r then {0<..<r} else {r<..<0})) &&& (if 0 \<le> r then {0<..<r} else {r<..<0}) = {0<..<r} &&& ball 0 r = (if - r \<le> r then {- r<..<r} else {r<..<- r}) &&& (if - r \<le> r then {- r<..<r} else {r<..<- r}) = {- r<..<r}) &&& (cball x r = (if x - r \<le> x + r then {x - r..x + r} else {x + r..x - r}) &&& (if x - r \<le> x + r then {x - r..x + r} else {x + r..x - r}) = {x - r..x + r} &&& cball (r / 2) (r / 2) = (if 0 \<le> r then {0..r} else {r..0})) &&& (if 0 \<le> r then {0..r} else {r..0}) = {0..r} &&& cball 0 r = (if - r \<le> r then {- r..r} else {r..- r}) &&& (if - r \<le> r then {- r..r} else {r..- r}) = {- r..r}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < r

goal (1 subgoal):
 1. ((ball x r = (if x - r \<le> x + r then {x - r<..<x + r} else {x + r<..<x - r}) &&& (if x - r \<le> x + r then {x - r<..<x + r} else {x + r<..<x - r}) = {x - r<..<x + r} &&& ball (r / 2) (r / 2) = (if 0 \<le> r then {0<..<r} else {r<..<0})) &&& (if 0 \<le> r then {0<..<r} else {r<..<0}) = {0<..<r} &&& ball 0 r = (if - r \<le> r then {- r<..<r} else {r<..<- r}) &&& (if - r \<le> r then {- r<..<r} else {r<..<- r}) = {- r<..<r}) &&& (cball x r = (if x - r \<le> x + r then {x - r..x + r} else {x + r..x - r}) &&& (if x - r \<le> x + r then {x - r..x + r} else {x + r..x - r}) = {x - r..x + r} &&& cball (r / 2) (r / 2) = (if 0 \<le> r then {0..r} else {r..0})) &&& (if 0 \<le> r then {0..r} else {r..0}) = {0..r} &&& cball 0 r = (if - r \<le> r then {- r..r} else {r..- r}) &&& (if - r \<le> r then {- r..r} else {r..- r}) = {- r..r}
[PROOF STEP]
by (auto simp: cball_def ball_def dist_norm field_simps)


[STATEMENT]
lemma inj_sur_semi_swap:
  assumes "is_sur z"
      and "is_inj x"
    shows "z \<le> y;x \<Longrightarrow> x \<le> y\<^sup>T;z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z \<le> y ; x \<Longrightarrow> x \<le> y\<^sup>T ; z
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. z \<le> y ; x \<Longrightarrow> x \<le> y\<^sup>T ; z
[PROOF STEP]
assume "z \<le> y;x"
[PROOF STATE]
proof (state)
this:
z \<le> y ; x

goal (1 subgoal):
 1. z \<le> y ; x \<Longrightarrow> x \<le> y\<^sup>T ; z
[PROOF STEP]
hence "z;x\<^sup>T \<le> y;(x;x\<^sup>T)"
[PROOF STATE]
proof (prove)
using this:
z \<le> y ; x

goal (1 subgoal):
 1. z ; x\<^sup>T \<le> y ; (x ; x\<^sup>T)
[PROOF STEP]
by (metis mult_isor mult_assoc)
[PROOF STATE]
proof (state)
this:
z ; x\<^sup>T \<le> y ; (x ; x\<^sup>T)

goal (1 subgoal):
 1. z \<le> y ; x \<Longrightarrow> x \<le> y\<^sup>T ; z
[PROOF STEP]
hence "z;x\<^sup>T \<le> y"
[PROOF STATE]
proof (prove)
using this:
z ; x\<^sup>T \<le> y ; (x ; x\<^sup>T)

goal (1 subgoal):
 1. z ; x\<^sup>T \<le> y
[PROOF STEP]
using \<open>is_inj x\<close>
[PROOF STATE]
proof (prove)
using this:
z ; x\<^sup>T \<le> y ; (x ; x\<^sup>T)
is_inj x

goal (1 subgoal):
 1. z ; x\<^sup>T \<le> y
[PROOF STEP]
unfolding is_inj_def
[PROOF STATE]
proof (prove)
using this:
z ; x\<^sup>T \<le> y ; (x ; x\<^sup>T)
x ; x\<^sup>T \<le> 1'

goal (1 subgoal):
 1. z ; x\<^sup>T \<le> y
[PROOF STEP]
by (metis mult_isol order.trans mult_1_right)
[PROOF STATE]
proof (state)
this:
z ; x\<^sup>T \<le> y

goal (1 subgoal):
 1. z \<le> y ; x \<Longrightarrow> x \<le> y\<^sup>T ; z
[PROOF STEP]
hence "(z\<^sup>T;z);x\<^sup>T \<le> z\<^sup>T;y"
[PROOF STATE]
proof (prove)
using this:
z ; x\<^sup>T \<le> y

goal (1 subgoal):
 1. z\<^sup>T ; z ; x\<^sup>T \<le> z\<^sup>T ; y
[PROOF STEP]
by (metis mult_isol mult_assoc)
[PROOF STATE]
proof (state)
this:
z\<^sup>T ; z ; x\<^sup>T \<le> z\<^sup>T ; y

goal (1 subgoal):
 1. z \<le> y ; x \<Longrightarrow> x \<le> y\<^sup>T ; z
[PROOF STEP]
hence "x\<^sup>T \<le> z\<^sup>T;y"
[PROOF STATE]
proof (prove)
using this:
z\<^sup>T ; z ; x\<^sup>T \<le> z\<^sup>T ; y

goal (1 subgoal):
 1. x\<^sup>T \<le> z\<^sup>T ; y
[PROOF STEP]
using \<open>is_sur z\<close>
[PROOF STATE]
proof (prove)
using this:
z\<^sup>T ; z ; x\<^sup>T \<le> z\<^sup>T ; y
is_sur z

goal (1 subgoal):
 1. x\<^sup>T \<le> z\<^sup>T ; y
[PROOF STEP]
unfolding is_sur_def
[PROOF STATE]
proof (prove)
using this:
z\<^sup>T ; z ; x\<^sup>T \<le> z\<^sup>T ; y
reflexive (z\<^sup>T ; z)

goal (1 subgoal):
 1. x\<^sup>T \<le> z\<^sup>T ; y
[PROOF STEP]
by (metis mult_isor order.trans mult_1_left)
[PROOF STATE]
proof (state)
this:
x\<^sup>T \<le> z\<^sup>T ; y

goal (1 subgoal):
 1. z \<le> y ; x \<Longrightarrow> x \<le> y\<^sup>T ; z
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
x\<^sup>T \<le> z\<^sup>T ; y

goal (1 subgoal):
 1. x \<le> y\<^sup>T ; z
[PROOF STEP]
using conv_iso
[PROOF STATE]
proof (prove)
using this:
x\<^sup>T \<le> z\<^sup>T ; y
(?x \<le> ?y) = (?x\<^sup>T \<le> ?y\<^sup>T)

goal (1 subgoal):
 1. x \<le> y\<^sup>T ; z
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
x \<le> y\<^sup>T ; z

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma difference_list_set :
  assumes "finite_tree t1"
shows "List.set (difference_list t1 t2) = (set t1 - set t2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. list.set (difference_list t1 t2) = Prefix_Tree.set t1 - Prefix_Tree.set t2
[PROOF STEP]
unfolding difference_list.simps
            filter_set[symmetric]
            sorted_list_of_sequences_in_tree_set[OF assms]
            set.simps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Set.filter (\<lambda>xs. \<not> isin t2 xs) (Collect (isin t1)) = Collect (isin t1) - Collect (isin t2)
[PROOF STEP]
by fastforce


[STATEMENT]
lemma basis_reduction_main: assumes "LLL_invariant upw i fs"
  and res: "basis_reduction_main (upw,i,fs) = fs'"
shows "LLL_invariant True m fs'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LLL_invariant True m fs'
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
LLL_invariant upw i fs
basis_reduction_main (upw, i, fs) = fs'

goal (1 subgoal):
 1. LLL_invariant True m fs'
[PROOF STEP]
proof (induct "LLL_measure i fs" arbitrary: i fs upw rule: less_induct)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i fs upw. \<lbrakk>\<And>ia fsa upw. \<lbrakk>LLL_measure ia fsa < LLL_measure i fs; LLL_invariant upw ia fsa; basis_reduction_main (upw, ia, fsa) = fs'\<rbrakk> \<Longrightarrow> LLL_invariant True m fs'; LLL_invariant upw i fs; basis_reduction_main (upw, i, fs) = fs'\<rbrakk> \<Longrightarrow> LLL_invariant True m fs'
[PROOF STEP]
case (less i fs upw)
[PROOF STATE]
proof (state)
this:
\<lbrakk>LLL_measure ?i1 ?fs1 < LLL_measure i fs; LLL_invariant ?upw1 ?i1 ?fs1; basis_reduction_main (?upw1, ?i1, ?fs1) = fs'\<rbrakk> \<Longrightarrow> LLL_invariant True m fs'
LLL_invariant upw i fs
basis_reduction_main (upw, i, fs) = fs'

goal (1 subgoal):
 1. \<And>i fs upw. \<lbrakk>\<And>ia fsa upw. \<lbrakk>LLL_measure ia fsa < LLL_measure i fs; LLL_invariant upw ia fsa; basis_reduction_main (upw, ia, fsa) = fs'\<rbrakk> \<Longrightarrow> LLL_invariant True m fs'; LLL_invariant upw i fs; basis_reduction_main (upw, i, fs) = fs'\<rbrakk> \<Longrightarrow> LLL_invariant True m fs'
[PROOF STEP]
have id: "LLL_invariant upw i fs = True"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LLL_invariant upw i fs = True
[PROOF STEP]
using less
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>LLL_measure ?i1 ?fs1 < LLL_measure i fs; LLL_invariant ?upw1 ?i1 ?fs1; basis_reduction_main (?upw1, ?i1, ?fs1) = fs'\<rbrakk> \<Longrightarrow> LLL_invariant True m fs'
LLL_invariant upw i fs
basis_reduction_main (upw, i, fs) = fs'

goal (1 subgoal):
 1. LLL_invariant upw i fs = True
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
LLL_invariant upw i fs = True

goal (1 subgoal):
 1. \<And>i fs upw. \<lbrakk>\<And>ia fsa upw. \<lbrakk>LLL_measure ia fsa < LLL_measure i fs; LLL_invariant upw ia fsa; basis_reduction_main (upw, ia, fsa) = fs'\<rbrakk> \<Longrightarrow> LLL_invariant True m fs'; LLL_invariant upw i fs; basis_reduction_main (upw, i, fs) = fs'\<rbrakk> \<Longrightarrow> LLL_invariant True m fs'
[PROOF STEP]
note res = less(3)[unfolded basis_reduction_main.simps[of upw i fs] id]
[PROOF STATE]
proof (state)
this:
(if i < m \<and> True then basis_reduction_main (basis_reduction_step upw i fs) else fs) = fs'

goal (1 subgoal):
 1. \<And>i fs upw. \<lbrakk>\<And>ia fsa upw. \<lbrakk>LLL_measure ia fsa < LLL_measure i fs; LLL_invariant upw ia fsa; basis_reduction_main (upw, ia, fsa) = fs'\<rbrakk> \<Longrightarrow> LLL_invariant True m fs'; LLL_invariant upw i fs; basis_reduction_main (upw, i, fs) = fs'\<rbrakk> \<Longrightarrow> LLL_invariant True m fs'
[PROOF STEP]
note inv = less(2)
[PROOF STATE]
proof (state)
this:
LLL_invariant upw i fs

goal (1 subgoal):
 1. \<And>i fs upw. \<lbrakk>\<And>ia fsa upw. \<lbrakk>LLL_measure ia fsa < LLL_measure i fs; LLL_invariant upw ia fsa; basis_reduction_main (upw, ia, fsa) = fs'\<rbrakk> \<Longrightarrow> LLL_invariant True m fs'; LLL_invariant upw i fs; basis_reduction_main (upw, i, fs) = fs'\<rbrakk> \<Longrightarrow> LLL_invariant True m fs'
[PROOF STEP]
note IH = less(1)
[PROOF STATE]
proof (state)
this:
\<lbrakk>LLL_measure ?i1 ?fs1 < LLL_measure i fs; LLL_invariant ?upw1 ?i1 ?fs1; basis_reduction_main (?upw1, ?i1, ?fs1) = fs'\<rbrakk> \<Longrightarrow> LLL_invariant True m fs'

goal (1 subgoal):
 1. \<And>i fs upw. \<lbrakk>\<And>ia fsa upw. \<lbrakk>LLL_measure ia fsa < LLL_measure i fs; LLL_invariant upw ia fsa; basis_reduction_main (upw, ia, fsa) = fs'\<rbrakk> \<Longrightarrow> LLL_invariant True m fs'; LLL_invariant upw i fs; basis_reduction_main (upw, i, fs) = fs'\<rbrakk> \<Longrightarrow> LLL_invariant True m fs'
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LLL_invariant True m fs'
[PROOF STEP]
proof (cases "i < m")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i < m \<Longrightarrow> LLL_invariant True m fs'
 2. \<not> i < m \<Longrightarrow> LLL_invariant True m fs'
[PROOF STEP]
case i: True
[PROOF STATE]
proof (state)
this:
i < m

goal (2 subgoals):
 1. i < m \<Longrightarrow> LLL_invariant True m fs'
 2. \<not> i < m \<Longrightarrow> LLL_invariant True m fs'
[PROOF STEP]
obtain i' fs' upw' where step: "basis_reduction_step upw i fs = (upw',i',fs')"
      (is "?step = _")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>upw' i' fs'. basis_reduction_step upw i fs = (upw', i', fs') \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (cases ?step, auto)
[PROOF STATE]
proof (state)
this:
basis_reduction_step upw i fs = (upw', i', fs')

goal (2 subgoals):
 1. i < m \<Longrightarrow> LLL_invariant True m fs'
 2. \<not> i < m \<Longrightarrow> LLL_invariant True m fs'
[PROOF STEP]
from IH[OF basis_reduction_step(2,1)[OF inv step i]] res[unfolded step] i
[PROOF STATE]
proof (chain)
picking this:
basis_reduction_main (upw', i', fs') = fs' \<Longrightarrow> LLL_invariant True m fs'
(if i < m \<and> True then basis_reduction_main (upw', i', fs') else fs) = fs'
i < m
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
basis_reduction_main (upw', i', fs') = fs' \<Longrightarrow> LLL_invariant True m fs'
(if i < m \<and> True then basis_reduction_main (upw', i', fs') else fs) = fs'
i < m

goal (1 subgoal):
 1. LLL_invariant True m fs'
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
LLL_invariant True m fs'

goal (1 subgoal):
 1. \<not> i < m \<Longrightarrow> LLL_invariant True m fs'
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> i < m \<Longrightarrow> LLL_invariant True m fs'
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> i < m

goal (1 subgoal):
 1. \<not> i < m \<Longrightarrow> LLL_invariant True m fs'
[PROOF STEP]
with LLL_invD[OF inv]
[PROOF STATE]
proof (chain)
picking this:
gs.lin_indpt_list (map of_int_hom.vec_hom fs)
length (map of_int_hom.vec_hom fs) = m
set fs \<subseteq> carrier_vec n
?i < m \<Longrightarrow> fs ! ?i \<in> carrier_vec n
?i < m \<Longrightarrow> gram_schmidt_fs.gso n (map of_int_hom.vec_hom fs) ?i \<in> Rn
length fs = m
lattice_of fs = L
gram_schmidt_fs.weakly_reduced n (map of_int_hom.vec_hom fs) \<alpha> i
i \<le> m
gram_schmidt_fs.reduced n (map of_int_hom.vec_hom fs) \<alpha> i
upw \<or> \<mu>_small fs i
\<not> i < m
[PROOF STEP]
have i: "i = m"
[PROOF STATE]
proof (prove)
using this:
gs.lin_indpt_list (map of_int_hom.vec_hom fs)
length (map of_int_hom.vec_hom fs) = m
set fs \<subseteq> carrier_vec n
?i < m \<Longrightarrow> fs ! ?i \<in> carrier_vec n
?i < m \<Longrightarrow> gram_schmidt_fs.gso n (map of_int_hom.vec_hom fs) ?i \<in> Rn
length fs = m
lattice_of fs = L
gram_schmidt_fs.weakly_reduced n (map of_int_hom.vec_hom fs) \<alpha> i
i \<le> m
gram_schmidt_fs.reduced n (map of_int_hom.vec_hom fs) \<alpha> i
upw \<or> \<mu>_small fs i
\<not> i < m

goal (1 subgoal):
 1. i = m
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i = m

goal (1 subgoal):
 1. \<not> i < m \<Longrightarrow> LLL_invariant True m fs'
[PROOF STEP]
with False res inv
[PROOF STATE]
proof (chain)
picking this:
\<not> i < m
(if i < m \<and> True then basis_reduction_main (basis_reduction_step upw i fs) else fs) = fs'
LLL_invariant upw i fs
i = m
[PROOF STEP]
have "LLL_invariant upw m fs'"
[PROOF STATE]
proof (prove)
using this:
\<not> i < m
(if i < m \<and> True then basis_reduction_main (basis_reduction_step upw i fs) else fs) = fs'
LLL_invariant upw i fs
i = m

goal (1 subgoal):
 1. LLL_invariant upw m fs'
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
LLL_invariant upw m fs'

goal (1 subgoal):
 1. \<not> i < m \<Longrightarrow> LLL_invariant True m fs'
[PROOF STEP]
thus "LLL_invariant True m fs'"
[PROOF STATE]
proof (prove)
using this:
LLL_invariant upw m fs'

goal (1 subgoal):
 1. LLL_invariant True m fs'
[PROOF STEP]
unfolding LLL_invariant_def
[PROOF STATE]
proof (prove)
using this:
gs.lin_indpt_list (map of_int_hom.vec_hom fs') \<and> lattice_of fs' = L \<and> gram_schmidt_fs.reduced n (map of_int_hom.vec_hom fs') \<alpha> m \<and> m \<le> m \<and> length fs' = m \<and> (upw \<or> \<mu>_small fs' m)

goal (1 subgoal):
 1. gs.lin_indpt_list (map of_int_hom.vec_hom fs') \<and> lattice_of fs' = L \<and> gram_schmidt_fs.reduced n (map of_int_hom.vec_hom fs') \<alpha> m \<and> m \<le> m \<and> length fs' = m \<and> (True \<or> \<mu>_small fs' m)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
LLL_invariant True m fs'

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
LLL_invariant True m fs'

goal:
No subgoals!
[PROOF STEP]
qed