[STATEMENT]
lemma smallest_norm_exists:
  \<comment> \<open>Theorem 2.5 in @{cite conway2013course} (inside the proof)\<close>
  includes notation_norm
  fixes M :: \<open>'a::chilbert_space set\<close>
  assumes q1: \<open>convex M\<close> and q2: \<open>closed M\<close> and q3: \<open>M \<noteq> {}\<close>
  shows  \<open>\<exists>k. is_arg_min (\<lambda> x. \<parallel>x\<parallel>) (\<lambda> t. t \<in> M) k\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
define d where \<open>d = Inf { \<parallel>x\<parallel>^2 | x. x \<in> M }\<close>
[PROOF STATE]
proof (state)
this:
d = Inf {\<parallel>x\<parallel>\<^sup>2 |x. x \<in> M}

goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
have w4: \<open>{ \<parallel>x\<parallel>^2 | x. x \<in> M } \<noteq> {}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {\<parallel>x\<parallel>\<^sup>2 |x. x \<in> M} \<noteq> {}
[PROOF STEP]
by (simp add: assms(3))
[PROOF STATE]
proof (state)
this:
{\<parallel>x\<parallel>\<^sup>2 |x. x \<in> M} \<noteq> {}

goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
have \<open>\<forall> x. \<parallel>x\<parallel>^2 \<ge> 0\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x. 0 \<le> \<parallel>x\<parallel>\<^sup>2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<forall>x. 0 \<le> \<parallel>x\<parallel>\<^sup>2

goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
hence bdd_below1: \<open>bdd_below { \<parallel>x\<parallel>^2 | x. x \<in> M }\<close>
[PROOF STATE]
proof (prove)
using this:
\<forall>x. 0 \<le> \<parallel>x\<parallel>\<^sup>2

goal (1 subgoal):
 1. bdd_below {\<parallel>x\<parallel>\<^sup>2 |x. x \<in> M}
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
bdd_below {\<parallel>x\<parallel>\<^sup>2 |x. x \<in> M}

goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
have \<open>d \<le> \<parallel>x\<parallel>^2\<close> if a1: "x \<in> M" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. d \<le> \<parallel>x\<parallel>\<^sup>2
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. d \<le> \<parallel>x\<parallel>\<^sup>2
[PROOF STEP]
have "\<forall>v. (\<exists>w. Re (v \<bullet>\<^sub>C v) = \<parallel>w\<parallel>\<^sup>2 \<and> w \<in> M) \<or> v \<notin> M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>v. (\<exists>w. Re (v \<bullet>\<^sub>C v) = \<parallel>w\<parallel>\<^sup>2 \<and> w \<in> M) \<or> v \<notin> M
[PROOF STEP]
by (metis (no_types) power2_norm_eq_cinner')
[PROOF STATE]
proof (state)
this:
\<forall>v. (\<exists>w. Re (v \<bullet>\<^sub>C v) = \<parallel>w\<parallel>\<^sup>2 \<and> w \<in> M) \<or> v \<notin> M

goal (1 subgoal):
 1. d \<le> \<parallel>x\<parallel>\<^sup>2
[PROOF STEP]
hence "Re (x \<bullet>\<^sub>C x) \<in> {\<parallel>v\<parallel>\<^sup>2 |v. v \<in> M}"
[PROOF STATE]
proof (prove)
using this:
\<forall>v. (\<exists>w. Re (v \<bullet>\<^sub>C v) = \<parallel>w\<parallel>\<^sup>2 \<and> w \<in> M) \<or> v \<notin> M

goal (1 subgoal):
 1. Re (x \<bullet>\<^sub>C x) \<in> {\<parallel>v\<parallel>\<^sup>2 |v. v \<in> M}
[PROOF STEP]
using a1
[PROOF STATE]
proof (prove)
using this:
\<forall>v. (\<exists>w. Re (v \<bullet>\<^sub>C v) = \<parallel>w\<parallel>\<^sup>2 \<and> w \<in> M) \<or> v \<notin> M
x \<in> M

goal (1 subgoal):
 1. Re (x \<bullet>\<^sub>C x) \<in> {\<parallel>v\<parallel>\<^sup>2 |v. v \<in> M}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
Re (x \<bullet>\<^sub>C x) \<in> {\<parallel>v\<parallel>\<^sup>2 |v. v \<in> M}

goal (1 subgoal):
 1. d \<le> \<parallel>x\<parallel>\<^sup>2
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
Re (x \<bullet>\<^sub>C x) \<in> {\<parallel>v\<parallel>\<^sup>2 |v. v \<in> M}

goal (1 subgoal):
 1. d \<le> \<parallel>x\<parallel>\<^sup>2
[PROOF STEP]
unfolding d_def
[PROOF STATE]
proof (prove)
using this:
Re (x \<bullet>\<^sub>C x) \<in> {\<parallel>v\<parallel>\<^sup>2 |v. v \<in> M}

goal (1 subgoal):
 1. Inf {\<parallel>x\<parallel>\<^sup>2 |x. x \<in> M} \<le> \<parallel>x\<parallel>\<^sup>2
[PROOF STEP]
by (metis (lifting) bdd_below1 cInf_lower power2_norm_eq_cinner')
[PROOF STATE]
proof (state)
this:
d \<le> \<parallel>x\<parallel>\<^sup>2

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?x1 \<in> M \<Longrightarrow> d \<le> \<parallel>?x1\<parallel>\<^sup>2

goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
have \<open>\<forall> \<epsilon> > 0. \<exists> t \<in> { \<parallel>x\<parallel>^2 | x. x \<in> M }.  t < d + \<epsilon>\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<epsilon>>0. \<exists>t\<in>{\<parallel>x\<parallel>\<^sup>2 |x. x \<in> M}. t < d + \<epsilon>
[PROOF STEP]
unfolding d_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<epsilon>>0. \<exists>t\<in>{\<parallel>x\<parallel>\<^sup>2 |x. x \<in> M}. t < Inf {\<parallel>x\<parallel>\<^sup>2 |x. x \<in> M} + \<epsilon>
[PROOF STEP]
using w4  bdd_below1
[PROOF STATE]
proof (prove)
using this:
{\<parallel>x\<parallel>\<^sup>2 |x. x \<in> M} \<noteq> {}
bdd_below {\<parallel>x\<parallel>\<^sup>2 |x. x \<in> M}

goal (1 subgoal):
 1. \<forall>\<epsilon>>0. \<exists>t\<in>{\<parallel>x\<parallel>\<^sup>2 |x. x \<in> M}. t < Inf {\<parallel>x\<parallel>\<^sup>2 |x. x \<in> M} + \<epsilon>
[PROOF STEP]
by (meson cInf_lessD less_add_same_cancel1)
[PROOF STATE]
proof (state)
this:
\<forall>\<epsilon>>0. \<exists>t\<in>{\<parallel>x\<parallel>\<^sup>2 |x. x \<in> M}. t < d + \<epsilon>

goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
hence \<open>\<forall> \<epsilon> > 0. \<exists> x \<in> M.  \<parallel>x\<parallel>^2 < d + \<epsilon>\<close>
[PROOF STATE]
proof (prove)
using this:
\<forall>\<epsilon>>0. \<exists>t\<in>{\<parallel>x\<parallel>\<^sup>2 |x. x \<in> M}. t < d + \<epsilon>

goal (1 subgoal):
 1. \<forall>\<epsilon>>0. \<exists>x\<in>M. \<parallel>x\<parallel>\<^sup>2 < d + \<epsilon>
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>\<epsilon>>0. \<exists>x\<in>M. \<parallel>x\<parallel>\<^sup>2 < d + \<epsilon>

goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
hence \<open>\<forall> \<epsilon> > 0. \<exists> x \<in> M.  \<parallel>x\<parallel>^2 < d + \<epsilon>\<close>
[PROOF STATE]
proof (prove)
using this:
\<forall>\<epsilon>>0. \<exists>x\<in>M. \<parallel>x\<parallel>\<^sup>2 < d + \<epsilon>

goal (1 subgoal):
 1. \<forall>\<epsilon>>0. \<exists>x\<in>M. \<parallel>x\<parallel>\<^sup>2 < d + \<epsilon>
[PROOF STEP]
by (simp add: \<open>\<And>x. x \<in> M \<Longrightarrow> d \<le> \<parallel>x\<parallel>\<^sup>2\<close>)
[PROOF STATE]
proof (state)
this:
\<forall>\<epsilon>>0. \<exists>x\<in>M. \<parallel>x\<parallel>\<^sup>2 < d + \<epsilon>

goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
hence w1: \<open>\<forall> n::nat. \<exists> x \<in> M.  \<parallel>x\<parallel>^2 < d + 1/(n+1)\<close>
[PROOF STATE]
proof (prove)
using this:
\<forall>\<epsilon>>0. \<exists>x\<in>M. \<parallel>x\<parallel>\<^sup>2 < d + \<epsilon>

goal (1 subgoal):
 1. \<forall>x. \<exists>xa\<in>M. \<parallel>xa\<parallel>\<^sup>2 < d + 1 / (real x + 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>x. \<exists>xa\<in>M. \<parallel>xa\<parallel>\<^sup>2 < d + 1 / (real x + 1)

goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>x. \<exists>xa\<in>M. \<parallel>xa\<parallel>\<^sup>2 < d + 1 / (real x + 1)
[PROOF STEP]
obtain r::\<open>nat \<Rightarrow> 'a\<close> where w2: \<open>\<forall> n. r n \<in> M \<and>  \<parallel> r n \<parallel>^2 < d + 1/(n+1)\<close>
[PROOF STATE]
proof (prove)
using this:
\<forall>x. \<exists>xa\<in>M. \<parallel>xa\<parallel>\<^sup>2 < d + 1 / (real x + 1)

goal (1 subgoal):
 1. (\<And>r. \<forall>n. r n \<in> M \<and> \<parallel>r n\<parallel>\<^sup>2 < d + 1 / (real n + 1) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
\<forall>n. r n \<in> M \<and> \<parallel>r n\<parallel>\<^sup>2 < d + 1 / (real n + 1)

goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
have w3: \<open>\<forall> n. r n \<in> M\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>n. r n \<in> M
[PROOF STEP]
by (simp add: w2)
[PROOF STATE]
proof (state)
this:
\<forall>n. r n \<in> M

goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
have \<open>\<forall> n. \<parallel> r n \<parallel>^2 < d + 1/(n+1)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>n. \<parallel>r n\<parallel>\<^sup>2 < d + 1 / (real n + 1)
[PROOF STEP]
by (simp add: w2)
[PROOF STATE]
proof (state)
this:
\<forall>n. \<parallel>r n\<parallel>\<^sup>2 < d + 1 / (real n + 1)

goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
have w5: \<open>\<parallel> (r n) - (r m) \<parallel>^2 < 2*(1/(n+1) + 1/(m+1))\<close>
    for m n
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
have w6: \<open>\<parallel> r n \<parallel>^2 < d + 1/(n+1)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>r n\<parallel>\<^sup>2 < d + 1 / real (n + 1)
[PROOF STEP]
by (metis w2  of_nat_1 of_nat_add)
[PROOF STATE]
proof (state)
this:
\<parallel>r n\<parallel>\<^sup>2 < d + 1 / real (n + 1)

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
have \<open> \<parallel> r m \<parallel>^2 < d + 1/(m+1)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>r m\<parallel>\<^sup>2 < d + 1 / real (m + 1)
[PROOF STEP]
by (metis w2 of_nat_1 of_nat_add)
[PROOF STATE]
proof (state)
this:
\<parallel>r m\<parallel>\<^sup>2 < d + 1 / real (m + 1)

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
have \<open>(r n) \<in> M\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r n \<in> M
[PROOF STEP]
by (simp add: \<open>\<forall>n. r n \<in> M\<close>)
[PROOF STATE]
proof (state)
this:
r n \<in> M

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
r n \<in> M

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
have \<open>(r m) \<in> M\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r m \<in> M
[PROOF STEP]
by (simp add: \<open>\<forall>n. r n \<in> M\<close>)
[PROOF STATE]
proof (state)
this:
r m \<in> M

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
r n \<in> M
r m \<in> M
[PROOF STEP]
have \<open>(1/2) *\<^sub>R (r n) + (1/2) *\<^sub>R (r m) \<in> M\<close>
[PROOF STATE]
proof (prove)
using this:
r n \<in> M
r m \<in> M

goal (1 subgoal):
 1. (1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m \<in> M
[PROOF STEP]
using \<open>convex M\<close>
[PROOF STATE]
proof (prove)
using this:
r n \<in> M
r m \<in> M
convex M

goal (1 subgoal):
 1. (1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m \<in> M
[PROOF STEP]
by (simp add: convexD)
[PROOF STATE]
proof (state)
this:
(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m \<in> M

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
hence \<open>\<parallel> (1/2) *\<^sub>R (r n) + (1/2) *\<^sub>R (r m) \<parallel>^2 \<ge> d\<close>
[PROOF STATE]
proof (prove)
using this:
(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m \<in> M

goal (1 subgoal):
 1. d \<le> \<parallel>(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2
[PROOF STEP]
by (simp add: \<open>\<And>x. x \<in> M \<Longrightarrow> d \<le> \<parallel>x\<parallel>\<^sup>2\<close>)
[PROOF STATE]
proof (state)
this:
d \<le> \<parallel>(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
have \<open>\<parallel> (1/2) *\<^sub>R (r n) - (1/2) *\<^sub>R (r m) \<parallel>^2
              = (1/2)*( \<parallel> r n \<parallel>^2 + \<parallel> r m \<parallel>^2 ) - \<parallel> (1/2) *\<^sub>R (r n) + (1/2) *\<^sub>R (r m) \<parallel>^2\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>(1 / 2) *\<^sub>R r n - (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2 = 1 / 2 * (\<parallel>r n\<parallel>\<^sup>2 + \<parallel>r m\<parallel>\<^sup>2) - \<parallel>(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2
[PROOF STEP]
by (smt (z3) div_by_1 field_sum_of_halves nonzero_mult_div_cancel_left parallelogram_law polar_identity power2_norm_eq_cinner' scaleR_collapse times_divide_eq_left)
[PROOF STATE]
proof (state)
this:
\<parallel>(1 / 2) *\<^sub>R r n - (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2 = 1 / 2 * (\<parallel>r n\<parallel>\<^sup>2 + \<parallel>r m\<parallel>\<^sup>2) - \<parallel>(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<parallel>(1 / 2) *\<^sub>R r n - (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2 = 1 / 2 * (\<parallel>r n\<parallel>\<^sup>2 + \<parallel>r m\<parallel>\<^sup>2) - \<parallel>(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
have  \<open>...
              < (1/2)*( d + 1/(n+1) + \<parallel> r m \<parallel>^2 ) - \<parallel> (1/2) *\<^sub>R (r n) + (1/2) *\<^sub>R (r m) \<parallel>^2\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 / 2 * (\<parallel>r n\<parallel>\<^sup>2 + \<parallel>r m\<parallel>\<^sup>2) - \<parallel>(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2 < 1 / 2 * (d + 1 / real (n + 1) + \<parallel>r m\<parallel>\<^sup>2) - \<parallel>(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2
[PROOF STEP]
using \<open>\<parallel>r n\<parallel>\<^sup>2 < d + 1 / real (n + 1)\<close>
[PROOF STATE]
proof (prove)
using this:
\<parallel>r n\<parallel>\<^sup>2 < d + 1 / real (n + 1)

goal (1 subgoal):
 1. 1 / 2 * (\<parallel>r n\<parallel>\<^sup>2 + \<parallel>r m\<parallel>\<^sup>2) - \<parallel>(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2 < 1 / 2 * (d + 1 / real (n + 1) + \<parallel>r m\<parallel>\<^sup>2) - \<parallel>(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
1 / 2 * (\<parallel>r n\<parallel>\<^sup>2 + \<parallel>r m\<parallel>\<^sup>2) - \<parallel>(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2 < 1 / 2 * (d + 1 / real (n + 1) + \<parallel>r m\<parallel>\<^sup>2) - \<parallel>(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 / 2 * (\<parallel>r n\<parallel>\<^sup>2 + \<parallel>r m\<parallel>\<^sup>2) - \<parallel>(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2 < 1 / 2 * (d + 1 / real (n + 1) + \<parallel>r m\<parallel>\<^sup>2) - \<parallel>(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
have  \<open>...
              < (1/2)*( d + 1/(n+1) + d + 1/(m+1) ) - \<parallel> (1/2) *\<^sub>R (r n) + (1/2) *\<^sub>R (r m) \<parallel>^2\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 / 2 * (d + 1 / real (n + 1) + \<parallel>r m\<parallel>\<^sup>2) - \<parallel>(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2 < 1 / 2 * (d + 1 / real (n + 1) + d + 1 / real (m + 1)) - \<parallel>(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2
[PROOF STEP]
using \<open>\<parallel>r m\<parallel>\<^sup>2 < d + 1 / real (m + 1)\<close>
[PROOF STATE]
proof (prove)
using this:
\<parallel>r m\<parallel>\<^sup>2 < d + 1 / real (m + 1)

goal (1 subgoal):
 1. 1 / 2 * (d + 1 / real (n + 1) + \<parallel>r m\<parallel>\<^sup>2) - \<parallel>(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2 < 1 / 2 * (d + 1 / real (n + 1) + d + 1 / real (m + 1)) - \<parallel>(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
1 / 2 * (d + 1 / real (n + 1) + \<parallel>r m\<parallel>\<^sup>2) - \<parallel>(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2 < 1 / 2 * (d + 1 / real (n + 1) + d + 1 / real (m + 1)) - \<parallel>(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 / 2 * (d + 1 / real (n + 1) + \<parallel>r m\<parallel>\<^sup>2) - \<parallel>(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2 < 1 / 2 * (d + 1 / real (n + 1) + d + 1 / real (m + 1)) - \<parallel>(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
have  \<open>...
              \<le> (1/2)*( d + 1/(n+1) + d + 1/(m+1) ) - d\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 / 2 * (d + 1 / real (n + 1) + d + 1 / real (m + 1)) - \<parallel>(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2 \<le> 1 / 2 * (d + 1 / real (n + 1) + d + 1 / real (m + 1)) - d
[PROOF STEP]
by (simp add: \<open>d \<le> \<parallel>(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2\<close>)
[PROOF STATE]
proof (state)
this:
1 / 2 * (d + 1 / real (n + 1) + d + 1 / real (m + 1)) - \<parallel>(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2 \<le> 1 / 2 * (d + 1 / real (n + 1) + d + 1 / real (m + 1)) - d

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 / 2 * (d + 1 / real (n + 1) + d + 1 / real (m + 1)) - \<parallel>(1 / 2) *\<^sub>R r n + (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2 \<le> 1 / 2 * (d + 1 / real (n + 1) + d + 1 / real (m + 1)) - d

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
have  \<open>...
              \<le> (1/2)*( 1/(n+1) + 1/(m+1) + 2*d ) - d\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 / 2 * (d + 1 / real (n + 1) + d + 1 / real (m + 1)) - d \<le> 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1) + 2 * d) - d
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 / 2 * (d + 1 / real (n + 1) + d + 1 / real (m + 1)) - d \<le> 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1) + 2 * d) - d

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 / 2 * (d + 1 / real (n + 1) + d + 1 / real (m + 1)) - d \<le> 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1) + 2 * d) - d

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
have  \<open>...
              \<le> (1/2)*( 1/(n+1) + 1/(m+1) ) + (1/2)*(2*d) - d\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1) + 2 * d) - d \<le> 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1)) + 1 / 2 * (2 * d) - d
[PROOF STEP]
by (simp add: distrib_left)
[PROOF STATE]
proof (state)
this:
1 / 2 * (1 / real (n + 1) + 1 / real (m + 1) + 2 * d) - d \<le> 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1)) + 1 / 2 * (2 * d) - d

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 / 2 * (1 / real (n + 1) + 1 / real (m + 1) + 2 * d) - d \<le> 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1)) + 1 / 2 * (2 * d) - d

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
have  \<open>...
              \<le> (1/2)*( 1/(n+1) + 1/(m+1) ) + d - d\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1)) + 1 / 2 * (2 * d) - d \<le> 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1)) + d - d
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 / 2 * (1 / real (n + 1) + 1 / real (m + 1)) + 1 / 2 * (2 * d) - d \<le> 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1)) + d - d

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 / 2 * (1 / real (n + 1) + 1 / real (m + 1)) + 1 / 2 * (2 * d) - d \<le> 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1)) + d - d

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
have  \<open>...
              \<le> (1/2)*( 1/(n+1) + 1/(m+1) )\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1)) + d - d \<le> 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 / 2 * (1 / real (n + 1) + 1 / real (m + 1)) + d - d \<le> 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1))

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<parallel>(1 / 2) *\<^sub>R r n - (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2 < 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1))
[PROOF STEP]
have \<open> \<parallel>(1 / 2) *\<^sub>R r n - (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2 < 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1)) \<close>
[PROOF STATE]
proof (prove)
using this:
\<parallel>(1 / 2) *\<^sub>R r n - (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2 < 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1))

goal (1 subgoal):
 1. \<parallel>(1 / 2) *\<^sub>R r n - (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2 < 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<parallel>(1 / 2) *\<^sub>R r n - (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2 < 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1))

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
hence \<open> \<parallel>(1 / 2) *\<^sub>R (r n - r m) \<parallel>\<^sup>2 < (1 / 2) * (1 / real (n + 1) + 1 / real (m + 1)) \<close>
[PROOF STATE]
proof (prove)
using this:
\<parallel>(1 / 2) *\<^sub>R r n - (1 / 2) *\<^sub>R r m\<parallel>\<^sup>2 < 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1))

goal (1 subgoal):
 1. \<parallel>(1 / 2) *\<^sub>R (r n - r m)\<parallel>\<^sup>2 < 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1))
[PROOF STEP]
by (simp add: real_vector.scale_right_diff_distrib)
[PROOF STATE]
proof (state)
this:
\<parallel>(1 / 2) *\<^sub>R (r n - r m)\<parallel>\<^sup>2 < 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1))

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
hence \<open> ((1 / 2)*\<parallel> (r n - r m) \<parallel>)\<^sup>2 < (1 / 2) * (1 / real (n + 1) + 1 / real (m + 1)) \<close>
[PROOF STATE]
proof (prove)
using this:
\<parallel>(1 / 2) *\<^sub>R (r n - r m)\<parallel>\<^sup>2 < 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1))

goal (1 subgoal):
 1. (1 / 2 * \<parallel>r n - r m\<parallel>)\<^sup>2 < 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(1 / 2 * \<parallel>r n - r m\<parallel>)\<^sup>2 < 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1))

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
hence \<open> (1 / 2)^2*(\<parallel> (r n - r m) \<parallel>)\<^sup>2 < (1 / 2) * (1 / real (n + 1) + 1 / real (m + 1)) \<close>
[PROOF STATE]
proof (prove)
using this:
(1 / 2 * \<parallel>r n - r m\<parallel>)\<^sup>2 < 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1))

goal (1 subgoal):
 1. (1 / 2)\<^sup>2 * \<parallel>r n - r m\<parallel>\<^sup>2 < 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1))
[PROOF STEP]
by (metis power_mult_distrib)
[PROOF STATE]
proof (state)
this:
(1 / 2)\<^sup>2 * \<parallel>r n - r m\<parallel>\<^sup>2 < 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1))

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
hence \<open> (1 / 4) *(\<parallel> (r n - r m) \<parallel>)\<^sup>2 < (1 / 2) * (1 / real (n + 1) + 1 / real (m + 1)) \<close>
[PROOF STATE]
proof (prove)
using this:
(1 / 2)\<^sup>2 * \<parallel>r n - r m\<parallel>\<^sup>2 < 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1))

goal (1 subgoal):
 1. 1 / 4 * \<parallel>r n - r m\<parallel>\<^sup>2 < 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1))
[PROOF STEP]
by (simp add: power_divide)
[PROOF STATE]
proof (state)
this:
1 / 4 * \<parallel>r n - r m\<parallel>\<^sup>2 < 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1))

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
hence \<open> \<parallel> (r n - r m) \<parallel>\<^sup>2 < 2 * (1 / real (n + 1) + 1 / real (m + 1)) \<close>
[PROOF STATE]
proof (prove)
using this:
1 / 4 * \<parallel>r n - r m\<parallel>\<^sup>2 < 1 / 2 * (1 / real (n + 1) + 1 / real (m + 1))

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / real (n + 1) + 1 / real (m + 1))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / real (n + 1) + 1 / real (m + 1))

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / real (n + 1) + 1 / real (m + 1))

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))
[PROOF STEP]
by (metis of_nat_1 of_nat_add)
[PROOF STATE]
proof (state)
this:
\<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<parallel>r ?n1 - r ?m1\<parallel>\<^sup>2 < 2 * (1 / (real ?n1 + 1) + 1 / (real ?m1 + 1))

goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
hence "\<exists> N. \<forall> n m. n \<ge> N \<and> m \<ge> N \<longrightarrow> \<parallel> (r n) - (r m) \<parallel>^2 < \<epsilon>^2"
    if "\<epsilon> > 0"
    for \<epsilon>
[PROOF STATE]
proof (prove)
using this:
\<parallel>r ?n1 - r ?m1\<parallel>\<^sup>2 < 2 * (1 / (real ?n1 + 1) + 1 / (real ?m1 + 1))

goal (1 subgoal):
 1. \<exists>N. \<forall>n m. N \<le> n \<and> N \<le> m \<longrightarrow> \<parallel>r n - r m\<parallel>\<^sup>2 < \<epsilon>\<^sup>2
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>n m. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))) \<Longrightarrow> \<exists>N. \<forall>n m. N \<le> n \<and> N \<le> m \<longrightarrow> \<parallel>r n - r m\<parallel>\<^sup>2 < \<epsilon>\<^sup>2
[PROOF STEP]
obtain N::nat where \<open>1/(N + 1) < \<epsilon>^2/4\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>N. 1 / real (N + 1) < \<epsilon>\<^sup>2 / 4 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using LIMSEQ_ignore_initial_segment[OF lim_inverse_n', where k=1]
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. 1 / real (n + 1)) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. (\<And>N. 1 / real (N + 1) < \<epsilon>\<^sup>2 / 4 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis Suc_eq_plus1 \<open>0 < \<epsilon>\<close> nat_approx_posE zero_less_divide_iff zero_less_numeral
          zero_less_power )
[PROOF STATE]
proof (state)
this:
1 / real (N + 1) < \<epsilon>\<^sup>2 / 4

goal (1 subgoal):
 1. (\<And>n m. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))) \<Longrightarrow> \<exists>N. \<forall>n m. N \<le> n \<and> N \<le> m \<longrightarrow> \<parallel>r n - r m\<parallel>\<^sup>2 < \<epsilon>\<^sup>2
[PROOF STEP]
hence \<open>4/(N + 1) < \<epsilon>^2\<close>
[PROOF STATE]
proof (prove)
using this:
1 / real (N + 1) < \<epsilon>\<^sup>2 / 4

goal (1 subgoal):
 1. 4 / real (N + 1) < \<epsilon>\<^sup>2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
4 / real (N + 1) < \<epsilon>\<^sup>2

goal (1 subgoal):
 1. (\<And>n m. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))) \<Longrightarrow> \<exists>N. \<forall>n m. N \<le> n \<and> N \<le> m \<longrightarrow> \<parallel>r n - r m\<parallel>\<^sup>2 < \<epsilon>\<^sup>2
[PROOF STEP]
have "2*(1/(n+1) + 1/(m+1)) < \<epsilon>^2"
      if f1: "n \<ge> N" and f2: "m \<ge> N"
      for m n::nat
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * (1 / real (n + 1) + 1 / real (m + 1)) < \<epsilon>\<^sup>2
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 2 * (1 / real (n + 1) + 1 / real (m + 1)) < \<epsilon>\<^sup>2
[PROOF STEP]
have \<open>1/(n+1) \<le> 1/(N+1)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 / real (n + 1) \<le> 1 / real (N + 1)
[PROOF STEP]
by (simp add: f1 linordered_field_class.frac_le)
[PROOF STATE]
proof (state)
this:
1 / real (n + 1) \<le> 1 / real (N + 1)

goal (1 subgoal):
 1. 2 * (1 / real (n + 1) + 1 / real (m + 1)) < \<epsilon>\<^sup>2
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
1 / real (n + 1) \<le> 1 / real (N + 1)

goal (1 subgoal):
 1. 2 * (1 / real (n + 1) + 1 / real (m + 1)) < \<epsilon>\<^sup>2
[PROOF STEP]
have \<open>1/(m+1) \<le> 1/(N+1)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 / real (m + 1) \<le> 1 / real (N + 1)
[PROOF STEP]
by (simp add: f2 linordered_field_class.frac_le)
[PROOF STATE]
proof (state)
this:
1 / real (m + 1) \<le> 1 / real (N + 1)

goal (1 subgoal):
 1. 2 * (1 / real (n + 1) + 1 / real (m + 1)) < \<epsilon>\<^sup>2
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
1 / real (n + 1) \<le> 1 / real (N + 1)
1 / real (m + 1) \<le> 1 / real (N + 1)
[PROOF STEP]
have  \<open>2*(1/(n+1) + 1/(m+1)) \<le> 4/(N+1)\<close>
[PROOF STATE]
proof (prove)
using this:
1 / real (n + 1) \<le> 1 / real (N + 1)
1 / real (m + 1) \<le> 1 / real (N + 1)

goal (1 subgoal):
 1. 2 * (1 / real (n + 1) + 1 / real (m + 1)) \<le> 4 / real (N + 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 * (1 / real (n + 1) + 1 / real (m + 1)) \<le> 4 / real (N + 1)

goal (1 subgoal):
 1. 2 * (1 / real (n + 1) + 1 / real (m + 1)) < \<epsilon>\<^sup>2
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
2 * (1 / real (n + 1) + 1 / real (m + 1)) \<le> 4 / real (N + 1)

goal (1 subgoal):
 1. 2 * (1 / real (n + 1) + 1 / real (m + 1)) < \<epsilon>\<^sup>2
[PROOF STEP]
using \<open>4/(N + 1) < \<epsilon>^2\<close>
[PROOF STATE]
proof (prove)
using this:
2 * (1 / real (n + 1) + 1 / real (m + 1)) \<le> 4 / real (N + 1)
4 / real (N + 1) < \<epsilon>\<^sup>2

goal (1 subgoal):
 1. 2 * (1 / real (n + 1) + 1 / real (m + 1)) < \<epsilon>\<^sup>2
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
2 * (1 / real (n + 1) + 1 / real (m + 1)) < \<epsilon>\<^sup>2

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<lbrakk>N \<le> ?n1; N \<le> ?m1\<rbrakk> \<Longrightarrow> 2 * (1 / real (?n1 + 1) + 1 / real (?m1 + 1)) < \<epsilon>\<^sup>2

goal (1 subgoal):
 1. (\<And>n m. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))) \<Longrightarrow> \<exists>N. \<forall>n m. N \<le> n \<and> N \<le> m \<longrightarrow> \<parallel>r n - r m\<parallel>\<^sup>2 < \<epsilon>\<^sup>2
[PROOF STEP]
hence "\<parallel> (r n) - (r m) \<parallel>^2 < \<epsilon>^2"
      if y1: "n \<ge> N" and y2: "m \<ge> N"
      for m n::nat
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>N \<le> ?n1; N \<le> ?m1\<rbrakk> \<Longrightarrow> 2 * (1 / real (?n1 + 1) + 1 / real (?m1 + 1)) < \<epsilon>\<^sup>2

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < \<epsilon>\<^sup>2
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>N \<le> ?n1; N \<le> ?m1\<rbrakk> \<Longrightarrow> 2 * (1 / real (?n1 + 1) + 1 / real (?m1 + 1)) < \<epsilon>\<^sup>2
N \<le> n
N \<le> m

goal (1 subgoal):
 1. \<parallel>r n - r m\<parallel>\<^sup>2 < \<epsilon>\<^sup>2
[PROOF STEP]
by (smt \<open>\<And>n m. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))\<close> of_nat_1 of_nat_add)
[PROOF STATE]
proof (state)
this:
\<lbrakk>N \<le> ?n1; N \<le> ?m1\<rbrakk> \<Longrightarrow> \<parallel>r ?n1 - r ?m1\<parallel>\<^sup>2 < \<epsilon>\<^sup>2

goal (1 subgoal):
 1. (\<And>n m. \<parallel>r n - r m\<parallel>\<^sup>2 < 2 * (1 / (real n + 1) + 1 / (real m + 1))) \<Longrightarrow> \<exists>N. \<forall>n m. N \<le> n \<and> N \<le> m \<longrightarrow> \<parallel>r n - r m\<parallel>\<^sup>2 < \<epsilon>\<^sup>2
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>N \<le> ?n1; N \<le> ?m1\<rbrakk> \<Longrightarrow> \<parallel>r ?n1 - r ?m1\<parallel>\<^sup>2 < \<epsilon>\<^sup>2

goal (1 subgoal):
 1. \<exists>N. \<forall>n m. N \<le> n \<and> N \<le> m \<longrightarrow> \<parallel>r n - r m\<parallel>\<^sup>2 < \<epsilon>\<^sup>2
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>N. \<forall>n m. N \<le> n \<and> N \<le> m \<longrightarrow> \<parallel>r n - r m\<parallel>\<^sup>2 < \<epsilon>\<^sup>2

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
0 < ?\<epsilon>1 \<Longrightarrow> \<exists>N. \<forall>n m. N \<le> n \<and> N \<le> m \<longrightarrow> \<parallel>r n - r m\<parallel>\<^sup>2 < ?\<epsilon>1\<^sup>2

goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
hence  \<open>\<forall> \<epsilon> > 0. \<exists> N::nat. \<forall> n m::nat. n \<ge> N \<and> m \<ge> N \<longrightarrow> \<parallel> (r n) - (r m) \<parallel>^2 < \<epsilon>^2\<close>
[PROOF STATE]
proof (prove)
using this:
0 < ?\<epsilon>1 \<Longrightarrow> \<exists>N. \<forall>n m. N \<le> n \<and> N \<le> m \<longrightarrow> \<parallel>r n - r m\<parallel>\<^sup>2 < ?\<epsilon>1\<^sup>2

goal (1 subgoal):
 1. \<forall>\<epsilon>>0. \<exists>N. \<forall>n m. N \<le> n \<and> N \<le> m \<longrightarrow> \<parallel>r n - r m\<parallel>\<^sup>2 < \<epsilon>\<^sup>2
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<forall>\<epsilon>>0. \<exists>N. \<forall>n m. N \<le> n \<and> N \<le> m \<longrightarrow> \<parallel>r n - r m\<parallel>\<^sup>2 < \<epsilon>\<^sup>2

goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
hence  \<open>\<forall> \<epsilon> > 0. \<exists> N::nat. \<forall> n m::nat. n \<ge> N \<and> m \<ge> N \<longrightarrow> \<parallel> (r n) - (r m) \<parallel> < \<epsilon>\<close>
[PROOF STATE]
proof (prove)
using this:
\<forall>\<epsilon>>0. \<exists>N. \<forall>n m. N \<le> n \<and> N \<le> m \<longrightarrow> \<parallel>r n - r m\<parallel>\<^sup>2 < \<epsilon>\<^sup>2

goal (1 subgoal):
 1. \<forall>\<epsilon>>0. \<exists>N. \<forall>n m. N \<le> n \<and> N \<le> m \<longrightarrow> \<parallel>r n - r m\<parallel> < \<epsilon>
[PROOF STEP]
by (meson less_eq_real_def power_less_imp_less_base)
[PROOF STATE]
proof (state)
this:
\<forall>\<epsilon>>0. \<exists>N. \<forall>n m. N \<le> n \<and> N \<le> m \<longrightarrow> \<parallel>r n - r m\<parallel> < \<epsilon>

goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
hence \<open>Cauchy r\<close>
[PROOF STATE]
proof (prove)
using this:
\<forall>\<epsilon>>0. \<exists>N. \<forall>n m. N \<le> n \<and> N \<le> m \<longrightarrow> \<parallel>r n - r m\<parallel> < \<epsilon>

goal (1 subgoal):
 1. Cauchy r
[PROOF STEP]
using CauchyI
[PROOF STATE]
proof (prove)
using this:
\<forall>\<epsilon>>0. \<exists>N. \<forall>n m. N \<le> n \<and> N \<le> m \<longrightarrow> \<parallel>r n - r m\<parallel> < \<epsilon>
(\<And>e. 0 < e \<Longrightarrow> \<exists>M. \<forall>m\<ge>M. \<forall>n\<ge>M. \<parallel>?X m - ?X n\<parallel> < e) \<Longrightarrow> Cauchy ?X

goal (1 subgoal):
 1. Cauchy r
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
Cauchy r

goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Cauchy r
[PROOF STEP]
obtain k where \<open>r \<longlonglongrightarrow> k\<close>
[PROOF STATE]
proof (prove)
using this:
Cauchy r

goal (1 subgoal):
 1. (\<And>k. r \<longlonglongrightarrow> k \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using  convergent_eq_Cauchy
[PROOF STATE]
proof (prove)
using this:
Cauchy r
(\<exists>l. ?S \<longlonglongrightarrow> l) = Cauchy ?S

goal (1 subgoal):
 1. (\<And>k. r \<longlonglongrightarrow> k \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
r \<longlonglongrightarrow> k

goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
have \<open>k \<in> M\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k \<in> M
[PROOF STEP]
using \<open>closed M\<close>
[PROOF STATE]
proof (prove)
using this:
closed M

goal (1 subgoal):
 1. k \<in> M
[PROOF STEP]
using \<open>\<forall>n. r n \<in> M\<close> \<open>r \<longlonglongrightarrow> k\<close> closed_sequentially
[PROOF STATE]
proof (prove)
using this:
closed M
\<forall>n. r n \<in> M
r \<longlonglongrightarrow> k
\<lbrakk>closed ?s; \<forall>n. ?f n \<in> ?s; ?f \<longlonglongrightarrow> ?l\<rbrakk> \<Longrightarrow> ?l \<in> ?s

goal (1 subgoal):
 1. k \<in> M
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
k \<in> M

goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
have  \<open>(\<lambda> n.  \<parallel> r n \<parallel>^2) \<longlonglongrightarrow>  \<parallel> k \<parallel>^2\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. \<parallel>r n\<parallel>\<^sup>2) \<longlonglongrightarrow> \<parallel>k\<parallel>\<^sup>2
[PROOF STEP]
by (simp add: \<open>r \<longlonglongrightarrow> k\<close> tendsto_norm tendsto_power)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<parallel>r n\<parallel>\<^sup>2) \<longlonglongrightarrow> \<parallel>k\<parallel>\<^sup>2

goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<parallel>r n\<parallel>\<^sup>2) \<longlonglongrightarrow> \<parallel>k\<parallel>\<^sup>2

goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
have  \<open>(\<lambda> n.  \<parallel> r n \<parallel>^2) \<longlonglongrightarrow>  d\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. \<parallel>r n\<parallel>\<^sup>2) \<longlonglongrightarrow> d
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>n. \<parallel>r n\<parallel>\<^sup>2) \<longlonglongrightarrow> d
[PROOF STEP]
have \<open>\<bar>\<parallel> r n \<parallel>^2 - d\<bar> < 1/(n+1)\<close> for n :: nat
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>\<parallel>r n\<parallel>\<^sup>2 - d\<bar> < 1 / real (n + 1)
[PROOF STEP]
using \<open>\<And>x. x \<in> M \<Longrightarrow> d \<le> \<parallel>x\<parallel>\<^sup>2\<close> \<open>\<forall>n. r n \<in> M \<and> \<parallel>r n\<parallel>\<^sup>2 < d + 1 / (real n + 1)\<close> of_nat_1 of_nat_add
[PROOF STATE]
proof (prove)
using this:
?x \<in> M \<Longrightarrow> d \<le> \<parallel>?x\<parallel>\<^sup>2
\<forall>n. r n \<in> M \<and> \<parallel>r n\<parallel>\<^sup>2 < d + 1 / (real n + 1)
of_nat 1 = (1::?'a)
of_nat (?m + ?n) = of_nat ?m + of_nat ?n

goal (1 subgoal):
 1. \<bar>\<parallel>r n\<parallel>\<^sup>2 - d\<bar> < 1 / real (n + 1)
[PROOF STEP]
by smt
[PROOF STATE]
proof (state)
this:
\<bar>\<parallel>r ?n1\<parallel>\<^sup>2 - d\<bar> < 1 / real (?n1 + 1)

goal (1 subgoal):
 1. (\<lambda>n. \<parallel>r n\<parallel>\<^sup>2) \<longlonglongrightarrow> d
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<bar>\<parallel>r ?n1\<parallel>\<^sup>2 - d\<bar> < 1 / real (?n1 + 1)

goal (1 subgoal):
 1. (\<lambda>n. \<parallel>r n\<parallel>\<^sup>2) \<longlonglongrightarrow> d
[PROOF STEP]
have \<open>(\<lambda>n. 1 / real (n + 1)) \<longlonglongrightarrow> 0\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. 1 / real (n + 1)) \<longlonglongrightarrow> 0
[PROOF STEP]
using  LIMSEQ_ignore_initial_segment[OF lim_inverse_n', where k=1]
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. 1 / real (n + 1)) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. (\<lambda>n. 1 / real (n + 1)) \<longlonglongrightarrow> 0
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(\<lambda>n. 1 / real (n + 1)) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. (\<lambda>n. \<parallel>r n\<parallel>\<^sup>2) \<longlonglongrightarrow> d
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<bar>\<parallel>r ?n1\<parallel>\<^sup>2 - d\<bar> < 1 / real (?n1 + 1)
(\<lambda>n. 1 / real (n + 1)) \<longlonglongrightarrow> 0
[PROOF STEP]
have \<open>(\<lambda> n. \<bar>\<parallel> r n \<parallel>^2 - d\<bar> ) \<longlonglongrightarrow> 0\<close>
[PROOF STATE]
proof (prove)
using this:
\<bar>\<parallel>r ?n1\<parallel>\<^sup>2 - d\<bar> < 1 / real (?n1 + 1)
(\<lambda>n. 1 / real (n + 1)) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. (\<lambda>n. \<bar>\<parallel>r n\<parallel>\<^sup>2 - d\<bar>) \<longlonglongrightarrow> 0
[PROOF STEP]
by (simp add: LIMSEQ_norm_0)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<bar>\<parallel>r n\<parallel>\<^sup>2 - d\<bar>) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. (\<lambda>n. \<parallel>r n\<parallel>\<^sup>2) \<longlonglongrightarrow> d
[PROOF STEP]
hence \<open>(\<lambda> n. \<parallel> r n \<parallel>^2 - d ) \<longlonglongrightarrow> 0\<close>
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. \<bar>\<parallel>r n\<parallel>\<^sup>2 - d\<bar>) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. (\<lambda>n. \<parallel>r n\<parallel>\<^sup>2 - d) \<longlonglongrightarrow> 0
[PROOF STEP]
by (simp add: tendsto_rabs_zero_iff)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<parallel>r n\<parallel>\<^sup>2 - d) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. (\<lambda>n. \<parallel>r n\<parallel>\<^sup>2) \<longlonglongrightarrow> d
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<parallel>r n\<parallel>\<^sup>2 - d) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. (\<lambda>n. \<parallel>r n\<parallel>\<^sup>2) \<longlonglongrightarrow> d
[PROOF STEP]
have \<open>(\<lambda> n. d ) \<longlonglongrightarrow> d\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. d) \<longlonglongrightarrow> d
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<lambda>n. d) \<longlonglongrightarrow> d

goal (1 subgoal):
 1. (\<lambda>n. \<parallel>r n\<parallel>\<^sup>2) \<longlonglongrightarrow> d
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>n. \<parallel>r n\<parallel>\<^sup>2 - d) \<longlonglongrightarrow> 0
(\<lambda>n. d) \<longlonglongrightarrow> d
[PROOF STEP]
have \<open>(\<lambda> n. (\<parallel> r n \<parallel>^2 - d)+d ) \<longlonglongrightarrow> 0+d\<close>
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. \<parallel>r n\<parallel>\<^sup>2 - d) \<longlonglongrightarrow> 0
(\<lambda>n. d) \<longlonglongrightarrow> d

goal (1 subgoal):
 1. (\<lambda>n. \<parallel>r n\<parallel>\<^sup>2 - d + d) \<longlonglongrightarrow> 0 + d
[PROOF STEP]
using tendsto_add
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. \<parallel>r n\<parallel>\<^sup>2 - d) \<longlonglongrightarrow> 0
(\<lambda>n. d) \<longlonglongrightarrow> d
\<lbrakk>(?f \<longlongrightarrow> ?a) ?F; (?g \<longlongrightarrow> ?b) ?F\<rbrakk> \<Longrightarrow> ((\<lambda>x. ?f x + ?g x) \<longlongrightarrow> ?a + ?b) ?F

goal (1 subgoal):
 1. (\<lambda>n. \<parallel>r n\<parallel>\<^sup>2 - d + d) \<longlonglongrightarrow> 0 + d
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<parallel>r n\<parallel>\<^sup>2 - d + d) \<longlonglongrightarrow> 0 + d

goal (1 subgoal):
 1. (\<lambda>n. \<parallel>r n\<parallel>\<^sup>2) \<longlonglongrightarrow> d
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. \<parallel>r n\<parallel>\<^sup>2 - d + d) \<longlonglongrightarrow> 0 + d

goal (1 subgoal):
 1. (\<lambda>n. \<parallel>r n\<parallel>\<^sup>2) \<longlonglongrightarrow> d
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<parallel>r n\<parallel>\<^sup>2) \<longlonglongrightarrow> d

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<parallel>r n\<parallel>\<^sup>2) \<longlonglongrightarrow> d

goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>n. \<parallel>r n\<parallel>\<^sup>2) \<longlonglongrightarrow> \<parallel>k\<parallel>\<^sup>2
(\<lambda>n. \<parallel>r n\<parallel>\<^sup>2) \<longlonglongrightarrow> d
[PROOF STEP]
have \<open>d = \<parallel> k \<parallel>^2\<close>
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. \<parallel>r n\<parallel>\<^sup>2) \<longlonglongrightarrow> \<parallel>k\<parallel>\<^sup>2
(\<lambda>n. \<parallel>r n\<parallel>\<^sup>2) \<longlonglongrightarrow> d

goal (1 subgoal):
 1. d = \<parallel>k\<parallel>\<^sup>2
[PROOF STEP]
using LIMSEQ_unique
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. \<parallel>r n\<parallel>\<^sup>2) \<longlonglongrightarrow> \<parallel>k\<parallel>\<^sup>2
(\<lambda>n. \<parallel>r n\<parallel>\<^sup>2) \<longlonglongrightarrow> d
\<lbrakk>?X \<longlonglongrightarrow> ?a; ?X \<longlonglongrightarrow> ?b\<rbrakk> \<Longrightarrow> ?a = ?b

goal (1 subgoal):
 1. d = \<parallel>k\<parallel>\<^sup>2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
d = \<parallel>k\<parallel>\<^sup>2

goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
hence \<open>t \<in> M \<Longrightarrow> \<parallel> k \<parallel>^2 \<le> \<parallel> t \<parallel>^2\<close> for t
[PROOF STATE]
proof (prove)
using this:
d = \<parallel>k\<parallel>\<^sup>2

goal (1 subgoal):
 1. t \<in> M \<Longrightarrow> \<parallel>k\<parallel>\<^sup>2 \<le> \<parallel>t\<parallel>\<^sup>2
[PROOF STEP]
using \<open>\<And>x. x \<in> M \<Longrightarrow> d \<le> \<parallel>x\<parallel>\<^sup>2\<close>
[PROOF STATE]
proof (prove)
using this:
d = \<parallel>k\<parallel>\<^sup>2
?x \<in> M \<Longrightarrow> d \<le> \<parallel>?x\<parallel>\<^sup>2

goal (1 subgoal):
 1. t \<in> M \<Longrightarrow> \<parallel>k\<parallel>\<^sup>2 \<le> \<parallel>t\<parallel>\<^sup>2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?t1 \<in> M \<Longrightarrow> \<parallel>k\<parallel>\<^sup>2 \<le> \<parallel>?t1\<parallel>\<^sup>2

goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
hence q1: \<open>\<exists> k. is_arg_min (\<lambda> x. \<parallel>x\<parallel>^2) (\<lambda> t. t \<in> M) k\<close>
[PROOF STATE]
proof (prove)
using this:
?t1 \<in> M \<Longrightarrow> \<parallel>k\<parallel>\<^sup>2 \<le> \<parallel>?t1\<parallel>\<^sup>2

goal (1 subgoal):
 1. \<exists>k. is_arg_min (\<lambda>x. \<parallel>x\<parallel>\<^sup>2) (\<lambda>t. t \<in> M) k
[PROOF STEP]
using \<open>k \<in> M\<close>
      is_arg_min_def \<open>d = \<parallel>k\<parallel>\<^sup>2\<close>
[PROOF STATE]
proof (prove)
using this:
?t1 \<in> M \<Longrightarrow> \<parallel>k\<parallel>\<^sup>2 \<le> \<parallel>?t1\<parallel>\<^sup>2
k \<in> M
is_arg_min ?f ?P ?x = (?P ?x \<and> (\<nexists>y. ?P y \<and> ?f y < ?f ?x))
d = \<parallel>k\<parallel>\<^sup>2

goal (1 subgoal):
 1. \<exists>k. is_arg_min (\<lambda>x. \<parallel>x\<parallel>\<^sup>2) (\<lambda>t. t \<in> M) k
[PROOF STEP]
by smt
[PROOF STATE]
proof (state)
this:
\<exists>k. is_arg_min (\<lambda>x. \<parallel>x\<parallel>\<^sup>2) (\<lambda>t. t \<in> M) k

goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
thus \<open>\<exists> k. is_arg_min (\<lambda> x. \<parallel>x\<parallel>) (\<lambda> t. t \<in> M) k\<close>
[PROOF STATE]
proof (prove)
using this:
\<exists>k. is_arg_min (\<lambda>x. \<parallel>x\<parallel>\<^sup>2) (\<lambda>t. t \<in> M) k

goal (1 subgoal):
 1. \<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k
[PROOF STEP]
by (smt is_arg_min_def norm_ge_zero power2_eq_square power2_le_imp_le)
[PROOF STATE]
proof (state)
this:
\<exists>k. is_arg_min norm (\<lambda>t. t \<in> M) k

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma tendsto_principal_singleton:
  shows "(f \<longlongrightarrow> f x) (principal {x})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f \<longlongrightarrow> f x) (principal {x})
[PROOF STEP]
unfolding tendsto_def eventually_principal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>S. open S \<longrightarrow> f x \<in> S \<longrightarrow> (\<forall>x\<in>{x}. f x \<in> S)
[PROOF STEP]
by simp


[STATEMENT]
lemma Suc_rtos_div_r_3:"\<lbrakk>0 < r; 0 < s; i mod s < s - Suc 0; i \<le> r * s - Suc 0;
      Suc (rtos r s i) < r * s; i div s < r - Suc 0\<rbrakk> \<Longrightarrow>
               Suc (rtos r s i) div r = i mod s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; i mod s < s - Suc 0; i \<le> r * s - Suc 0; Suc (rtos r s i) < r * s; i div s < r - Suc 0\<rbrakk> \<Longrightarrow> Suc (rtos r s i) div r = i mod s
[PROOF STEP]
apply (simp add:rtos_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; i mod s < s - Suc 0; i \<le> r * s - Suc 0; Suc (if i < r * s then i mod s * r + i div s else r * s) < r * s; i div s < r - Suc 0\<rbrakk> \<Longrightarrow> i < r * s \<longrightarrow> Suc (i mod s * r + i div s) div r = i mod s
[PROOF STEP]
apply (frule le_less_trans [of "i" "r * s - Suc 0" "r * s"])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>0 < r; 0 < s; i mod s < s - Suc 0; i \<le> r * s - Suc 0; Suc (if i < r * s then i mod s * r + i div s else r * s) < r * s; i div s < r - Suc 0\<rbrakk> \<Longrightarrow> r * s - Suc 0 < r * s
 2. \<lbrakk>0 < r; 0 < s; i mod s < s - Suc 0; i \<le> r * s - Suc 0; Suc (if i < r * s then i mod s * r + i div s else r * s) < r * s; i div s < r - Suc 0; i < r * s\<rbrakk> \<Longrightarrow> i < r * s \<longrightarrow> Suc (i mod s * r + i div s) div r = i mod s
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; i mod s < s - Suc 0; i \<le> r * s - Suc 0; Suc (if i < r * s then i mod s * r + i div s else r * s) < r * s; i div s < r - Suc 0; i < r * s\<rbrakk> \<Longrightarrow> i < r * s \<longrightarrow> Suc (i mod s * r + i div s) div r = i mod s
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; i mod s < s - Suc 0; i \<le> r * s - Suc 0; Suc (i mod s * r + i div s) < r * s; i div s < r - Suc 0; i < r * s\<rbrakk> \<Longrightarrow> Suc (i mod s * r + i div s) div r = i mod s
[PROOF STEP]
apply (subst add_Suc_right[THEN sym, of "i mod s * r" "i div s"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; i mod s < s - Suc 0; i \<le> r * s - Suc 0; Suc (i mod s * r + i div s) < r * s; i div s < r - Suc 0; i < r * s\<rbrakk> \<Longrightarrow> (i mod s * r + Suc (i div s)) div r = i mod s
[PROOF STEP]
apply (subst add.commute[of "i mod s * r" "Suc (i div s)"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; i mod s < s - Suc 0; i \<le> r * s - Suc 0; Suc (i mod s * r + i div s) < r * s; i div s < r - Suc 0; i < r * s\<rbrakk> \<Longrightarrow> (Suc (i div s) + i mod s * r) div r = i mod s
[PROOF STEP]
apply (frule Suc_leI[of "i div s" "r - Suc 0"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; i mod s < s - Suc 0; i \<le> r * s - Suc 0; Suc (i mod s * r + i div s) < r * s; i div s < r - Suc 0; i < r * s; Suc (i div s) \<le> r - Suc 0\<rbrakk> \<Longrightarrow> (Suc (i div s) + i mod s * r) div r = i mod s
[PROOF STEP]
apply (frule le_less_trans[of "Suc (i div s)" "r - Suc 0" "r"], simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; i mod s < s - Suc 0; i \<le> r * s - Suc 0; Suc (i mod s * r + i div s) < r * s; i div s < r - Suc 0; i < r * s; Suc (i div s) \<le> r - Suc 0; Suc (i div s) < r\<rbrakk> \<Longrightarrow> (Suc (i div s) + i mod s * r) div r = i mod s
[PROOF STEP]
apply (subst div_mult_self1 [of "r" "Suc (i div s)" "i mod s"])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>0 < r; 0 < s; i mod s < s - Suc 0; i \<le> r * s - Suc 0; Suc (i mod s * r + i div s) < r * s; i div s < r - Suc 0; i < r * s; Suc (i div s) \<le> r - Suc 0; Suc (i div s) < r\<rbrakk> \<Longrightarrow> r \<noteq> 0
 2. \<lbrakk>0 < r; 0 < s; i mod s < s - Suc 0; i \<le> r * s - Suc 0; Suc (i mod s * r + i div s) < r * s; i div s < r - Suc 0; i < r * s; Suc (i div s) \<le> r - Suc 0; Suc (i div s) < r\<rbrakk> \<Longrightarrow> i mod s + Suc (i div s) div r = i mod s
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma div_le_conv: "0 < m \<Longrightarrow> n div m \<le> k = (n \<le> Suc k * m - Suc 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < m \<Longrightarrow> (n div m \<le> k) = (n \<le> Suc k * m - Suc 0)
[PROOF STEP]
apply (rule iffI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>0 < m; n div m \<le> k\<rbrakk> \<Longrightarrow> n \<le> Suc k * m - Suc 0
 2. \<lbrakk>0 < m; n \<le> Suc k * m - Suc 0\<rbrakk> \<Longrightarrow> n div m \<le> k
[PROOF STEP]
apply (drule mult_le_mono1[of _ _ m])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>0 < m; n div m * m \<le> k * m\<rbrakk> \<Longrightarrow> n \<le> Suc k * m - Suc 0
 2. \<lbrakk>0 < m; n \<le> Suc k * m - Suc 0\<rbrakk> \<Longrightarrow> n div m \<le> k
[PROOF STEP]
apply (simp only: mult.commute[of _ m] minus_mod_eq_mult_div [symmetric])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>0 < m; n - n mod m \<le> m * k\<rbrakk> \<Longrightarrow> n \<le> m * Suc k - Suc 0
 2. \<lbrakk>0 < m; n \<le> Suc k * m - Suc 0\<rbrakk> \<Longrightarrow> n div m \<le> k
[PROOF STEP]
apply (drule le_diff_conv[THEN iffD1])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>0 < m; n \<le> m * k + n mod m\<rbrakk> \<Longrightarrow> n \<le> m * Suc k - Suc 0
 2. \<lbrakk>0 < m; n \<le> Suc k * m - Suc 0\<rbrakk> \<Longrightarrow> n div m \<le> k
[PROOF STEP]
apply (rule le_trans[of _ "m * k + n mod m"], assumption)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>0 < m; n \<le> m * k + n mod m\<rbrakk> \<Longrightarrow> m * k + n mod m \<le> m * Suc k - Suc 0
 2. \<lbrakk>0 < m; n \<le> Suc k * m - Suc 0\<rbrakk> \<Longrightarrow> n div m \<le> k
[PROOF STEP]
apply (simp add: add.commute[of m])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>0 < m; n \<le> m * k + n mod m\<rbrakk> \<Longrightarrow> m * k + n mod m \<le> m * k + m - Suc 0
 2. \<lbrakk>0 < m; n \<le> Suc k * m - Suc 0\<rbrakk> \<Longrightarrow> n div m \<le> k
[PROOF STEP]
apply (simp only: diff_add_assoc[OF Suc_leI])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>0 < m; n \<le> m * k + n mod m\<rbrakk> \<Longrightarrow> m * k + n mod m \<le> m * k + (m - Suc 0)
 2. \<lbrakk>0 < m; n \<le> Suc k * m - Suc 0\<rbrakk> \<Longrightarrow> n div m \<le> k
[PROOF STEP]
apply (rule add_le_mono[OF le_refl])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>0 < m; n \<le> m * k + n mod m\<rbrakk> \<Longrightarrow> n mod m \<le> m - Suc 0
 2. \<lbrakk>0 < m; n \<le> Suc k * m - Suc 0\<rbrakk> \<Longrightarrow> n div m \<le> k
[PROOF STEP]
apply (rule less_imp_le_pred)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>0 < m; n \<le> m * k + n mod m\<rbrakk> \<Longrightarrow> n mod m < m
 2. \<lbrakk>0 < m; n \<le> Suc k * m - Suc 0\<rbrakk> \<Longrightarrow> n div m \<le> k
[PROOF STEP]
apply (rule mod_less_divisor, assumption)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < m; n \<le> Suc k * m - Suc 0\<rbrakk> \<Longrightarrow> n div m \<le> k
[PROOF STEP]
apply (drule div_le_mono[of _ _ m])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < m; n div m \<le> (Suc k * m - Suc 0) div m\<rbrakk> \<Longrightarrow> n div m \<le> k
[PROOF STEP]
apply (simp add: mod_0_imp_sub_1_div_conv)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma butterfly_sgn_eq_proj:
  shows "selfbutter (sgn x) = proj x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. selfbutter (sgn x) = proj x
[PROOF STEP]
proof (cases \<open>x = 0\<close>)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x = (0::'a) \<Longrightarrow> selfbutter (sgn x) = proj x
 2. x \<noteq> (0::'a) \<Longrightarrow> selfbutter (sgn x) = proj x
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
x = (0::'a)

goal (2 subgoals):
 1. x = (0::'a) \<Longrightarrow> selfbutter (sgn x) = proj x
 2. x \<noteq> (0::'a) \<Longrightarrow> selfbutter (sgn x) = proj x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x = (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
x = (0::'a)

goal (1 subgoal):
 1. selfbutter (sgn x) = proj x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
selfbutter (sgn x) = proj x

goal (1 subgoal):
 1. x \<noteq> (0::'a) \<Longrightarrow> selfbutter (sgn x) = proj x
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x \<noteq> (0::'a) \<Longrightarrow> selfbutter (sgn x) = proj x
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
x \<noteq> (0::'a)

goal (1 subgoal):
 1. x \<noteq> (0::'a) \<Longrightarrow> selfbutter (sgn x) = proj x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<noteq> (0::'a)
[PROOF STEP]
have \<open>selfbutter (sgn x) = proj (sgn x)\<close>
[PROOF STATE]
proof (prove)
using this:
x \<noteq> (0::'a)

goal (1 subgoal):
 1. selfbutter (sgn x) = proj (sgn x)
[PROOF STEP]
by (simp add: butterfly_eq_proj norm_sgn)
[PROOF STATE]
proof (state)
this:
selfbutter (sgn x) = proj (sgn x)

goal (1 subgoal):
 1. x \<noteq> (0::'a) \<Longrightarrow> selfbutter (sgn x) = proj x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
selfbutter (sgn x) = proj (sgn x)

goal (1 subgoal):
 1. x \<noteq> (0::'a) \<Longrightarrow> selfbutter (sgn x) = proj x
[PROOF STEP]
have \<open>ccspan {sgn x} = ccspan {x}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ccspan {sgn x} = ccspan {x}
[PROOF STEP]
by (metis ccspan_singleton_scaleC scaleC_eq_0_iff scaleR_scaleC sgn_div_norm sgn_zero_iff)
[PROOF STATE]
proof (state)
this:
ccspan {sgn x} = ccspan {x}

goal (1 subgoal):
 1. x \<noteq> (0::'a) \<Longrightarrow> selfbutter (sgn x) = proj x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
selfbutter (sgn x) = proj x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
selfbutter (sgn x) = proj x

goal (1 subgoal):
 1. selfbutter (sgn x) = proj x
[PROOF STEP]
by -
[PROOF STATE]
proof (state)
this:
selfbutter (sgn x) = proj x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma poly_rel_karatsuba_main: "list_all2 R x1 x2 \<Longrightarrow> list_all2 R y1 y2 \<Longrightarrow>
  poly_rel (karatsuba_main_i ops x1 n y1 m) (karatsuba_main x2 n y2 m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>list_all2 R x1 x2; list_all2 R y1 y2\<rbrakk> \<Longrightarrow> poly_rel (karatsuba_main_i ops x1 n y1 m) (karatsuba_main x2 n y2 m)
[PROOF STEP]
proof (induct n arbitrary: x1 y1 x2 y2 m rule: less_induct)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x x1 y1 x2 y2 m. \<lbrakk>\<And>y x1 y1 x2 y2 m. \<lbrakk>y < x; list_all2 R x1 x2; list_all2 R y1 y2\<rbrakk> \<Longrightarrow> poly_rel (karatsuba_main_i ops x1 y y1 m) (karatsuba_main x2 y y2 m); list_all2 R x1 x2; list_all2 R y1 y2\<rbrakk> \<Longrightarrow> poly_rel (karatsuba_main_i ops x1 x y1 m) (karatsuba_main x2 x y2 m)
[PROOF STEP]
case (less n f g F G m)
[PROOF STATE]
proof (state)
this:
\<lbrakk>?y < n; list_all2 R ?x1.0 ?x2.0; list_all2 R ?y1.0 ?y2.0\<rbrakk> \<Longrightarrow> poly_rel (karatsuba_main_i ops ?x1.0 ?y ?y1.0 ?m) (karatsuba_main ?x2.0 ?y ?y2.0 ?m)
list_all2 R f F
list_all2 R g G

goal (1 subgoal):
 1. \<And>x x1 y1 x2 y2 m. \<lbrakk>\<And>y x1 y1 x2 y2 m. \<lbrakk>y < x; list_all2 R x1 x2; list_all2 R y1 y2\<rbrakk> \<Longrightarrow> poly_rel (karatsuba_main_i ops x1 y y1 m) (karatsuba_main x2 y y2 m); list_all2 R x1 x2; list_all2 R y1 y2\<rbrakk> \<Longrightarrow> poly_rel (karatsuba_main_i ops x1 x y1 m) (karatsuba_main x2 x y2 m)
[PROOF STEP]
note simp[simp] = karatsuba_main.simps[of F n G m] karatsuba_main_i.simps[of ops f n g m]
[PROOF STATE]
proof (state)
this:
karatsuba_main F n G m = (if n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound then let ff = poly_of_list F in foldr (\<lambda>a p. smult a ff + pCons (0::'a) p) G 0 else let n2 = n div 2 in if n2 < m then case split_at n2 F of (f0, f1) \<Rightarrow> case split_at n2 G of (g0, g1) \<Rightarrow> let p1 = karatsuba_main f1 (n - n2) g1 (m - n2); p2 = karatsuba_main (coeffs_minus f1 f0) n2 (coeffs_minus g1 g0) n2; p3 = karatsuba_main f0 n2 g0 n2 in monom_mult (n2 + n2) p1 + (monom_mult n2 (p1 - p2 + p3) + p3) else case split_at n2 F of (f0, f1) \<Rightarrow> let p1 = karatsuba_main f1 (n - n2) G m in Let (karatsuba_main f0 n2 G m) ((+) (monom_mult n2 p1)))
karatsuba_main_i ops f n g m = (if n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound then let ff = poly_of_list_i ops f in foldr (\<lambda>a p. plus_poly_i ops (smult_i ops a ff) (cCons_i ops (arith_ops_record.zero ops) p)) g [] else let n2 = n div 2 in if n2 < m then case split_at n2 f of (f0, f1) \<Rightarrow> case split_at n2 g of (g0, g1) \<Rightarrow> let p1 = karatsuba_main_i ops f1 (n - n2) g1 (m - n2); p2 = karatsuba_main_i ops (coeffs_minus_i ops f1 f0) n2 (coeffs_minus_i ops g1 g0) n2; p3 = karatsuba_main_i ops f0 n2 g0 n2 in plus_poly_i ops (monom_mult_i ops (n2 + n2) p1) (plus_poly_i ops (monom_mult_i ops n2 (plus_poly_i ops (minus_poly_i ops p1 p2) p3)) p3) else case split_at n2 f of (f0, f1) \<Rightarrow> let p1 = karatsuba_main_i ops f1 (n - n2) g m in Let (karatsuba_main_i ops f0 n2 g m) (plus_poly_i ops (monom_mult_i ops n2 p1)))

goal (1 subgoal):
 1. \<And>x x1 y1 x2 y2 m. \<lbrakk>\<And>y x1 y1 x2 y2 m. \<lbrakk>y < x; list_all2 R x1 x2; list_all2 R y1 y2\<rbrakk> \<Longrightarrow> poly_rel (karatsuba_main_i ops x1 y y1 m) (karatsuba_main x2 y y2 m); list_all2 R x1 x2; list_all2 R y1 y2\<rbrakk> \<Longrightarrow> poly_rel (karatsuba_main_i ops x1 x y1 m) (karatsuba_main x2 x y2 m)
[PROOF STEP]
note IH = less(1)
[PROOF STATE]
proof (state)
this:
\<lbrakk>?y < n; list_all2 R ?x1.0 ?x2.0; list_all2 R ?y1.0 ?y2.0\<rbrakk> \<Longrightarrow> poly_rel (karatsuba_main_i ops ?x1.0 ?y ?y1.0 ?m) (karatsuba_main ?x2.0 ?y ?y2.0 ?m)

goal (1 subgoal):
 1. \<And>x x1 y1 x2 y2 m. \<lbrakk>\<And>y x1 y1 x2 y2 m. \<lbrakk>y < x; list_all2 R x1 x2; list_all2 R y1 y2\<rbrakk> \<Longrightarrow> poly_rel (karatsuba_main_i ops x1 y y1 m) (karatsuba_main x2 y y2 m); list_all2 R x1 x2; list_all2 R y1 y2\<rbrakk> \<Longrightarrow> poly_rel (karatsuba_main_i ops x1 x y1 m) (karatsuba_main x2 x y2 m)
[PROOF STEP]
note rel[transfer_rule] = less(2-3)
[PROOF STATE]
proof (state)
this:
list_all2 R f F
list_all2 R g G

goal (1 subgoal):
 1. \<And>x x1 y1 x2 y2 m. \<lbrakk>\<And>y x1 y1 x2 y2 m. \<lbrakk>y < x; list_all2 R x1 x2; list_all2 R y1 y2\<rbrakk> \<Longrightarrow> poly_rel (karatsuba_main_i ops x1 y y1 m) (karatsuba_main x2 y y2 m); list_all2 R x1 x2; list_all2 R y1 y2\<rbrakk> \<Longrightarrow> poly_rel (karatsuba_main_i ops x1 x y1 m) (karatsuba_main x2 x y2 m)
[PROOF STEP]
show ?case (is "poly_rel ?lhs ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
proof (cases "(n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
 2. (n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) \<noteq> False \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
(n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) \<noteq> False

goal (2 subgoals):
 1. (n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
 2. (n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) \<noteq> False \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
from False
[PROOF STATE]
proof (chain)
picking this:
(n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) \<noteq> False
[PROOF STEP]
have lhs: "?lhs = foldr (\<lambda>a p. plus_poly_i ops (smult_i ops a (poly_of_list_i ops f))
         (cCons_i ops zero p)) g []"
[PROOF STATE]
proof (prove)
using this:
(n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) \<noteq> False

goal (1 subgoal):
 1. karatsuba_main_i ops f n g m = foldr (\<lambda>a p. plus_poly_i ops (smult_i ops a (poly_of_list_i ops f)) (cCons_i ops (arith_ops_record.zero ops) p)) g []
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
karatsuba_main_i ops f n g m = foldr (\<lambda>a p. plus_poly_i ops (smult_i ops a (poly_of_list_i ops f)) (cCons_i ops (arith_ops_record.zero ops) p)) g []

goal (2 subgoals):
 1. (n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
 2. (n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) \<noteq> False \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
from False
[PROOF STATE]
proof (chain)
picking this:
(n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) \<noteq> False
[PROOF STEP]
have rhs: "?rhs = foldr (\<lambda>a p. smult a (poly_of_list F) + pCons 0 p) G 0"
[PROOF STATE]
proof (prove)
using this:
(n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) \<noteq> False

goal (1 subgoal):
 1. karatsuba_main F n G m = foldr (\<lambda>a p. smult a (poly_of_list F) + pCons (0::'a) p) G 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
karatsuba_main F n G m = foldr (\<lambda>a p. smult a (poly_of_list F) + pCons (0::'a) p) G 0

goal (2 subgoals):
 1. (n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
 2. (n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) \<noteq> False \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
unfolding lhs rhs
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_rel (foldr (\<lambda>a p. plus_poly_i ops (smult_i ops a (poly_of_list_i ops f)) (cCons_i ops (arith_ops_record.zero ops) p)) g []) (foldr (\<lambda>a p. smult a (poly_of_list F) + pCons (0::'a) p) G 0)
[PROOF STEP]
by transfer_prover
[PROOF STATE]
proof (state)
this:
poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)

goal (1 subgoal):
 1. (n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
(n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False

goal (1 subgoal):
 1. (n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
note * = this
[PROOF STATE]
proof (state)
this:
(n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False

goal (1 subgoal):
 1. (n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
let ?n2 = "n div 2"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
have "?n2 < n" "n - ?n2 < n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n div 2 < n &&& n - n div 2 < n
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
(n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False

goal (1 subgoal):
 1. n div 2 < n &&& n - n div 2 < n
[PROOF STEP]
unfolding karatsuba_lower_bound_def
[PROOF STATE]
proof (prove)
using this:
(n \<le> 7 \<or> m \<le> 7) = False

goal (1 subgoal):
 1. n div 2 < n &&& n - n div 2 < n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
n div 2 < n
n - n div 2 < n

goal (1 subgoal):
 1. (n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
note IH = IH[OF this(1)] IH[OF this(2)]
[PROOF STATE]
proof (state)
this:
\<lbrakk>list_all2 R ?x1.0 ?x2.0; list_all2 R ?y1.0 ?y2.0\<rbrakk> \<Longrightarrow> poly_rel (karatsuba_main_i ops ?x1.0 (n div 2) ?y1.0 ?m) (karatsuba_main ?x2.0 (n div 2) ?y2.0 ?m)
\<lbrakk>list_all2 R ?x1.0 ?x2.0; list_all2 R ?y1.0 ?y2.0\<rbrakk> \<Longrightarrow> poly_rel (karatsuba_main_i ops ?x1.0 (n - n div 2) ?y1.0 ?m) (karatsuba_main ?x2.0 (n - n div 2) ?y2.0 ?m)

goal (1 subgoal):
 1. (n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
obtain f1 f0 where f: "split_at ?n2 f = (f0,f1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>f0 f1. split_at (n div 2) f = (f0, f1) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
split_at (n div 2) f = (f0, f1)

goal (1 subgoal):
 1. (n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
obtain g1 g0 where g: "split_at ?n2 g = (g0,g1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>g0 g1. split_at (n div 2) g = (g0, g1) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
split_at (n div 2) g = (g0, g1)

goal (1 subgoal):
 1. (n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
obtain F1 F0 where F: "split_at ?n2 F = (F0,F1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>F0 F1. split_at (n div 2) F = (F0, F1) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
split_at (n div 2) F = (F0, F1)

goal (1 subgoal):
 1. (n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
obtain G1 G0 where G: "split_at ?n2 G = (G0,G1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>G0 G1. split_at (n div 2) G = (G0, G1) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
split_at (n div 2) G = (G0, G1)

goal (1 subgoal):
 1. (n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
from rel f F
[PROOF STATE]
proof (chain)
picking this:
list_all2 R f F
list_all2 R g G
split_at (n div 2) f = (f0, f1)
split_at (n div 2) F = (F0, F1)
[PROOF STEP]
have relf[transfer_rule]: "list_all2 R f0 F0" "list_all2 R f1 F1"
[PROOF STATE]
proof (prove)
using this:
list_all2 R f F
list_all2 R g G
split_at (n div 2) f = (f0, f1)
split_at (n div 2) F = (F0, F1)

goal (1 subgoal):
 1. list_all2 R f0 F0 &&& list_all2 R f1 F1
[PROOF STEP]
unfolding split_at_def
[PROOF STATE]
proof (prove)
using this:
list_all2 R f F
list_all2 R g G
(take (n div 2) f, drop (n div 2) f) = (f0, f1)
(take (n div 2) F, drop (n div 2) F) = (F0, F1)

goal (1 subgoal):
 1. list_all2 R f0 F0 &&& list_all2 R f1 F1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
list_all2 R f0 F0
list_all2 R f1 F1

goal (1 subgoal):
 1. (n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
from rel g G
[PROOF STATE]
proof (chain)
picking this:
list_all2 R f F
list_all2 R g G
split_at (n div 2) g = (g0, g1)
split_at (n div 2) G = (G0, G1)
[PROOF STEP]
have relg[transfer_rule]: "list_all2 R g0 G0" "list_all2 R g1 G1"
[PROOF STATE]
proof (prove)
using this:
list_all2 R f F
list_all2 R g G
split_at (n div 2) g = (g0, g1)
split_at (n div 2) G = (G0, G1)

goal (1 subgoal):
 1. list_all2 R g0 G0 &&& list_all2 R g1 G1
[PROOF STEP]
unfolding split_at_def
[PROOF STATE]
proof (prove)
using this:
list_all2 R f F
list_all2 R g G
(take (n div 2) g, drop (n div 2) g) = (g0, g1)
(take (n div 2) G, drop (n div 2) G) = (G0, G1)

goal (1 subgoal):
 1. list_all2 R g0 G0 &&& list_all2 R g1 G1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
list_all2 R g0 G0
list_all2 R g1 G1

goal (1 subgoal):
 1. (n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
proof (cases "?n2 < m")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
 2. \<not> n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
n div 2 < m

goal (2 subgoals):
 1. n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
 2. \<not> n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
obtain p1 P1 where p1: "p1 = karatsuba_main_i ops f1 (n - n div 2) g1 (m - n div 2)"
          "P1 = karatsuba_main F1 (n - n div 2) G1 (m - n div 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>p1 P1. \<lbrakk>p1 = karatsuba_main_i ops f1 (n - n div 2) g1 (m - n div 2); P1 = karatsuba_main F1 (n - n div 2) G1 (m - n div 2)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
p1 = karatsuba_main_i ops f1 (n - n div 2) g1 (m - n div 2)
P1 = karatsuba_main F1 (n - n div 2) G1 (m - n div 2)

goal (2 subgoals):
 1. n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
 2. \<not> n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
obtain p2 P2 where p2: "p2 = karatsuba_main_i ops (coeffs_minus_i ops f1 f0) (n div 2)
                          (coeffs_minus_i ops g1 g0) (n div 2)"
          "P2 = karatsuba_main (coeffs_minus F1 F0) (n div 2)
                          (coeffs_minus G1 G0) (n div 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>p2 P2. \<lbrakk>p2 = karatsuba_main_i ops (coeffs_minus_i ops f1 f0) (n div 2) (coeffs_minus_i ops g1 g0) (n div 2); P2 = karatsuba_main (coeffs_minus F1 F0) (n div 2) (coeffs_minus G1 G0) (n div 2)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
p2 = karatsuba_main_i ops (coeffs_minus_i ops f1 f0) (n div 2) (coeffs_minus_i ops g1 g0) (n div 2)
P2 = karatsuba_main (coeffs_minus F1 F0) (n div 2) (coeffs_minus G1 G0) (n div 2)

goal (2 subgoals):
 1. n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
 2. \<not> n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
obtain p3 P3 where p3: "p3 = karatsuba_main_i ops f0 (n div 2) g0 (n div 2)"
          "P3 = karatsuba_main F0 (n div 2) G0 (n div 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>p3 P3. \<lbrakk>p3 = karatsuba_main_i ops f0 (n div 2) g0 (n div 2); P3 = karatsuba_main F0 (n div 2) G0 (n div 2)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
p3 = karatsuba_main_i ops f0 (n div 2) g0 (n div 2)
P3 = karatsuba_main F0 (n div 2) G0 (n div 2)

goal (2 subgoals):
 1. n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
 2. \<not> n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
from * True
[PROOF STATE]
proof (chain)
picking this:
(n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False
n div 2 < m
[PROOF STEP]
have lhs: "?lhs = plus_poly_i ops (monom_mult_i ops (n div 2 + n div 2) p1)
                (plus_poly_i ops
                  (monom_mult_i ops (n div 2)
                    (plus_poly_i ops (minus_poly_i ops p1 p2) p3)) p3)"
[PROOF STATE]
proof (prove)
using this:
(n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False
n div 2 < m

goal (1 subgoal):
 1. karatsuba_main_i ops f n g m = plus_poly_i ops (monom_mult_i ops (n div 2 + n div 2) p1) (plus_poly_i ops (monom_mult_i ops (n div 2) (plus_poly_i ops (minus_poly_i ops p1 p2) p3)) p3)
[PROOF STEP]
unfolding simp Let_def f g split p1 p2 p3
[PROOF STATE]
proof (prove)
using this:
(n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False
n div 2 < m

goal (1 subgoal):
 1. (if n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound then foldr (\<lambda>a p. plus_poly_i ops (smult_i ops a (poly_of_list_i ops f)) (cCons_i ops (arith_ops_record.zero ops) p)) g [] else if n div 2 < m then plus_poly_i ops (monom_mult_i ops (n div 2 + n div 2) (karatsuba_main_i ops f1 (n - n div 2) g1 (m - n div 2))) (plus_poly_i ops (monom_mult_i ops (n div 2) (plus_poly_i ops (minus_poly_i ops (karatsuba_main_i ops f1 (n - n div 2) g1 (m - n div 2)) (karatsuba_main_i ops (coeffs_minus_i ops f1 f0) (n div 2) (coeffs_minus_i ops g1 g0) (n div 2))) (karatsuba_main_i ops f0 (n div 2) g0 (n div 2)))) (karatsuba_main_i ops f0 (n div 2) g0 (n div 2))) else plus_poly_i ops (monom_mult_i ops (n div 2) (karatsuba_main_i ops f1 (n - n div 2) g m)) (karatsuba_main_i ops f0 (n div 2) g m)) = plus_poly_i ops (monom_mult_i ops (n div 2 + n div 2) (karatsuba_main_i ops f1 (n - n div 2) g1 (m - n div 2))) (plus_poly_i ops (monom_mult_i ops (n div 2) (plus_poly_i ops (minus_poly_i ops (karatsuba_main_i ops f1 (n - n div 2) g1 (m - n div 2)) (karatsuba_main_i ops (coeffs_minus_i ops f1 f0) (n div 2) (coeffs_minus_i ops g1 g0) (n div 2))) (karatsuba_main_i ops f0 (n div 2) g0 (n div 2)))) (karatsuba_main_i ops f0 (n div 2) g0 (n div 2)))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
karatsuba_main_i ops f n g m = plus_poly_i ops (monom_mult_i ops (n div 2 + n div 2) p1) (plus_poly_i ops (monom_mult_i ops (n div 2) (plus_poly_i ops (minus_poly_i ops p1 p2) p3)) p3)

goal (2 subgoals):
 1. n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
 2. \<not> n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
have [transfer_rule]: "poly_rel p1 P1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_rel p1 P1
[PROOF STEP]
using IH(2)[OF relf(2) relg(2)]
[PROOF STATE]
proof (prove)
using this:
poly_rel (karatsuba_main_i ops f1 (n - n div 2) g1 ?m) (karatsuba_main F1 (n - n div 2) G1 ?m)

goal (1 subgoal):
 1. poly_rel p1 P1
[PROOF STEP]
unfolding p1
[PROOF STATE]
proof (prove)
using this:
poly_rel (karatsuba_main_i ops f1 (n - n div 2) g1 ?m) (karatsuba_main F1 (n - n div 2) G1 ?m)

goal (1 subgoal):
 1. poly_rel (karatsuba_main_i ops f1 (n - n div 2) g1 (m - n div 2)) (karatsuba_main F1 (n - n div 2) G1 (m - n div 2))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
poly_rel p1 P1

goal (2 subgoals):
 1. n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
 2. \<not> n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
have [transfer_rule]: "poly_rel p3 P3"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_rel p3 P3
[PROOF STEP]
using IH(1)[OF relf(1) relg(1)]
[PROOF STATE]
proof (prove)
using this:
poly_rel (karatsuba_main_i ops f0 (n div 2) g0 ?m) (karatsuba_main F0 (n div 2) G0 ?m)

goal (1 subgoal):
 1. poly_rel p3 P3
[PROOF STEP]
unfolding p3
[PROOF STATE]
proof (prove)
using this:
poly_rel (karatsuba_main_i ops f0 (n div 2) g0 ?m) (karatsuba_main F0 (n div 2) G0 ?m)

goal (1 subgoal):
 1. poly_rel (karatsuba_main_i ops f0 (n div 2) g0 (n div 2)) (karatsuba_main F0 (n div 2) G0 (n div 2))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
poly_rel p3 P3

goal (2 subgoals):
 1. n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
 2. \<not> n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
have [transfer_rule]: "poly_rel p2 P2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_rel p2 P2
[PROOF STEP]
unfolding p2
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_rel (karatsuba_main_i ops (coeffs_minus_i ops f1 f0) (n div 2) (coeffs_minus_i ops g1 g0) (n div 2)) (karatsuba_main (coeffs_minus F1 F0) (n div 2) (coeffs_minus G1 G0) (n div 2))
[PROOF STEP]
by (rule IH(1)[OF list_rel_coeffs_minus_i list_rel_coeffs_minus_i], insert relf relg)
[PROOF STATE]
proof (state)
this:
poly_rel p2 P2

goal (2 subgoals):
 1. n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
 2. \<not> n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
from True *
[PROOF STATE]
proof (chain)
picking this:
n div 2 < m
(n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False
[PROOF STEP]
have rhs: "?rhs = monom_mult (n div 2 + n div 2) P1 +
               (monom_mult (n div 2) (P1 - P2 + P3) + P3)"
[PROOF STATE]
proof (prove)
using this:
n div 2 < m
(n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False

goal (1 subgoal):
 1. karatsuba_main F n G m = monom_mult (n div 2 + n div 2) P1 + (monom_mult (n div 2) (P1 - P2 + P3) + P3)
[PROOF STEP]
unfolding simp Let_def F G split p1 p2 p3
[PROOF STATE]
proof (prove)
using this:
n div 2 < m
(n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False

goal (1 subgoal):
 1. (if n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound then foldr (\<lambda>a p. smult a (poly_of_list F) + pCons (0::'a) p) G 0 else if n div 2 < m then monom_mult (n div 2 + n div 2) (karatsuba_main F1 (n - n div 2) G1 (m - n div 2)) + (monom_mult (n div 2) (karatsuba_main F1 (n - n div 2) G1 (m - n div 2) - karatsuba_main (coeffs_minus F1 F0) (n div 2) (coeffs_minus G1 G0) (n div 2) + karatsuba_main F0 (n div 2) G0 (n div 2)) + karatsuba_main F0 (n div 2) G0 (n div 2)) else monom_mult (n div 2) (karatsuba_main F1 (n - n div 2) G m) + karatsuba_main F0 (n div 2) G m) = monom_mult (n div 2 + n div 2) (karatsuba_main F1 (n - n div 2) G1 (m - n div 2)) + (monom_mult (n div 2) (karatsuba_main F1 (n - n div 2) G1 (m - n div 2) - karatsuba_main (coeffs_minus F1 F0) (n div 2) (coeffs_minus G1 G0) (n div 2) + karatsuba_main F0 (n div 2) G0 (n div 2)) + karatsuba_main F0 (n div 2) G0 (n div 2))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
karatsuba_main F n G m = monom_mult (n div 2 + n div 2) P1 + (monom_mult (n div 2) (P1 - P2 + P3) + P3)

goal (2 subgoals):
 1. n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
 2. \<not> n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
unfolding lhs rhs
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_rel (plus_poly_i ops (monom_mult_i ops (n div 2 + n div 2) p1) (plus_poly_i ops (monom_mult_i ops (n div 2) (plus_poly_i ops (minus_poly_i ops p1 p2) p3)) p3)) (monom_mult (n div 2 + n div 2) P1 + (monom_mult (n div 2) (P1 - P2 + P3) + P3))
[PROOF STEP]
by transfer_prover
[PROOF STATE]
proof (state)
this:
poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)

goal (1 subgoal):
 1. \<not> n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> n div 2 < m

goal (1 subgoal):
 1. \<not> n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
obtain p1 P1 where p1: "p1 = karatsuba_main_i ops f1 (n - n div 2) g m"
          "P1 = karatsuba_main F1 (n - n div 2) G m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>p1 P1. \<lbrakk>p1 = karatsuba_main_i ops f1 (n - n div 2) g m; P1 = karatsuba_main F1 (n - n div 2) G m\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
p1 = karatsuba_main_i ops f1 (n - n div 2) g m
P1 = karatsuba_main F1 (n - n div 2) G m

goal (1 subgoal):
 1. \<not> n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
obtain p2 P2 where p2: "p2 = karatsuba_main_i ops f0 (n div 2) g m"
          "P2 = karatsuba_main F0 (n div 2) G m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>p2 P2. \<lbrakk>p2 = karatsuba_main_i ops f0 (n div 2) g m; P2 = karatsuba_main F0 (n div 2) G m\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
p2 = karatsuba_main_i ops f0 (n div 2) g m
P2 = karatsuba_main F0 (n div 2) G m

goal (1 subgoal):
 1. \<not> n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
from * False
[PROOF STATE]
proof (chain)
picking this:
(n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False
\<not> n div 2 < m
[PROOF STEP]
have lhs: "?lhs = plus_poly_i ops (monom_mult_i ops (n div 2) p1) p2"
[PROOF STATE]
proof (prove)
using this:
(n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False
\<not> n div 2 < m

goal (1 subgoal):
 1. karatsuba_main_i ops f n g m = plus_poly_i ops (monom_mult_i ops (n div 2) p1) p2
[PROOF STEP]
unfolding simp Let_def f split p1 p2
[PROOF STATE]
proof (prove)
using this:
(n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False
\<not> n div 2 < m

goal (1 subgoal):
 1. (if n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound then foldr (\<lambda>a p. plus_poly_i ops (smult_i ops a (poly_of_list_i ops f)) (cCons_i ops (arith_ops_record.zero ops) p)) g [] else if n div 2 < m then case split_at (n div 2) g of (g0, g1) \<Rightarrow> plus_poly_i ops (monom_mult_i ops (n div 2 + n div 2) (karatsuba_main_i ops f1 (n - n div 2) g1 (m - n div 2))) (plus_poly_i ops (monom_mult_i ops (n div 2) (plus_poly_i ops (minus_poly_i ops (karatsuba_main_i ops f1 (n - n div 2) g1 (m - n div 2)) (karatsuba_main_i ops (coeffs_minus_i ops f1 f0) (n div 2) (coeffs_minus_i ops g1 g0) (n div 2))) (karatsuba_main_i ops f0 (n div 2) g0 (n div 2)))) (karatsuba_main_i ops f0 (n div 2) g0 (n div 2))) else plus_poly_i ops (monom_mult_i ops (n div 2) (karatsuba_main_i ops f1 (n - n div 2) g m)) (karatsuba_main_i ops f0 (n div 2) g m)) = plus_poly_i ops (monom_mult_i ops (n div 2) (karatsuba_main_i ops f1 (n - n div 2) g m)) (karatsuba_main_i ops f0 (n div 2) g m)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
karatsuba_main_i ops f n g m = plus_poly_i ops (monom_mult_i ops (n div 2) p1) p2

goal (1 subgoal):
 1. \<not> n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
from * False
[PROOF STATE]
proof (chain)
picking this:
(n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False
\<not> n div 2 < m
[PROOF STEP]
have rhs: "?rhs = monom_mult (n div 2) P1 + P2"
[PROOF STATE]
proof (prove)
using this:
(n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False
\<not> n div 2 < m

goal (1 subgoal):
 1. karatsuba_main F n G m = monom_mult (n div 2) P1 + P2
[PROOF STEP]
unfolding simp Let_def F split p1 p2
[PROOF STATE]
proof (prove)
using this:
(n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound) = False
\<not> n div 2 < m

goal (1 subgoal):
 1. (if n \<le> karatsuba_lower_bound \<or> m \<le> karatsuba_lower_bound then foldr (\<lambda>a p. smult a (poly_of_list F) + pCons (0::'a) p) G 0 else if n div 2 < m then case split_at (n div 2) G of (g0, g1) \<Rightarrow> monom_mult (n div 2 + n div 2) (karatsuba_main F1 (n - n div 2) g1 (m - n div 2)) + (monom_mult (n div 2) (karatsuba_main F1 (n - n div 2) g1 (m - n div 2) - karatsuba_main (coeffs_minus F1 F0) (n div 2) (coeffs_minus g1 g0) (n div 2) + karatsuba_main F0 (n div 2) g0 (n div 2)) + karatsuba_main F0 (n div 2) g0 (n div 2)) else monom_mult (n div 2) (karatsuba_main F1 (n - n div 2) G m) + karatsuba_main F0 (n div 2) G m) = monom_mult (n div 2) (karatsuba_main F1 (n - n div 2) G m) + karatsuba_main F0 (n div 2) G m
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
karatsuba_main F n G m = monom_mult (n div 2) P1 + P2

goal (1 subgoal):
 1. \<not> n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
have [transfer_rule]: "poly_rel p1 P1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_rel p1 P1
[PROOF STEP]
using IH(2)[OF relf(2) rel(2)]
[PROOF STATE]
proof (prove)
using this:
poly_rel (karatsuba_main_i ops f1 (n - n div 2) g ?m) (karatsuba_main F1 (n - n div 2) G ?m)

goal (1 subgoal):
 1. poly_rel p1 P1
[PROOF STEP]
unfolding p1
[PROOF STATE]
proof (prove)
using this:
poly_rel (karatsuba_main_i ops f1 (n - n div 2) g ?m) (karatsuba_main F1 (n - n div 2) G ?m)

goal (1 subgoal):
 1. poly_rel (karatsuba_main_i ops f1 (n - n div 2) g m) (karatsuba_main F1 (n - n div 2) G m)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
poly_rel p1 P1

goal (1 subgoal):
 1. \<not> n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
have [transfer_rule]: "poly_rel p2 P2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_rel p2 P2
[PROOF STEP]
using IH(1)[OF relf(1) rel(2)]
[PROOF STATE]
proof (prove)
using this:
poly_rel (karatsuba_main_i ops f0 (n div 2) g ?m) (karatsuba_main F0 (n div 2) G ?m)

goal (1 subgoal):
 1. poly_rel p2 P2
[PROOF STEP]
unfolding p2
[PROOF STATE]
proof (prove)
using this:
poly_rel (karatsuba_main_i ops f0 (n div 2) g ?m) (karatsuba_main F0 (n div 2) G ?m)

goal (1 subgoal):
 1. poly_rel (karatsuba_main_i ops f0 (n div 2) g m) (karatsuba_main F0 (n div 2) G m)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
poly_rel p2 P2

goal (1 subgoal):
 1. \<not> n div 2 < m \<Longrightarrow> poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)
[PROOF STEP]
unfolding lhs rhs
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_rel (plus_poly_i ops (monom_mult_i ops (n div 2) p1) p2) (monom_mult (n div 2) P1 + P2)
[PROOF STEP]
by transfer_prover
[PROOF STATE]
proof (state)
this:
poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
poly_rel (karatsuba_main_i ops f n g m) (karatsuba_main F n G m)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma residue_holomorphic_over_power:
  assumes "open A" "z0 \<in> A" "f holomorphic_on A"
  shows   "residue (\<lambda>z. f z / (z - z0) ^ Suc n) z0 = (deriv ^^ n) f z0 / fact n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. residue (\<lambda>z. f z / (z - z0) ^ Suc n) z0 = (deriv ^^ n) f z0 / fact n
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. residue (\<lambda>z. f z / (z - z0) ^ Suc n) z0 = (deriv ^^ n) f z0 / fact n
[PROOF STEP]
let ?f = "\<lambda>z. f z / (z - z0) ^ Suc n"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. residue (\<lambda>z. f z / (z - z0) ^ Suc n) z0 = (deriv ^^ n) f z0 / fact n
[PROOF STEP]
from assms(1,2)
[PROOF STATE]
proof (chain)
picking this:
open A
z0 \<in> A
[PROOF STEP]
obtain r where r: "r > 0" "cball z0 r \<subseteq> A"
[PROOF STATE]
proof (prove)
using this:
open A
z0 \<in> A

goal (1 subgoal):
 1. (\<And>r. \<lbrakk>0 < r; cball z0 r \<subseteq> A\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: open_contains_cball)
[PROOF STATE]
proof (state)
this:
0 < r
cball z0 r \<subseteq> A

goal (1 subgoal):
 1. residue (\<lambda>z. f z / (z - z0) ^ Suc n) z0 = (deriv ^^ n) f z0 / fact n
[PROOF STEP]
have "(?f has_contour_integral 2 * pi * \<i> * residue ?f z0) (circlepath z0 r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>z. f z / (z - z0) ^ Suc n) has_contour_integral complex_of_real (2 * pi) * \<i> * residue (\<lambda>z. f z / (z - z0) ^ Suc n) z0) (circlepath z0 r)
[PROOF STEP]
using r assms
[PROOF STATE]
proof (prove)
using this:
0 < r
cball z0 r \<subseteq> A
open A
z0 \<in> A
f holomorphic_on A

goal (1 subgoal):
 1. ((\<lambda>z. f z / (z - z0) ^ Suc n) has_contour_integral complex_of_real (2 * pi) * \<i> * residue (\<lambda>z. f z / (z - z0) ^ Suc n) z0) (circlepath z0 r)
[PROOF STEP]
by (intro base_residue[of A]) (auto intro!: holomorphic_intros)
[PROOF STATE]
proof (state)
this:
((\<lambda>z. f z / (z - z0) ^ Suc n) has_contour_integral complex_of_real (2 * pi) * \<i> * residue (\<lambda>z. f z / (z - z0) ^ Suc n) z0) (circlepath z0 r)

goal (1 subgoal):
 1. residue (\<lambda>z. f z / (z - z0) ^ Suc n) z0 = (deriv ^^ n) f z0 / fact n
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
((\<lambda>z. f z / (z - z0) ^ Suc n) has_contour_integral complex_of_real (2 * pi) * \<i> * residue (\<lambda>z. f z / (z - z0) ^ Suc n) z0) (circlepath z0 r)

goal (1 subgoal):
 1. residue (\<lambda>z. f z / (z - z0) ^ Suc n) z0 = (deriv ^^ n) f z0 / fact n
[PROOF STEP]
have "(?f has_contour_integral 2 * pi * \<i> / fact n * (deriv ^^ n) f z0) (circlepath z0 r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>z. f z / (z - z0) ^ Suc n) has_contour_integral complex_of_real (2 * pi) * \<i> / fact n * (deriv ^^ n) f z0) (circlepath z0 r)
[PROOF STEP]
using assms r
[PROOF STATE]
proof (prove)
using this:
open A
z0 \<in> A
f holomorphic_on A
0 < r
cball z0 r \<subseteq> A

goal (1 subgoal):
 1. ((\<lambda>z. f z / (z - z0) ^ Suc n) has_contour_integral complex_of_real (2 * pi) * \<i> / fact n * (deriv ^^ n) f z0) (circlepath z0 r)
[PROOF STEP]
by (intro Cauchy_has_contour_integral_higher_derivative_circlepath)
       (auto intro!: holomorphic_on_subset[OF assms(3)] holomorphic_on_imp_continuous_on)
[PROOF STATE]
proof (state)
this:
((\<lambda>z. f z / (z - z0) ^ Suc n) has_contour_integral complex_of_real (2 * pi) * \<i> / fact n * (deriv ^^ n) f z0) (circlepath z0 r)

goal (1 subgoal):
 1. residue (\<lambda>z. f z / (z - z0) ^ Suc n) z0 = (deriv ^^ n) f z0 / fact n
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
((\<lambda>z. f z / (z - z0) ^ Suc n) has_contour_integral complex_of_real (2 * pi) * \<i> * residue (\<lambda>z. f z / (z - z0) ^ Suc n) z0) (circlepath z0 r)
((\<lambda>z. f z / (z - z0) ^ Suc n) has_contour_integral complex_of_real (2 * pi) * \<i> / fact n * (deriv ^^ n) f z0) (circlepath z0 r)
[PROOF STEP]
have "2 * pi * \<i> * residue ?f z0 = 2 * pi * \<i> / fact n * (deriv ^^ n) f z0"
[PROOF STATE]
proof (prove)
using this:
((\<lambda>z. f z / (z - z0) ^ Suc n) has_contour_integral complex_of_real (2 * pi) * \<i> * residue (\<lambda>z. f z / (z - z0) ^ Suc n) z0) (circlepath z0 r)
((\<lambda>z. f z / (z - z0) ^ Suc n) has_contour_integral complex_of_real (2 * pi) * \<i> / fact n * (deriv ^^ n) f z0) (circlepath z0 r)

goal (1 subgoal):
 1. complex_of_real (2 * pi) * \<i> * residue (\<lambda>z. f z / (z - z0) ^ Suc n) z0 = complex_of_real (2 * pi) * \<i> / fact n * (deriv ^^ n) f z0
[PROOF STEP]
by (rule has_contour_integral_unique)
[PROOF STATE]
proof (state)
this:
complex_of_real (2 * pi) * \<i> * residue (\<lambda>z. f z / (z - z0) ^ Suc n) z0 = complex_of_real (2 * pi) * \<i> / fact n * (deriv ^^ n) f z0

goal (1 subgoal):
 1. residue (\<lambda>z. f z / (z - z0) ^ Suc n) z0 = (deriv ^^ n) f z0 / fact n
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
complex_of_real (2 * pi) * \<i> * residue (\<lambda>z. f z / (z - z0) ^ Suc n) z0 = complex_of_real (2 * pi) * \<i> / fact n * (deriv ^^ n) f z0

goal (1 subgoal):
 1. residue (\<lambda>z. f z / (z - z0) ^ Suc n) z0 = (deriv ^^ n) f z0 / fact n
[PROOF STEP]
by (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
residue (\<lambda>z. f z / (z - z0) ^ Suc n) z0 = (deriv ^^ n) f z0 / fact n

goal:
No subgoals!
[PROOF STEP]
qed