[STATEMENT]
lemma (in vec_space) rank_ge_card_indpt:
assumes "A \<in> carrier_mat n nc"
assumes "U \<subseteq> set (cols A)"
assumes "lin_indpt U"
shows "rank A \<ge> card U"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card U \<le> rank A
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card U \<le> rank A
[PROOF STEP]
obtain S where "maximal S (\<lambda>T. T \<subseteq> set (cols A) \<and> lin_indpt T)" "U\<subseteq>S" "finite S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>S. \<lbrakk>maximal S (\<lambda>T. T \<subseteq> set (cols A) \<and> lin_indpt T); U \<subseteq> S; finite S\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using maximal_exists_superset[of "set (cols A)" "(\<lambda>T. T \<subseteq> set (cols A) \<and> lin_indpt T)" U]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>finite (set (cols A)); \<And>Aa. Aa \<subseteq> set (cols A) \<and> lin_indpt Aa \<Longrightarrow> Aa \<subseteq> set (cols A); U \<subseteq> set (cols A) \<and> lin_indpt U\<rbrakk> \<Longrightarrow> \<exists>Aa. finite Aa \<and> maximal Aa (\<lambda>T. T \<subseteq> set (cols A) \<and> lin_indpt T) \<and> U \<subseteq> Aa

goal (1 subgoal):
 1. (\<And>S. \<lbrakk>maximal S (\<lambda>T. T \<subseteq> set (cols A) \<and> lin_indpt T); U \<subseteq> S; finite S\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using List.finite_set assms(2) assms(3) maximal_exists_superset
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>finite (set (cols A)); \<And>Aa. Aa \<subseteq> set (cols A) \<and> lin_indpt Aa \<Longrightarrow> Aa \<subseteq> set (cols A); U \<subseteq> set (cols A) \<and> lin_indpt U\<rbrakk> \<Longrightarrow> \<exists>Aa. finite Aa \<and> maximal Aa (\<lambda>T. T \<subseteq> set (cols A) \<and> lin_indpt T) \<and> U \<subseteq> Aa
finite (set ?xs)
U \<subseteq> set (cols A)
lin_indpt U
\<lbrakk>finite ?S; \<And>A. ?P A \<Longrightarrow> A \<subseteq> ?S; ?P ?B\<rbrakk> \<Longrightarrow> \<exists>A. finite A \<and> maximal A ?P \<and> ?B \<subseteq> A

goal (1 subgoal):
 1. (\<And>S. \<lbrakk>maximal S (\<lambda>T. T \<subseteq> set (cols A) \<and> lin_indpt T); U \<subseteq> S; finite S\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
maximal S (\<lambda>T. T \<subseteq> set (cols A) \<and> lin_indpt T)
U \<subseteq> S
finite S

goal (1 subgoal):
 1. card U \<le> rank A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
maximal S (\<lambda>T. T \<subseteq> set (cols A) \<and> lin_indpt T)
U \<subseteq> S
finite S
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
maximal S (\<lambda>T. T \<subseteq> set (cols A) \<and> lin_indpt T)
U \<subseteq> S
finite S

goal (1 subgoal):
 1. card U \<le> rank A
[PROOF STEP]
unfolding rank_card_indpt[OF \<open>A \<in> carrier_mat n nc\<close> \<open>maximal S (\<lambda>T. T \<subseteq> set (cols A) \<and> lin_indpt T)\<close>]
[PROOF STATE]
proof (prove)
using this:
maximal S (\<lambda>T. T \<subseteq> set (cols A) \<and> lin_indpt T)
U \<subseteq> S
finite S

goal (1 subgoal):
 1. card U \<le> card S
[PROOF STEP]
using card_mono
[PROOF STATE]
proof (prove)
using this:
maximal S (\<lambda>T. T \<subseteq> set (cols A) \<and> lin_indpt T)
U \<subseteq> S
finite S
\<lbrakk>finite ?B; ?A \<subseteq> ?B\<rbrakk> \<Longrightarrow> card ?A \<le> card ?B

goal (1 subgoal):
 1. card U \<le> card S
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
card U \<le> rank A

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma power_swap: "((\<^bold>g [^] (\<alpha>0::nat)) [^] (r::nat)) = ((\<^bold>g [^] r) [^] \<alpha>0)"
(is "?lhs = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<^bold>g [^] \<alpha>0) [^] r = (\<^bold>g [^] r) [^] \<alpha>0
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<^bold>g [^] \<alpha>0) [^] r = (\<^bold>g [^] r) [^] \<alpha>0
[PROOF STEP]
have "?lhs = \<^bold>g [^] (\<alpha>0 * r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<^bold>g [^] \<alpha>0) [^] r = \<^bold>g [^] (\<alpha>0 * r)
[PROOF STEP]
using nat_pow_pow mult.commute
[PROOF STATE]
proof (prove)
using this:
?x \<in> carrier G \<Longrightarrow> (?x [^] ?n) [^] ?m = ?x [^] (?n * ?m)
?a * ?b = ?b * ?a

goal (1 subgoal):
 1. (\<^bold>g [^] \<alpha>0) [^] r = \<^bold>g [^] (\<alpha>0 * r)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<^bold>g [^] \<alpha>0) [^] r = \<^bold>g [^] (\<alpha>0 * r)

goal (1 subgoal):
 1. (\<^bold>g [^] \<alpha>0) [^] r = (\<^bold>g [^] r) [^] \<alpha>0
[PROOF STEP]
hence "... = \<^bold>g [^] (r * \<alpha>0)"
[PROOF STATE]
proof (prove)
using this:
(\<^bold>g [^] \<alpha>0) [^] r = \<^bold>g [^] (\<alpha>0 * r)

goal (1 subgoal):
 1. \<^bold>g [^] (\<alpha>0 * r) = \<^bold>g [^] (r * \<alpha>0)
[PROOF STEP]
by(metis mult.commute)
[PROOF STATE]
proof (state)
this:
\<^bold>g [^] (\<alpha>0 * r) = \<^bold>g [^] (r * \<alpha>0)

goal (1 subgoal):
 1. (\<^bold>g [^] \<alpha>0) [^] r = (\<^bold>g [^] r) [^] \<alpha>0
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<^bold>g [^] (\<alpha>0 * r) = \<^bold>g [^] (r * \<alpha>0)

goal (1 subgoal):
 1. (\<^bold>g [^] \<alpha>0) [^] r = (\<^bold>g [^] r) [^] \<alpha>0
[PROOF STEP]
using nat_pow_pow
[PROOF STATE]
proof (prove)
using this:
\<^bold>g [^] (\<alpha>0 * r) = \<^bold>g [^] (r * \<alpha>0)
?x \<in> carrier G \<Longrightarrow> (?x [^] ?n) [^] ?m = ?x [^] (?n * ?m)

goal (1 subgoal):
 1. (\<^bold>g [^] \<alpha>0) [^] r = (\<^bold>g [^] r) [^] \<alpha>0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<^bold>g [^] \<alpha>0) [^] r = (\<^bold>g [^] r) [^] \<alpha>0

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma [code abstract]: "vec_nth (columnvector v) = columnvector_row v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ($) (columnvector v) = columnvector_row v
[PROOF STEP]
unfolding columnvector_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ($) (\<chi>i j. v $ i) = columnvector_row v
[PROOF STEP]
unfolding columnvector_row_def[abs_def]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ($) (\<chi>i j. v $ i) = (\<lambda>i. \<chi>j. v $ i)
[PROOF STEP]
by auto


[STATEMENT]
lemma real_le_inf_subset: "t \<noteq> {} \<Longrightarrow> t \<subseteq> s \<Longrightarrow> \<exists>b. b <=* s \<Longrightarrow> Inf s \<le> Inf (t::real set)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>t \<noteq> {}; t \<subseteq> s; \<exists>b. b <=* s\<rbrakk> \<Longrightarrow> Inf s \<le> Inf t
[PROOF STEP]
by (rule cInf_superset_mono) (auto simp: bdd_below_setge)


[STATEMENT]
lemma path_image_linear_image: "linear f \<Longrightarrow> path_image(f \<circ> g) = f ` (path_image g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. linear f \<Longrightarrow> path_image (f \<circ> g) = f ` path_image g
[PROOF STEP]
by (simp add: image_comp path_image_def)


[STATEMENT]
lemma d_nom_i_nom: "1 - $d^{m}/m = 1 / (1 + $i^{m}/m)" if "m \<noteq> 0" for m::nat
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 - $d^{m} / real m = 1 / (1 + $i^{m} / real m)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 1 - $d^{m} / real m = 1 / (1 + $i^{m} / real m)
[PROOF STEP]
have "1 - $d^{m}/m = 1 - ($i^{m}/m) / (1 + $i^{m}/m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 - $d^{m} / real m = 1 - $i^{m} / real m / (1 + $i^{m} / real m)
[PROOF STEP]
by (simp add: d_nom_def)
[PROOF STATE]
proof (state)
this:
1 - $d^{m} / real m = 1 - $i^{m} / real m / (1 + $i^{m} / real m)

goal (1 subgoal):
 1. 1 - $d^{m} / real m = 1 / (1 + $i^{m} / real m)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 - $d^{m} / real m = 1 - $i^{m} / real m / (1 + $i^{m} / real m)

goal (1 subgoal):
 1. 1 - $d^{m} / real m = 1 / (1 + $i^{m} / real m)
[PROOF STEP]
have "\<dots> = 1 / (1 + $i^{m}/m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 - $i^{m} / real m / (1 + $i^{m} / real m) = 1 / (1 + $i^{m} / real m)
[PROOF STEP]
using v_futr_m_pos
[PROOF STATE]
proof (prove)
using this:
?m \<noteq> 0 \<Longrightarrow> 0 < 1 + $i^{?m} / real ?m

goal (1 subgoal):
 1. 1 - $i^{m} / real m / (1 + $i^{m} / real m) = 1 / (1 + $i^{m} / real m)
[PROOF STEP]
by (smt (verit, ccfv_SIG) add_divide_distrib that div_self)
[PROOF STATE]
proof (state)
this:
1 - $i^{m} / real m / (1 + $i^{m} / real m) = 1 / (1 + $i^{m} / real m)

goal (1 subgoal):
 1. 1 - $d^{m} / real m = 1 / (1 + $i^{m} / real m)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
1 - $d^{m} / real m = 1 / (1 + $i^{m} / real m)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
1 - $d^{m} / real m = 1 / (1 + $i^{m} / real m)

goal (1 subgoal):
 1. 1 - $d^{m} / real m = 1 / (1 + $i^{m} / real m)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
1 - $d^{m} / real m = 1 / (1 + $i^{m} / real m)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma linord_of_listP_empty:
  shows "(\<forall>x y. \<not>linord_of_listP x y xs) \<longleftrightarrow> xs = []"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x y. \<not> linord_of_listP x y xs) = (xs = [])
[PROOF STEP]
by (metis linord_of_listP.simps list.exhaust list.set_intros(1))


[STATEMENT]
lemma \<pi>_upper_bound_aux:
  fixes c :: real
  assumes "c > 0"
  defines "f \<equiv> (\<lambda>x. x powr (-c) * ln x)"
  assumes x: "x > 0"
  shows "f x \<le> 1 / (c * exp 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f x \<le> 1 / (c * exp 1)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. f x \<le> 1 / (c * exp 1)
[PROOF STEP]
define f' where "f' = (\<lambda>x. x powr (-c - 1) * (1 - c * ln x))"
[PROOF STATE]
proof (state)
this:
f' = (\<lambda>x. x powr (- c - 1) * (1 - c * ln x))

goal (1 subgoal):
 1. f x \<le> 1 / (c * exp 1)
[PROOF STEP]
define z where "z = exp (1 / c)"
[PROOF STATE]
proof (state)
this:
z = exp (1 / c)

goal (1 subgoal):
 1. f x \<le> 1 / (c * exp 1)
[PROOF STEP]
have "z > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < z
[PROOF STEP]
by (simp add: z_def)
[PROOF STATE]
proof (state)
this:
0 < z

goal (1 subgoal):
 1. f x \<le> 1 / (c * exp 1)
[PROOF STEP]
have deriv: "(f has_real_derivative f' t) (at t)" if "t > 0" for t
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f has_real_derivative f' t) (at t)
[PROOF STEP]
unfolding f_def f'_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. x powr - c * ln x) has_real_derivative t powr (- c - 1) * (1 - c * ln t)) (at t)
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
0 < t

goal (1 subgoal):
 1. ((\<lambda>x. x powr - c * ln x) has_real_derivative t powr (- c - 1) * (1 - c * ln t)) (at t)
[PROOF STEP]
by (auto intro!: derivative_eq_intros simp: field_simps powr_diff powr_minus)
[PROOF STATE]
proof (state)
this:
0 < ?t \<Longrightarrow> (f has_real_derivative f' ?t) (at ?t)

goal (1 subgoal):
 1. f x \<le> 1 / (c * exp 1)
[PROOF STEP]
have [simp]: "f z = 1 / (c * exp 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f z = 1 / (c * exp 1)
[PROOF STEP]
by (simp add: z_def f_def powr_def exp_minus field_simps)
[PROOF STATE]
proof (state)
this:
f z = 1 / (c * exp 1)

goal (1 subgoal):
 1. f x \<le> 1 / (c * exp 1)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f x \<le> 1 / (c * exp 1)
[PROOF STEP]
proof (cases x z rule: linorder_cases)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. x < z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 2. x = z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 3. z < x \<Longrightarrow> f x \<le> 1 / (c * exp 1)
[PROOF STEP]
assume x: "x < z"
[PROOF STATE]
proof (state)
this:
x < z

goal (3 subgoals):
 1. x < z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 2. x = z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 3. z < x \<Longrightarrow> f x \<le> 1 / (c * exp 1)
[PROOF STEP]
from x assms
[PROOF STATE]
proof (chain)
picking this:
x < z
0 < c
f \<equiv> \<lambda>x. x powr - c * ln x
0 < x
[PROOF STEP]
have t: "\<exists>t. t > x \<and> t < z \<and> f z - f x = (z - x) * f' t"
[PROOF STATE]
proof (prove)
using this:
x < z
0 < c
f \<equiv> \<lambda>x. x powr - c * ln x
0 < x

goal (1 subgoal):
 1. \<exists>t>x. t < z \<and> f z - f x = (z - x) * f' t
[PROOF STEP]
by (intro MVT2 deriv) auto
[PROOF STATE]
proof (state)
this:
\<exists>t>x. t < z \<and> f z - f x = (z - x) * f' t

goal (3 subgoals):
 1. x < z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 2. x = z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 3. z < x \<Longrightarrow> f x \<le> 1 / (c * exp 1)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>t>x. t < z \<and> f z - f x = (z - x) * f' t
[PROOF STEP]
obtain t where t: "t > x" "t < z" "f z - f x = (z - x) * f' t"
[PROOF STATE]
proof (prove)
using this:
\<exists>t>x. t < z \<and> f z - f x = (z - x) * f' t

goal (1 subgoal):
 1. (\<And>t. \<lbrakk>x < t; t < z; f z - f x = (z - x) * f' t\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
x < t
t < z
f z - f x = (z - x) * f' t

goal (3 subgoals):
 1. x < z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 2. x = z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 3. z < x \<Longrightarrow> f x \<le> 1 / (c * exp 1)
[PROOF STEP]
hence "ln t < ln z"
[PROOF STATE]
proof (prove)
using this:
x < t
t < z
f z - f x = (z - x) * f' t

goal (1 subgoal):
 1. ln t < ln z
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
x < t
t < z
f z - f x = (z - x) * f' t
0 < c
f \<equiv> \<lambda>x. x powr - c * ln x
0 < x

goal (1 subgoal):
 1. ln t < ln z
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
ln t < ln z

goal (3 subgoals):
 1. x < z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 2. x = z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 3. z < x \<Longrightarrow> f x \<le> 1 / (c * exp 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ln t < ln z

goal (3 subgoals):
 1. x < z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 2. x = z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 3. z < x \<Longrightarrow> f x \<le> 1 / (c * exp 1)
[PROOF STEP]
have "ln z = 1 / c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ln z = 1 / c
[PROOF STEP]
by (simp add: z_def)
[PROOF STATE]
proof (state)
this:
ln z = 1 / c

goal (3 subgoals):
 1. x < z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 2. x = z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 3. z < x \<Longrightarrow> f x \<le> 1 / (c * exp 1)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
ln t < 1 / c
[PROOF STEP]
have "0 \<le> (z - x) * f' t"
[PROOF STATE]
proof (prove)
using this:
ln t < 1 / c

goal (1 subgoal):
 1. 0 \<le> (z - x) * f' t
[PROOF STEP]
unfolding f'_def
[PROOF STATE]
proof (prove)
using this:
ln t < 1 / c

goal (1 subgoal):
 1. 0 \<le> (z - x) * (t powr (- c - 1) * (1 - c * ln t))
[PROOF STEP]
using \<open>c > 0\<close> x
[PROOF STATE]
proof (prove)
using this:
ln t < 1 / c
0 < c
x < z

goal (1 subgoal):
 1. 0 \<le> (z - x) * (t powr (- c - 1) * (1 - c * ln t))
[PROOF STEP]
by (intro mult_nonneg_nonneg) (auto simp: z_def field_simps)
[PROOF STATE]
proof (state)
this:
0 \<le> (z - x) * f' t

goal (3 subgoals):
 1. x < z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 2. x = z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 3. z < x \<Longrightarrow> f x \<le> 1 / (c * exp 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
0 \<le> (z - x) * f' t

goal (3 subgoals):
 1. x < z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 2. x = z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 3. z < x \<Longrightarrow> f x \<le> 1 / (c * exp 1)
[PROOF STEP]
from t
[PROOF STATE]
proof (chain)
picking this:
x < t
t < z
f z - f x = (z - x) * f' t
[PROOF STEP]
have "\<dots> = f z - f x"
[PROOF STATE]
proof (prove)
using this:
x < t
t < z
f z - f x = (z - x) * f' t

goal (1 subgoal):
 1. (z - x) * f' t = f z - f x
[PROOF STEP]
by (simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
(z - x) * f' t = f z - f x

goal (3 subgoals):
 1. x < z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 2. x = z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 3. z < x \<Longrightarrow> f x \<le> 1 / (c * exp 1)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
0 \<le> f z - f x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
0 \<le> f z - f x

goal (1 subgoal):
 1. f x \<le> 1 / (c * exp 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
f x \<le> 1 / (c * exp 1)

goal (2 subgoals):
 1. x = z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 2. z < x \<Longrightarrow> f x \<le> 1 / (c * exp 1)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x = z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 2. z < x \<Longrightarrow> f x \<le> 1 / (c * exp 1)
[PROOF STEP]
assume x: "x > z"
[PROOF STATE]
proof (state)
this:
z < x

goal (2 subgoals):
 1. x = z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 2. z < x \<Longrightarrow> f x \<le> 1 / (c * exp 1)
[PROOF STEP]
from x assms \<open>z > 0\<close>
[PROOF STATE]
proof (chain)
picking this:
z < x
0 < c
f \<equiv> \<lambda>x. x powr - c * ln x
0 < x
0 < z
[PROOF STEP]
have t: "\<exists>t. t > z \<and> t < x \<and> f x - f z = (x - z) * f' t"
[PROOF STATE]
proof (prove)
using this:
z < x
0 < c
f \<equiv> \<lambda>x. x powr - c * ln x
0 < x
0 < z

goal (1 subgoal):
 1. \<exists>t>z. t < x \<and> f x - f z = (x - z) * f' t
[PROOF STEP]
by (intro MVT2 deriv) auto
[PROOF STATE]
proof (state)
this:
\<exists>t>z. t < x \<and> f x - f z = (x - z) * f' t

goal (2 subgoals):
 1. x = z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 2. z < x \<Longrightarrow> f x \<le> 1 / (c * exp 1)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>t>z. t < x \<and> f x - f z = (x - z) * f' t
[PROOF STEP]
obtain t where t: "t > z" "t < x" "f x - f z = (x - z) * f' t"
[PROOF STATE]
proof (prove)
using this:
\<exists>t>z. t < x \<and> f x - f z = (x - z) * f' t

goal (1 subgoal):
 1. (\<And>t. \<lbrakk>z < t; t < x; f x - f z = (x - z) * f' t\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
z < t
t < x
f x - f z = (x - z) * f' t

goal (2 subgoals):
 1. x = z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 2. z < x \<Longrightarrow> f x \<le> 1 / (c * exp 1)
[PROOF STEP]
hence "ln z < ln t"
[PROOF STATE]
proof (prove)
using this:
z < t
t < x
f x - f z = (x - z) * f' t

goal (1 subgoal):
 1. ln z < ln t
[PROOF STEP]
using \<open>z > 0\<close> assms
[PROOF STATE]
proof (prove)
using this:
z < t
t < x
f x - f z = (x - z) * f' t
0 < z
0 < c
f \<equiv> \<lambda>x. x powr - c * ln x
0 < x

goal (1 subgoal):
 1. ln z < ln t
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
ln z < ln t

goal (2 subgoals):
 1. x = z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 2. z < x \<Longrightarrow> f x \<le> 1 / (c * exp 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ln z < ln t

goal (2 subgoals):
 1. x = z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 2. z < x \<Longrightarrow> f x \<le> 1 / (c * exp 1)
[PROOF STEP]
have "ln z = 1 / c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ln z = 1 / c
[PROOF STEP]
by (simp add: z_def)
[PROOF STATE]
proof (state)
this:
ln z = 1 / c

goal (2 subgoals):
 1. x = z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 2. z < x \<Longrightarrow> f x \<le> 1 / (c * exp 1)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
1 / c < ln t
[PROOF STEP]
have "0 \<le> (z - x) * f' t"
[PROOF STATE]
proof (prove)
using this:
1 / c < ln t

goal (1 subgoal):
 1. 0 \<le> (z - x) * f' t
[PROOF STEP]
unfolding f'_def
[PROOF STATE]
proof (prove)
using this:
1 / c < ln t

goal (1 subgoal):
 1. 0 \<le> (z - x) * (t powr (- c - 1) * (1 - c * ln t))
[PROOF STEP]
using \<open>c > 0\<close> x
[PROOF STATE]
proof (prove)
using this:
1 / c < ln t
0 < c
z < x

goal (1 subgoal):
 1. 0 \<le> (z - x) * (t powr (- c - 1) * (1 - c * ln t))
[PROOF STEP]
by (intro mult_nonpos_nonpos mult_nonneg_nonpos) (auto simp: z_def field_simps)
[PROOF STATE]
proof (state)
this:
0 \<le> (z - x) * f' t

goal (2 subgoals):
 1. x = z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 2. z < x \<Longrightarrow> f x \<le> 1 / (c * exp 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
0 \<le> (z - x) * f' t

goal (2 subgoals):
 1. x = z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 2. z < x \<Longrightarrow> f x \<le> 1 / (c * exp 1)
[PROOF STEP]
from t
[PROOF STATE]
proof (chain)
picking this:
z < t
t < x
f x - f z = (x - z) * f' t
[PROOF STEP]
have "\<dots> = f z - f x"
[PROOF STATE]
proof (prove)
using this:
z < t
t < x
f x - f z = (x - z) * f' t

goal (1 subgoal):
 1. (z - x) * f' t = f z - f x
[PROOF STEP]
by (simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
(z - x) * f' t = f z - f x

goal (2 subgoals):
 1. x = z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
 2. z < x \<Longrightarrow> f x \<le> 1 / (c * exp 1)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
0 \<le> f z - f x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
0 \<le> f z - f x

goal (1 subgoal):
 1. f x \<le> 1 / (c * exp 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
f x \<le> 1 / (c * exp 1)

goal (1 subgoal):
 1. x = z \<Longrightarrow> f x \<le> 1 / (c * exp 1)
[PROOF STEP]
qed auto
[PROOF STATE]
proof (state)
this:
f x \<le> 1 / (c * exp 1)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in domain) pprimeI:
  assumes "subfield K R" "p \<in> carrier (K[X])" "p \<noteq> []" "p \<notin> Units (K[X])"
    and "\<And>q r. \<lbrakk> q \<in> carrier (K[X]); r \<in> carrier (K[X])\<rbrakk> \<Longrightarrow>
                 p pdivides (q \<otimes>\<^bsub>K[X]\<^esub> r) \<Longrightarrow> p pdivides q \<or> p pdivides r"
  shows "pprime K p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pprime K p
[PROOF STEP]
using assms(2-5) poly_mult_closed[OF subfieldE(1)[OF assms(1)]] pdivides_iff[OF assms(1)]
[PROOF STATE]
proof (prove)
using this:
p \<in> carrier (K [X])
p \<noteq> []
p \<notin> Units (K [X])
\<lbrakk>?q \<in> carrier (K [X]); ?r \<in> carrier (K [X]); p pdivides ?q \<otimes>\<^bsub>K [X]\<^esub> ?r\<rbrakk> \<Longrightarrow> p pdivides ?q \<or> p pdivides ?r
\<lbrakk>polynomial K ?p1.0; polynomial K ?p2.0\<rbrakk> \<Longrightarrow> polynomial K (poly_mult ?p1.0 ?p2.0)
\<lbrakk>polynomial K ?p; polynomial K ?q\<rbrakk> \<Longrightarrow> ?p pdivides ?q = ?p divides\<^bsub>K [X]\<^esub> ?q

goal (1 subgoal):
 1. pprime K p
[PROOF STEP]
unfolding ring_prime_def prime_def
[PROOF STATE]
proof (prove)
using this:
p \<in> carrier (K [X])
p \<noteq> []
p \<notin> Units (K [X])
\<lbrakk>?q \<in> carrier (K [X]); ?r \<in> carrier (K [X]); p pdivides ?q \<otimes>\<^bsub>K [X]\<^esub> ?r\<rbrakk> \<Longrightarrow> p pdivides ?q \<or> p pdivides ?r
\<lbrakk>polynomial K ?p1.0; polynomial K ?p2.0\<rbrakk> \<Longrightarrow> polynomial K (poly_mult ?p1.0 ?p2.0)
\<lbrakk>polynomial K ?p; polynomial K ?q\<rbrakk> \<Longrightarrow> ?p pdivides ?q = ?p divides\<^bsub>K [X]\<^esub> ?q

goal (1 subgoal):
 1. p \<noteq> \<zero>\<^bsub>K [X]\<^esub> \<and> p \<notin> Units (K [X]) \<and> (\<forall>a\<in>carrier (K [X]). \<forall>b\<in>carrier (K [X]). p divides\<^bsub>K [X]\<^esub> a \<otimes>\<^bsub>K [X]\<^esub> b \<longrightarrow> p divides\<^bsub>K [X]\<^esub> a \<or> p divides\<^bsub>K [X]\<^esub> b)
[PROOF STEP]
by (auto simp add: univ_poly_mult univ_poly_carrier univ_poly_zero)


[STATEMENT]
lemma continuous_on_cosh [continuous_intros]:
  fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
  assumes "continuous_on A f"
  shows   "continuous_on A (\<lambda>x. cosh (f x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous_on A (\<lambda>x. cosh (f x))
[PROOF STEP]
unfolding cosh_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous_on A (\<lambda>x. (exp (f x) + exp (- f x)) /\<^sub>R 2)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
continuous_on A f

goal (1 subgoal):
 1. continuous_on A (\<lambda>x. (exp (f x) + exp (- f x)) /\<^sub>R 2)
[PROOF STEP]
by (intro continuous_intros)


[STATEMENT]
lemma poly2_poly_x_minus_y[simp]:
  fixes p :: "'a :: comm_ring_1 poly"
  shows "poly2 (poly_x_minus_y p) x y = poly p (x-y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly2 (poly_x_minus_y p) x y = poly p (x - y)
[PROOF STEP]
unfolding poly2_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly (poly (poly_x_minus_y p) [:y:]) x = poly p (x - y)
[PROOF STEP]
by simp


[STATEMENT]
lemma summable_on_Re:
  assumes "f summable_on M"
  shows "(\<lambda>x. Re (f x)) summable_on M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. Re (f x)) summable_on M
[PROOF STEP]
apply (rule summable_on_comm_additive[where f=Re, unfolded o_def])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. additive Re
 2. isCont Re (infsum f M)
 3. f summable_on M
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f summable_on M

goal (3 subgoals):
 1. additive Re
 2. isCont Re (infsum f M)
 3. f summable_on M
[PROOF STEP]
by (auto intro!: additive.intro)


[STATEMENT]
lemma fmeasurableI2: "A \<in> fmeasurable M \<Longrightarrow> B \<subseteq> A \<Longrightarrow> B \<in> sets M \<Longrightarrow> B \<in> fmeasurable M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A \<in> fmeasurable M; B \<subseteq> A; B \<in> sets M\<rbrakk> \<Longrightarrow> B \<in> fmeasurable M
[PROOF STEP]
using emeasure_mono[of B A M]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>B \<subseteq> A; A \<in> sets M\<rbrakk> \<Longrightarrow> emeasure M B \<le> emeasure M A

goal (1 subgoal):
 1. \<lbrakk>A \<in> fmeasurable M; B \<subseteq> A; B \<in> sets M\<rbrakk> \<Longrightarrow> B \<in> fmeasurable M
[PROOF STEP]
by (auto simp: fmeasurable_def)


[STATEMENT]
lemma scalar_prod_inc_vec_block_size_mat:
  assumes "j < dim_col M"
  shows "(col M j) \<bullet> (col M j) = of_nat (mat_block_size M j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. col M j \<bullet> col M j = of_nat (mat_block_size M j)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. col M j \<bullet> col M j = of_nat (mat_block_size M j)
[PROOF STEP]
have "(col M j) \<bullet> (col M j) = (\<Sum> i \<in> {0..<dim_row M} . (col M j) $ i * (col M j) $ i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. col M j \<bullet> col M j = (\<Sum>i = 0..<dim_row M. col M j $ i * col M j $ i)
[PROOF STEP]
using assms  scalar_prod_def sum.cong
[PROOF STATE]
proof (prove)
using this:
j < dim_col M
?v \<bullet> ?w \<equiv> \<Sum>i = 0..<dim_vec ?w. ?v $ i * ?w $ i
\<lbrakk>?A = ?B; \<And>x. x \<in> ?B \<Longrightarrow> ?g x = ?h x\<rbrakk> \<Longrightarrow> sum ?g ?A = sum ?h ?B

goal (1 subgoal):
 1. col M j \<bullet> col M j = (\<Sum>i = 0..<dim_row M. col M j $ i * col M j $ i)
[PROOF STEP]
by (smt (verit, ccfv_threshold) dim_col)
[PROOF STATE]
proof (state)
this:
col M j \<bullet> col M j = (\<Sum>i = 0..<dim_row M. col M j $ i * col M j $ i)

goal (1 subgoal):
 1. col M j \<bullet> col M j = of_nat (mat_block_size M j)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
col M j \<bullet> col M j = (\<Sum>i = 0..<dim_row M. col M j $ i * col M j $ i)

goal (1 subgoal):
 1. col M j \<bullet> col M j = of_nat (mat_block_size M j)
[PROOF STEP]
have "... = (\<Sum> i \<in> {0..<dim_row M} . ((col M j) $ i)^2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<dim_row M. col M j $ i * col M j $ i) = (\<Sum>i = 0..<dim_row M. (col M j $ i)\<^sup>2)
[PROOF STEP]
by (simp add: power2_eq_square )
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<dim_row M. col M j $ i * col M j $ i) = (\<Sum>i = 0..<dim_row M. (col M j $ i)\<^sup>2)

goal (1 subgoal):
 1. col M j \<bullet> col M j = of_nat (mat_block_size M j)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<dim_row M. col M j $ i * col M j $ i) = (\<Sum>i = 0..<dim_row M. (col M j $ i)\<^sup>2)

goal (1 subgoal):
 1. col M j \<bullet> col M j = of_nat (mat_block_size M j)
[PROOF STEP]
have "... = (\<Sum> i \<in> {0..<dim_row M} . ((col M j) $ i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<dim_row M. (col M j $ i)\<^sup>2) = sum (($) (col M j)) {0..<dim_row M}
[PROOF STEP]
using M_col_index_square_itself assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?j < dim_col M; ?i < dim_row M\<rbrakk> \<Longrightarrow> (col M ?j $ ?i)\<^sup>2 = col M ?j $ ?i
j < dim_col M

goal (1 subgoal):
 1. (\<Sum>i = 0..<dim_row M. (col M j $ i)\<^sup>2) = sum (($) (col M j)) {0..<dim_row M}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<dim_row M. (col M j $ i)\<^sup>2) = sum (($) (col M j)) {0..<dim_row M}

goal (1 subgoal):
 1. col M j \<bullet> col M j = of_nat (mat_block_size M j)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
col M j \<bullet> col M j = sum (($) (col M j)) {0..<dim_row M}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
col M j \<bullet> col M j = sum (($) (col M j)) {0..<dim_row M}

goal (1 subgoal):
 1. col M j \<bullet> col M j = of_nat (mat_block_size M j)
[PROOF STEP]
using sum_vec_def mat_block_size_sum_alt
[PROOF STATE]
proof (prove)
using this:
col M j \<bullet> col M j = sum (($) (col M j)) {0..<dim_row M}
sum_vec ?v \<equiv> sum (($) ?v) {0..<dim_vec ?v}
\<lbrakk>elements_mat ?M \<subseteq> {0::?'a, 1::?'a}; ?j < dim_col ?M\<rbrakk> \<Longrightarrow> of_nat (mat_block_size ?M ?j) = sum_vec (col ?M ?j)

goal (1 subgoal):
 1. col M j \<bullet> col M j = of_nat (mat_block_size M j)
[PROOF STEP]
by (metis assms dim_col elems01)
[PROOF STATE]
proof (state)
this:
col M j \<bullet> col M j = of_nat (mat_block_size M j)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma make_ext:
  assumes "\<And>x. P x = P (restrict x I)"
  shows "(\<forall>x \<in> Pi I A. P x) = (\<forall>x \<in> PiE I A. P x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x\<in>Pi I A. P x) = (\<forall>x\<in>Pi\<^sub>E I A. P x)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
P ?x = P (restrict ?x I)

goal (1 subgoal):
 1. (\<forall>x\<in>Pi I A. P x) = (\<forall>x\<in>Pi\<^sub>E I A. P x)
[PROOF STEP]
by (simp add:PiE_def Pi_def set_eq_iff, force)


[STATEMENT]
lemma norm_hyp2_rep_lt_1: "norm (hyp2_rep p) < 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (hyp2_rep p) < 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. norm (hyp2_rep p) < 1
[PROOF STEP]
have "proj2_pt (hyp2_rep p) = Rep_hyp2 p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proj2_pt (hyp2_rep p) = Rep_hyp2 p
[PROOF STEP]
by (rule proj2_pt_hyp2_rep)
[PROOF STATE]
proof (state)
this:
proj2_pt (hyp2_rep p) = Rep_hyp2 p

goal (1 subgoal):
 1. norm (hyp2_rep p) < 1
[PROOF STEP]
hence "proj2_pt (hyp2_rep p) \<in> hyp2"
[PROOF STATE]
proof (prove)
using this:
proj2_pt (hyp2_rep p) = Rep_hyp2 p

goal (1 subgoal):
 1. proj2_pt (hyp2_rep p) \<in> hyp2
[PROOF STEP]
by (simp add: Rep_hyp2)
[PROOF STATE]
proof (state)
this:
proj2_pt (hyp2_rep p) \<in> hyp2

goal (1 subgoal):
 1. norm (hyp2_rep p) < 1
[PROOF STEP]
thus "norm (hyp2_rep p) < 1"
[PROOF STATE]
proof (prove)
using this:
proj2_pt (hyp2_rep p) \<in> hyp2

goal (1 subgoal):
 1. norm (hyp2_rep p) < 1
[PROOF STEP]
by (simp add: norm_lt_1_iff_in_hyp2)
[PROOF STATE]
proof (state)
this:
norm (hyp2_rep p) < 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma newman_ingham_aux2:
  fixes m :: nat and w z :: complex
  assumes "1 \<le> m" "1 \<le> Re w" "0 < Re z" and f: "\<And>n. 1 \<le> n \<Longrightarrow> norm (f n) \<le> C"
  shows "norm (\<Sum>n=1..m. f n / n powr (w - z)) \<le> C * (m powr Re z) * (1 / m + 1 / Re z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cmod (\<Sum>n = 1..m. f n / of_nat n powr (w - z)) \<le> C * real m powr Re z * (1 / real m + 1 / Re z)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. cmod (\<Sum>n = 1..m. f n / of_nat n powr (w - z)) \<le> C * real m powr Re z * (1 / real m + 1 / Re z)
[PROOF STEP]
have [simp]: "C \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> C
[PROOF STEP]
by (rule order.trans[OF _ f[of 1]]) auto
[PROOF STATE]
proof (state)
this:
0 \<le> C

goal (1 subgoal):
 1. cmod (\<Sum>n = 1..m. f n / of_nat n powr (w - z)) \<le> C * real m powr Re z * (1 / real m + 1 / Re z)
[PROOF STEP]
have "norm (\<Sum>n=1..m. f n / n powr (w - z)) \<le> (\<Sum>n=1..m. C / n powr (1 - Re z))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cmod (\<Sum>n = 1..m. f n / of_nat n powr (w - z)) \<le> (\<Sum>n = 1..m. C / real n powr (1 - Re z))
[PROOF STEP]
by (rule sum_norm_le)
       (insert assms, auto simp: norm_divide norm_powr_real_powr intro!: frac_le assms powr_mono)
[PROOF STATE]
proof (state)
this:
cmod (\<Sum>n = 1..m. f n / of_nat n powr (w - z)) \<le> (\<Sum>n = 1..m. C / real n powr (1 - Re z))

goal (1 subgoal):
 1. cmod (\<Sum>n = 1..m. f n / of_nat n powr (w - z)) \<le> C * real m powr Re z * (1 / real m + 1 / Re z)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
cmod (\<Sum>n = 1..m. f n / of_nat n powr (w - z)) \<le> (\<Sum>n = 1..m. C / real n powr (1 - Re z))

goal (1 subgoal):
 1. cmod (\<Sum>n = 1..m. f n / of_nat n powr (w - z)) \<le> C * real m powr Re z * (1 / real m + 1 / Re z)
[PROOF STEP]
have "\<dots> = C * (\<Sum>n=1..m. n powr (Re z - 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>n = 1..m. C / real n powr (1 - Re z)) = C * (\<Sum>n = 1..m. real n powr (Re z - 1))
[PROOF STEP]
by (subst sum_distrib_left) (simp_all add: powr_diff)
[PROOF STATE]
proof (state)
this:
(\<Sum>n = 1..m. C / real n powr (1 - Re z)) = C * (\<Sum>n = 1..m. real n powr (Re z - 1))

goal (1 subgoal):
 1. cmod (\<Sum>n = 1..m. f n / of_nat n powr (w - z)) \<le> C * real m powr Re z * (1 / real m + 1 / Re z)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>n = 1..m. C / real n powr (1 - Re z)) = C * (\<Sum>n = 1..m. real n powr (Re z - 1))

goal (1 subgoal):
 1. cmod (\<Sum>n = 1..m. f n / of_nat n powr (w - z)) \<le> C * real m powr Re z * (1 / real m + 1 / Re z)
[PROOF STEP]
have "\<dots> \<le> C * (m powr Re z * (1 / Re z + 1 / m))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. C * (\<Sum>n = 1..m. real n powr (Re z - 1)) \<le> C * (real m powr Re z * (1 / Re z + 1 / real m))
[PROOF STEP]
using zeta_partial_sum_le'[of "Re z" m] assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 < Re z; 0 < m\<rbrakk> \<Longrightarrow> (\<Sum>n = 1..m. real n powr (Re z - 1)) \<le> real m powr Re z * (1 / Re z + 1 / real m)
1 \<le> m
1 \<le> Re w
0 < Re z
1 \<le> ?n \<Longrightarrow> cmod (f ?n) \<le> C

goal (1 subgoal):
 1. C * (\<Sum>n = 1..m. real n powr (Re z - 1)) \<le> C * (real m powr Re z * (1 / Re z + 1 / real m))
[PROOF STEP]
by (intro mult_left_mono) auto
[PROOF STATE]
proof (state)
this:
C * (\<Sum>n = 1..m. real n powr (Re z - 1)) \<le> C * (real m powr Re z * (1 / Re z + 1 / real m))

goal (1 subgoal):
 1. cmod (\<Sum>n = 1..m. f n / of_nat n powr (w - z)) \<le> C * real m powr Re z * (1 / real m + 1 / Re z)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
cmod (\<Sum>n = 1..m. f n / of_nat n powr (w - z)) \<le> C * (real m powr Re z * (1 / Re z + 1 / real m))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
cmod (\<Sum>n = 1..m. f n / of_nat n powr (w - z)) \<le> C * (real m powr Re z * (1 / Re z + 1 / real m))

goal (1 subgoal):
 1. cmod (\<Sum>n = 1..m. f n / of_nat n powr (w - z)) \<le> C * real m powr Re z * (1 / real m + 1 / Re z)
[PROOF STEP]
by (simp add: mult_ac add_ac)
[PROOF STATE]
proof (state)
this:
cmod (\<Sum>n = 1..m. f n / of_nat n powr (w - z)) \<le> C * real m powr Re z * (1 / real m + 1 / Re z)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mssnth_exp_series_stream:
  "mssnth exp_series_stream n = 1 / fact n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mssnth exp_series_stream n = 1 / fact n
[PROOF STEP]
unfolding exp_series_stream_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mssnth (exp_series_stream_aux 1 1) n = 1 / fact n
[PROOF STEP]
using mssnth_exp_series_stream_aux[of 0 n]
[PROOF STATE]
proof (prove)
using this:
mssnth (exp_series_stream_aux (1 / fact 0) (real (0 + 1))) n = 1 / fact (0 + n)

goal (1 subgoal):
 1. mssnth (exp_series_stream_aux 1 1) n = 1 / fact n
[PROOF STEP]
by simp


[STATEMENT]
lemma FindPreHNF_rectangular_soundness:
  fixes A::"int mat"
  assumes A: "A \<in> carrier_mat m n"
  shows "\<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A
    \<and> echelon_form_JNF (FindPreHNF_rectangular A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
proof (cases "m < 2 \<or> n = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. m < 2 \<or> n = 0 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
 2. \<not> (m < 2 \<or> n = 0) \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
m < 2 \<or> n = 0

goal (2 subgoals):
 1. m < 2 \<or> n = 0 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
 2. \<not> (m < 2 \<or> n = 0) \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
m < 2 \<or> n = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
m < 2 \<or> n = 0

goal (1 subgoal):
 1. \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
by (smt A FindPreHNF_rectangular_def carrier_matD echelon_form_JNF_1xn echelon_form_mx0
        invertible_mat_one left_mult_one_mat one_carrier_mat)
[PROOF STATE]
proof (state)
this:
\<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)

goal (1 subgoal):
 1. \<not> (m < 2 \<or> n = 0) \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> (m < 2 \<or> n = 0) \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> (m < 2 \<or> n = 0)

goal (1 subgoal):
 1. \<not> (m < 2 \<or> n = 0) \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
have m1: "m>1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 < m
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
\<not> (m < 2 \<or> n = 0)

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

goal (1 subgoal):
 1. \<not> (m < 2 \<or> n = 0) \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
have n0: "n>0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < n
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
\<not> (m < 2 \<or> n = 0)

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

goal (1 subgoal):
 1. \<not> (m < 2 \<or> n = 0) \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
proof (cases "n=1")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
 2. n \<noteq> 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
n = 1

goal (2 subgoals):
 1. n = 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
 2. n \<noteq> 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
note n1 = True
[PROOF STATE]
proof (state)
this:
n = 1

goal (2 subgoals):
 1. n = 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
 2. n \<noteq> 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
let ?nz = "filter (\<lambda>i. A $$ (i,0) \<noteq> 0) [1..<dim_row A]"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
 2. n \<noteq> 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
let ?A' = "(if A$$(0,0) \<noteq> 0 then A else let i = ?nz ! 0 in swaprows 0 i A)"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
 2. n \<noteq> 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
have A': "?A' \<in> carrier_mat m n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) \<in> carrier_mat m n
[PROOF STEP]
using A
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat m n

goal (1 subgoal):
 1. (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) \<in> carrier_mat m n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) \<in> carrier_mat m n

goal (2 subgoals):
 1. n = 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
 2. n \<noteq> 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
have A'00: "?A' $$ (0,0) \<noteq> 0" if "?nz \<noteq> []"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (0, 0) \<noteq> 0
[PROOF STEP]
by (smt True assms carrier_matD index_mat_swaprows(1) length_greater_0_conv m1
          mem_Collect_eq nat_SN.gt_trans nth_mem set_filter that zero_less_one_class.zero_less_one)
[PROOF STATE]
proof (state)
this:
filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] \<noteq> [] \<Longrightarrow> (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (0, 0) \<noteq> 0

goal (2 subgoals):
 1. n = 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
 2. n \<noteq> 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
have e_r: "echelon_form_JNF (reduce_below 0 ?nz 0 ?A')" if nz_not_empty: "?nz \<noteq> []"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. echelon_form_JNF (reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A))
[PROOF STEP]
proof (rule echelon_form_JNF_mx1)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) \<in> carrier_mat ?m ?n
 2. ?n < 2
 3. \<forall>i\<in>{1..<?m}. reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = 0
[PROOF STEP]
show "(reduce_below 0 ?nz 0 ?A') \<in> carrier_mat m n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) \<in> carrier_mat m n
[PROOF STEP]
using A reduce_below
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat m n
?A \<in> carrier_mat ?m ?n \<Longrightarrow> reduce_below ?a ?xs ?D ?A \<in> carrier_mat ?m ?n

goal (1 subgoal):
 1. reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) \<in> carrier_mat m n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) \<in> carrier_mat m n

goal (2 subgoals):
 1. n < 2
 2. \<forall>i\<in>{1..<m}. reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = 0
[PROOF STEP]
have "(reduce_below 0 ?nz 0 ?A') $$ (i,0) = 0" if i: "i \<in> {1..<m}" for i
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = 0
[PROOF STEP]
proof (cases "i \<in> set ?nz")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i \<in> set (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) \<Longrightarrow> reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = 0
 2. i \<notin> set (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) \<Longrightarrow> reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = 0
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
i \<in> set (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A])

goal (2 subgoals):
 1. i \<in> set (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) \<Longrightarrow> reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = 0
 2. i \<notin> set (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) \<Longrightarrow> reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = 0
[PROOF STEP]
by (rule reduce_below_0_D0[OF A' _ _ A'00 True], insert m1 n0 True A nz_not_empty, auto)
[PROOF STATE]
proof (state)
this:
reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = 0

goal (1 subgoal):
 1. i \<notin> set (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) \<Longrightarrow> reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = 0
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i \<notin> set (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) \<Longrightarrow> reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = 0
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
i \<notin> set (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A])

goal (1 subgoal):
 1. i \<notin> set (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) \<Longrightarrow> reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = 0
[PROOF STEP]
have "(reduce_below 0 ?nz 0 ?A') $$ (i,0) = ?A' $$ (i,0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0)
[PROOF STEP]
by (rule reduce_below_preserves_D0[OF A' _ _ A'00 False], insert m1 n0 True A i nz_not_empty, auto)
[PROOF STATE]
proof (state)
this:
reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0)

goal (1 subgoal):
 1. i \<notin> set (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) \<Longrightarrow> reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = 0
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0)

goal (1 subgoal):
 1. i \<notin> set (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) \<Longrightarrow> reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = 0
[PROOF STEP]
have "... = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = 0
[PROOF STEP]
using False n1 assms that
[PROOF STATE]
proof (prove)
using this:
i \<notin> set (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A])
n = 1
A \<in> carrier_mat m n
i \<in> {1..<m}

goal (1 subgoal):
 1. (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = 0

goal (1 subgoal):
 1. i \<notin> set (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) \<Longrightarrow> reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = 0
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = 0

goal (1 subgoal):
 1. reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = 0
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = 0

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?i \<in> {1..<m} \<Longrightarrow> reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (?i, 0) = 0

goal (2 subgoals):
 1. n < 2
 2. \<forall>i\<in>{1..<m}. reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = 0
[PROOF STEP]
thus "\<forall>i \<in> {1..<m}. (reduce_below 0 ?nz 0 ?A') $$ (i,0) = 0"
[PROOF STATE]
proof (prove)
using this:
?i \<in> {1..<m} \<Longrightarrow> reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (?i, 0) = 0

goal (1 subgoal):
 1. \<forall>i\<in>{1..<m}. reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<forall>i\<in>{1..<m}. reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) $$ (i, 0) = 0

goal (1 subgoal):
 1. n < 2
[PROOF STEP]
qed (insert True, simp)
[PROOF STATE]
proof (state)
this:
filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] \<noteq> [] \<Longrightarrow> echelon_form_JNF (reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A))

goal (2 subgoals):
 1. n = 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
 2. n \<noteq> 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
have "\<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> reduce_below 0 ?nz 0 ?A' = P * ?A'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) = P * (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A)
[PROOF STEP]
by (rule reduce_below_invertible_mat_D0[OF A'], insert m1 n0 True A, auto)
[PROOF STATE]
proof (state)
this:
\<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) = P * (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A)

goal (2 subgoals):
 1. n = 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
 2. n \<noteq> 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) = P * (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A)

goal (2 subgoals):
 1. n = 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
 2. n \<noteq> 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
have "\<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> ?A' = P * A"   if "?nz \<noteq> []"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) = P * A
[PROOF STEP]
using A A'_swaprows_invertible_mat m1 that
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat m n
\<lbrakk>?A \<in> carrier_mat ?m ?n; ?A' = (if ?A $$ (0, 0) \<noteq> 0 then ?A else let i = ?non_zero_positions ! 0 in swaprows 0 i ?A); ?non_zero_positions = filter (\<lambda>i. ?A $$ (i, 0) \<noteq> 0) [1..<dim_row ?A]; ?A $$ (0, 0) = 0 \<Longrightarrow> ?non_zero_positions \<noteq> []; 0 < ?m\<rbrakk> \<Longrightarrow> \<exists>P. P \<in> carrier_mat ?m ?m \<and> invertible_mat P \<and> ?A' = P * ?A
1 < m
filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] \<noteq> []

goal (1 subgoal):
 1. \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) = P * A
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] \<noteq> [] \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) = P * A

goal (2 subgoals):
 1. n = 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
 2. n \<noteq> 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) = P * (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A)
filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] \<noteq> [] \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) = P * A
[PROOF STEP]
have e_inv: "\<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> reduce_below 0 ?nz 0 ?A' = P * A"
      if "?nz \<noteq> []"
[PROOF STATE]
proof (prove)
using this:
\<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) = P * (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A)
filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] \<noteq> [] \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) = P * A

goal (1 subgoal):
 1. \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) = P * A
[PROOF STEP]
by (smt that A assoc_mult_mat invertible_mult_JNF mult_carrier_mat)
[PROOF STATE]
proof (state)
this:
filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] \<noteq> [] \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) = P * A

goal (2 subgoals):
 1. n = 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
 2. n \<noteq> 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
have e_r1: "echelon_form_JNF A" if nz_empty: "?nz = []"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. echelon_form_JNF A
[PROOF STEP]
proof (rule echelon_form_JNF_mx1[OF A])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n < 2
 2. \<forall>i\<in>{1..<m}. A $$ (i, 0) = 0
[PROOF STEP]
show "\<forall>i\<in>{1..<m}. A $$ (i, 0) = 0 "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i\<in>{1..<m}. A $$ (i, 0) = 0
[PROOF STEP]
using nz_empty
[PROOF STATE]
proof (prove)
using this:
filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] = []

goal (1 subgoal):
 1. \<forall>i\<in>{1..<m}. A $$ (i, 0) = 0
[PROOF STEP]
by (metis (mono_tags, lifting) A carrier_matD(1) empty_filter_conv set_upt)
[PROOF STATE]
proof (state)
this:
\<forall>i\<in>{1..<m}. A $$ (i, 0) = 0

goal (1 subgoal):
 1. n < 2
[PROOF STEP]
qed (insert n1, simp)
[PROOF STATE]
proof (state)
this:
filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] = [] \<Longrightarrow> echelon_form_JNF A

goal (2 subgoals):
 1. n = 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
 2. n \<noteq> 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
have e_inv1: "\<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> A = P * A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> A = P * A
[PROOF STEP]
by (metis A invertible_mat_one left_mult_one_mat one_carrier_mat)
[PROOF STATE]
proof (state)
this:
\<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> A = P * A

goal (2 subgoals):
 1. n = 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
 2. n \<noteq> 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
have "FindPreHNF_rectangular A = (if ?nz = [] then A else reduce_below_impl 0 ?nz 0 ?A')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. FindPreHNF_rectangular A = (if filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] = [] then A else reduce_below_impl 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A))
[PROOF STEP]
unfolding FindPreHNF_rectangular_def Let_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if dim_row A < 2 \<or> dim_col A = 0 then A else if dim_col A = 1 then if filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] = [] then A else reduce_below_impl 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else swaprows 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0) A) else echelon_form_of_JNF A euclid_ext2) = (if filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] = [] then A else reduce_below_impl 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else swaprows 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0) A))
[PROOF STEP]
using m1 n1 A True
[PROOF STATE]
proof (prove)
using this:
1 < m
n = 1
A \<in> carrier_mat m n
n = 1

goal (1 subgoal):
 1. (if dim_row A < 2 \<or> dim_col A = 0 then A else if dim_col A = 1 then if filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] = [] then A else reduce_below_impl 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else swaprows 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0) A) else echelon_form_of_JNF A euclid_ext2) = (if filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] = [] then A else reduce_below_impl 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else swaprows 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0) A))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
FindPreHNF_rectangular A = (if filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] = [] then A else reduce_below_impl 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A))

goal (2 subgoals):
 1. n = 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
 2. n \<noteq> 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
FindPreHNF_rectangular A = (if filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] = [] then A else reduce_below_impl 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A))

goal (2 subgoals):
 1. n = 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
 2. n \<noteq> 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
have "reduce_below_impl 0 ?nz 0 ?A' = reduce_below 0 ?nz 0 ?A'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reduce_below_impl 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) = reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A)
[PROOF STEP]
by (rule reduce_below_impl[OF _ _ _ _ A'], insert m1 n0 A, auto)
[PROOF STATE]
proof (state)
this:
reduce_below_impl 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) = reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A)

goal (2 subgoals):
 1. n = 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
 2. n \<noteq> 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
FindPreHNF_rectangular A = (if filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] = [] then A else reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
FindPreHNF_rectangular A = (if filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] = [] then A else reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A))

goal (1 subgoal):
 1. \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
using e_inv e_r e_r1 e_inv1
[PROOF STATE]
proof (prove)
using this:
FindPreHNF_rectangular A = (if filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] = [] then A else reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A))
filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] \<noteq> [] \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A) = P * A
filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] \<noteq> [] \<Longrightarrow> echelon_form_JNF (reduce_below 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else let i = filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0 in swaprows 0 i A))
filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] = [] \<Longrightarrow> echelon_form_JNF A
\<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> A = P * A

goal (1 subgoal):
 1. \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
\<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)

goal (1 subgoal):
 1. n \<noteq> 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n \<noteq> 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
n \<noteq> 1

goal (1 subgoal):
 1. n \<noteq> 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
have f_rw: "FindPreHNF_rectangular A = echelon_form_of_JNF A euclid_ext2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. FindPreHNF_rectangular A = echelon_form_of_JNF A euclid_ext2
[PROOF STEP]
unfolding FindPreHNF_rectangular_def Let_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if dim_row A < 2 \<or> dim_col A = 0 then A else if dim_col A = 1 then if filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] = [] then A else reduce_below_impl 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else swaprows 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0) A) else echelon_form_of_JNF A euclid_ext2) = echelon_form_of_JNF A euclid_ext2
[PROOF STEP]
using m1 n0 A False
[PROOF STATE]
proof (prove)
using this:
1 < m
0 < n
A \<in> carrier_mat m n
n \<noteq> 1

goal (1 subgoal):
 1. (if dim_row A < 2 \<or> dim_col A = 0 then A else if dim_col A = 1 then if filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] = [] then A else reduce_below_impl 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A]) 0 (if A $$ (0, 0) \<noteq> 0 then A else swaprows 0 (filter (\<lambda>i. A $$ (i, 0) \<noteq> 0) [1..<dim_row A] ! 0) A) else echelon_form_of_JNF A euclid_ext2) = echelon_form_of_JNF A euclid_ext2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
FindPreHNF_rectangular A = echelon_form_of_JNF A euclid_ext2

goal (1 subgoal):
 1. n \<noteq> 1 \<Longrightarrow> \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)
[PROOF STEP]
unfolding f_rw
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = echelon_form_of_JNF A euclid_ext2 \<and> echelon_form_JNF (echelon_form_of_JNF A euclid_ext2)
[PROOF STEP]
by (rule echelon_form_of_euclidean_invertible'[OF A], insert False n0 m1, auto)
[PROOF STATE]
proof (state)
this:
\<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>P. invertible_mat P \<and> P \<in> carrier_mat m m \<and> P * A = FindPreHNF_rectangular A \<and> echelon_form_JNF (FindPreHNF_rectangular A)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma vec_of_basis_enum_canonical_basis:
  assumes "i < length (canonical_basis :: 'a list)"
  shows "vec_of_basis_enum (canonical_basis!i :: 'a)
       = unit_vec (length (canonical_basis :: 'a::basis_enum list)) i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_of_basis_enum (canonical_basis ! i) = unit_vec (length canonical_basis) i
[PROOF STEP]
by (metis assms basis_enum_of_vec_inverse basis_enum_of_vec_unit_vec index_unit_vec(3))


[STATEMENT]
lemma MSB_append[simp]: "MSB (I1 @ I2) = max (MSB I1) (MSB I2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. MSB (I1 @ I2) = max (MSB I1) (MSB I2)
[PROOF STEP]
by (induct I1) auto


[STATEMENT]
lemma (in group) l_cancel_one' [simp]: "x \<in> carrier G \<Longrightarrow> a \<in> carrier G \<Longrightarrow> x = x \<otimes> a \<longleftrightarrow> a = one G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x \<in> carrier G; a \<in> carrier G\<rbrakk> \<Longrightarrow> (x = x \<otimes> a) = (a = \<one>)
[PROOF STEP]
using l_cancel_one
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?x \<in> carrier G; ?a \<in> carrier G\<rbrakk> \<Longrightarrow> (?x \<otimes> ?a = ?x) = (?a = \<one>)

goal (1 subgoal):
 1. \<lbrakk>x \<in> carrier G; a \<in> carrier G\<rbrakk> \<Longrightarrow> (x = x \<otimes> a) = (a = \<one>)
[PROOF STEP]
by fastforce


[STATEMENT]
lemma inconsistent_eq_rank_less_code[code]:
fixes A::"'a::{field}^'cols::{mod_type}^'rows::{mod_type}"
shows "inconsistent A b = (let GJ_P=Gauss_Jordan_PA A;
                                P_mult_b = (fst(GJ_P) *v b);
                                rank_A = (if A = 0 then 0 else to_nat (GREATEST a. row a (snd GJ_P) \<noteq> 0) + 1)  in (rank_A < (if (\<exists>a. P_mult_b $ a \<noteq> 0)
                                            then (to_nat (GREATEST a. P_mult_b $ a \<noteq> 0) + 1) else 0)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inconsistent A b = (let GJ_P = Gauss_Jordan_PA A; P_mult_b = fst GJ_P *v b; rank_A = if A = 0 then 0 else mod_type_class.to_nat (GREATEST a. row a (snd GJ_P) \<noteq> 0) + 1 in rank_A < (if \<exists>a. P_mult_b $ a \<noteq> (0::'a) then mod_type_class.to_nat (GREATEST a. P_mult_b $ a \<noteq> (0::'a)) + 1 else 0))
[PROOF STEP]
unfolding inconsistent_eq_rank_less Let_def rank_Gauss_Jordan_code
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((if A = 0 then 0 else mod_type_class.to_nat (GREATEST a. row a (Gauss_Jordan A) \<noteq> 0) + 1) < (if \<exists>a. (P_Gauss_Jordan A *v b) $ a \<noteq> (0::'a) then mod_type_class.to_nat (GREATEST a. (P_Gauss_Jordan A *v b) $ a \<noteq> (0::'a)) + 1 else 0)) = ((if A = 0 then 0 else mod_type_class.to_nat (GREATEST a. row a (snd (Gauss_Jordan_PA A)) \<noteq> 0) + 1) < (if \<exists>a. (fst (Gauss_Jordan_PA A) *v b) $ a \<noteq> (0::'a) then mod_type_class.to_nat (GREATEST a. (fst (Gauss_Jordan_PA A) *v b) $ a \<noteq> (0::'a)) + 1 else 0))
[PROOF STEP]
unfolding Gauss_Jordan_PA_eq P_Gauss_Jordan_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((if A = 0 then 0 else mod_type_class.to_nat (GREATEST a. row a (Gauss_Jordan A) \<noteq> 0) + 1) < (if \<exists>a. (fst (Gauss_Jordan_PA A) *v b) $ a \<noteq> (0::'a) then mod_type_class.to_nat (GREATEST a. (fst (Gauss_Jordan_PA A) *v b) $ a \<noteq> (0::'a)) + 1 else 0)) = ((if A = 0 then 0 else mod_type_class.to_nat (GREATEST a. row a (Gauss_Jordan A) \<noteq> 0) + 1) < (if \<exists>a. (fst (Gauss_Jordan_PA A) *v b) $ a \<noteq> (0::'a) then mod_type_class.to_nat (GREATEST a. (fst (Gauss_Jordan_PA A) *v b) $ a \<noteq> (0::'a)) + 1 else 0))
[PROOF STEP]
..


[STATEMENT]
lemma e1_squared [simp]: "e1 ^ 2 = -1"
  and e2_squared [simp]: "e2 ^ 2 = -1"
  and e3_squared [simp]: "e3 ^ 2 = -1"
  and e4_squared [simp]: "e4 ^ 2 = -1"
  and e5_squared [simp]: "e5 ^ 2 = -1"
  and e6_squared [simp]: "e6 ^ 2 = -1"
  and e7_squared [simp]: "e7 ^ 2 = -1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (e1\<^sup>2 = - 1 &&& e2\<^sup>2 = - 1 &&& e3\<^sup>2 = - 1) &&& (e4\<^sup>2 = - 1 &&& e5\<^sup>2 = - 1) &&& e6\<^sup>2 = - 1 &&& e7\<^sup>2 = - 1
[PROOF STEP]
by (simp_all add: octo_eq_iff power2_eq_square_octo octo_mult_components)


[STATEMENT]
lemma filter_even_map: "filter even [0..<2*(x::nat)] = map ((*) (2::nat)) [0..<x]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. filter even [0..<2 * x] = map ((*) 2) [0..<x]
[PROOF STEP]
by(induction x) simp+


[STATEMENT]
lemma Collect_permI:
  fixes pi :: "'x prm"
  and   x  :: "'a"
  assumes a: "\<forall>x. (P1 x = P2 x)"
  shows "{pi\<bullet>x| x. P1 x} = {pi\<bullet>x| x. P2 x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {pi \<bullet> x |x. P1 x} = {pi \<bullet> x |x. P2 x}
[PROOF STEP]
using a
[PROOF STATE]
proof (prove)
using this:
\<forall>x. P1 x = P2 x

goal (1 subgoal):
 1. {pi \<bullet> x |x. P1 x} = {pi \<bullet> x |x. P2 x}
[PROOF STEP]
by force


[STATEMENT]
lemma mpi_val_Suc: "mpi_val (Suc n) = L_pow (mpi_val n) (mpi_pol n) (m n (mpi_val n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mpi_val (Suc n) = L_pow (mpi_val n) (mpi_pol n) (m n (mpi_val n))
[PROOF STEP]
unfolding mpi_val_def mpi_pol_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. snd (mpi (Suc n)) = L_pow (snd (mpi n)) (fst (mpi n)) (m n (snd (mpi n)))
[PROOF STEP]
by (auto simp: case_prod_beta' Let_def)


[STATEMENT]
lemma vec_elem_exists_mset: "(\<exists> i \<in> {..<dim_vec v}. v $ i = x) \<longleftrightarrow> x \<in># vec_mset v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<exists>i\<in>{..<dim_vec v}. v $ i = x) = (x \<in># vec_mset v)
[PROOF STEP]
by (auto simp add: vec_mset_def)


[STATEMENT]
lemma has_integral_combine_tagged_division_topdown:
  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  assumes f: "f integrable_on cbox a b"
    and p: "p tagged_division_of (cbox a b)"
  shows "(f has_integral (sum (\<lambda>(x,K). integral K f) p)) (cbox a b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f has_integral (\<Sum>(x, K)\<in>p. integral K f)) (cbox a b)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (f has_integral (\<Sum>(x, K)\<in>p. integral K f)) (cbox a b)
[PROOF STEP]
have "(f has_integral integral K f) K" if "(x,K) \<in> p" for x K
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f has_integral integral K f) K
[PROOF STEP]
by (metis assms integrable_integral integrable_on_subcbox tagged_division_ofD(3,4) that)
[PROOF STATE]
proof (state)
this:
(?x, ?K) \<in> p \<Longrightarrow> (f has_integral integral ?K f) ?K

goal (1 subgoal):
 1. (f has_integral (\<Sum>(x, K)\<in>p. integral K f)) (cbox a b)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(?x, ?K) \<in> p \<Longrightarrow> (f has_integral integral ?K f) ?K
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(?x, ?K) \<in> p \<Longrightarrow> (f has_integral integral ?K f) ?K

goal (1 subgoal):
 1. (f has_integral (\<Sum>(x, K)\<in>p. integral K f)) (cbox a b)
[PROOF STEP]
by (simp add: has_integral_combine_tagged_division p)
[PROOF STATE]
proof (state)
this:
(f has_integral (\<Sum>(x, K)\<in>p. integral K f)) (cbox a b)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma combining_sys_satisfies_properties:
  fixes p:: "real poly"
  fixes qs1 :: "real poly list"
  fixes qs2 :: "real poly list"
  assumes nonzero: "p \<noteq> 0"
  assumes nontriv1: "length qs1 > 0"
  assumes pairwise_rel_prime1: "\<forall>q. ((List.member qs1 q) \<longrightarrow> (coprime p q))"
  assumes nontriv2: "length qs2 > 0"
  assumes pairwise_rel_prime2: "\<forall>q. ((List.member qs2 q) \<longrightarrow> (coprime p q))"
  assumes satisfies_properties_sys1: "satisfies_properties p qs1 (get_subsets (calculate_data p qs1)) (get_signs (calculate_data p qs1)) (get_matrix (calculate_data p qs1))"
  assumes satisfies_properties_sys2: "satisfies_properties p qs2 (get_subsets (calculate_data p qs2)) (get_signs (calculate_data p qs2)) (get_matrix (calculate_data p qs2))"
  shows  "satisfies_properties p (qs1@qs2) (get_subsets (snd ((combine_systems p (qs1,calculate_data p qs1) (qs2,calculate_data p qs2)))))
  (get_signs (snd ((combine_systems p (qs1,calculate_data p qs1) (qs2,calculate_data p qs2)))))
  (get_matrix (snd ((combine_systems p (qs1,calculate_data p qs1) (qs2,calculate_data p qs2)))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. satisfies_properties p (qs1 @ qs2) (get_subsets (snd (combine_systems p (qs1, calculate_data p qs1) (qs2, calculate_data p qs2)))) (get_signs (snd (combine_systems p (qs1, calculate_data p qs1) (qs2, calculate_data p qs2)))) (get_matrix (snd (combine_systems p (qs1, calculate_data p qs1) (qs2, calculate_data p qs2))))
[PROOF STEP]
using combining_sys_satisfies_properties_helper
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?p \<noteq> 0; 0 < length ?qs1.0; \<forall>q. List.member ?qs1.0 q \<longrightarrow> coprime ?p q; 0 < length ?qs2.0; \<forall>q. List.member ?qs2.0 q \<longrightarrow> coprime ?p q; satisfies_properties ?p ?qs1.0 ?subsets1.0 ?signs1.0 ?matrix1.0; satisfies_properties ?p ?qs2.0 ?subsets2.0 ?signs2.0 ?matrix2.0\<rbrakk> \<Longrightarrow> satisfies_properties ?p (?qs1.0 @ ?qs2.0) (get_subsets (snd (combine_systems ?p (?qs1.0, ?matrix1.0, ?subsets1.0, ?signs1.0) (?qs2.0, ?matrix2.0, ?subsets2.0, ?signs2.0)))) (get_signs (snd (combine_systems ?p (?qs1.0, ?matrix1.0, ?subsets1.0, ?signs1.0) (?qs2.0, ?matrix2.0, ?subsets2.0, ?signs2.0)))) (get_matrix (snd (combine_systems ?p (?qs1.0, ?matrix1.0, ?subsets1.0, ?signs1.0) (?qs2.0, ?matrix2.0, ?subsets2.0, ?signs2.0))))

goal (1 subgoal):
 1. satisfies_properties p (qs1 @ qs2) (get_subsets (snd (combine_systems p (qs1, calculate_data p qs1) (qs2, calculate_data p qs2)))) (get_signs (snd (combine_systems p (qs1, calculate_data p qs1) (qs2, calculate_data p qs2)))) (get_matrix (snd (combine_systems p (qs1, calculate_data p qs1) (qs2, calculate_data p qs2))))
[PROOF STEP]
by (metis getter_functions nontriv1 nontriv2 nonzero pairwise_rel_prime1 pairwise_rel_prime2 nonzero satisfies_properties_sys1 satisfies_properties_sys2)


[STATEMENT]
lemma contour_integrable_negatepath:
  assumes \<gamma>: "valid_path \<gamma>" and pi: "(\<lambda>z. f (- z)) contour_integrable_on \<gamma>"
  shows "f contour_integrable_on (uminus \<circ> \<gamma>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f contour_integrable_on uminus \<circ> \<gamma>
[PROOF STEP]
by (metis \<gamma> add.inverse_inverse contour_integrable_on_def has_contour_integral_negatepath pi)


[STATEMENT]
lemma separatedin_closed_sets:
     "\<lbrakk>closedin X S; closedin X T\<rbrakk> \<Longrightarrow> separatedin X S T \<longleftrightarrow> disjnt S T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>closedin X S; closedin X T\<rbrakk> \<Longrightarrow> separatedin X S T = disjnt S T
[PROOF STEP]
unfolding closure_of_eq disjnt_def separatedin_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>closedin X S; closedin X T\<rbrakk> \<Longrightarrow> (S \<subseteq> topspace X \<and> T \<subseteq> topspace X \<and> S \<inter> X closure_of T = {} \<and> T \<inter> X closure_of S = {}) = (S \<inter> T = {})
[PROOF STEP]
by (metis closedin_def closure_of_eq inf_commute)


[STATEMENT]
lemma tendsto_Pair [tendsto_intros]:
  assumes "(f \<longlongrightarrow> a) F" and "(g \<longlongrightarrow> b) F"
  shows "((\<lambda>x. (f x, g x)) \<longlongrightarrow> (a, b)) F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. (f x, g x)) \<longlongrightarrow> (a, b)) F
[PROOF STEP]
unfolding nhds_prod
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LIM x F. (f x, g x) :> nhds a \<times>\<^sub>F nhds b
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
(f \<longlongrightarrow> a) F
(g \<longlongrightarrow> b) F

goal (1 subgoal):
 1. LIM x F. (f x, g x) :> nhds a \<times>\<^sub>F nhds b
[PROOF STEP]
by (rule filterlim_Pair)


[STATEMENT]
lemma subtuple_to_trancl:
  "reflp r \<Longrightarrow>
   subtuple r\<^sup>+\<^sup>+ xm ym \<Longrightarrow>
   (subtuple r)\<^sup>+\<^sup>+ xm ym"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>reflp r; subtuple r\<^sup>+\<^sup>+ xm ym\<rbrakk> \<Longrightarrow> (subtuple r)\<^sup>+\<^sup>+ xm ym
[PROOF STEP]
apply (rule fmrel_to_subtuple_trancl)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>reflp r; subtuple r\<^sup>+\<^sup>+ xm ym\<rbrakk> \<Longrightarrow> reflp r
 2. \<lbrakk>reflp r; subtuple r\<^sup>+\<^sup>+ xm ym\<rbrakk> \<Longrightarrow> (fmrel r)\<^sup>+\<^sup>+ (fmrestrict_fset (fmdom ym) xm) ym
[PROOF STEP]
unfolding fmrel_on_fset_fmrel_restrict
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>reflp r; fmrel r\<^sup>+\<^sup>+ (fmrestrict_fset (fmdom ym) xm) (fmrestrict_fset (fmdom ym) ym)\<rbrakk> \<Longrightarrow> reflp r
 2. \<lbrakk>reflp r; fmrel r\<^sup>+\<^sup>+ (fmrestrict_fset (fmdom ym) xm) (fmrestrict_fset (fmdom ym) ym)\<rbrakk> \<Longrightarrow> (fmrel r)\<^sup>+\<^sup>+ (fmrestrict_fset (fmdom ym) xm) ym
[PROOF STEP]
by (simp_all add: fmrel_to_trancl)


[STATEMENT]
lemma tl_rev_take_Suc:
  "n + 1 \<le> length l \<Longrightarrow> rev (take n l) = tl (rev (take (Suc n) l))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n + 1 \<le> length l \<Longrightarrow> rev (take n l) = tl (rev (take (Suc n) l))
[PROOF STEP]
by(simp add: rev_take tl_drop Suc_diff_Suc flip: drop_Suc)


[STATEMENT]
lemma (in comm_group) subgroup_imp_normal: "subgroup A G \<Longrightarrow> A \<lhd> G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. subgroup A G \<Longrightarrow> A \<lhd> G
[PROOF STEP]
by (simp add: normal_def normal_axioms_def is_group l_coset_def r_coset_def m_comm subgroup.mem_carrier)


[STATEMENT]
lemma to_nat_on_finite: "finite S \<Longrightarrow> bij_betw (to_nat_on S) S {..< card S}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite S \<Longrightarrow> bij_betw (to_nat_on S) S {..<card S}
[PROOF STEP]
using ex_bij_betw_finite_nat
[PROOF STATE]
proof (prove)
using this:
finite ?M \<Longrightarrow> \<exists>h. bij_betw h ?M {0..<card ?M}

goal (1 subgoal):
 1. finite S \<Longrightarrow> bij_betw (to_nat_on S) S {..<card S}
[PROOF STEP]
unfolding to_nat_on_def
[PROOF STATE]
proof (prove)
using this:
finite ?M \<Longrightarrow> \<exists>h. bij_betw h ?M {0..<card ?M}

goal (1 subgoal):
 1. finite S \<Longrightarrow> bij_betw (SOME f. if finite S then bij_betw f S {..<card S} else bij_betw f S UNIV) S {..<card S}
[PROOF STEP]
by (intro someI2_ex[where Q="\<lambda>f. bij_betw f S {..<card S}"]) (auto simp add: atLeast0LessThan)


[STATEMENT]
lemma beukers_nn_integral1_same:
  assumes "r = s"
  shows   "beukers_nn_integral1 r s = ennreal (2 * (Re (zeta 3) - (\<Sum>k=1..r. 1 / k ^ 3)))"
    and   "2 * (Re (zeta 3) - (\<Sum>k=1..r. 1 / k ^ 3)) \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. beukers_nn_integral1 r s = ennreal (2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3)))) &&& 0 \<le> 2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. beukers_nn_integral1 r s = ennreal (2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3))))
 2. 0 \<le> 2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3)))
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
r = s
[PROOF STEP]
have [simp]: "s = r"
[PROOF STATE]
proof (prove)
using this:
r = s

goal (1 subgoal):
 1. s = r
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
s = r

goal (2 subgoals):
 1. beukers_nn_integral1 r s = ennreal (2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3))))
 2. 0 \<le> 2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3)))
[PROOF STEP]
have *: "Suc 2 = 3"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc 2 = 3
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Suc 2 = 3

goal (2 subgoals):
 1. beukers_nn_integral1 r s = ennreal (2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3))))
 2. 0 \<le> 2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3)))
[PROOF STEP]
have "beukers_nn_integral1 r s = (\<Sum>k. ennreal (2 / (r + k + 1) ^ 3))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. beukers_nn_integral1 r s = (\<Sum>k. ennreal (2 / real ((r + k + 1) ^ 3)))
[PROOF STEP]
unfolding beukers_nn_integral1_series
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k. ennreal (1 / real ((k + r + 1)\<^sup>2 * (k + s + 1)) + 1 / real ((k + r + 1) * (k + s + 1)\<^sup>2))) = (\<Sum>k. ennreal (2 / real ((r + k + 1) ^ 3)))
[PROOF STEP]
by (simp only: assms power_Suc [symmetric] mult.commute[of "x ^ 2" for x] *
                   times_divide_eq_right mult_1_right add_ac flip: mult_2)
[PROOF STATE]
proof (state)
this:
beukers_nn_integral1 r s = (\<Sum>k. ennreal (2 / real ((r + k + 1) ^ 3)))

goal (2 subgoals):
 1. beukers_nn_integral1 r s = ennreal (2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3))))
 2. 0 \<le> 2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
beukers_nn_integral1 r s = (\<Sum>k. ennreal (2 / real ((r + k + 1) ^ 3)))

goal (2 subgoals):
 1. beukers_nn_integral1 r s = ennreal (2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3))))
 2. 0 \<le> 2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3)))
[PROOF STEP]
have **: "(\<lambda>k. 2 / (r + k + 1) ^ 3) sums
              (2 * (Re (zeta 3) - (\<Sum>k=1..r. 1 / k ^ 3)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>k. 2 / real ((r + k + 1) ^ 3)) sums (2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3))))
[PROOF STEP]
using sums_mult[OF sums_Re_zeta_of_nat_offset[of 3], of 2]
[PROOF STATE]
proof (prove)
using this:
1 < 3 \<Longrightarrow> (\<lambda>n. 2 * (1 / real ((?r1 + n + 1) ^ 3))) sums (2 * (Re (zeta (of_nat 3)) - (\<Sum>k = 1..?r1. 1 / real (k ^ 3))))

goal (1 subgoal):
 1. (\<lambda>k. 2 / real ((r + k + 1) ^ 3)) sums (2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3))))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<lambda>k. 2 / real ((r + k + 1) ^ 3)) sums (2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3))))

goal (2 subgoals):
 1. beukers_nn_integral1 r s = ennreal (2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3))))
 2. 0 \<le> 2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3)))
[PROOF STEP]
hence "(\<Sum>k. ennreal (2 / (r + k + 1) ^ 3)) = ennreal \<dots>"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>k. 2 / real ((r + k + 1) ^ 3)) sums (2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3))))

goal (1 subgoal):
 1. (\<Sum>k. ennreal (2 / real ((r + k + 1) ^ 3))) = ennreal (2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3))))
[PROOF STEP]
by (intro suminf_ennreal_eq) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>k. ennreal (2 / real ((r + k + 1) ^ 3))) = ennreal (2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3))))

goal (2 subgoals):
 1. beukers_nn_integral1 r s = ennreal (2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3))))
 2. 0 \<le> 2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3)))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
beukers_nn_integral1 r s = ennreal (2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3))))
[PROOF STEP]
show "beukers_nn_integral1 r s = ennreal (2 * (Re (zeta 3) - (\<Sum>k=1..r. 1 / k ^ 3)))"
[PROOF STATE]
proof (prove)
using this:
beukers_nn_integral1 r s = ennreal (2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3))))

goal (1 subgoal):
 1. beukers_nn_integral1 r s = ennreal (2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3))))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
beukers_nn_integral1 r s = ennreal (2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3))))

goal (1 subgoal):
 1. 0 \<le> 2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3)))
[PROOF STEP]
show "2 * (Re (zeta 3) - (\<Sum>k=1..r. 1 / k ^ 3)) \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> 2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3)))
[PROOF STEP]
by (rule sums_le[OF _ sums_zero **]) auto
[PROOF STATE]
proof (state)
this:
0 \<le> 2 * (Re (zeta 3) - (\<Sum>k = 1..r. 1 / real (k ^ 3)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma DirProds_mult:
  "(\<otimes>\<^bsub>DirProds G I\<^esub>) = (\<lambda>x y. restrict (\<lambda>i. x i \<otimes>\<^bsub>G i\<^esub> y i) I)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<otimes>\<^bsub>DirProds G I\<^esub>) = (\<lambda>x y. \<lambda>i\<in>I. x i \<otimes>\<^bsub>G i\<^esub> y i)
[PROOF STEP]
unfolding DirProds_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<otimes>\<^bsub>\<lparr>carrier = Pi\<^sub>E I (carrier \<circ> G), monoid.mult = \<lambda>x y. \<lambda>i\<in>I. x i \<otimes>\<^bsub>G i\<^esub> y i, one = \<lambda>i\<in>I. \<one>\<^bsub>G i\<^esub>\<rparr>\<^esub>) = (\<lambda>x y. \<lambda>i\<in>I. x i \<otimes>\<^bsub>G i\<^esub> y i)
[PROOF STEP]
by simp


[STATEMENT]
lemma fset_of_list_sort: "fset_of_list l = fset_of_list (sort l)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fset_of_list l = fset_of_list (sort l)
[PROOF STEP]
by (simp add: fset_of_list.abs_eq)