[STATEMENT]
lemma cong_gcd_eq:
  "gcd a m = gcd b m" if "[a = b] (mod m)"
  for a b :: "'a :: {unique_euclidean_semiring, euclidean_semiring_gcd}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcd a m = gcd b m
[PROOF STEP]
proof (cases "m = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. m = (0::'a) \<Longrightarrow> gcd a m = gcd b m
 2. m \<noteq> (0::'a) \<Longrightarrow> gcd a m = gcd b m
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
m = (0::'a)

goal (2 subgoals):
 1. m = (0::'a) \<Longrightarrow> gcd a m = gcd b m
 2. m \<noteq> (0::'a) \<Longrightarrow> gcd a m = gcd b m
[PROOF STEP]
with that
[PROOF STATE]
proof (chain)
picking this:
[a = b] (mod m)
m = (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
[a = b] (mod m)
m = (0::'a)

goal (1 subgoal):
 1. gcd a m = gcd b m
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
gcd a m = gcd b m

goal (1 subgoal):
 1. m \<noteq> (0::'a) \<Longrightarrow> gcd a m = gcd b m
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. m \<noteq> (0::'a) \<Longrightarrow> gcd a m = gcd b m
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
m \<noteq> (0::'a)

goal (1 subgoal):
 1. m \<noteq> (0::'a) \<Longrightarrow> gcd a m = gcd b m
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
m \<noteq> (0::'a)

goal (1 subgoal):
 1. m \<noteq> (0::'a) \<Longrightarrow> gcd a m = gcd b m
[PROOF STEP]
have "gcd (a mod m) m = gcd (b mod m) m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcd (a mod m) m = gcd (b mod m) m
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
[a = b] (mod m)

goal (1 subgoal):
 1. gcd (a mod m) m = gcd (b mod m) m
[PROOF STEP]
by (simp add: cong_def)
[PROOF STATE]
proof (state)
this:
gcd (a mod m) m = gcd (b mod m) m

goal (1 subgoal):
 1. m \<noteq> (0::'a) \<Longrightarrow> gcd a m = gcd b m
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
m \<noteq> (0::'a)
gcd (a mod m) m = gcd (b mod m) m
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
m \<noteq> (0::'a)
gcd (a mod m) m = gcd (b mod m) m

goal (1 subgoal):
 1. gcd a m = gcd b m
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
gcd a m = gcd b m

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma funpow_lesseq_iter:
  fixes f :: "('a::order) \<Rightarrow> 'a"
  assumes mono: "\<And>k. k \<le> f k" and m_le_n: "m \<le> n"
  shows "(f ^^ m) k \<le> (f ^^ n) k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f ^^ m) k \<le> (f ^^ n) k
[PROOF STEP]
using m_le_n
[PROOF STATE]
proof (prove)
using this:
m \<le> n

goal (1 subgoal):
 1. (f ^^ m) k \<le> (f ^^ n) k
[PROOF STEP]
by (induct n) (fastforce simp: le_Suc_eq intro: mono order_trans)+


[STATEMENT]
lemma rank_mono:
  assumes "finite S"
  shows "x \<le> y \<Longrightarrow> rank_of x S \<le> rank_of y S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<le> y \<Longrightarrow> rank_of x S \<le> rank_of y S
[PROOF STEP]
unfolding rank_of_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<le> y \<Longrightarrow> card {y \<in> S. y < x} \<le> card {ya \<in> S. ya < y}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite S

goal (1 subgoal):
 1. x \<le> y \<Longrightarrow> card {y \<in> S. y < x} \<le> card {ya \<in> S. ya < y}
[PROOF STEP]
by (intro card_mono, auto)


[STATEMENT]
lemma polynomial_function_mult [intro]:
  assumes f: "polynomial_function f" and g: "polynomial_function g"
  shows "polynomial_function (\<lambda>x. f x *\<^sub>R g x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. polynomial_function (\<lambda>x. f x *\<^sub>R g x)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. polynomial_function (\<lambda>x. f x *\<^sub>R g x)
[PROOF STEP]
have "real_polynomial_function (\<lambda>x. h (g x))" if "bounded_linear h" for h
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_polynomial_function (\<lambda>x. h (g x))
[PROOF STEP]
using g that
[PROOF STATE]
proof (prove)
using this:
polynomial_function g
bounded_linear h

goal (1 subgoal):
 1. real_polynomial_function (\<lambda>x. h (g x))
[PROOF STEP]
unfolding polynomial_function_def o_def bounded_linear_def
[PROOF STATE]
proof (prove)
using this:
\<forall>f. linear f \<and> bounded_linear_axioms f \<longrightarrow> real_polynomial_function (\<lambda>x. f (g x))
linear h \<and> bounded_linear_axioms h

goal (1 subgoal):
 1. real_polynomial_function (\<lambda>x. h (g x))
[PROOF STEP]
by (auto simp: real_polynomial_function_eq)
[PROOF STATE]
proof (state)
this:
bounded_linear ?h \<Longrightarrow> real_polynomial_function (\<lambda>x. ?h (g x))

goal (1 subgoal):
 1. polynomial_function (\<lambda>x. f x *\<^sub>R g x)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
bounded_linear ?h \<Longrightarrow> real_polynomial_function (\<lambda>x. ?h (g x))

goal (1 subgoal):
 1. polynomial_function (\<lambda>x. f x *\<^sub>R g x)
[PROOF STEP]
have "real_polynomial_function f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_polynomial_function f
[PROOF STEP]
by (simp add: f real_polynomial_function_eq)
[PROOF STATE]
proof (state)
this:
real_polynomial_function f

goal (1 subgoal):
 1. polynomial_function (\<lambda>x. f x *\<^sub>R g x)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
bounded_linear ?h \<Longrightarrow> real_polynomial_function (\<lambda>x. ?h (g x))
real_polynomial_function f
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
bounded_linear ?h \<Longrightarrow> real_polynomial_function (\<lambda>x. ?h (g x))
real_polynomial_function f

goal (1 subgoal):
 1. polynomial_function (\<lambda>x. f x *\<^sub>R g x)
[PROOF STEP]
unfolding polynomial_function_def bounded_linear_def o_def
[PROOF STATE]
proof (prove)
using this:
linear ?h \<and> bounded_linear_axioms ?h \<Longrightarrow> real_polynomial_function (\<lambda>x. ?h (g x))
real_polynomial_function f

goal (1 subgoal):
 1. \<forall>fa. linear fa \<and> bounded_linear_axioms fa \<longrightarrow> real_polynomial_function (\<lambda>x. fa (f x *\<^sub>R g x))
[PROOF STEP]
by (auto simp: linear.scaleR)
[PROOF STATE]
proof (state)
this:
polynomial_function (\<lambda>x. f x *\<^sub>R g x)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fermat_theorem_mod_ring2[simp]:
fixes a::"'a::{prime_card} mod_ring"
shows "a ^ (CARD('a)^n) = a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a ^ CARD('a) ^ n = a
[PROOF STEP]
proof (induct n arbitrary: a)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>a. a ^ CARD('a) ^ 0 = a
 2. \<And>n a. (\<And>a. a ^ CARD('a) ^ n = a) \<Longrightarrow> a ^ CARD('a) ^ Suc n = a
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
?a ^ CARD('a) ^ n = ?a

goal (2 subgoals):
 1. \<And>a. a ^ CARD('a) ^ 0 = a
 2. \<And>n a. (\<And>a. a ^ CARD('a) ^ n = a) \<Longrightarrow> a ^ CARD('a) ^ Suc n = a
[PROOF STEP]
define p where "p = CARD('a)"
[PROOF STATE]
proof (state)
this:
p = CARD('a)

goal (2 subgoals):
 1. \<And>a. a ^ CARD('a) ^ 0 = a
 2. \<And>n a. (\<And>a. a ^ CARD('a) ^ n = a) \<Longrightarrow> a ^ CARD('a) ^ Suc n = a
[PROOF STEP]
have "a ^ p ^ Suc n = a ^ (p * (p ^ n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a ^ p ^ Suc n = a ^ (p * p ^ n)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a ^ p ^ Suc n = a ^ (p * p ^ n)

goal (2 subgoals):
 1. \<And>a. a ^ CARD('a) ^ 0 = a
 2. \<And>n a. (\<And>a. a ^ CARD('a) ^ n = a) \<Longrightarrow> a ^ CARD('a) ^ Suc n = a
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
a ^ p ^ Suc n = a ^ (p * p ^ n)

goal (2 subgoals):
 1. \<And>a. a ^ CARD('a) ^ 0 = a
 2. \<And>n a. (\<And>a. a ^ CARD('a) ^ n = a) \<Longrightarrow> a ^ CARD('a) ^ Suc n = a
[PROOF STEP]
have "... = (a ^ p) ^(p ^ n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a ^ (p * p ^ n) = (a ^ p) ^ p ^ n
[PROOF STEP]
by (simp add: power_mult)
[PROOF STATE]
proof (state)
this:
a ^ (p * p ^ n) = (a ^ p) ^ p ^ n

goal (2 subgoals):
 1. \<And>a. a ^ CARD('a) ^ 0 = a
 2. \<And>n a. (\<And>a. a ^ CARD('a) ^ n = a) \<Longrightarrow> a ^ CARD('a) ^ Suc n = a
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
a ^ (p * p ^ n) = (a ^ p) ^ p ^ n

goal (2 subgoals):
 1. \<And>a. a ^ CARD('a) ^ 0 = a
 2. \<And>n a. (\<And>a. a ^ CARD('a) ^ n = a) \<Longrightarrow> a ^ CARD('a) ^ Suc n = a
[PROOF STEP]
have "... = a^(p ^ n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a ^ p) ^ p ^ n = a ^ p ^ n
[PROOF STEP]
using fermat_theorem_mod_ring[of "a^p"]
[PROOF STATE]
proof (prove)
using this:
(a ^ p) ^ CARD('a) = a ^ p

goal (1 subgoal):
 1. (a ^ p) ^ p ^ n = a ^ p ^ n
[PROOF STEP]
unfolding p_def
[PROOF STATE]
proof (prove)
using this:
(a ^ CARD('a)) ^ CARD('a) = a ^ CARD('a)

goal (1 subgoal):
 1. (a ^ CARD('a)) ^ CARD('a) ^ n = a ^ CARD('a) ^ n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(a ^ p) ^ p ^ n = a ^ p ^ n

goal (2 subgoals):
 1. \<And>a. a ^ CARD('a) ^ 0 = a
 2. \<And>n a. (\<And>a. a ^ CARD('a) ^ n = a) \<Longrightarrow> a ^ CARD('a) ^ Suc n = a
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(a ^ p) ^ p ^ n = a ^ p ^ n

goal (2 subgoals):
 1. \<And>a. a ^ CARD('a) ^ 0 = a
 2. \<And>n a. (\<And>a. a ^ CARD('a) ^ n = a) \<Longrightarrow> a ^ CARD('a) ^ Suc n = a
[PROOF STEP]
have "... = a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a ^ p ^ n = a
[PROOF STEP]
using Suc.hyps p_def
[PROOF STATE]
proof (prove)
using this:
?a ^ CARD('a) ^ n = ?a
p = CARD('a)

goal (1 subgoal):
 1. a ^ p ^ n = a
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a ^ p ^ n = a

goal (2 subgoals):
 1. \<And>a. a ^ CARD('a) ^ 0 = a
 2. \<And>n a. (\<And>a. a ^ CARD('a) ^ n = a) \<Longrightarrow> a ^ CARD('a) ^ Suc n = a
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
a ^ p ^ Suc n = a
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
a ^ p ^ Suc n = a

goal (1 subgoal):
 1. a ^ CARD('a) ^ Suc n = a
[PROOF STEP]
by (simp add: p_def)
[PROOF STATE]
proof (state)
this:
a ^ CARD('a) ^ Suc n = a

goal (1 subgoal):
 1. \<And>a. a ^ CARD('a) ^ 0 = a
[PROOF STEP]
qed auto


[STATEMENT]
lemma poly_newton_poly_xj: assumes "j \<le> n"
  shows "poly (newton_poly n) (x j) = sum_list (map (\<lambda> i. c i * poly (N i) (x j)) [0 ..< Suc j])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly (local.newton_poly n) (x j) = (\<Sum>i\<leftarrow>[0..<Suc j]. c i * poly (N i) (x j))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. poly (local.newton_poly n) (x j) = (\<Sum>i\<leftarrow>[0..<Suc j]. c i * poly (N i) (x j))
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
j \<le> n
[PROOF STEP]
have id: "[0 ..< Suc n] = [0 ..< Suc j] @ [Suc j ..< Suc n]"
[PROOF STATE]
proof (prove)
using this:
j \<le> n

goal (1 subgoal):
 1. [0..<Suc n] = [0..<Suc j] @ [Suc j..<Suc n]
[PROOF STEP]
by (metis Suc_le_mono le_Suc_ex less_eq_nat.simps(1) upt_add_eq_append)
[PROOF STATE]
proof (state)
this:
[0..<Suc n] = [0..<Suc j] @ [Suc j..<Suc n]

goal (1 subgoal):
 1. poly (local.newton_poly n) (x j) = (\<Sum>i\<leftarrow>[0..<Suc j]. c i * poly (N i) (x j))
[PROOF STEP]
have id2: "(\<Sum>i\<leftarrow>[Suc j..< Suc n]. c i * poly (N i) (x j)) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<leftarrow>[Suc j..<Suc n]. c i * poly (N i) (x j)) = (0::'a)
[PROOF STEP]
by (rule sum_list_neutral, unfold poly_N_xi_cond, auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<leftarrow>[Suc j..<Suc n]. c i * poly (N i) (x j)) = (0::'a)

goal (1 subgoal):
 1. poly (local.newton_poly n) (x j) = (\<Sum>i\<leftarrow>[0..<Suc j]. c i * poly (N i) (x j))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly (local.newton_poly n) (x j) = (\<Sum>i\<leftarrow>[0..<Suc j]. c i * poly (N i) (x j))
[PROOF STEP]
unfolding poly_newton_poly id map_append sum_list_append id2
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<leftarrow>[0..<Suc j]. c i * poly (N i) (x j)) + (0::'a) = (\<Sum>i\<leftarrow>[0..<Suc j]. c i * poly (N i) (x j))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
poly (local.newton_poly n) (x j) = (\<Sum>i\<leftarrow>[0..<Suc j]. c i * poly (N i) (x j))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma arcosh_real_has_field_derivative [derivative_intros]:
  fixes x :: real
  assumes "x > 1"
  shows   "(arcosh has_field_derivative (1 / (sqrt (x ^ 2 - 1)))) (at x within A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (arcosh has_real_derivative 1 / sqrt (x\<^sup>2 - 1)) (at x within A)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (arcosh has_real_derivative 1 / sqrt (x\<^sup>2 - 1)) (at x within A)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
1 < x
[PROOF STEP]
have "x + sqrt (x\<^sup>2 - 1) > 0"
[PROOF STATE]
proof (prove)
using this:
1 < x

goal (1 subgoal):
 1. 0 < x + sqrt (x\<^sup>2 - 1)
[PROOF STEP]
by (simp add: add_pos_pos)
[PROOF STATE]
proof (state)
this:
0 < x + sqrt (x\<^sup>2 - 1)

goal (1 subgoal):
 1. (arcosh has_real_derivative 1 / sqrt (x\<^sup>2 - 1)) (at x within A)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
0 < x + sqrt (x\<^sup>2 - 1)

goal (1 subgoal):
 1. (arcosh has_real_derivative 1 / sqrt (x\<^sup>2 - 1)) (at x within A)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < x + sqrt (x\<^sup>2 - 1)
1 < x

goal (1 subgoal):
 1. (arcosh has_real_derivative 1 / sqrt (x\<^sup>2 - 1)) (at x within A)
[PROOF STEP]
unfolding arcosh_def [abs_def]
[PROOF STATE]
proof (prove)
using this:
0 < x + sqrt (x\<^sup>2 - 1)
1 < x

goal (1 subgoal):
 1. ((\<lambda>x. ln (x + (x\<^sup>2 - 1) powr of_real (1 / 2))) has_real_derivative 1 / sqrt (x\<^sup>2 - 1)) (at x within A)
[PROOF STEP]
by (auto intro!: derivative_eq_intros
             simp: powr_minus powr_half_sqrt field_split_simps power2_eq_1_iff)
[PROOF STATE]
proof (state)
this:
(arcosh has_real_derivative 1 / sqrt (x\<^sup>2 - 1)) (at x within A)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma comm_not_prim: assumes "u \<noteq> \<epsilon>" "v \<noteq> \<epsilon>" "u\<cdot>v = v\<cdot>u" shows "\<not> primitive (u\<cdot>v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> primitive (u \<cdot> v)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> primitive (u \<cdot> v)
[PROOF STEP]
obtain t k m where "u = t\<^sup>@k"  "v = t\<^sup>@m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>t k m. \<lbrakk>u = t \<^sup>@ k; v = t \<^sup>@ m\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using \<open>u\<cdot>v = v\<cdot>u\<close>[unfolded comm]
[PROOF STATE]
proof (prove)
using this:
\<exists>t k m. u = t \<^sup>@ k \<and> v = t \<^sup>@ m

goal (1 subgoal):
 1. (\<And>t k m. \<lbrakk>u = t \<^sup>@ k; v = t \<^sup>@ m\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
u = t \<^sup>@ k
v = t \<^sup>@ m

goal (1 subgoal):
 1. \<not> primitive (u \<cdot> v)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> primitive (u \<cdot> v)
[PROOF STEP]
using pow_non_prim[of "k+m" "t"]
[PROOF STATE]
proof (prove)
using this:
k + m \<noteq> 1 \<Longrightarrow> \<not> primitive (t \<^sup>@ (k + m))

goal (1 subgoal):
 1. \<not> primitive (u \<cdot> v)
[PROOF STEP]
unfolding \<open>u = t\<^sup>@k\<close> \<open>v = t\<^sup>@m\<close> add_exps[of t k m]
[PROOF STATE]
proof (prove)
using this:
k + m \<noteq> 1 \<Longrightarrow> \<not> primitive (t \<^sup>@ k \<cdot> t \<^sup>@ m)

goal (1 subgoal):
 1. \<not> primitive (t \<^sup>@ k \<cdot> t \<^sup>@ m)
[PROOF STEP]
using nemp_pow[OF \<open>u \<noteq> \<epsilon>\<close>[unfolded \<open>u = t\<^sup>@k\<close>]] nemp_pow[OF \<open>v \<noteq> \<epsilon>\<close>[unfolded \<open>v = t\<^sup>@m\<close>]]
[PROOF STATE]
proof (prove)
using this:
k + m \<noteq> 1 \<Longrightarrow> \<not> primitive (t \<^sup>@ k \<cdot> t \<^sup>@ m)
k \<noteq> 0
m \<noteq> 0

goal (1 subgoal):
 1. \<not> primitive (t \<^sup>@ k \<cdot> t \<^sup>@ m)
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
\<not> primitive (u \<cdot> v)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma smult_1:
fixes A::"'a::ring_1 tensor"
shows "A = 1 \<cdot> A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A = (1::'a) \<cdot> A
[PROOF STEP]
unfolding smult_def tensor_one_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A = tensor_from_vec (dims A) (vec_smult (1::'a) (vec A))
[PROOF STEP]
apply (rule tensor_eqI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. dims A = dims (tensor_from_vec (dims A) (vec_smult (1::'a) (vec A)))
 2. vec A = vec (tensor_from_vec (dims A) (vec_smult (1::'a) (vec A)))
[PROOF STEP]
apply (simp add: length_vec length_vec_smult)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec A = vec (tensor_from_vec (dims A) (vec_smult (1::'a) (vec A)))
[PROOF STEP]
by (metis dims_tensor length_vec length_vec_smult lookup_smult mult.left_neutral smult_def tensor_lookup_eqI)


[STATEMENT]
lemma nth_prime_double_sqrt_less:
  assumes "\<epsilon> > 0"
  shows "\<forall>\<^sub>F n in sequentially. (nth_prime (2*n) - nth_prime n)
            / sqrt (nth_prime n) < n powr (1/2+\<epsilon>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. real (nth_prime (2 * n) - nth_prime n) / sqrt (real (nth_prime n)) < real n powr (1 / 2 + \<epsilon>)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. real (nth_prime (2 * n) - nth_prime n) / sqrt (real (nth_prime n)) < real n powr (1 / 2 + \<epsilon>)
[PROOF STEP]
define pp ll where
    "pp=(\<lambda>n. (nth_prime (2*n) - nth_prime n) / sqrt (nth_prime n))" and
    "ll=(\<lambda>x::nat. x * ln x)"
[PROOF STATE]
proof (state)
this:
pp = (\<lambda>n. real (nth_prime (2 * n) - nth_prime n) / sqrt (real (nth_prime n)))
ll = (\<lambda>x. real x * ln (real x))

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. real (nth_prime (2 * n) - nth_prime n) / sqrt (real (nth_prime n)) < real n powr (1 / 2 + \<epsilon>)
[PROOF STEP]
have pp_pos:"pp (n+1) > 0" for n
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < pp (n + 1)
[PROOF STEP]
unfolding pp_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < real (nth_prime (2 * (n + 1)) - nth_prime (n + 1)) / sqrt (real (nth_prime (n + 1)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 < pp (?n + 1)

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. real (nth_prime (2 * n) - nth_prime n) / sqrt (real (nth_prime n)) < real n powr (1 / 2 + \<epsilon>)
[PROOF STEP]
have "(\<lambda>x. nth_prime (2 * x)) \<sim>[sequentially] (\<lambda>x. (2 * x) * ln (2 * x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. real (nth_prime (2 * x))) \<sim>[sequentially] (\<lambda>x. real (2 * x) * ln (real (2 * x)))
[PROOF STEP]
using nth_prime_asymptotics[THEN asymp_equiv_compose
        ,of "(*) 2" sequentially,unfolded comp_def]
[PROOF STATE]
proof (prove)
using this:
filterlim ((*) 2) sequentially sequentially \<Longrightarrow> (\<lambda>x. real (nth_prime (2 * x))) \<sim>[sequentially] (\<lambda>x. real (2 * x) * ln (real (2 * x)))

goal (1 subgoal):
 1. (\<lambda>x. real (nth_prime (2 * x))) \<sim>[sequentially] (\<lambda>x. real (2 * x) * ln (real (2 * x)))
[PROOF STEP]
using mult_nat_left_at_top pos2
[PROOF STATE]
proof (prove)
using this:
filterlim ((*) 2) sequentially sequentially \<Longrightarrow> (\<lambda>x. real (nth_prime (2 * x))) \<sim>[sequentially] (\<lambda>x. real (2 * x) * ln (real (2 * x)))
0 < ?c \<Longrightarrow> filterlim ((*) ?c) sequentially sequentially
0 < 2

goal (1 subgoal):
 1. (\<lambda>x. real (nth_prime (2 * x))) \<sim>[sequentially] (\<lambda>x. real (2 * x) * ln (real (2 * x)))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(\<lambda>x. real (nth_prime (2 * x))) \<sim>[sequentially] (\<lambda>x. real (2 * x) * ln (real (2 * x)))

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. real (nth_prime (2 * n) - nth_prime n) / sqrt (real (nth_prime n)) < real n powr (1 / 2 + \<epsilon>)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<lambda>x. real (nth_prime (2 * x))) \<sim>[sequentially] (\<lambda>x. real (2 * x) * ln (real (2 * x)))

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. real (nth_prime (2 * n) - nth_prime n) / sqrt (real (nth_prime n)) < real n powr (1 / 2 + \<epsilon>)
[PROOF STEP]
have "... \<sim>[sequentially] (\<lambda>x. 2 *x * ln x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. real (2 * x) * ln (real (2 * x))) \<sim>[sequentially] (\<lambda>x. real (2 * x) * ln (real x))
[PROOF STEP]
by real_asymp
[PROOF STATE]
proof (state)
this:
(\<lambda>x. real (2 * x) * ln (real (2 * x))) \<sim>[sequentially] (\<lambda>x. real (2 * x) * ln (real x))

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. real (nth_prime (2 * n) - nth_prime n) / sqrt (real (nth_prime n)) < real n powr (1 / 2 + \<epsilon>)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<And>c d. c \<sim>[sequentially] d \<Longrightarrow> c \<sim>[sequentially] d) \<Longrightarrow> (\<lambda>x. real (nth_prime (2 * x))) \<sim>[sequentially] (\<lambda>a. real (2 * a) * ln (real a))
[PROOF STEP]
have "(\<lambda>x. nth_prime (2 * x)) \<sim>[sequentially] (\<lambda>x. 2 *x * ln x)"
[PROOF STATE]
proof (prove)
using this:
(\<And>c d. c \<sim>[sequentially] d \<Longrightarrow> c \<sim>[sequentially] d) \<Longrightarrow> (\<lambda>x. real (nth_prime (2 * x))) \<sim>[sequentially] (\<lambda>a. real (2 * a) * ln (real a))

goal (1 subgoal):
 1. (\<lambda>x. real (nth_prime (2 * x))) \<sim>[sequentially] (\<lambda>x. real (2 * x) * ln (real x))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<lambda>x. real (nth_prime (2 * x))) \<sim>[sequentially] (\<lambda>x. real (2 * x) * ln (real x))

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. real (nth_prime (2 * n) - nth_prime n) / sqrt (real (nth_prime n)) < real n powr (1 / 2 + \<epsilon>)
[PROOF STEP]
from this[unfolded asymp_equiv_def, THEN tendsto_mult_left,of 2]
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>x. 2 * (if real (nth_prime (2 * x)) = 0 \<and> real (2 * x) * ln (real x) = 0 then 1 else real (nth_prime (2 * x)) / (real (2 * x) * ln (real x)))) \<longlonglongrightarrow> 2 * 1
[PROOF STEP]
have "(\<lambda>x. nth_prime (2 * x) / (x * ln x)) \<longlonglongrightarrow> 2"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. 2 * (if real (nth_prime (2 * x)) = 0 \<and> real (2 * x) * ln (real x) = 0 then 1 else real (nth_prime (2 * x)) / (real (2 * x) * ln (real x)))) \<longlonglongrightarrow> 2 * 1

goal (1 subgoal):
 1. (\<lambda>x. real (nth_prime (2 * x)) / (real x * ln (real x))) \<longlonglongrightarrow> 2
[PROOF STEP]
unfolding asymp_equiv_def
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. 2 * (if real (nth_prime (2 * x)) = 0 \<and> real (2 * x) * ln (real x) = 0 then 1 else real (nth_prime (2 * x)) / (real (2 * x) * ln (real x)))) \<longlonglongrightarrow> 2 * 1

goal (1 subgoal):
 1. (\<lambda>x. real (nth_prime (2 * x)) / (real x * ln (real x))) \<longlonglongrightarrow> 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>x. real (nth_prime (2 * x)) / (real x * ln (real x))) \<longlonglongrightarrow> 2

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. real (nth_prime (2 * n) - nth_prime n) / sqrt (real (nth_prime n)) < real n powr (1 / 2 + \<epsilon>)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<lambda>x. real (nth_prime (2 * x)) / (real x * ln (real x))) \<longlonglongrightarrow> 2

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. real (nth_prime (2 * n) - nth_prime n) / sqrt (real (nth_prime n)) < real n powr (1 / 2 + \<epsilon>)
[PROOF STEP]
have *:"(\<lambda>x. nth_prime x / (x * ln x)) \<longlonglongrightarrow> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. real (nth_prime x) / (real x * ln (real x))) \<longlonglongrightarrow> 1
[PROOF STEP]
using nth_prime_asymptotics
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. real (nth_prime n)) \<sim>[sequentially] (\<lambda>n. real n * ln (real n))

goal (1 subgoal):
 1. (\<lambda>x. real (nth_prime x) / (real x * ln (real x))) \<longlonglongrightarrow> 1
[PROOF STEP]
unfolding asymp_equiv_def
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. if real (nth_prime x) = 0 \<and> real x * ln (real x) = 0 then 1 else real (nth_prime x) / (real x * ln (real x))) \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. (\<lambda>x. real (nth_prime x) / (real x * ln (real x))) \<longlonglongrightarrow> 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>x. real (nth_prime x) / (real x * ln (real x))) \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. real (nth_prime (2 * n) - nth_prime n) / sqrt (real (nth_prime n)) < real n powr (1 / 2 + \<epsilon>)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>x. real (nth_prime (2 * x)) / (real x * ln (real x))) \<longlonglongrightarrow> 2
(\<lambda>x. real (nth_prime x) / (real x * ln (real x))) \<longlonglongrightarrow> 1
[PROOF STEP]
have "(\<lambda>x. (nth_prime (2 * x) - nth_prime x) / ll x) \<longlonglongrightarrow> 1"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. real (nth_prime (2 * x)) / (real x * ln (real x))) \<longlonglongrightarrow> 2
(\<lambda>x. real (nth_prime x) / (real x * ln (real x))) \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. (\<lambda>x. real (nth_prime (2 * x) - nth_prime x) / ll x) \<longlonglongrightarrow> 1
[PROOF STEP]
unfolding ll_def
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. real (nth_prime (2 * x)) / (real x * ln (real x))) \<longlonglongrightarrow> 2
(\<lambda>x. real (nth_prime x) / (real x * ln (real x))) \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. (\<lambda>x. real (nth_prime (2 * x) - nth_prime x) / (real x * ln (real x))) \<longlonglongrightarrow> 1
[PROOF STEP]
apply -
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(\<lambda>x. real (nth_prime (2 * x)) / (real x * ln (real x))) \<longlonglongrightarrow> 2; (\<lambda>x. real (nth_prime x) / (real x * ln (real x))) \<longlonglongrightarrow> 1\<rbrakk> \<Longrightarrow> (\<lambda>x. real (nth_prime (2 * x) - nth_prime x) / (real x * ln (real x))) \<longlonglongrightarrow> 1
[PROOF STEP]
apply (drule (1) tendsto_diff)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(\<lambda>x. real (nth_prime x) / (real x * ln (real x))) \<longlonglongrightarrow> 1; (\<lambda>x. real (nth_prime (2 * x)) / (real x * ln (real x)) - real (nth_prime x) / (real x * ln (real x))) \<longlonglongrightarrow> 2 - 1\<rbrakk> \<Longrightarrow> (\<lambda>x. real (nth_prime (2 * x) - nth_prime x) / (real x * ln (real x))) \<longlonglongrightarrow> 1
[PROOF STEP]
apply (subst of_nat_diff,simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(\<lambda>x. real (nth_prime x) / (real x * ln (real x))) \<longlonglongrightarrow> 1; (\<lambda>x. real (nth_prime (2 * x)) / (real x * ln (real x)) - real (nth_prime x) / (real x * ln (real x))) \<longlonglongrightarrow> 2 - 1\<rbrakk> \<Longrightarrow> (\<lambda>x. (real (nth_prime (2 * x)) - real (nth_prime x)) / (real x * ln (real x))) \<longlonglongrightarrow> 1
[PROOF STEP]
by (subst diff_divide_distrib,simp)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. real (nth_prime (2 * x) - nth_prime x) / ll x) \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. real (nth_prime (2 * n) - nth_prime n) / sqrt (real (nth_prime n)) < real n powr (1 / 2 + \<epsilon>)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<lambda>x. real (nth_prime (2 * x) - nth_prime x) / ll x) \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. real (nth_prime (2 * n) - nth_prime n) / sqrt (real (nth_prime n)) < real n powr (1 / 2 + \<epsilon>)
[PROOF STEP]
have "(\<lambda>x. sqrt (nth_prime x) / sqrt (ll x)) \<longlonglongrightarrow> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. sqrt (real (nth_prime x)) / sqrt (ll x)) \<longlonglongrightarrow> 1
[PROOF STEP]
unfolding ll_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. sqrt (real (nth_prime x)) / sqrt (real x * ln (real x))) \<longlonglongrightarrow> 1
[PROOF STEP]
using tendsto_real_sqrt[OF *]
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. sqrt (real (nth_prime x) / (real x * ln (real x)))) \<longlonglongrightarrow> sqrt 1

goal (1 subgoal):
 1. (\<lambda>x. sqrt (real (nth_prime x)) / sqrt (real x * ln (real x))) \<longlonglongrightarrow> 1
[PROOF STEP]
by (auto simp: real_sqrt_divide)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. sqrt (real (nth_prime x)) / sqrt (ll x)) \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. real (nth_prime (2 * n) - nth_prime n) / sqrt (real (nth_prime n)) < real n powr (1 / 2 + \<epsilon>)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>x. real (nth_prime (2 * x) - nth_prime x) / ll x) \<longlonglongrightarrow> 1
(\<lambda>x. sqrt (real (nth_prime x)) / sqrt (ll x)) \<longlonglongrightarrow> 1
[PROOF STEP]
have "(\<lambda>x. pp x * (sqrt (ll x) / (ll x))) \<longlonglongrightarrow> 1"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. real (nth_prime (2 * x) - nth_prime x) / ll x) \<longlonglongrightarrow> 1
(\<lambda>x. sqrt (real (nth_prime x)) / sqrt (ll x)) \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. (\<lambda>x. pp x * (sqrt (ll x) / ll x)) \<longlonglongrightarrow> 1
[PROOF STEP]
apply -
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(\<lambda>x. real (nth_prime (2 * x) - nth_prime x) / ll x) \<longlonglongrightarrow> 1; (\<lambda>x. sqrt (real (nth_prime x)) / sqrt (ll x)) \<longlonglongrightarrow> 1\<rbrakk> \<Longrightarrow> (\<lambda>x. pp x * (sqrt (ll x) / ll x)) \<longlonglongrightarrow> 1
[PROOF STEP]
apply (drule (1) tendsto_divide,simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(\<lambda>x. sqrt (real (nth_prime x)) / sqrt (ll x)) \<longlonglongrightarrow> 1; (\<lambda>x. real (nth_prime (2 * x) - nth_prime x) / ll x / (sqrt (real (nth_prime x)) / sqrt (ll x))) \<longlonglongrightarrow> 1 / 1\<rbrakk> \<Longrightarrow> (\<lambda>x. pp x * (sqrt (ll x) / ll x)) \<longlonglongrightarrow> 1
[PROOF STEP]
by (auto simp:field_simps of_nat_diff pp_def)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. pp x * (sqrt (ll x) / ll x)) \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. real (nth_prime (2 * n) - nth_prime n) / sqrt (real (nth_prime n)) < real n powr (1 / 2 + \<epsilon>)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<lambda>x. pp x * (sqrt (ll x) / ll x)) \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. real (nth_prime (2 * n) - nth_prime n) / sqrt (real (nth_prime n)) < real n powr (1 / 2 + \<epsilon>)
[PROOF STEP]
have "\<forall>\<^sub>F x in sequentially. sqrt (ll x) / ll x = 1/sqrt (ll x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in sequentially. sqrt (ll x) / ll x = 1 / sqrt (ll x)
[PROOF STEP]
apply (subst eventually_sequentially_Suc[symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F i in sequentially. sqrt (ll (Suc i)) / ll (Suc i) = 1 / sqrt (ll (Suc i))
[PROOF STEP]
by (auto intro!:eventuallyI simp:ll_def divide_simps)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in sequentially. sqrt (ll x) / ll x = 1 / sqrt (ll x)

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. real (nth_prime (2 * n) - nth_prime n) / sqrt (real (nth_prime n)) < real n powr (1 / 2 + \<epsilon>)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>x. pp x * (sqrt (ll x) / ll x)) \<longlonglongrightarrow> 1
\<forall>\<^sub>F x in sequentially. sqrt (ll x) / ll x = 1 / sqrt (ll x)
[PROOF STEP]
have "(\<lambda>x. pp x / sqrt (ll x)) \<longlonglongrightarrow> 1"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. pp x * (sqrt (ll x) / ll x)) \<longlonglongrightarrow> 1
\<forall>\<^sub>F x in sequentially. sqrt (ll x) / ll x = 1 / sqrt (ll x)

goal (1 subgoal):
 1. (\<lambda>x. pp x / sqrt (ll x)) \<longlonglongrightarrow> 1
[PROOF STEP]
apply (elim filterlim_mono_eventually)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<forall>\<^sub>F x in sequentially. sqrt (ll x) / ll x = 1 / sqrt (ll x) \<Longrightarrow> nhds 1 \<le> nhds 1
 2. \<forall>\<^sub>F x in sequentially. sqrt (ll x) / ll x = 1 / sqrt (ll x) \<Longrightarrow> sequentially \<le> sequentially
 3. \<forall>\<^sub>F x in sequentially. sqrt (ll x) / ll x = 1 / sqrt (ll x) \<Longrightarrow> \<forall>\<^sub>F x in sequentially. pp x * (sqrt (ll x) / ll x) = pp x / sqrt (ll x)
[PROOF STEP]
by (auto elim!:eventually_mono) (metis mult.right_neutral times_divide_eq_right)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. pp x / sqrt (ll x)) \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. real (nth_prime (2 * n) - nth_prime n) / sqrt (real (nth_prime n)) < real n powr (1 / 2 + \<epsilon>)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<lambda>x. pp x / sqrt (ll x)) \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. real (nth_prime (2 * n) - nth_prime n) / sqrt (real (nth_prime n)) < real n powr (1 / 2 + \<epsilon>)
[PROOF STEP]
have "(\<lambda>x. sqrt (ll x) / x powr (1/2+\<epsilon>)) \<longlonglongrightarrow> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. sqrt (ll x) / real x powr (1 / 2 + \<epsilon>)) \<longlonglongrightarrow> 0
[PROOF STEP]
unfolding ll_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. sqrt (real x * ln (real x)) / real x powr (1 / 2 + \<epsilon>)) \<longlonglongrightarrow> 0
[PROOF STEP]
using \<open>\<epsilon>>0\<close>
[PROOF STATE]
proof (prove)
using this:
0 < \<epsilon>

goal (1 subgoal):
 1. (\<lambda>x. sqrt (real x * ln (real x)) / real x powr (1 / 2 + \<epsilon>)) \<longlonglongrightarrow> 0
[PROOF STEP]
by real_asymp
[PROOF STATE]
proof (state)
this:
(\<lambda>x. sqrt (ll x) / real x powr (1 / 2 + \<epsilon>)) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. real (nth_prime (2 * n) - nth_prime n) / sqrt (real (nth_prime n)) < real n powr (1 / 2 + \<epsilon>)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>x. pp x / sqrt (ll x)) \<longlonglongrightarrow> 1
(\<lambda>x. sqrt (ll x) / real x powr (1 / 2 + \<epsilon>)) \<longlonglongrightarrow> 0
[PROOF STEP]
have "(\<lambda>x. pp x / x powr (1/2+\<epsilon>) *
                      (sqrt (ll x) / sqrt (ll x))) \<longlonglongrightarrow> 0"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. pp x / sqrt (ll x)) \<longlonglongrightarrow> 1
(\<lambda>x. sqrt (ll x) / real x powr (1 / 2 + \<epsilon>)) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. (\<lambda>x. pp x / real x powr (1 / 2 + \<epsilon>) * (sqrt (ll x) / sqrt (ll x))) \<longlonglongrightarrow> 0
[PROOF STEP]
apply -
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(\<lambda>x. pp x / sqrt (ll x)) \<longlonglongrightarrow> 1; (\<lambda>x. sqrt (ll x) / real x powr (1 / 2 + \<epsilon>)) \<longlonglongrightarrow> 0\<rbrakk> \<Longrightarrow> (\<lambda>x. pp x / real x powr (1 / 2 + \<epsilon>) * (sqrt (ll x) / sqrt (ll x))) \<longlonglongrightarrow> 0
[PROOF STEP]
apply (drule (1) tendsto_mult)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(\<lambda>x. sqrt (ll x) / real x powr (1 / 2 + \<epsilon>)) \<longlonglongrightarrow> 0; (\<lambda>x. pp x / sqrt (ll x) * (sqrt (ll x) / real x powr (1 / 2 + \<epsilon>))) \<longlonglongrightarrow> 1 * 0\<rbrakk> \<Longrightarrow> (\<lambda>x. pp x / real x powr (1 / 2 + \<epsilon>) * (sqrt (ll x) / sqrt (ll x))) \<longlonglongrightarrow> 0
[PROOF STEP]
by (auto elim:filterlim_mono_eventually)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. pp x / real x powr (1 / 2 + \<epsilon>) * (sqrt (ll x) / sqrt (ll x))) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. real (nth_prime (2 * n) - nth_prime n) / sqrt (real (nth_prime n)) < real n powr (1 / 2 + \<epsilon>)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<lambda>x. pp x / real x powr (1 / 2 + \<epsilon>) * (sqrt (ll x) / sqrt (ll x))) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. real (nth_prime (2 * n) - nth_prime n) / sqrt (real (nth_prime n)) < real n powr (1 / 2 + \<epsilon>)
[PROOF STEP]
have "\<forall>\<^sub>F x in sequentially. sqrt (ll x) / sqrt (ll x) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in sequentially. sqrt (ll x) / sqrt (ll x) = 1
[PROOF STEP]
apply (subst eventually_sequentially_Suc[symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F i in sequentially. sqrt (ll (Suc i)) / sqrt (ll (Suc i)) = 1
[PROOF STEP]
by (auto intro!:eventuallyI simp:ll_def )
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in sequentially. sqrt (ll x) / sqrt (ll x) = 1

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. real (nth_prime (2 * n) - nth_prime n) / sqrt (real (nth_prime n)) < real n powr (1 / 2 + \<epsilon>)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>x. pp x / real x powr (1 / 2 + \<epsilon>) * (sqrt (ll x) / sqrt (ll x))) \<longlonglongrightarrow> 0
\<forall>\<^sub>F x in sequentially. sqrt (ll x) / sqrt (ll x) = 1
[PROOF STEP]
have "(\<lambda>x. pp x / x powr (1/2+\<epsilon>)) \<longlonglongrightarrow> 0"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. pp x / real x powr (1 / 2 + \<epsilon>) * (sqrt (ll x) / sqrt (ll x))) \<longlonglongrightarrow> 0
\<forall>\<^sub>F x in sequentially. sqrt (ll x) / sqrt (ll x) = 1

goal (1 subgoal):
 1. (\<lambda>x. pp x / real x powr (1 / 2 + \<epsilon>)) \<longlonglongrightarrow> 0
[PROOF STEP]
apply (elim filterlim_mono_eventually)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<forall>\<^sub>F x in sequentially. sqrt (ll x) / sqrt (ll x) = 1 \<Longrightarrow> nhds 0 \<le> nhds 0
 2. \<forall>\<^sub>F x in sequentially. sqrt (ll x) / sqrt (ll x) = 1 \<Longrightarrow> sequentially \<le> sequentially
 3. \<forall>\<^sub>F x in sequentially. sqrt (ll x) / sqrt (ll x) = 1 \<Longrightarrow> \<forall>\<^sub>F x in sequentially. pp x / real x powr (1 / 2 + \<epsilon>) * (sqrt (ll x) / sqrt (ll x)) = pp x / real x powr (1 / 2 + \<epsilon>)
[PROOF STEP]
by (auto elim:eventually_mono)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. pp x / real x powr (1 / 2 + \<epsilon>)) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. real (nth_prime (2 * n) - nth_prime n) / sqrt (real (nth_prime n)) < real n powr (1 / 2 + \<epsilon>)
[PROOF STEP]
from tendstoD[OF this, of 1,simplified]
[PROOF STATE]
proof (chain)
picking this:
\<forall>\<^sub>F x in sequentially. \<bar>pp x\<bar> / real x powr (1 / 2 + \<epsilon>) < 1
[PROOF STEP]
show "\<forall>\<^sub>F x in sequentially. pp x < x powr (1 / 2 + \<epsilon>)"
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in sequentially. \<bar>pp x\<bar> / real x powr (1 / 2 + \<epsilon>) < 1

goal (1 subgoal):
 1. \<forall>\<^sub>F x in sequentially. pp x < real x powr (1 / 2 + \<epsilon>)
[PROOF STEP]
apply (elim eventually_mono_sequentially[of _ 1])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<bar>pp (x + 1)\<bar> / real (x + 1) powr (1 / 2 + \<epsilon>) < 1 \<Longrightarrow> pp (x + 1) < real (x + 1) powr (1 / 2 + \<epsilon>)
[PROOF STEP]
using pp_pos
[PROOF STATE]
proof (prove)
using this:
0 < pp (?n + 1)

goal (1 subgoal):
 1. \<And>x. \<bar>pp (x + 1)\<bar> / real (x + 1) powr (1 / 2 + \<epsilon>) < 1 \<Longrightarrow> pp (x + 1) < real (x + 1) powr (1 / 2 + \<epsilon>)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in sequentially. pp x < real x powr (1 / 2 + \<epsilon>)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in finite_measure) measure_zero_union:
  assumes "s \<in> sets M" "t \<in> sets M" "measure M t = 0"
  shows "measure M (s \<union> t) = measure M s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Sigma_Algebra.measure M (s \<union> t) = Sigma_Algebra.measure M s
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
s \<in> sets M
t \<in> sets M
Sigma_Algebra.measure M t = 0

goal (1 subgoal):
 1. Sigma_Algebra.measure M (s \<union> t) = Sigma_Algebra.measure M s
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>s \<in> sets M; t \<in> sets M; Sigma_Algebra.measure M t = 0\<rbrakk> \<Longrightarrow> Sigma_Algebra.measure M (s \<union> t) = Sigma_Algebra.measure M s
[PROOF STEP]
have "measure M (s \<union> t) \<le> measure M s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Sigma_Algebra.measure M (s \<union> t) \<le> Sigma_Algebra.measure M s
[PROOF STEP]
using finite_measure_subadditive[of s t] assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>s \<in> sets M; t \<in> sets M\<rbrakk> \<Longrightarrow> Sigma_Algebra.measure M (s \<union> t) \<le> Sigma_Algebra.measure M s + Sigma_Algebra.measure M t
s \<in> sets M
t \<in> sets M
Sigma_Algebra.measure M t = 0

goal (1 subgoal):
 1. Sigma_Algebra.measure M (s \<union> t) \<le> Sigma_Algebra.measure M s
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Sigma_Algebra.measure M (s \<union> t) \<le> Sigma_Algebra.measure M s

goal (1 subgoal):
 1. \<lbrakk>s \<in> sets M; t \<in> sets M; Sigma_Algebra.measure M t = 0\<rbrakk> \<Longrightarrow> Sigma_Algebra.measure M (s \<union> t) = Sigma_Algebra.measure M s
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
Sigma_Algebra.measure M (s \<union> t) \<le> Sigma_Algebra.measure M s

goal (1 subgoal):
 1. \<lbrakk>s \<in> sets M; t \<in> sets M; Sigma_Algebra.measure M t = 0\<rbrakk> \<Longrightarrow> Sigma_Algebra.measure M (s \<union> t) = Sigma_Algebra.measure M s
[PROOF STEP]
have "measure M (s \<union> t) \<ge> measure M s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Sigma_Algebra.measure M s \<le> Sigma_Algebra.measure M (s \<union> t)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
s \<in> sets M
t \<in> sets M
Sigma_Algebra.measure M t = 0

goal (1 subgoal):
 1. Sigma_Algebra.measure M s \<le> Sigma_Algebra.measure M (s \<union> t)
[PROOF STEP]
by (blast intro: finite_measure_mono)
[PROOF STATE]
proof (state)
this:
Sigma_Algebra.measure M s \<le> Sigma_Algebra.measure M (s \<union> t)

goal (1 subgoal):
 1. \<lbrakk>s \<in> sets M; t \<in> sets M; Sigma_Algebra.measure M t = 0\<rbrakk> \<Longrightarrow> Sigma_Algebra.measure M (s \<union> t) = Sigma_Algebra.measure M s
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
Sigma_Algebra.measure M (s \<union> t) \<le> Sigma_Algebra.measure M s
Sigma_Algebra.measure M s \<le> Sigma_Algebra.measure M (s \<union> t)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Sigma_Algebra.measure M (s \<union> t) \<le> Sigma_Algebra.measure M s
Sigma_Algebra.measure M s \<le> Sigma_Algebra.measure M (s \<union> t)

goal (1 subgoal):
 1. Sigma_Algebra.measure M (s \<union> t) = Sigma_Algebra.measure M s
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Sigma_Algebra.measure M (s \<union> t) = Sigma_Algebra.measure M s

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem convergent_prod_iff_summable_real:
  fixes a :: "nat \<Rightarrow> real"
  assumes "\<And>n. a n > 0"
  shows "convergent_prod (\<lambda>k. 1 + a k) \<longleftrightarrow> summable a" (is "?lhs = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. convergent_prod (\<lambda>k. 1 + a k) = summable a
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. convergent_prod (\<lambda>k. 1 + a k) \<Longrightarrow> summable a
 2. summable a \<Longrightarrow> convergent_prod (\<lambda>k. 1 + a k)
[PROOF STEP]
assume ?lhs
[PROOF STATE]
proof (state)
this:
convergent_prod (\<lambda>k. 1 + a k)

goal (2 subgoals):
 1. convergent_prod (\<lambda>k. 1 + a k) \<Longrightarrow> summable a
 2. summable a \<Longrightarrow> convergent_prod (\<lambda>k. 1 + a k)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
convergent_prod (\<lambda>k. 1 + a k)
[PROOF STEP]
obtain p where "raw_has_prod (\<lambda>k. 1 + a k) 0 p"
[PROOF STATE]
proof (prove)
using this:
convergent_prod (\<lambda>k. 1 + a k)

goal (1 subgoal):
 1. (\<And>p. raw_has_prod (\<lambda>k. 1 + a k) 0 p \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis assms add_less_same_cancel2 convergent_prod_offset_0 not_one_less_zero)
[PROOF STATE]
proof (state)
this:
raw_has_prod (\<lambda>k. 1 + a k) 0 p

goal (2 subgoals):
 1. convergent_prod (\<lambda>k. 1 + a k) \<Longrightarrow> summable a
 2. summable a \<Longrightarrow> convergent_prod (\<lambda>k. 1 + a k)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
raw_has_prod (\<lambda>k. 1 + a k) 0 p
[PROOF STEP]
have to_p: "(\<lambda>n. \<Prod>k\<le>n. 1 + a k) \<longlonglongrightarrow> p"
[PROOF STATE]
proof (prove)
using this:
raw_has_prod (\<lambda>k. 1 + a k) 0 p

goal (1 subgoal):
 1. (\<lambda>n. \<Prod>k\<le>n. 1 + a k) \<longlonglongrightarrow> p
[PROOF STEP]
by (auto simp: raw_has_prod_def)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<Prod>k\<le>n. 1 + a k) \<longlonglongrightarrow> p

goal (2 subgoals):
 1. convergent_prod (\<lambda>k. 1 + a k) \<Longrightarrow> summable a
 2. summable a \<Longrightarrow> convergent_prod (\<lambda>k. 1 + a k)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<Prod>k\<le>n. 1 + a k) \<longlonglongrightarrow> p

goal (2 subgoals):
 1. convergent_prod (\<lambda>k. 1 + a k) \<Longrightarrow> summable a
 2. summable a \<Longrightarrow> convergent_prod (\<lambda>k. 1 + a k)
[PROOF STEP]
have le: "(\<Sum>k\<le>n. a k) \<le> (\<Prod>k\<le>n. 1 + a k)" for n
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum a {..n} \<le> (\<Prod>k\<le>n. 1 + a k)
[PROOF STEP]
by (rule sum_le_prod) (use assms less_le in force)
[PROOF STATE]
proof (state)
this:
sum a {..?n} \<le> (\<Prod>k\<le>?n. 1 + a k)

goal (2 subgoals):
 1. convergent_prod (\<lambda>k. 1 + a k) \<Longrightarrow> summable a
 2. summable a \<Longrightarrow> convergent_prod (\<lambda>k. 1 + a k)
[PROOF STEP]
have "(\<Prod>k\<le>n. 1 + a k) \<le> p" for n
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>k\<le>n. 1 + a k) \<le> p
[PROOF STEP]
proof (rule incseq_le [OF _ to_p])
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. incseq (\<lambda>n. \<Prod>k\<le>n. 1 + a k)
[PROOF STEP]
show "incseq (\<lambda>n. \<Prod>k\<le>n. 1 + a k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. incseq (\<lambda>n. \<Prod>k\<le>n. 1 + a k)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < a ?n

goal (1 subgoal):
 1. incseq (\<lambda>n. \<Prod>k\<le>n. 1 + a k)
[PROOF STEP]
by (auto simp: mono_def order.strict_implies_order intro!: prod_mono2)
[PROOF STATE]
proof (state)
this:
incseq (\<lambda>n. \<Prod>k\<le>n. 1 + a k)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Prod>k\<le>?n. 1 + a k) \<le> p

goal (2 subgoals):
 1. convergent_prod (\<lambda>k. 1 + a k) \<Longrightarrow> summable a
 2. summable a \<Longrightarrow> convergent_prod (\<lambda>k. 1 + a k)
[PROOF STEP]
with le
[PROOF STATE]
proof (chain)
picking this:
sum a {..?n} \<le> (\<Prod>k\<le>?n. 1 + a k)
(\<Prod>k\<le>?n. 1 + a k) \<le> p
[PROOF STEP]
have "(\<Sum>k\<le>n. a k) \<le> p" for n
[PROOF STATE]
proof (prove)
using this:
sum a {..?n} \<le> (\<Prod>k\<le>?n. 1 + a k)
(\<Prod>k\<le>?n. 1 + a k) \<le> p

goal (1 subgoal):
 1. sum a {..n} \<le> p
[PROOF STEP]
by (metis order_trans)
[PROOF STATE]
proof (state)
this:
sum a {..?n} \<le> p

goal (2 subgoals):
 1. convergent_prod (\<lambda>k. 1 + a k) \<Longrightarrow> summable a
 2. summable a \<Longrightarrow> convergent_prod (\<lambda>k. 1 + a k)
[PROOF STEP]
with assms bounded_imp_summable
[PROOF STATE]
proof (chain)
picking this:
0 < a ?n
\<lbrakk>\<And>n. (0::?'a) \<le> ?a n; \<And>n. sum ?a {..n} \<le> ?B\<rbrakk> \<Longrightarrow> summable ?a
sum a {..?n} \<le> p
[PROOF STEP]
show ?rhs
[PROOF STATE]
proof (prove)
using this:
0 < a ?n
\<lbrakk>\<And>n. (0::?'a) \<le> ?a n; \<And>n. sum ?a {..n} \<le> ?B\<rbrakk> \<Longrightarrow> summable ?a
sum a {..?n} \<le> p

goal (1 subgoal):
 1. summable a
[PROOF STEP]
by (metis not_less order.asym)
[PROOF STATE]
proof (state)
this:
summable a

goal (1 subgoal):
 1. summable a \<Longrightarrow> convergent_prod (\<lambda>k. 1 + a k)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. summable a \<Longrightarrow> convergent_prod (\<lambda>k. 1 + a k)
[PROOF STEP]
assume R: ?rhs
[PROOF STATE]
proof (state)
this:
summable a

goal (1 subgoal):
 1. summable a \<Longrightarrow> convergent_prod (\<lambda>k. 1 + a k)
[PROOF STEP]
have "(\<Prod>k\<le>n. 1 + a k) \<le> exp (suminf a)" for n
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>k\<le>n. 1 + a k) \<le> exp (suminf a)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Prod>k\<le>n. 1 + a k) \<le> exp (suminf a)
[PROOF STEP]
have "(\<Prod>k\<le>n. 1 + a k) \<le> exp (\<Sum>k\<le>n. a k)" for n
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>k\<le>n. 1 + a k) \<le> exp (sum a {..n})
[PROOF STEP]
by (rule prod_le_exp_sum) (use assms less_le in force)
[PROOF STATE]
proof (state)
this:
(\<Prod>k\<le>?n. 1 + a k) \<le> exp (sum a {..?n})

goal (1 subgoal):
 1. (\<Prod>k\<le>n. 1 + a k) \<le> exp (suminf a)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<Prod>k\<le>?n. 1 + a k) \<le> exp (sum a {..?n})

goal (1 subgoal):
 1. (\<Prod>k\<le>n. 1 + a k) \<le> exp (suminf a)
[PROOF STEP]
have "exp (\<Sum>k\<le>n. a k) \<le> exp (suminf a)" for n
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. exp (sum a {..n}) \<le> exp (suminf a)
[PROOF STEP]
unfolding exp_le_cancel_iff
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum a {..n} \<le> suminf a
[PROOF STEP]
by (meson sum_le_suminf R assms finite_atMost less_eq_real_def)
[PROOF STATE]
proof (state)
this:
exp (sum a {..?n}) \<le> exp (suminf a)

goal (1 subgoal):
 1. (\<Prod>k\<le>n. 1 + a k) \<le> exp (suminf a)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<Prod>k\<le>?n. 1 + a k) \<le> exp (sum a {..?n})
exp (sum a {..?n}) \<le> exp (suminf a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Prod>k\<le>?n. 1 + a k) \<le> exp (sum a {..?n})
exp (sum a {..?n}) \<le> exp (suminf a)

goal (1 subgoal):
 1. (\<Prod>k\<le>n. 1 + a k) \<le> exp (suminf a)
[PROOF STEP]
by (meson order_trans)
[PROOF STATE]
proof (state)
this:
(\<Prod>k\<le>n. 1 + a k) \<le> exp (suminf a)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Prod>k\<le>?n. 1 + a k) \<le> exp (suminf a)

goal (1 subgoal):
 1. summable a \<Longrightarrow> convergent_prod (\<lambda>k. 1 + a k)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<Prod>k\<le>?n. 1 + a k) \<le> exp (suminf a)
[PROOF STEP]
obtain L where L: "(\<lambda>n. \<Prod>k\<le>n. 1 + a k) \<longlonglongrightarrow> L"
[PROOF STATE]
proof (prove)
using this:
(\<Prod>k\<le>?n. 1 + a k) \<le> exp (suminf a)

goal (1 subgoal):
 1. (\<And>L. (\<lambda>n. \<Prod>k\<le>n. 1 + a k) \<longlonglongrightarrow> L \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis assms bounded_imp_convergent_prod convergent_prod_iff_nz_lim le_add_same_cancel1 le_add_same_cancel2 less_le not_le zero_le_one)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<Prod>k\<le>n. 1 + a k) \<longlonglongrightarrow> L

goal (1 subgoal):
 1. summable a \<Longrightarrow> convergent_prod (\<lambda>k. 1 + a k)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<Prod>k\<le>n. 1 + a k) \<longlonglongrightarrow> L

goal (1 subgoal):
 1. summable a \<Longrightarrow> convergent_prod (\<lambda>k. 1 + a k)
[PROOF STEP]
have "L \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. L \<noteq> 0
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. L = 0 \<Longrightarrow> False
[PROOF STEP]
assume "L = 0"
[PROOF STATE]
proof (state)
this:
L = 0

goal (1 subgoal):
 1. L = 0 \<Longrightarrow> False
[PROOF STEP]
with L
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>n. \<Prod>k\<le>n. 1 + a k) \<longlonglongrightarrow> L
L = 0
[PROOF STEP]
have "(\<lambda>n. \<Prod>k\<le>n. 1 + a k) \<longlonglongrightarrow> 0"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. \<Prod>k\<le>n. 1 + a k) \<longlonglongrightarrow> L
L = 0

goal (1 subgoal):
 1. (\<lambda>n. \<Prod>k\<le>n. 1 + a k) \<longlonglongrightarrow> 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<Prod>k\<le>n. 1 + a k) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. L = 0 \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<Prod>k\<le>n. 1 + a k) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. L = 0 \<Longrightarrow> False
[PROOF STEP]
have "(\<Prod>k\<le>n. 1 + a k) > 1" for n
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 < (\<Prod>k\<le>n. 1 + a k)
[PROOF STEP]
by (simp add: assms less_1_prod)
[PROOF STATE]
proof (state)
this:
1 < (\<Prod>k\<le>?n. 1 + a k)

goal (1 subgoal):
 1. L = 0 \<Longrightarrow> False
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>n. \<Prod>k\<le>n. 1 + a k) \<longlonglongrightarrow> 0
1 < (\<Prod>k\<le>?n. 1 + a k)
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. \<Prod>k\<le>n. 1 + a k) \<longlonglongrightarrow> 0
1 < (\<Prod>k\<le>?n. 1 + a k)

goal (1 subgoal):
 1. False
[PROOF STEP]
by (meson Lim_bounded2 not_one_le_zero less_imp_le)
[PROOF STATE]
proof (state)
this:
False

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
L \<noteq> 0

goal (1 subgoal):
 1. summable a \<Longrightarrow> convergent_prod (\<lambda>k. 1 + a k)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>n. \<Prod>k\<le>n. 1 + a k) \<longlonglongrightarrow> L
L \<noteq> 0
[PROOF STEP]
show ?lhs
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. \<Prod>k\<le>n. 1 + a k) \<longlonglongrightarrow> L
L \<noteq> 0

goal (1 subgoal):
 1. convergent_prod (\<lambda>k. 1 + a k)
[PROOF STEP]
using assms convergent_prod_iff_nz_lim
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. \<Prod>k\<le>n. 1 + a k) \<longlonglongrightarrow> L
L \<noteq> 0
0 < a ?n
(\<And>i. ?f i \<noteq> (0::?'a)) \<Longrightarrow> convergent_prod ?f = (\<exists>L. (\<lambda>n. prod ?f {..n}) \<longlonglongrightarrow> L \<and> L \<noteq> (0::?'a))

goal (1 subgoal):
 1. convergent_prod (\<lambda>k. 1 + a k)
[PROOF STEP]
by (metis add_less_same_cancel1 less_le not_le zero_less_one)
[PROOF STATE]
proof (state)
this:
convergent_prod (\<lambda>k. 1 + a k)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma in_Inf_multiset_iff:
  assumes "A \<noteq> {}"
  shows   "x \<in># Inf A \<longleftrightarrow> (\<forall>X\<in>A. x \<in># X)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x \<in># Inf A) = (\<forall>X\<in>A. x \<in># X)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (x \<in># Inf A) = (\<forall>X\<in>A. x \<in># X)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
A \<noteq> {}
[PROOF STEP]
have "set_mset (Inf A) = (\<Inter>X\<in>A. set_mset X)"
[PROOF STATE]
proof (prove)
using this:
A \<noteq> {}

goal (1 subgoal):
 1. set_mset (Inf A) = \<Inter> (set_mset ` A)
[PROOF STEP]
by (rule set_mset_Inf)
[PROOF STATE]
proof (state)
this:
set_mset (Inf A) = \<Inter> (set_mset ` A)

goal (1 subgoal):
 1. (x \<in># Inf A) = (\<forall>X\<in>A. x \<in># X)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
set_mset (Inf A) = \<Inter> (set_mset ` A)

goal (1 subgoal):
 1. (x \<in># Inf A) = (\<forall>X\<in>A. x \<in># X)
[PROOF STEP]
have "x \<in> \<dots> \<longleftrightarrow> (\<forall>X\<in>A. x \<in># X)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x \<in> \<Inter> (set_mset ` A)) = (\<forall>X\<in>A. x \<in># X)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(x \<in> \<Inter> (set_mset ` A)) = (\<forall>X\<in>A. x \<in># X)

goal (1 subgoal):
 1. (x \<in># Inf A) = (\<forall>X\<in>A. x \<in># X)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(x \<in># Inf A) = (\<forall>X\<in>A. x \<in># X)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(x \<in># Inf A) = (\<forall>X\<in>A. x \<in># X)

goal (1 subgoal):
 1. (x \<in># Inf A) = (\<forall>X\<in>A. x \<in># X)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(x \<in># Inf A) = (\<forall>X\<in>A. x \<in># X)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma NatPredicateTippingPoint:
fixes
  n2 Pr
assumes
  Min:     "0 < n2" and
  Pr0:     "Pr 0" and
  NotPrN2: "\<not>Pr n2"
shows
  "\<exists>n<n2. Pr n \<and> \<not>Pr (Suc n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>n<n2. Pr n \<and> \<not> Pr (Suc n)
[PROOF STEP]
proof (rule classical, simp)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<forall>n. Pr n \<longrightarrow> n < n2 \<longrightarrow> Pr (Suc n) \<Longrightarrow> \<exists>n<n2. Pr n \<and> \<not> Pr (Suc n)
[PROOF STEP]
assume Asm: "\<forall>n. Pr n \<longrightarrow> n < n2 \<longrightarrow> Pr (Suc n)"
[PROOF STATE]
proof (state)
this:
\<forall>n. Pr n \<longrightarrow> n < n2 \<longrightarrow> Pr (Suc n)

goal (1 subgoal):
 1. \<forall>n. Pr n \<longrightarrow> n < n2 \<longrightarrow> Pr (Suc n) \<Longrightarrow> \<exists>n<n2. Pr n \<and> \<not> Pr (Suc n)
[PROOF STEP]
have "\<And>n. n < n2 \<Longrightarrow> Pr n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. n < n2 \<Longrightarrow> Pr n
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. n < n2 \<Longrightarrow> Pr n
[PROOF STEP]
fix n
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. n < n2 \<Longrightarrow> Pr n
[PROOF STEP]
show "n < n2 \<Longrightarrow> Pr n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n < n2 \<Longrightarrow> Pr n
[PROOF STEP]
by (induct n, auto simp add: Pr0 Asm)
[PROOF STATE]
proof (state)
this:
n < n2 \<Longrightarrow> Pr n

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?n < n2 \<Longrightarrow> Pr ?n

goal (1 subgoal):
 1. \<forall>n. Pr n \<longrightarrow> n < n2 \<longrightarrow> Pr (Suc n) \<Longrightarrow> \<exists>n<n2. Pr n \<and> \<not> Pr (Suc n)
[PROOF STEP]
hence False
[PROOF STATE]
proof (prove)
using this:
?n < n2 \<Longrightarrow> Pr ?n

goal (1 subgoal):
 1. False
[PROOF STEP]
using Asm[rule_format, of "n2 - 1"] Min NotPrN2
[PROOF STATE]
proof (prove)
using this:
?n < n2 \<Longrightarrow> Pr ?n
\<lbrakk>Pr (n2 - 1); n2 - 1 < n2\<rbrakk> \<Longrightarrow> Pr (Suc (n2 - 1))
0 < n2
\<not> Pr n2

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

goal (1 subgoal):
 1. \<forall>n. Pr n \<longrightarrow> n < n2 \<longrightarrow> Pr (Suc n) \<Longrightarrow> \<exists>n<n2. Pr n \<and> \<not> Pr (Suc n)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
False

goal (1 subgoal):
 1. \<exists>n<n2. Pr n \<and> \<not> Pr (Suc n)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>n<n2. Pr n \<and> \<not> Pr (Suc n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma homotopic_loopsI:
  fixes h :: "real \<times> real \<Rightarrow> _"
  assumes "continuous_on ({0..1} \<times> {0..1}) h"
          "h ` ({0..1} \<times> {0..1}) \<subseteq> s"
          "\<And>x. x \<in> {0..1} \<Longrightarrow> h (0, x) = p x"
          "\<And>x. x \<in> {0..1} \<Longrightarrow> h (1, x) = q x"
          "\<And>x. x \<in> {0..1} \<Longrightarrow> pathfinish (h \<circ> Pair x) = pathstart (h \<circ> Pair x)"
  shows   "homotopic_loops s p q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. homotopic_loops s p q
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
continuous_on ({0..1} \<times> {0..1}) h
h ` ({0..1} \<times> {0..1}) \<subseteq> s
?x \<in> {0..1} \<Longrightarrow> h (0, ?x) = p ?x
?x \<in> {0..1} \<Longrightarrow> h (1, ?x) = q ?x
?x \<in> {0..1} \<Longrightarrow> pathfinish (h \<circ> Pair ?x) = pathstart (h \<circ> Pair ?x)

goal (1 subgoal):
 1. homotopic_loops s p q
[PROOF STEP]
unfolding homotopic_loops
[PROOF STATE]
proof (prove)
using this:
continuous_on ({0..1} \<times> {0..1}) h
h ` ({0..1} \<times> {0..1}) \<subseteq> s
?x \<in> {0..1} \<Longrightarrow> h (0, ?x) = p ?x
?x \<in> {0..1} \<Longrightarrow> h (1, ?x) = q ?x
?x \<in> {0..1} \<Longrightarrow> pathfinish (h \<circ> Pair ?x) = pathstart (h \<circ> Pair ?x)

goal (1 subgoal):
 1. \<exists>h. continuous_on ({0..1} \<times> {0..1}) h \<and> h ` ({0..1} \<times> {0..1}) \<subseteq> s \<and> (\<forall>x\<in>{0..1}. h (0, x) = p x) \<and> (\<forall>x\<in>{0..1}. h (1, x) = q x) \<and> (\<forall>t\<in>{0..1}. pathfinish (h \<circ> Pair t) = pathstart (h \<circ> Pair t))
[PROOF STEP]
by (intro exI[of _ h]) auto


[STATEMENT]
lemma flow_funcset_ex_ivl:
  assumes "s \<in> S"
  shows "flow t\<^sub>0 s \<in> ex_ivl s \<rightarrow> S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. flow t\<^sub>0 s \<in> ex_ivl s \<rightarrow> S
[PROOF STEP]
using flow_usolves_ode[OF init_time \<open>s \<in> S\<close>]
[PROOF STATE]
proof (prove)
using this:
(flow t\<^sub>0 s usolves_ode f from t\<^sub>0) (ex_ivl s) S

goal (1 subgoal):
 1. flow t\<^sub>0 s \<in> ex_ivl s \<rightarrow> S
[PROOF STEP]
unfolding usolves_ode_from_def solves_ode_def
[PROOF STATE]
proof (prove)
using this:
( D flow t\<^sub>0 s = (\<lambda>t. f t (flow t\<^sub>0 s t)) on ex_ivl s \<and> flow t\<^sub>0 s \<in> ex_ivl s \<rightarrow> S) \<and> t\<^sub>0 \<in> ex_ivl s \<and> is_interval (ex_ivl s) \<and> (\<forall>z T'. t\<^sub>0 \<in> T' \<and> is_interval T' \<and> T' \<subseteq> ex_ivl s \<and>  D z = (\<lambda>t. f t (z t)) on T' \<and> z \<in> T' \<rightarrow> S \<longrightarrow> z t\<^sub>0 = flow t\<^sub>0 s t\<^sub>0 \<longrightarrow> (\<forall>t\<in>T'. z t = flow t\<^sub>0 s t))

goal (1 subgoal):
 1. flow t\<^sub>0 s \<in> ex_ivl s \<rightarrow> S
[PROOF STEP]
by blast


[STATEMENT]
theorem queue_length_estimate_lower:
  "invar bq \<Longrightarrow> (size (queue_to_multiset bq)) \<ge> 2^(length bq) - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invar bq \<Longrightarrow> 2 ^ length bq - 1 \<le> size (queue_to_multiset bq)
[PROOF STEP]
proof (induct bq rule: rev_induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. invar [] \<Longrightarrow> 2 ^ length [] - 1 \<le> size (queue_to_multiset [])
 2. \<And>x xs. \<lbrakk>invar xs \<Longrightarrow> 2 ^ length xs - 1 \<le> size (queue_to_multiset xs); invar (xs @ [x])\<rbrakk> \<Longrightarrow> 2 ^ length (xs @ [x]) - 1 \<le> size (queue_to_multiset (xs @ [x]))
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
invar []

goal (2 subgoals):
 1. invar [] \<Longrightarrow> 2 ^ length [] - 1 \<le> size (queue_to_multiset [])
 2. \<And>x xs. \<lbrakk>invar xs \<Longrightarrow> 2 ^ length xs - 1 \<le> size (queue_to_multiset xs); invar (xs @ [x])\<rbrakk> \<Longrightarrow> 2 ^ length (xs @ [x]) - 1 \<le> size (queue_to_multiset (xs @ [x]))
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
invar []

goal (1 subgoal):
 1. 2 ^ length [] - 1 \<le> size (queue_to_multiset [])
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 ^ length [] - 1 \<le> size (queue_to_multiset [])

goal (1 subgoal):
 1. \<And>x xs. \<lbrakk>invar xs \<Longrightarrow> 2 ^ length xs - 1 \<le> size (queue_to_multiset xs); invar (xs @ [x])\<rbrakk> \<Longrightarrow> 2 ^ length (xs @ [x]) - 1 \<le> size (queue_to_multiset (xs @ [x]))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x xs. \<lbrakk>invar xs \<Longrightarrow> 2 ^ length xs - 1 \<le> size (queue_to_multiset xs); invar (xs @ [x])\<rbrakk> \<Longrightarrow> 2 ^ length (xs @ [x]) - 1 \<le> size (queue_to_multiset (xs @ [x]))
[PROOF STEP]
case (snoc x xs)
[PROOF STATE]
proof (state)
this:
invar xs \<Longrightarrow> 2 ^ length xs - 1 \<le> size (queue_to_multiset xs)
invar (xs @ [x])

goal (1 subgoal):
 1. \<And>x xs. \<lbrakk>invar xs \<Longrightarrow> 2 ^ length xs - 1 \<le> size (queue_to_multiset xs); invar (xs @ [x])\<rbrakk> \<Longrightarrow> 2 ^ length (xs @ [x]) - 1 \<le> size (queue_to_multiset (xs @ [x]))
[PROOF STEP]
from snoc.hyps[OF invar_butlast[OF snoc.prems]]
[PROOF STATE]
proof (chain)
picking this:
2 ^ length xs - 1 \<le> size (queue_to_multiset xs)
[PROOF STEP]
have IH: "2 ^ length xs \<le> Suc (size (queue_to_multiset xs))"
[PROOF STATE]
proof (prove)
using this:
2 ^ length xs - 1 \<le> size (queue_to_multiset xs)

goal (1 subgoal):
 1. 2 ^ length xs \<le> Suc (size (queue_to_multiset xs))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 ^ length xs \<le> Suc (size (queue_to_multiset xs))

goal (1 subgoal):
 1. \<And>x xs. \<lbrakk>invar xs \<Longrightarrow> 2 ^ length xs - 1 \<le> size (queue_to_multiset xs); invar (xs @ [x])\<rbrakk> \<Longrightarrow> 2 ^ length (xs @ [x]) - 1 \<le> size (queue_to_multiset (xs @ [x]))
[PROOF STEP]
have size_q:
    "size (queue_to_multiset (xs @ [x])) =
    size (queue_to_multiset xs) + size (tree_to_multiset x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. size (queue_to_multiset (xs @ [x])) = size (queue_to_multiset xs) + size (tree_to_multiset x)
[PROOF STEP]
by (simp add: size_queue_sum_list)
[PROOF STATE]
proof (state)
this:
size (queue_to_multiset (xs @ [x])) = size (queue_to_multiset xs) + size (tree_to_multiset x)

goal (1 subgoal):
 1. \<And>x xs. \<lbrakk>invar xs \<Longrightarrow> 2 ^ length xs - 1 \<le> size (queue_to_multiset xs); invar (xs @ [x])\<rbrakk> \<Longrightarrow> 2 ^ length (xs @ [x]) - 1 \<le> size (queue_to_multiset (xs @ [x]))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
size (queue_to_multiset (xs @ [x])) = size (queue_to_multiset xs) + size (tree_to_multiset x)

goal (1 subgoal):
 1. \<And>x xs. \<lbrakk>invar xs \<Longrightarrow> 2 ^ length xs - 1 \<le> size (queue_to_multiset xs); invar (xs @ [x])\<rbrakk> \<Longrightarrow> 2 ^ length (xs @ [x]) - 1 \<le> size (queue_to_multiset (xs @ [x]))
[PROOF STEP]
from snoc.prems
[PROOF STATE]
proof (chain)
picking this:
invar (xs @ [x])
[PROOF STEP]
have inv_x: "tree_invar x"
[PROOF STATE]
proof (prove)
using this:
invar (xs @ [x])

goal (1 subgoal):
 1. tree_invar x
[PROOF STEP]
by (simp add: invar_def)
[PROOF STATE]
proof (state)
this:
tree_invar x

goal (1 subgoal):
 1. \<And>x xs. \<lbrakk>invar xs \<Longrightarrow> 2 ^ length xs - 1 \<le> size (queue_to_multiset xs); invar (xs @ [x])\<rbrakk> \<Longrightarrow> 2 ^ length (xs @ [x]) - 1 \<le> size (queue_to_multiset (xs @ [x]))
[PROOF STEP]
hence "size (tree_to_multiset x) = 2 ^ rank x"
[PROOF STATE]
proof (prove)
using this:
tree_invar x

goal (1 subgoal):
 1. size (tree_to_multiset x) = 2 ^ rank x
[PROOF STEP]
by (simp add: size_mset_tree)
[PROOF STATE]
proof (state)
this:
size (tree_to_multiset x) = 2 ^ rank x

goal (1 subgoal):
 1. \<And>x xs. \<lbrakk>invar xs \<Longrightarrow> 2 ^ length xs - 1 \<le> size (queue_to_multiset xs); invar (xs @ [x])\<rbrakk> \<Longrightarrow> 2 ^ length (xs @ [x]) - 1 \<le> size (queue_to_multiset (xs @ [x]))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
size (queue_to_multiset (xs @ [x])) = size (queue_to_multiset xs) + 2 ^ rank x
[PROOF STEP]
have
    eq: "size (queue_to_multiset (xs @ [x])) =
         size (queue_to_multiset xs) + (2::nat)^(rank x)"
[PROOF STATE]
proof (prove)
using this:
size (queue_to_multiset (xs @ [x])) = size (queue_to_multiset xs) + 2 ^ rank x

goal (1 subgoal):
 1. size (queue_to_multiset (xs @ [x])) = size (queue_to_multiset xs) + 2 ^ rank x
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
size (queue_to_multiset (xs @ [x])) = size (queue_to_multiset xs) + 2 ^ rank x

goal (1 subgoal):
 1. \<And>x xs. \<lbrakk>invar xs \<Longrightarrow> 2 ^ length xs - 1 \<le> size (queue_to_multiset xs); invar (xs @ [x])\<rbrakk> \<Longrightarrow> 2 ^ length (xs @ [x]) - 1 \<le> size (queue_to_multiset (xs @ [x]))
[PROOF STEP]
from invar_length[OF snoc.prems]
[PROOF STATE]
proof (chain)
picking this:
length (xs @ [x]) \<le> Suc (rank (last (xs @ [x])))
[PROOF STEP]
have "length xs \<le> rank x"
[PROOF STATE]
proof (prove)
using this:
length (xs @ [x]) \<le> Suc (rank (last (xs @ [x])))

goal (1 subgoal):
 1. length xs \<le> rank x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
length xs \<le> rank x

goal (1 subgoal):
 1. \<And>x xs. \<lbrakk>invar xs \<Longrightarrow> 2 ^ length xs - 1 \<le> size (queue_to_multiset xs); invar (xs @ [x])\<rbrakk> \<Longrightarrow> 2 ^ length (xs @ [x]) - 1 \<le> size (queue_to_multiset (xs @ [x]))
[PROOF STEP]
hence snd: "(2::nat) ^ length xs \<le> (2::nat) ^ rank x"
[PROOF STATE]
proof (prove)
using this:
length xs \<le> rank x

goal (1 subgoal):
 1. 2 ^ length xs \<le> 2 ^ rank x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 ^ length xs \<le> 2 ^ rank x

goal (1 subgoal):
 1. \<And>x xs. \<lbrakk>invar xs \<Longrightarrow> 2 ^ length xs - 1 \<le> size (queue_to_multiset xs); invar (xs @ [x])\<rbrakk> \<Longrightarrow> 2 ^ length (xs @ [x]) - 1 \<le> size (queue_to_multiset (xs @ [x]))
[PROOF STEP]
have
    "(2::nat) ^ length (xs @ [x]) = (2::nat) ^ (length xs) + (2::nat) ^ (length xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 ^ length (xs @ [x]) = 2 ^ length xs + 2 ^ length xs
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 ^ length (xs @ [x]) = 2 ^ length xs + 2 ^ length xs

goal (1 subgoal):
 1. \<And>x xs. \<lbrakk>invar xs \<Longrightarrow> 2 ^ length xs - 1 \<le> size (queue_to_multiset xs); invar (xs @ [x])\<rbrakk> \<Longrightarrow> 2 ^ length (xs @ [x]) - 1 \<le> size (queue_to_multiset (xs @ [x]))
[PROOF STEP]
with IH
[PROOF STATE]
proof (chain)
picking this:
2 ^ length xs \<le> Suc (size (queue_to_multiset xs))
2 ^ length (xs @ [x]) = 2 ^ length xs + 2 ^ length xs
[PROOF STEP]
have
    "2 ^ length (xs @ [x]) \<le> Suc (size (queue_to_multiset xs)) + 2 ^ length xs"
[PROOF STATE]
proof (prove)
using this:
2 ^ length xs \<le> Suc (size (queue_to_multiset xs))
2 ^ length (xs @ [x]) = 2 ^ length xs + 2 ^ length xs

goal (1 subgoal):
 1. 2 ^ length (xs @ [x]) \<le> Suc (size (queue_to_multiset xs)) + 2 ^ length xs
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 ^ length (xs @ [x]) \<le> Suc (size (queue_to_multiset xs)) + 2 ^ length xs

goal (1 subgoal):
 1. \<And>x xs. \<lbrakk>invar xs \<Longrightarrow> 2 ^ length xs - 1 \<le> size (queue_to_multiset xs); invar (xs @ [x])\<rbrakk> \<Longrightarrow> 2 ^ length (xs @ [x]) - 1 \<le> size (queue_to_multiset (xs @ [x]))
[PROOF STEP]
with snd
[PROOF STATE]
proof (chain)
picking this:
2 ^ length xs \<le> 2 ^ rank x
2 ^ length (xs @ [x]) \<le> Suc (size (queue_to_multiset xs)) + 2 ^ length xs
[PROOF STEP]
have "2 ^ length (xs @ [x]) \<le>
    Suc (size (queue_to_multiset xs)) + 2 ^ rank x"
[PROOF STATE]
proof (prove)
using this:
2 ^ length xs \<le> 2 ^ rank x
2 ^ length (xs @ [x]) \<le> Suc (size (queue_to_multiset xs)) + 2 ^ length xs

goal (1 subgoal):
 1. 2 ^ length (xs @ [x]) \<le> Suc (size (queue_to_multiset xs)) + 2 ^ rank x
[PROOF STEP]
by arith
[PROOF STATE]
proof (state)
this:
2 ^ length (xs @ [x]) \<le> Suc (size (queue_to_multiset xs)) + 2 ^ rank x

goal (1 subgoal):
 1. \<And>x xs. \<lbrakk>invar xs \<Longrightarrow> 2 ^ length xs - 1 \<le> size (queue_to_multiset xs); invar (xs @ [x])\<rbrakk> \<Longrightarrow> 2 ^ length (xs @ [x]) - 1 \<le> size (queue_to_multiset (xs @ [x]))
[PROOF STEP]
with eq
[PROOF STATE]
proof (chain)
picking this:
size (queue_to_multiset (xs @ [x])) = size (queue_to_multiset xs) + 2 ^ rank x
2 ^ length (xs @ [x]) \<le> Suc (size (queue_to_multiset xs)) + 2 ^ rank x
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
size (queue_to_multiset (xs @ [x])) = size (queue_to_multiset xs) + 2 ^ rank x
2 ^ length (xs @ [x]) \<le> Suc (size (queue_to_multiset xs)) + 2 ^ rank x

goal (1 subgoal):
 1. 2 ^ length (xs @ [x]) - 1 \<le> size (queue_to_multiset (xs @ [x]))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 ^ length (xs @ [x]) - 1 \<le> size (queue_to_multiset (xs @ [x]))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma integrable_on_indicator:
  fixes S :: "'a::euclidean_space set"
  shows "indicat_real S integrable_on T \<longleftrightarrow> (S \<inter> T) \<in> lmeasurable"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (indicat_real S integrable_on T) = (S \<inter> T \<in> lmeasurable)
[PROOF STEP]
unfolding measurable_integrable
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (indicat_real S integrable_on T) = (indicat_real (S \<inter> T) integrable_on UNIV)
[PROOF STEP]
unfolding integrable_restrict_UNIV [of T, symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. if x \<in> T then indicat_real S x else 0) integrable_on UNIV) = (indicat_real (S \<inter> T) integrable_on UNIV)
[PROOF STEP]
by (fastforce simp add: indicator_def elim: integrable_eq)


[STATEMENT]
lemma make_mono_less:
"\<forall>n. f n < oLimit f \<Longrightarrow> make_mono f n < make_mono f (Suc n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>n. f n < oLimit f \<Longrightarrow> make_mono f n < make_mono f (Suc n)
[PROOF STEP]
apply (frule_tac n=n in f_make_mono_less)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>n. f n < oLimit f; f (make_mono f n) < f (make_mono f (Suc n))\<rbrakk> \<Longrightarrow> make_mono f n < make_mono f (Suc n)
[PROOF STEP]
apply (rule ccontr, simp only: linorder_not_less)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>n. f n < oLimit f; f (make_mono f n) < f (make_mono f (Suc n)); make_mono f (Suc n) \<le> make_mono f n\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
apply (drule le_f_make_mono, assumption)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f (make_mono f n) < f (make_mono f (Suc n)); make_mono f (Suc n) \<le> make_mono f n; f (make_mono f (Suc n)) \<le> f (make_mono f n)\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
apply (simp add: linorder_not_less[symmetric])
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma vec_le_iff_diff_le_0: fixes a :: "'a :: ordered_ab_group_add vec"
  shows "(a \<le> b) = (a - b \<le> 0\<^sub>v (dim_vec a))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a \<le> b) = (a - b \<le> 0\<^sub>v (dim_vec a))
[PROOF STEP]
unfolding less_eq_vec_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (dim_vec a = dim_vec b \<and> (\<forall>i<dim_vec b. a $ i \<le> b $ i)) = (dim_vec (a - b) = dim_vec (0\<^sub>v (dim_vec a)) \<and> (\<forall>i<dim_vec (0\<^sub>v (dim_vec a)). (a - b) $ i \<le> 0\<^sub>v (dim_vec a) $ i))
[PROOF STEP]
by auto


[STATEMENT]
lemma tensor_mat_mult_vec:
  assumes "m1 \<in> carrier_mat d1 d1"
    and "m2 \<in> carrier_mat d2 d2"
    and "v1 \<in> carrier_vec d1"
    and "v2 \<in> carrier_vec d2"
  shows "tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) = tensor_mat m1 m2 *\<^sub>v tensor_vec v1 v2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) = tensor_mat m1 m2 *\<^sub>v tensor_vec v1 v2
[PROOF STEP]
proof (rule eq_vecI, auto)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < d \<Longrightarrow> tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) $ i = row (tensor_mat m1 m2) i \<bullet> tensor_vec v1 v2
[PROOF STEP]
fix i j :: nat
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < d \<Longrightarrow> tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) $ i = row (tensor_mat m1 m2) i \<bullet> tensor_vec v1 v2
[PROOF STEP]
assume i: "i < d"
[PROOF STATE]
proof (state)
this:
i < d

goal (1 subgoal):
 1. \<And>i. i < d \<Longrightarrow> tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) $ i = row (tensor_mat m1 m2) i \<bullet> tensor_vec v1 v2
[PROOF STEP]
let ?i1 = "encode1 i" and ?i2 = "encode2 i"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < d \<Longrightarrow> tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) $ i = row (tensor_mat m1 m2) i \<bullet> tensor_vec v1 v2
[PROOF STEP]
have "tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) $ i = (m1 *\<^sub>v v1) $ ?i1 * (m2 *\<^sub>v v2) $ ?i2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) $ i = (m1 *\<^sub>v v1) $ encode1 i * (m2 *\<^sub>v v2) $ encode2 i
[PROOF STEP]
using i
[PROOF STATE]
proof (prove)
using this:
i < d

goal (1 subgoal):
 1. tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) $ i = (m1 *\<^sub>v v1) $ encode1 i * (m2 *\<^sub>v v2) $ encode2 i
[PROOF STEP]
by (simp add: tensor_vec_eval)
[PROOF STATE]
proof (state)
this:
tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) $ i = (m1 *\<^sub>v v1) $ encode1 i * (m2 *\<^sub>v v2) $ encode2 i

goal (1 subgoal):
 1. \<And>i. i < d \<Longrightarrow> tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) $ i = row (tensor_mat m1 m2) i \<bullet> tensor_vec v1 v2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) $ i = (m1 *\<^sub>v v1) $ encode1 i * (m2 *\<^sub>v v2) $ encode2 i

goal (1 subgoal):
 1. \<And>i. i < d \<Longrightarrow> tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) $ i = row (tensor_mat m1 m2) i \<bullet> tensor_vec v1 v2
[PROOF STEP]
have "\<dots> = (row m1 ?i1 \<bullet> v1) * (row m2 ?i2 \<bullet> v2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (m1 *\<^sub>v v1) $ encode1 i * (m2 *\<^sub>v v2) $ encode2 i = row m1 (encode1 i) \<bullet> v1 * (row m2 (encode2 i) \<bullet> v2)
[PROOF STEP]
using assms i
[PROOF STATE]
proof (prove)
using this:
m1 \<in> carrier_mat d1 d1
m2 \<in> carrier_mat d2 d2
v1 \<in> carrier_vec d1
v2 \<in> carrier_vec d2
i < d

goal (1 subgoal):
 1. (m1 *\<^sub>v v1) $ encode1 i * (m2 *\<^sub>v v2) $ encode2 i = row m1 (encode1 i) \<bullet> v1 * (row m2 (encode2 i) \<bullet> v2)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(m1 *\<^sub>v v1) $ encode1 i * (m2 *\<^sub>v v2) $ encode2 i = row m1 (encode1 i) \<bullet> v1 * (row m2 (encode2 i) \<bullet> v2)

goal (1 subgoal):
 1. \<And>i. i < d \<Longrightarrow> tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) $ i = row (tensor_mat m1 m2) i \<bullet> tensor_vec v1 v2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(m1 *\<^sub>v v1) $ encode1 i * (m2 *\<^sub>v v2) $ encode2 i = row m1 (encode1 i) \<bullet> v1 * (row m2 (encode2 i) \<bullet> v2)

goal (1 subgoal):
 1. \<And>i. i < d \<Longrightarrow> tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) $ i = row (tensor_mat m1 m2) i \<bullet> tensor_vec v1 v2
[PROOF STEP]
have "\<dots> = (\<Sum>i = 0..<d1. m1 $$ (?i1, i) * v1 $ i) * (\<Sum>j = 0..<d2. m2 $$ (?i2, j) * v2 $ j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. row m1 (encode1 i) \<bullet> v1 * (row m2 (encode2 i) \<bullet> v2) = (\<Sum>ia = 0..<d1. m1 $$ (encode1 i, ia) * v1 $ ia) * (\<Sum>j = 0..<d2. m2 $$ (encode2 i, j) * v2 $ j)
[PROOF STEP]
using assms i
[PROOF STATE]
proof (prove)
using this:
m1 \<in> carrier_mat d1 d1
m2 \<in> carrier_mat d2 d2
v1 \<in> carrier_vec d1
v2 \<in> carrier_vec d2
i < d

goal (1 subgoal):
 1. row m1 (encode1 i) \<bullet> v1 * (row m2 (encode2 i) \<bullet> v2) = (\<Sum>ia = 0..<d1. m1 $$ (encode1 i, ia) * v1 $ ia) * (\<Sum>j = 0..<d2. m2 $$ (encode2 i, j) * v2 $ j)
[PROOF STEP]
by (simp add: scalar_prod_def)
[PROOF STATE]
proof (state)
this:
row m1 (encode1 i) \<bullet> v1 * (row m2 (encode2 i) \<bullet> v2) = (\<Sum>ia = 0..<d1. m1 $$ (encode1 i, ia) * v1 $ ia) * (\<Sum>j = 0..<d2. m2 $$ (encode2 i, j) * v2 $ j)

goal (1 subgoal):
 1. \<And>i. i < d \<Longrightarrow> tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) $ i = row (tensor_mat m1 m2) i \<bullet> tensor_vec v1 v2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
row m1 (encode1 i) \<bullet> v1 * (row m2 (encode2 i) \<bullet> v2) = (\<Sum>ia = 0..<d1. m1 $$ (encode1 i, ia) * v1 $ ia) * (\<Sum>j = 0..<d2. m2 $$ (encode2 i, j) * v2 $ j)

goal (1 subgoal):
 1. \<And>i. i < d \<Longrightarrow> tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) $ i = row (tensor_mat m1 m2) i \<bullet> tensor_vec v1 v2
[PROOF STEP]
have "\<dots> = (\<Sum>i = 0..<d1. \<Sum>j = 0..<d2. (m1 $$ (?i1, i) * v1 $ i) * (m2 $$ (?i2, j) * v2 $ j))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia = 0..<d1. m1 $$ (encode1 i, ia) * v1 $ ia) * (\<Sum>j = 0..<d2. m2 $$ (encode2 i, j) * v2 $ j) = (\<Sum>ia = 0..<d1. \<Sum>j = 0..<d2. m1 $$ (encode1 i, ia) * v1 $ ia * (m2 $$ (encode2 i, j) * v2 $ j))
[PROOF STEP]
by (rule Groups_Big.sum_product)
[PROOF STATE]
proof (state)
this:
(\<Sum>ia = 0..<d1. m1 $$ (encode1 i, ia) * v1 $ ia) * (\<Sum>j = 0..<d2. m2 $$ (encode2 i, j) * v2 $ j) = (\<Sum>ia = 0..<d1. \<Sum>j = 0..<d2. m1 $$ (encode1 i, ia) * v1 $ ia * (m2 $$ (encode2 i, j) * v2 $ j))

goal (1 subgoal):
 1. \<And>i. i < d \<Longrightarrow> tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) $ i = row (tensor_mat m1 m2) i \<bullet> tensor_vec v1 v2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ia = 0..<d1. m1 $$ (encode1 i, ia) * v1 $ ia) * (\<Sum>j = 0..<d2. m2 $$ (encode2 i, j) * v2 $ j) = (\<Sum>ia = 0..<d1. \<Sum>j = 0..<d2. m1 $$ (encode1 i, ia) * v1 $ ia * (m2 $$ (encode2 i, j) * v2 $ j))

goal (1 subgoal):
 1. \<And>i. i < d \<Longrightarrow> tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) $ i = row (tensor_mat m1 m2) i \<bullet> tensor_vec v1 v2
[PROOF STEP]
have "\<dots> = (\<Sum>i = 0..<d. (m1 $$ (?i1, encode1 i) * v1 $ (encode1 i)) * (m2 $$ (?i2, encode2 i) * v2 $ (encode2 i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia = 0..<d1. \<Sum>j = 0..<d2. m1 $$ (encode1 i, ia) * v1 $ ia * (m2 $$ (encode2 i, j) * v2 $ j)) = (\<Sum>ia = 0..<d. m1 $$ (encode1 i, encode1 ia) * v1 $ encode1 ia * (m2 $$ (encode2 i, encode2 ia) * v2 $ encode2 ia))
[PROOF STEP]
by (rule sum_encode)
[PROOF STATE]
proof (state)
this:
(\<Sum>ia = 0..<d1. \<Sum>j = 0..<d2. m1 $$ (encode1 i, ia) * v1 $ ia * (m2 $$ (encode2 i, j) * v2 $ j)) = (\<Sum>ia = 0..<d. m1 $$ (encode1 i, encode1 ia) * v1 $ encode1 ia * (m2 $$ (encode2 i, encode2 ia) * v2 $ encode2 ia))

goal (1 subgoal):
 1. \<And>i. i < d \<Longrightarrow> tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) $ i = row (tensor_mat m1 m2) i \<bullet> tensor_vec v1 v2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ia = 0..<d1. \<Sum>j = 0..<d2. m1 $$ (encode1 i, ia) * v1 $ ia * (m2 $$ (encode2 i, j) * v2 $ j)) = (\<Sum>ia = 0..<d. m1 $$ (encode1 i, encode1 ia) * v1 $ encode1 ia * (m2 $$ (encode2 i, encode2 ia) * v2 $ encode2 ia))

goal (1 subgoal):
 1. \<And>i. i < d \<Longrightarrow> tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) $ i = row (tensor_mat m1 m2) i \<bullet> tensor_vec v1 v2
[PROOF STEP]
have "\<dots> = row (tensor_mat m1 m2) i \<bullet> tensor_vec v1 v2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia = 0..<d. m1 $$ (encode1 i, encode1 ia) * v1 $ encode1 ia * (m2 $$ (encode2 i, encode2 ia) * v2 $ encode2 ia)) = row (tensor_mat m1 m2) i \<bullet> tensor_vec v1 v2
[PROOF STEP]
apply (simp add: scalar_prod_def tensor_mat_eval tensor_vec_eval i)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia = 0..<d. m1 $$ (encode1 i, encode1 ia) * v1 $ encode1 ia * (m2 $$ (encode2 i, encode2 ia) * v2 $ encode2 ia)) = (\<Sum>ia = 0..<d. m1 $$ (encode1 i, encode1 ia) * m2 $$ (encode2 i, encode2 ia) * (v1 $ encode1 ia * v2 $ encode2 ia))
[PROOF STEP]
by (rule sum.cong, auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>ia = 0..<d. m1 $$ (encode1 i, encode1 ia) * v1 $ encode1 ia * (m2 $$ (encode2 i, encode2 ia) * v2 $ encode2 ia)) = row (tensor_mat m1 m2) i \<bullet> tensor_vec v1 v2

goal (1 subgoal):
 1. \<And>i. i < d \<Longrightarrow> tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) $ i = row (tensor_mat m1 m2) i \<bullet> tensor_vec v1 v2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) $ i = row (tensor_mat m1 m2) i \<bullet> tensor_vec v1 v2
[PROOF STEP]
show "tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) $ i = row (tensor_mat m1 m2) i \<bullet> tensor_vec v1 v2"
[PROOF STATE]
proof (prove)
using this:
tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) $ i = row (tensor_mat m1 m2) i \<bullet> tensor_vec v1 v2

goal (1 subgoal):
 1. tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) $ i = row (tensor_mat m1 m2) i \<bullet> tensor_vec v1 v2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
tensor_vec (m1 *\<^sub>v v1) (m2 *\<^sub>v v2) $ i = row (tensor_mat m1 m2) i \<bullet> tensor_vec v1 v2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma num_leaves_ge_card: "num_leaves (Node r xs) \<ge> fcard xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fcard xs \<le> num_leaves (Node r xs)
[PROOF STEP]
proof(cases "xs = {||}")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. xs = {||} \<Longrightarrow> fcard xs \<le> num_leaves (Node r xs)
 2. xs \<noteq> {||} \<Longrightarrow> fcard xs \<le> num_leaves (Node r xs)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
xs \<noteq> {||}

goal (2 subgoals):
 1. xs = {||} \<Longrightarrow> fcard xs \<le> num_leaves (Node r xs)
 2. xs \<noteq> {||} \<Longrightarrow> fcard xs \<le> num_leaves (Node r xs)
[PROOF STEP]
have "fcard xs = (\<Sum>x\<in> fset xs. 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fcard xs = (\<Sum>x\<in>fset xs. 1)
[PROOF STEP]
using fcard.rep_eq
[PROOF STATE]
proof (prove)
using this:
fcard ?x = card (fset ?x)

goal (1 subgoal):
 1. fcard xs = (\<Sum>x\<in>fset xs. 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
fcard xs = (\<Sum>x\<in>fset xs. 1)

goal (2 subgoals):
 1. xs = {||} \<Longrightarrow> fcard xs \<le> num_leaves (Node r xs)
 2. xs \<noteq> {||} \<Longrightarrow> fcard xs \<le> num_leaves (Node r xs)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
fcard xs = (\<Sum>x\<in>fset xs. 1)

goal (2 subgoals):
 1. xs = {||} \<Longrightarrow> fcard xs \<le> num_leaves (Node r xs)
 2. xs \<noteq> {||} \<Longrightarrow> fcard xs \<le> num_leaves (Node r xs)
[PROOF STEP]
have "\<dots> \<le> (\<Sum>x\<in> fset xs. num_leaves (fst x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>fset xs. 1) \<le> (\<Sum>x\<in>fset xs. num_leaves (fst x))
[PROOF STEP]
using num_leaves_ge1 sum_mono
[PROOF STATE]
proof (prove)
using this:
1 \<le> num_leaves ?t
(\<And>i. i \<in> ?K \<Longrightarrow> ?f i \<le> ?g i) \<Longrightarrow> sum ?f ?K \<le> sum ?g ?K

goal (1 subgoal):
 1. (\<Sum>x\<in>fset xs. 1) \<le> (\<Sum>x\<in>fset xs. num_leaves (fst x))
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>fset xs. 1) \<le> (\<Sum>x\<in>fset xs. num_leaves (fst x))

goal (2 subgoals):
 1. xs = {||} \<Longrightarrow> fcard xs \<le> num_leaves (Node r xs)
 2. xs \<noteq> {||} \<Longrightarrow> fcard xs \<le> num_leaves (Node r xs)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
fcard xs \<le> (\<Sum>x\<in>fset xs. num_leaves (fst x))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
fcard xs \<le> (\<Sum>x\<in>fset xs. num_leaves (fst x))

goal (1 subgoal):
 1. fcard xs \<le> num_leaves (Node r xs)
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
fcard xs \<le> (\<Sum>x\<in>fset xs. num_leaves (fst x))
xs \<noteq> {||}

goal (1 subgoal):
 1. fcard xs \<le> num_leaves (Node r xs)
[PROOF STEP]
by (simp add: fst_def prod.case_distrib)
[PROOF STATE]
proof (state)
this:
fcard xs \<le> num_leaves (Node r xs)

goal (1 subgoal):
 1. xs = {||} \<Longrightarrow> fcard xs \<le> num_leaves (Node r xs)
[PROOF STEP]
qed (simp add: fcard_fempty)


[STATEMENT]
lemma lm022:
  assumes "finite X" "mx \<in> X" "\<forall>x \<in> X-{mx}. f x < f mx"
  shows "argmax f X = {mx}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. argmax f X = {mx}
[PROOF STEP]
using assms lm021
[PROOF STATE]
proof (prove)
using this:
finite X
mx \<in> X
\<forall>x\<in>X - {mx}. f x < f mx
\<lbrakk>finite ?X; ?mx \<in> ?X; \<forall>x\<in>?X - {?mx}. ?f x < ?f ?mx\<rbrakk> \<Longrightarrow> argmax ?f ?X \<subseteq> {?mx}

goal (1 subgoal):
 1. argmax f X = {mx}
[PROOF STEP]
by (metis argmax_non_empty_iff equals0D subset_singletonD)