[STATEMENT]
lemma proots_upper_cindex_eq:
  assumes "lead_coeff p=1" and no_real_roots:"\<forall>x\<in>proots p. Im x\<noteq>0"
  shows "proots_upper p =
             (degree p - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) /2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
proof (cases "degree p = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. degree p = 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
 2. degree p \<noteq> 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
degree p = 0

goal (2 subgoals):
 1. degree p = 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
 2. degree p \<noteq> 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
degree p = 0
[PROOF STEP]
obtain c where "p=[:c:]"
[PROOF STATE]
proof (prove)
using this:
degree p = 0

goal (1 subgoal):
 1. (\<And>c. p = [:c:] \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using degree_eq_zeroE
[PROOF STATE]
proof (prove)
using this:
degree p = 0
\<lbrakk>degree ?p = 0; \<And>a. ?p = [:a:] \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. (\<And>c. p = [:c:] \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
p = [:c:]

goal (2 subgoals):
 1. degree p = 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
 2. degree p \<noteq> 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
p = [:c:]
[PROOF STEP]
have p_def:"p=[:1:]"
[PROOF STATE]
proof (prove)
using this:
p = [:c:]

goal (1 subgoal):
 1. p = [:1:]
[PROOF STEP]
using \<open>lead_coeff p=1\<close>
[PROOF STATE]
proof (prove)
using this:
p = [:c:]
monic p

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

goal (2 subgoals):
 1. degree p = 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
 2. degree p \<noteq> 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
have "proots_count p {x. Im x>0} = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proots_count p {x. 0 < Im x} = 0
[PROOF STEP]
unfolding p_def proots_count_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>r\<in>proots_within [:1:] {x. 0 < Im x}. order r [:1:]) = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
proots_count p {x. 0 < Im x} = 0

goal (2 subgoals):
 1. degree p = 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
 2. degree p \<noteq> 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
proots_count p {x. 0 < Im x} = 0

goal (2 subgoals):
 1. degree p = 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
 2. degree p \<noteq> 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
have "cindex_poly_ubd (map_poly Im p) (map_poly Re p) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cindex_poly_ubd (map_poly Im p) (map_poly Re p) = 0
[PROOF STEP]
apply (subst cindex_poly_ubd_code)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. changes_R_smods (map_poly Re p) (map_poly Im p) = 0
[PROOF STEP]
unfolding p_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. changes_R_smods (map_poly Re [:1:]) (map_poly Im [:1:]) = 0
[PROOF STEP]
by (auto simp add:map_poly_pCons changes_R_smods_def changes_poly_neg_inf_def
        changes_poly_pos_inf_def)
[PROOF STATE]
proof (state)
this:
cindex_poly_ubd (map_poly Im p) (map_poly Re p) = 0

goal (2 subgoals):
 1. degree p = 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
 2. degree p \<noteq> 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
proots_count p {x. 0 < Im x} = 0
cindex_poly_ubd (map_poly Im p) (map_poly Re p) = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
proots_count p {x. 0 < Im x} = 0
cindex_poly_ubd (map_poly Im p) (map_poly Re p) = 0

goal (1 subgoal):
 1. real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
proots_count p {x. 0 < Im x} = 0
cindex_poly_ubd (map_poly Im p) (map_poly Re p) = 0
degree p = 0

goal (1 subgoal):
 1. real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
unfolding proots_upper_def
[PROOF STATE]
proof (prove)
using this:
proots_count p {x. 0 < Im x} = 0
cindex_poly_ubd (map_poly Im p) (map_poly Re p) = 0
degree p = 0

goal (1 subgoal):
 1. real (proots_count p {z. 0 < Im z}) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2

goal (1 subgoal):
 1. degree p \<noteq> 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. degree p \<noteq> 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
degree p \<noteq> 0

goal (1 subgoal):
 1. degree p \<noteq> 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
degree p \<noteq> 0
[PROOF STEP]
have "degree p>0" "p\<noteq>0"
[PROOF STATE]
proof (prove)
using this:
degree p \<noteq> 0

goal (1 subgoal):
 1. 0 < degree p &&& p \<noteq> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < degree p
p \<noteq> 0

goal (1 subgoal):
 1. degree p \<noteq> 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
define w1 where "w1=(\<lambda>r. Re (winding_number (poly p \<circ>
              (\<lambda>x. complex_of_real (linepath (- r) (of_real r) x))) 0))"
[PROOF STATE]
proof (state)
this:
w1 = (\<lambda>r. Re (winding_number (poly p \<circ> (\<lambda>x. complex_of_real (linepath (- r) (of_real r) x))) 0))

goal (1 subgoal):
 1. degree p \<noteq> 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
define w2 where "w2=(\<lambda>r. Re (winding_number (poly p \<circ> part_circlepath 0 r 0 pi) 0))"
[PROOF STATE]
proof (state)
this:
w2 = (\<lambda>r. Re (winding_number (poly p \<circ> part_circlepath 0 r 0 pi) 0))

goal (1 subgoal):
 1. degree p \<noteq> 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
define cp where "cp=(\<lambda>r. cindex_pathE (poly p \<circ> (\<lambda>x.
      of_real (linepath (- r) (of_real r) x))) 0)"
[PROOF STATE]
proof (state)
this:
cp = (\<lambda>r. cindex_pathE (poly p \<circ> (\<lambda>x. complex_of_real (linepath (- r) (of_real r) x))) 0)

goal (1 subgoal):
 1. degree p \<noteq> 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
define ci where "ci=(\<lambda>r. cindexE (-r) r (\<lambda>x. poly (map_poly Im p) x/poly (map_poly Re p) x))"
[PROOF STATE]
proof (state)
this:
ci = (\<lambda>r. cindexE (- r) r (\<lambda>x. poly (map_poly Im p) x / poly (map_poly Re p) x))

goal (1 subgoal):
 1. degree p \<noteq> 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
define cubd where "cubd =cindex_poly_ubd (map_poly Im p) (map_poly Re p)"
[PROOF STATE]
proof (state)
this:
cubd = cindex_poly_ubd (map_poly Im p) (map_poly Re p)

goal (1 subgoal):
 1. degree p \<noteq> 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
obtain R where "proots p \<subseteq> ball 0 R" and "R>0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>R. \<lbrakk>proots p \<subseteq> ball 0 R; 0 < R\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using \<open>p\<noteq>0\<close> finite_ball_include[of "proots p" 0]
[PROOF STATE]
proof (prove)
using this:
p \<noteq> 0
finite (proots p) \<Longrightarrow> \<exists>e>0. proots p \<subseteq> ball 0 e

goal (1 subgoal):
 1. (\<And>R. \<lbrakk>proots p \<subseteq> ball 0 R; 0 < R\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
proots p \<subseteq> ball 0 R
0 < R

goal (1 subgoal):
 1. degree p \<noteq> 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
have "((\<lambda>r. w1 r  +w2 r+ cp r / 2 -ci r/2)
       \<longlongrightarrow> real (degree p) / 2 - of_int cubd / 2) at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>r. w1 r + w2 r + cp r / 2 - ci r / 2) \<longlongrightarrow> real (degree p) / 2 - real_of_int cubd / 2) at_top
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ((\<lambda>r. w1 r + w2 r + cp r / 2 - ci r / 2) \<longlongrightarrow> real (degree p) / 2 - real_of_int cubd / 2) at_top
[PROOF STEP]
have t1:"((\<lambda>r. 2 * w1 r + cp r) \<longlongrightarrow> 0) at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>r. 2 * w1 r + cp r) \<longlongrightarrow> 0) at_top
[PROOF STEP]
using Re_winding_number_poly_linepth[OF assms]
[PROOF STATE]
proof (prove)
using this:
((\<lambda>r. 2 * Re (winding_number (poly p \<circ> (\<lambda>x. complex_of_real (linepath (- r) (of_real r) x))) 0) + cindex_pathE (poly p \<circ> (\<lambda>x. complex_of_real (linepath (- r) (of_real r) x))) 0) \<longlongrightarrow> 0) at_top

goal (1 subgoal):
 1. ((\<lambda>r. 2 * w1 r + cp r) \<longlongrightarrow> 0) at_top
[PROOF STEP]
unfolding w1_def cp_def
[PROOF STATE]
proof (prove)
using this:
((\<lambda>r. 2 * Re (winding_number (poly p \<circ> (\<lambda>x. complex_of_real (linepath (- r) (of_real r) x))) 0) + cindex_pathE (poly p \<circ> (\<lambda>x. complex_of_real (linepath (- r) (of_real r) x))) 0) \<longlongrightarrow> 0) at_top

goal (1 subgoal):
 1. ((\<lambda>r. 2 * Re (winding_number (poly p \<circ> (\<lambda>x. complex_of_real (linepath (- r) (of_real r) x))) 0) + cindex_pathE (poly p \<circ> (\<lambda>x. complex_of_real (linepath (- r) (of_real r) x))) 0) \<longlongrightarrow> 0) at_top
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
((\<lambda>r. 2 * w1 r + cp r) \<longlongrightarrow> 0) at_top

goal (1 subgoal):
 1. ((\<lambda>r. w1 r + w2 r + cp r / 2 - ci r / 2) \<longlongrightarrow> real (degree p) / 2 - real_of_int cubd / 2) at_top
[PROOF STEP]
have t2:"(w2 \<longlongrightarrow> real (degree p) / 2) at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (w2 \<longlongrightarrow> real (degree p) / 2) at_top
[PROOF STEP]
using Re_winding_number_poly_part_circlepath[OF \<open>degree p>0\<close>,of 0]
[PROOF STATE]
proof (prove)
using this:
((\<lambda>r. Re (winding_number (poly p \<circ> part_circlepath 0 r 0 pi) 0)) \<longlongrightarrow> real (degree p) / 2) at_top

goal (1 subgoal):
 1. (w2 \<longlongrightarrow> real (degree p) / 2) at_top
[PROOF STEP]
unfolding w2_def
[PROOF STATE]
proof (prove)
using this:
((\<lambda>r. Re (winding_number (poly p \<circ> part_circlepath 0 r 0 pi) 0)) \<longlongrightarrow> real (degree p) / 2) at_top

goal (1 subgoal):
 1. ((\<lambda>r. Re (winding_number (poly p \<circ> part_circlepath 0 r 0 pi) 0)) \<longlongrightarrow> real (degree p) / 2) at_top
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(w2 \<longlongrightarrow> real (degree p) / 2) at_top

goal (1 subgoal):
 1. ((\<lambda>r. w1 r + w2 r + cp r / 2 - ci r / 2) \<longlongrightarrow> real (degree p) / 2 - real_of_int cubd / 2) at_top
[PROOF STEP]
have t3:"(ci \<longlongrightarrow> of_int cubd) at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (ci \<longlongrightarrow> real_of_int cubd) at_top
[PROOF STEP]
apply (rule tendsto_eventually)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_top. ci x = real_of_int cubd
[PROOF STEP]
using cindex_poly_ubd_eventually[of "map_poly Im p" "map_poly Re p"]
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F r in at_top. cindexE (- r) r (\<lambda>x. poly (map_poly Im p) x / poly (map_poly Re p) x) = real_of_int (cindex_poly_ubd (map_poly Im p) (map_poly Re p))

goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_top. ci x = real_of_int cubd
[PROOF STEP]
unfolding ci_def cubd_def
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F r in at_top. cindexE (- r) r (\<lambda>x. poly (map_poly Im p) x / poly (map_poly Re p) x) = real_of_int (cindex_poly_ubd (map_poly Im p) (map_poly Re p))

goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_top. cindexE (- x) x (\<lambda>x. poly (map_poly Im p) x / poly (map_poly Re p) x) = real_of_int (cindex_poly_ubd (map_poly Im p) (map_poly Re p))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(ci \<longlongrightarrow> real_of_int cubd) at_top

goal (1 subgoal):
 1. ((\<lambda>r. w1 r + w2 r + cp r / 2 - ci r / 2) \<longlongrightarrow> real (degree p) / 2 - real_of_int cubd / 2) at_top
[PROOF STEP]
from tendsto_add[OF tendsto_add[OF tendsto_mult_left[OF t3,of "-1/2",simplified]
         tendsto_mult_left[OF t1,of "1/2",simplified]]
         t2]
[PROOF STATE]
proof (chain)
picking this:
((\<lambda>x. - (ci x / 2) + (w1 x + cp x / 2) + w2 x) \<longlongrightarrow> - (real_of_int cubd / 2) + 0 + real (degree p) / 2) at_top
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. - (ci x / 2) + (w1 x + cp x / 2) + w2 x) \<longlongrightarrow> - (real_of_int cubd / 2) + 0 + real (degree p) / 2) at_top

goal (1 subgoal):
 1. ((\<lambda>r. w1 r + w2 r + cp r / 2 - ci r / 2) \<longlongrightarrow> real (degree p) / 2 - real_of_int cubd / 2) at_top
[PROOF STEP]
by (simp add:algebra_simps)
[PROOF STATE]
proof (state)
this:
((\<lambda>r. w1 r + w2 r + cp r / 2 - ci r / 2) \<longlongrightarrow> real (degree p) / 2 - real_of_int cubd / 2) at_top

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
((\<lambda>r. w1 r + w2 r + cp r / 2 - ci r / 2) \<longlongrightarrow> real (degree p) / 2 - real_of_int cubd / 2) at_top

goal (1 subgoal):
 1. degree p \<noteq> 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
((\<lambda>r. w1 r + w2 r + cp r / 2 - ci r / 2) \<longlongrightarrow> real (degree p) / 2 - real_of_int cubd / 2) at_top

goal (1 subgoal):
 1. degree p \<noteq> 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
have "\<forall>\<^sub>F r in at_top. w1 r  +w2 r+ cp r / 2 -ci r/2 = proots_count p {x. Im x>0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F r in at_top. w1 r + w2 r + cp r / 2 - ci r / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
proof (rule eventually_at_top_linorderI[of R])
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. R \<le> x \<Longrightarrow> w1 x + w2 x + cp x / 2 - ci x / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
fix r
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. R \<le> x \<Longrightarrow> w1 x + w2 x + cp x / 2 - ci x / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
assume "r\<ge>R"
[PROOF STATE]
proof (state)
this:
R \<le> r

goal (1 subgoal):
 1. \<And>x. R \<le> x \<Longrightarrow> w1 x + w2 x + cp x / 2 - ci x / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
R \<le> r
[PROOF STEP]
have r_ball:"proots p \<subseteq> ball 0 r" and "r>0"
[PROOF STATE]
proof (prove)
using this:
R \<le> r

goal (1 subgoal):
 1. proots p \<subseteq> ball 0 r &&& 0 < r
[PROOF STEP]
using \<open>R>0\<close> \<open>proots p \<subseteq> ball 0 R\<close>
[PROOF STATE]
proof (prove)
using this:
R \<le> r
0 < R
proots p \<subseteq> ball 0 R

goal (1 subgoal):
 1. proots p \<subseteq> ball 0 r &&& 0 < r
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
proots p \<subseteq> ball 0 r
0 < r

goal (1 subgoal):
 1. \<And>x. R \<le> x \<Longrightarrow> w1 x + w2 x + cp x / 2 - ci x / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
define ll where "ll=linepath (- complex_of_real r) r"
[PROOF STATE]
proof (state)
this:
ll = linepath (- complex_of_real r) (complex_of_real r)

goal (1 subgoal):
 1. \<And>x. R \<le> x \<Longrightarrow> w1 x + w2 x + cp x / 2 - ci x / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
define rr where "rr=part_circlepath 0 r 0 pi"
[PROOF STATE]
proof (state)
this:
rr = part_circlepath 0 r 0 pi

goal (1 subgoal):
 1. \<And>x. R \<le> x \<Longrightarrow> w1 x + w2 x + cp x / 2 - ci x / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
define lr where "lr = ll +++ rr"
[PROOF STATE]
proof (state)
this:
lr = ll +++ rr

goal (1 subgoal):
 1. \<And>x. R \<le> x \<Longrightarrow> w1 x + w2 x + cp x / 2 - ci x / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
have img_ll:"path_image ll \<subseteq> - proots p" and img_rr: "path_image rr \<subseteq> - proots p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. path_image ll \<subseteq> - proots p &&& path_image rr \<subseteq> - proots p
[PROOF STEP]
subgoal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. path_image ll \<subseteq> - proots p
[PROOF STEP]
unfolding ll_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. path_image (linepath (- complex_of_real r) (complex_of_real r)) \<subseteq> - proots p
[PROOF STEP]
using \<open>0 < r\<close> closed_segment_degen_complex(2) no_real_roots
[PROOF STATE]
proof (prove)
using this:
0 < r
\<lbrakk>Im ?lb = Im ?ub; Re ?lb \<le> Re ?ub\<rbrakk> \<Longrightarrow> (?x \<in> closed_segment ?lb ?ub) = (Im ?x = Im ?lb \<and> Re ?lb \<le> Re ?x \<and> Re ?x \<le> Re ?ub)
\<forall>x\<in>proots p. Im x \<noteq> 0

goal (1 subgoal):
 1. path_image (linepath (- complex_of_real r) (complex_of_real r)) \<subseteq> - proots p
[PROOF STEP]
by auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. path_image rr \<subseteq> - proots p
[PROOF STEP]
subgoal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. path_image rr \<subseteq> - proots p
[PROOF STEP]
unfolding rr_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. path_image (part_circlepath 0 r 0 pi) \<subseteq> - proots p
[PROOF STEP]
using in_path_image_part_circlepath \<open>0 < r\<close> r_ball
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?w \<in> path_image (part_circlepath ?z ?r ?st ?tt); 0 \<le> ?r\<rbrakk> \<Longrightarrow> cmod (?w - ?z) = ?r
0 < r
proots p \<subseteq> ball 0 r

goal (1 subgoal):
 1. path_image (part_circlepath 0 r 0 pi) \<subseteq> - proots p
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
path_image ll \<subseteq> - proots p
path_image rr \<subseteq> - proots p

goal (1 subgoal):
 1. \<And>x. R \<le> x \<Longrightarrow> w1 x + w2 x + cp x / 2 - ci x / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
have [simp]:"valid_path (poly p o ll)" "valid_path (poly p o rr)"
        "valid_path ll" "valid_path rr"
        "pathfinish rr=pathstart ll" "pathfinish ll = pathstart rr"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (valid_path (poly p \<circ> ll) &&& valid_path (poly p \<circ> rr) &&& valid_path ll) &&& valid_path rr &&& pathfinish rr = pathstart ll &&& pathfinish ll = pathstart rr
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (6 subgoals):
 1. valid_path (poly p \<circ> ll)
 2. valid_path (poly p \<circ> rr)
 3. valid_path ll
 4. valid_path rr
 5. pathfinish rr = pathstart ll
 6. pathfinish ll = pathstart rr
[PROOF STEP]
show "valid_path (poly p o ll)" "valid_path (poly p o rr)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. valid_path (poly p \<circ> ll) &&& valid_path (poly p \<circ> rr)
[PROOF STEP]
unfolding ll_def rr_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. valid_path (poly p \<circ> linepath (- complex_of_real r) (complex_of_real r)) &&& valid_path (poly p \<circ> part_circlepath 0 r 0 pi)
[PROOF STEP]
by (auto intro:valid_path_compose_holomorphic)
[PROOF STATE]
proof (state)
this:
valid_path (poly p \<circ> ll)
valid_path (poly p \<circ> rr)

goal (4 subgoals):
 1. valid_path ll
 2. valid_path rr
 3. pathfinish rr = pathstart ll
 4. pathfinish ll = pathstart rr
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
valid_path (poly p \<circ> ll)
valid_path (poly p \<circ> rr)
[PROOF STEP]
show "valid_path ll" "valid_path rr"
[PROOF STATE]
proof (prove)
using this:
valid_path (poly p \<circ> ll)
valid_path (poly p \<circ> rr)

goal (1 subgoal):
 1. valid_path ll &&& valid_path rr
[PROOF STEP]
unfolding ll_def rr_def
[PROOF STATE]
proof (prove)
using this:
valid_path (poly p \<circ> linepath (- complex_of_real r) (complex_of_real r))
valid_path (poly p \<circ> part_circlepath 0 r 0 pi)

goal (1 subgoal):
 1. valid_path (linepath (- complex_of_real r) (complex_of_real r)) &&& valid_path (part_circlepath 0 r 0 pi)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
valid_path ll
valid_path rr

goal (2 subgoals):
 1. pathfinish rr = pathstart ll
 2. pathfinish ll = pathstart rr
[PROOF STEP]
show "pathfinish rr=pathstart ll" "pathfinish ll = pathstart rr"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pathfinish rr = pathstart ll &&& pathfinish ll = pathstart rr
[PROOF STEP]
unfolding ll_def rr_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pathfinish (part_circlepath 0 r 0 pi) = pathstart (linepath (- complex_of_real r) (complex_of_real r)) &&& pathfinish (linepath (- complex_of_real r) (complex_of_real r)) = pathstart (part_circlepath 0 r 0 pi)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
pathfinish rr = pathstart ll
pathfinish ll = pathstart rr

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
valid_path (poly p \<circ> ll)
valid_path (poly p \<circ> rr)
valid_path ll
valid_path rr
pathfinish rr = pathstart ll
pathfinish ll = pathstart rr

goal (1 subgoal):
 1. \<And>x. R \<le> x \<Longrightarrow> w1 x + w2 x + cp x / 2 - ci x / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
have "proots_count p {x. Im x>0} = (\<Sum>x\<in>proots p. winding_number lr x * of_nat (order x p))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_nat (proots_count p {x. 0 < Im x}) = (\<Sum>x\<in>proots p. winding_number lr x * of_nat (order x p))
[PROOF STEP]
unfolding proots_count_def of_nat_sum
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>proots_within p {x. 0 < Im x}. of_nat (order x p)) = (\<Sum>x\<in>proots p. winding_number lr x * of_nat (order x p))
[PROOF STEP]
proof (rule sum.mono_neutral_cong_left)
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. finite (proots p)
 2. proots_within p {x. 0 < Im x} \<subseteq> proots p
 3. \<forall>i\<in>proots p - proots_within p {x. 0 < Im x}. winding_number lr i * of_nat (order i p) = 0
 4. \<And>x. x \<in> proots_within p {x. 0 < Im x} \<Longrightarrow> of_nat (order x p) = winding_number lr x * of_nat (order x p)
[PROOF STEP]
show "finite (proots p)" "proots_within p {x. 0 < Im x} \<subseteq> proots p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (proots p) &&& proots_within p {x. 0 < Im x} \<subseteq> proots p
[PROOF STEP]
using \<open>p\<noteq>0\<close>
[PROOF STATE]
proof (prove)
using this:
p \<noteq> 0

goal (1 subgoal):
 1. finite (proots p) &&& proots_within p {x. 0 < Im x} \<subseteq> proots p
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite (proots p)
proots_within p {x. 0 < Im x} \<subseteq> proots p

goal (2 subgoals):
 1. \<forall>i\<in>proots p - proots_within p {x. 0 < Im x}. winding_number lr i * of_nat (order i p) = 0
 2. \<And>x. x \<in> proots_within p {x. 0 < Im x} \<Longrightarrow> of_nat (order x p) = winding_number lr x * of_nat (order x p)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<forall>i\<in>proots p - proots_within p {x. 0 < Im x}. winding_number lr i * of_nat (order i p) = 0
 2. \<And>x. x \<in> proots_within p {x. 0 < Im x} \<Longrightarrow> of_nat (order x p) = winding_number lr x * of_nat (order x p)
[PROOF STEP]
have "winding_number lr x=0" when "x\<in>proots p - proots_within p {x. 0 < Im x}" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. winding_number lr x = 0
[PROOF STEP]
unfolding lr_def ll_def rr_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. winding_number (linepath (- complex_of_real r) (complex_of_real r) +++ part_circlepath 0 r 0 pi) x = 0
[PROOF STEP]
proof (eval_winding,simp_all)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. x \<notin> closed_segment (- complex_of_real r) (complex_of_real r)
 2. x \<notin> path_image (part_circlepath 0 r 0 pi)
 3. - cindex_pathE (linepath (- complex_of_real r) (complex_of_real r)) x = cindex_pathE (part_circlepath 0 r 0 pi) x
[PROOF STEP]
show *:"x \<notin> closed_segment (- complex_of_real r) (complex_of_real r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<notin> closed_segment (- complex_of_real r) (complex_of_real r)
[PROOF STEP]
using img_ll that
[PROOF STATE]
proof (prove)
using this:
path_image ll \<subseteq> - proots p
x \<in> proots p - proots_within p {x. 0 < Im x}

goal (1 subgoal):
 1. x \<notin> closed_segment (- complex_of_real r) (complex_of_real r)
[PROOF STEP]
unfolding ll_def
[PROOF STATE]
proof (prove)
using this:
path_image (linepath (- complex_of_real r) (complex_of_real r)) \<subseteq> - proots p
x \<in> proots p - proots_within p {x. 0 < Im x}

goal (1 subgoal):
 1. x \<notin> closed_segment (- complex_of_real r) (complex_of_real r)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<notin> closed_segment (- complex_of_real r) (complex_of_real r)

goal (2 subgoals):
 1. x \<notin> path_image (part_circlepath 0 r 0 pi)
 2. - cindex_pathE (linepath (- complex_of_real r) (complex_of_real r)) x = cindex_pathE (part_circlepath 0 r 0 pi) x
[PROOF STEP]
show "x \<notin> path_image (part_circlepath 0 r 0 pi)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<notin> path_image (part_circlepath 0 r 0 pi)
[PROOF STEP]
using img_rr that
[PROOF STATE]
proof (prove)
using this:
path_image rr \<subseteq> - proots p
x \<in> proots p - proots_within p {x. 0 < Im x}

goal (1 subgoal):
 1. x \<notin> path_image (part_circlepath 0 r 0 pi)
[PROOF STEP]
unfolding rr_def
[PROOF STATE]
proof (prove)
using this:
path_image (part_circlepath 0 r 0 pi) \<subseteq> - proots p
x \<in> proots p - proots_within p {x. 0 < Im x}

goal (1 subgoal):
 1. x \<notin> path_image (part_circlepath 0 r 0 pi)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<notin> path_image (part_circlepath 0 r 0 pi)

goal (1 subgoal):
 1. - cindex_pathE (linepath (- complex_of_real r) (complex_of_real r)) x = cindex_pathE (part_circlepath 0 r 0 pi) x
[PROOF STEP]
have xr_facts:"0 > Im x" "-r<Re x" "Re x<r" "cmod x<r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Im x < 0 &&& - r < Re x) &&& Re x < r &&& cmod x < r
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. Im x < 0
 2. - r < Re x
 3. Re x < r
 4. cmod x < r
[PROOF STEP]
have "Im x\<le>0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Im x \<le> 0
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
x \<in> proots p - proots_within p {x. 0 < Im x}

goal (1 subgoal):
 1. Im x \<le> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Im x \<le> 0

goal (4 subgoals):
 1. Im x < 0
 2. - r < Re x
 3. Re x < r
 4. cmod x < r
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
Im x \<le> 0

goal (4 subgoals):
 1. Im x < 0
 2. - r < Re x
 3. Re x < r
 4. cmod x < r
[PROOF STEP]
have "Im x\<noteq>0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Im x \<noteq> 0
[PROOF STEP]
using no_real_roots that
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>proots p. Im x \<noteq> 0
x \<in> proots p - proots_within p {x. 0 < Im x}

goal (1 subgoal):
 1. Im x \<noteq> 0
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
Im x \<noteq> 0

goal (4 subgoals):
 1. Im x < 0
 2. - r < Re x
 3. Re x < r
 4. cmod x < r
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
Im x \<le> 0
Im x \<noteq> 0
[PROOF STEP]
show "0 > Im x"
[PROOF STATE]
proof (prove)
using this:
Im x \<le> 0
Im x \<noteq> 0

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

goal (3 subgoals):
 1. - r < Re x
 2. Re x < r
 3. cmod x < r
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. - r < Re x
 2. Re x < r
 3. cmod x < r
[PROOF STEP]
show "cmod x<r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cmod x < r
[PROOF STEP]
using that r_ball
[PROOF STATE]
proof (prove)
using this:
x \<in> proots p - proots_within p {x. 0 < Im x}
proots p \<subseteq> ball 0 r

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

goal (2 subgoals):
 1. - r < Re x
 2. Re x < r
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
cmod x < r
[PROOF STEP]
have "\<bar>Re x\<bar> < r"
[PROOF STATE]
proof (prove)
using this:
cmod x < r

goal (1 subgoal):
 1. \<bar>Re x\<bar> < r
[PROOF STEP]
using abs_Re_le_cmod[of x]
[PROOF STATE]
proof (prove)
using this:
cmod x < r
\<bar>Re x\<bar> \<le> cmod x

goal (1 subgoal):
 1. \<bar>Re x\<bar> < r
[PROOF STEP]
by argo
[PROOF STATE]
proof (state)
this:
\<bar>Re x\<bar> < r

goal (2 subgoals):
 1. - r < Re x
 2. Re x < r
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<bar>Re x\<bar> < r
[PROOF STEP]
show "-r<Re x" "Re x<r"
[PROOF STATE]
proof (prove)
using this:
\<bar>Re x\<bar> < r

goal (1 subgoal):
 1. - r < Re x &&& Re x < r
[PROOF STEP]
by linarith+
[PROOF STATE]
proof (state)
this:
- r < Re x
Re x < r

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Im x < 0
- r < Re x
Re x < r
cmod x < r

goal (1 subgoal):
 1. - cindex_pathE (linepath (- complex_of_real r) (complex_of_real r)) x = cindex_pathE (part_circlepath 0 r 0 pi) x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Im x < 0
- r < Re x
Re x < r
cmod x < r
[PROOF STEP]
have "cindex_pathE ll x = 1"
[PROOF STATE]
proof (prove)
using this:
Im x < 0
- r < Re x
Re x < r
cmod x < r

goal (1 subgoal):
 1. cindex_pathE ll x = 1
[PROOF STEP]
using \<open>r>0\<close>
[PROOF STATE]
proof (prove)
using this:
Im x < 0
- r < Re x
Re x < r
cmod x < r
0 < r

goal (1 subgoal):
 1. cindex_pathE ll x = 1
[PROOF STEP]
unfolding cindex_pathE_linepath[OF *] ll_def
[PROOF STATE]
proof (prove)
using this:
Im x < 0
- r < Re x
Re x < r
cmod x < r
0 < r

goal (1 subgoal):
 1. (let c1 = Re (- complex_of_real r) - Re x; c2 = Re (complex_of_real r) - Re x; c3 = Im (- complex_of_real r) * Re (complex_of_real r) + Re x * Im (complex_of_real r) + Im x * Re (- complex_of_real r) - Im x * Re (complex_of_real r) - Im (complex_of_real r) * Re (- complex_of_real r) - Re x * Im (- complex_of_real r); d1 = Im (- complex_of_real r) - Im x; d2 = Im (complex_of_real r) - Im x in if 0 < c1 \<and> c2 < 0 \<or> c1 < 0 \<and> 0 < c2 then if 0 < c3 then 1 else - 1 else if (c1 = 0) = (c2 \<noteq> 0) \<and> (c1 = 0 \<longrightarrow> d1 \<noteq> 0) \<and> (c2 = 0 \<longrightarrow> d2 \<noteq> 0) then if c1 = 0 \<and> (0 < c2) = (0 < d1) \<or> c2 = 0 \<and> (0 < c1) = (d2 < 0) then 1 / 2 else - 1 / 2 else 0) = 1
[PROOF STEP]
by (auto simp add: mult_pos_neg)
[PROOF STATE]
proof (state)
this:
cindex_pathE ll x = 1

goal (1 subgoal):
 1. - cindex_pathE (linepath (- complex_of_real r) (complex_of_real r)) x = cindex_pathE (part_circlepath 0 r 0 pi) x
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
cindex_pathE ll x = 1

goal (1 subgoal):
 1. - cindex_pathE (linepath (- complex_of_real r) (complex_of_real r)) x = cindex_pathE (part_circlepath 0 r 0 pi) x
[PROOF STEP]
have "cindex_pathE rr x=-1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cindex_pathE rr x = - 1
[PROOF STEP]
unfolding rr_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cindex_pathE (part_circlepath 0 r 0 pi) x = - 1
[PROOF STEP]
using r_ball that
[PROOF STATE]
proof (prove)
using this:
proots p \<subseteq> ball 0 r
x \<in> proots p - proots_within p {x. 0 < Im x}

goal (1 subgoal):
 1. cindex_pathE (part_circlepath 0 r 0 pi) x = - 1
[PROOF STEP]
by (auto intro!: cindex_pathE_circlepath_upper)
[PROOF STATE]
proof (state)
this:
cindex_pathE rr x = - 1

goal (1 subgoal):
 1. - cindex_pathE (linepath (- complex_of_real r) (complex_of_real r)) x = cindex_pathE (part_circlepath 0 r 0 pi) x
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
cindex_pathE ll x = 1
cindex_pathE rr x = - 1
[PROOF STEP]
show "-cindex_pathE (linepath (- of_real r) (of_real r)) x =
            cindex_pathE (part_circlepath 0 r 0 pi) x"
[PROOF STATE]
proof (prove)
using this:
cindex_pathE ll x = 1
cindex_pathE rr x = - 1

goal (1 subgoal):
 1. - cindex_pathE (linepath (- complex_of_real r) (complex_of_real r)) x = cindex_pathE (part_circlepath 0 r 0 pi) x
[PROOF STEP]
unfolding ll_def rr_def
[PROOF STATE]
proof (prove)
using this:
cindex_pathE (linepath (- complex_of_real r) (complex_of_real r)) x = 1
cindex_pathE (part_circlepath 0 r 0 pi) x = - 1

goal (1 subgoal):
 1. - cindex_pathE (linepath (- complex_of_real r) (complex_of_real r)) x = cindex_pathE (part_circlepath 0 r 0 pi) x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
- cindex_pathE (linepath (- complex_of_real r) (complex_of_real r)) x = cindex_pathE (part_circlepath 0 r 0 pi) x

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?x \<in> proots p - proots_within p {x. 0 < Im x} \<Longrightarrow> winding_number lr ?x = 0

goal (2 subgoals):
 1. \<forall>i\<in>proots p - proots_within p {x. 0 < Im x}. winding_number lr i * of_nat (order i p) = 0
 2. \<And>x. x \<in> proots_within p {x. 0 < Im x} \<Longrightarrow> of_nat (order x p) = winding_number lr x * of_nat (order x p)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?x \<in> proots p - proots_within p {x. 0 < Im x} \<Longrightarrow> winding_number lr ?x = 0
[PROOF STEP]
show "\<forall>i\<in>proots p - proots_within p {x. 0 < Im x}.
          winding_number lr i * of_nat (order i p) = 0"
[PROOF STATE]
proof (prove)
using this:
?x \<in> proots p - proots_within p {x. 0 < Im x} \<Longrightarrow> winding_number lr ?x = 0

goal (1 subgoal):
 1. \<forall>i\<in>proots p - proots_within p {x. 0 < Im x}. winding_number lr i * of_nat (order i p) = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>i\<in>proots p - proots_within p {x. 0 < Im x}. winding_number lr i * of_nat (order i p) = 0

goal (1 subgoal):
 1. \<And>x. x \<in> proots_within p {x. 0 < Im x} \<Longrightarrow> of_nat (order x p) = winding_number lr x * of_nat (order x p)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> proots_within p {x. 0 < Im x} \<Longrightarrow> of_nat (order x p) = winding_number lr x * of_nat (order x p)
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> proots_within p {x. 0 < Im x} \<Longrightarrow> of_nat (order x p) = winding_number lr x * of_nat (order x p)
[PROOF STEP]
assume x_asm:"x \<in> proots_within p {x. 0 < Im x}"
[PROOF STATE]
proof (state)
this:
x \<in> proots_within p {x. 0 < Im x}

goal (1 subgoal):
 1. \<And>x. x \<in> proots_within p {x. 0 < Im x} \<Longrightarrow> of_nat (order x p) = winding_number lr x * of_nat (order x p)
[PROOF STEP]
have "winding_number lr x=1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. winding_number lr x = 1
[PROOF STEP]
unfolding lr_def ll_def rr_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. winding_number (linepath (- complex_of_real r) (complex_of_real r) +++ part_circlepath 0 r 0 pi) x = 1
[PROOF STEP]
proof (eval_winding,simp_all)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. x \<notin> closed_segment (- complex_of_real r) (complex_of_real r)
 2. x \<notin> path_image (part_circlepath 0 r 0 pi)
 3. - complex_of_real (cindex_pathE (linepath (- complex_of_real r) (complex_of_real r)) x) - complex_of_real (cindex_pathE (part_circlepath 0 r 0 pi) x) = 2
[PROOF STEP]
show *:"x \<notin> closed_segment (- complex_of_real r) (complex_of_real r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<notin> closed_segment (- complex_of_real r) (complex_of_real r)
[PROOF STEP]
using img_ll x_asm
[PROOF STATE]
proof (prove)
using this:
path_image ll \<subseteq> - proots p
x \<in> proots_within p {x. 0 < Im x}

goal (1 subgoal):
 1. x \<notin> closed_segment (- complex_of_real r) (complex_of_real r)
[PROOF STEP]
unfolding ll_def
[PROOF STATE]
proof (prove)
using this:
path_image (linepath (- complex_of_real r) (complex_of_real r)) \<subseteq> - proots p
x \<in> proots_within p {x. 0 < Im x}

goal (1 subgoal):
 1. x \<notin> closed_segment (- complex_of_real r) (complex_of_real r)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<notin> closed_segment (- complex_of_real r) (complex_of_real r)

goal (2 subgoals):
 1. x \<notin> path_image (part_circlepath 0 r 0 pi)
 2. - complex_of_real (cindex_pathE (linepath (- complex_of_real r) (complex_of_real r)) x) - complex_of_real (cindex_pathE (part_circlepath 0 r 0 pi) x) = 2
[PROOF STEP]
show "x \<notin> path_image (part_circlepath 0 r 0 pi)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<notin> path_image (part_circlepath 0 r 0 pi)
[PROOF STEP]
using img_rr x_asm
[PROOF STATE]
proof (prove)
using this:
path_image rr \<subseteq> - proots p
x \<in> proots_within p {x. 0 < Im x}

goal (1 subgoal):
 1. x \<notin> path_image (part_circlepath 0 r 0 pi)
[PROOF STEP]
unfolding rr_def
[PROOF STATE]
proof (prove)
using this:
path_image (part_circlepath 0 r 0 pi) \<subseteq> - proots p
x \<in> proots_within p {x. 0 < Im x}

goal (1 subgoal):
 1. x \<notin> path_image (part_circlepath 0 r 0 pi)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<notin> path_image (part_circlepath 0 r 0 pi)

goal (1 subgoal):
 1. - complex_of_real (cindex_pathE (linepath (- complex_of_real r) (complex_of_real r)) x) - complex_of_real (cindex_pathE (part_circlepath 0 r 0 pi) x) = 2
[PROOF STEP]
have xr_facts:"0 < Im x" "-r<Re x" "Re x<r" "cmod x<r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0 < Im x &&& - r < Re x) &&& Re x < r &&& cmod x < r
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. 0 < Im x
 2. - r < Re x
 3. Re x < r
 4. cmod x < r
[PROOF STEP]
show "0 < Im x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < Im x
[PROOF STEP]
using x_asm
[PROOF STATE]
proof (prove)
using this:
x \<in> proots_within p {x. 0 < Im x}

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

goal (3 subgoals):
 1. - r < Re x
 2. Re x < r
 3. cmod x < r
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. - r < Re x
 2. Re x < r
 3. cmod x < r
[PROOF STEP]
show "cmod x<r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cmod x < r
[PROOF STEP]
using x_asm r_ball
[PROOF STATE]
proof (prove)
using this:
x \<in> proots_within p {x. 0 < Im x}
proots p \<subseteq> ball 0 r

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

goal (2 subgoals):
 1. - r < Re x
 2. Re x < r
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
cmod x < r
[PROOF STEP]
have "\<bar>Re x\<bar> < r"
[PROOF STATE]
proof (prove)
using this:
cmod x < r

goal (1 subgoal):
 1. \<bar>Re x\<bar> < r
[PROOF STEP]
using abs_Re_le_cmod[of x]
[PROOF STATE]
proof (prove)
using this:
cmod x < r
\<bar>Re x\<bar> \<le> cmod x

goal (1 subgoal):
 1. \<bar>Re x\<bar> < r
[PROOF STEP]
by argo
[PROOF STATE]
proof (state)
this:
\<bar>Re x\<bar> < r

goal (2 subgoals):
 1. - r < Re x
 2. Re x < r
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<bar>Re x\<bar> < r
[PROOF STEP]
show "-r<Re x" "Re x<r"
[PROOF STATE]
proof (prove)
using this:
\<bar>Re x\<bar> < r

goal (1 subgoal):
 1. - r < Re x &&& Re x < r
[PROOF STEP]
by linarith+
[PROOF STATE]
proof (state)
this:
- r < Re x
Re x < r

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
0 < Im x
- r < Re x
Re x < r
cmod x < r

goal (1 subgoal):
 1. - complex_of_real (cindex_pathE (linepath (- complex_of_real r) (complex_of_real r)) x) - complex_of_real (cindex_pathE (part_circlepath 0 r 0 pi) x) = 2
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 < Im x
- r < Re x
Re x < r
cmod x < r
[PROOF STEP]
have "cindex_pathE ll x = -1"
[PROOF STATE]
proof (prove)
using this:
0 < Im x
- r < Re x
Re x < r
cmod x < r

goal (1 subgoal):
 1. cindex_pathE ll x = - 1
[PROOF STEP]
using \<open>r>0\<close>
[PROOF STATE]
proof (prove)
using this:
0 < Im x
- r < Re x
Re x < r
cmod x < r
0 < r

goal (1 subgoal):
 1. cindex_pathE ll x = - 1
[PROOF STEP]
unfolding cindex_pathE_linepath[OF *] ll_def
[PROOF STATE]
proof (prove)
using this:
0 < Im x
- r < Re x
Re x < r
cmod x < r
0 < r

goal (1 subgoal):
 1. (let c1 = Re (- complex_of_real r) - Re x; c2 = Re (complex_of_real r) - Re x; c3 = Im (- complex_of_real r) * Re (complex_of_real r) + Re x * Im (complex_of_real r) + Im x * Re (- complex_of_real r) - Im x * Re (complex_of_real r) - Im (complex_of_real r) * Re (- complex_of_real r) - Re x * Im (- complex_of_real r); d1 = Im (- complex_of_real r) - Im x; d2 = Im (complex_of_real r) - Im x in if 0 < c1 \<and> c2 < 0 \<or> c1 < 0 \<and> 0 < c2 then if 0 < c3 then 1 else - 1 else if (c1 = 0) = (c2 \<noteq> 0) \<and> (c1 = 0 \<longrightarrow> d1 \<noteq> 0) \<and> (c2 = 0 \<longrightarrow> d2 \<noteq> 0) then if c1 = 0 \<and> (0 < c2) = (0 < d1) \<or> c2 = 0 \<and> (0 < c1) = (d2 < 0) then 1 / 2 else - 1 / 2 else 0) = - 1
[PROOF STEP]
by (auto simp add: mult_less_0_iff)
[PROOF STATE]
proof (state)
this:
cindex_pathE ll x = - 1

goal (1 subgoal):
 1. - complex_of_real (cindex_pathE (linepath (- complex_of_real r) (complex_of_real r)) x) - complex_of_real (cindex_pathE (part_circlepath 0 r 0 pi) x) = 2
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
cindex_pathE ll x = - 1

goal (1 subgoal):
 1. - complex_of_real (cindex_pathE (linepath (- complex_of_real r) (complex_of_real r)) x) - complex_of_real (cindex_pathE (part_circlepath 0 r 0 pi) x) = 2
[PROOF STEP]
have "cindex_pathE rr x=-1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cindex_pathE rr x = - 1
[PROOF STEP]
unfolding rr_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cindex_pathE (part_circlepath 0 r 0 pi) x = - 1
[PROOF STEP]
using r_ball x_asm
[PROOF STATE]
proof (prove)
using this:
proots p \<subseteq> ball 0 r
x \<in> proots_within p {x. 0 < Im x}

goal (1 subgoal):
 1. cindex_pathE (part_circlepath 0 r 0 pi) x = - 1
[PROOF STEP]
by (auto intro!: cindex_pathE_circlepath_upper)
[PROOF STATE]
proof (state)
this:
cindex_pathE rr x = - 1

goal (1 subgoal):
 1. - complex_of_real (cindex_pathE (linepath (- complex_of_real r) (complex_of_real r)) x) - complex_of_real (cindex_pathE (part_circlepath 0 r 0 pi) x) = 2
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
cindex_pathE ll x = - 1
cindex_pathE rr x = - 1
[PROOF STEP]
show "- of_real (cindex_pathE (linepath (- of_real r) (of_real r)) x) -
            of_real (cindex_pathE (part_circlepath 0 r 0 pi) x) = 2"
[PROOF STATE]
proof (prove)
using this:
cindex_pathE ll x = - 1
cindex_pathE rr x = - 1

goal (1 subgoal):
 1. - of_real (cindex_pathE (linepath (- complex_of_real r) (complex_of_real r)) x) - of_real (cindex_pathE (part_circlepath 0 r 0 pi) x) = (2::'a)
[PROOF STEP]
unfolding ll_def rr_def
[PROOF STATE]
proof (prove)
using this:
cindex_pathE (linepath (- complex_of_real r) (complex_of_real r)) x = - 1
cindex_pathE (part_circlepath 0 r 0 pi) x = - 1

goal (1 subgoal):
 1. - of_real (cindex_pathE (linepath (- complex_of_real r) (complex_of_real r)) x) - of_real (cindex_pathE (part_circlepath 0 r 0 pi) x) = (2::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
- of_real (cindex_pathE (linepath (- complex_of_real r) (complex_of_real r)) x) - of_real (cindex_pathE (part_circlepath 0 r 0 pi) x) = (2::?'a1)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
winding_number lr x = 1

goal (1 subgoal):
 1. \<And>x. x \<in> proots_within p {x. 0 < Im x} \<Longrightarrow> of_nat (order x p) = winding_number lr x * of_nat (order x p)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
winding_number lr x = 1
[PROOF STEP]
show "of_nat (order x p) = winding_number lr x * of_nat (order x p)"
[PROOF STATE]
proof (prove)
using this:
winding_number lr x = 1

goal (1 subgoal):
 1. of_nat (order x p) = winding_number lr x * of_nat (order x p)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
of_nat (order x p) = winding_number lr x * of_nat (order x p)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
of_nat (proots_count p {x. 0 < Im x}) = (\<Sum>x\<in>proots p. winding_number lr x * of_nat (order x p))

goal (1 subgoal):
 1. \<And>x. R \<le> x \<Longrightarrow> w1 x + w2 x + cp x / 2 - ci x / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
of_nat (proots_count p {x. 0 < Im x}) = (\<Sum>x\<in>proots p. winding_number lr x * of_nat (order x p))

goal (1 subgoal):
 1. \<And>x. R \<le> x \<Longrightarrow> w1 x + w2 x + cp x / 2 - ci x / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
have "... = 1/(2*pi*\<i>) * contour_integral lr (\<lambda>x. deriv (poly p) x / poly p x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>proots p. winding_number lr x * of_nat (order x p)) = 1 / (complex_of_real (2 * pi) * \<i>) * contour_integral lr (\<lambda>x. deriv (poly p) x / poly p x)
[PROOF STEP]
apply (subst argument_principle_poly[of p lr])
[PROOF STATE]
proof (prove)
goal (5 subgoals):
 1. p \<noteq> 0
 2. valid_path lr
 3. pathfinish lr = pathstart lr
 4. path_image lr \<subseteq> - proots p
 5. (\<Sum>x\<in>proots p. winding_number lr x * of_nat (order x p)) = 1 / (complex_of_real (2 * pi) * \<i>) * (2 * complex_of_real pi * \<i> * (\<Sum>x\<in>proots p. winding_number lr x * of_nat (order x p)))
[PROOF STEP]
using \<open>p\<noteq>0\<close> img_ll img_rr
[PROOF STATE]
proof (prove)
using this:
p \<noteq> 0
path_image ll \<subseteq> - proots p
path_image rr \<subseteq> - proots p

goal (5 subgoals):
 1. p \<noteq> 0
 2. valid_path lr
 3. pathfinish lr = pathstart lr
 4. path_image lr \<subseteq> - proots p
 5. (\<Sum>x\<in>proots p. winding_number lr x * of_nat (order x p)) = 1 / (complex_of_real (2 * pi) * \<i>) * (2 * complex_of_real pi * \<i> * (\<Sum>x\<in>proots p. winding_number lr x * of_nat (order x p)))
[PROOF STEP]
unfolding lr_def ll_def rr_def
[PROOF STATE]
proof (prove)
using this:
p \<noteq> 0
path_image (linepath (- complex_of_real r) (complex_of_real r)) \<subseteq> - proots p
path_image (part_circlepath 0 r 0 pi) \<subseteq> - proots p

goal (5 subgoals):
 1. p \<noteq> 0
 2. valid_path (linepath (- complex_of_real r) (complex_of_real r) +++ part_circlepath 0 r 0 pi)
 3. pathfinish (linepath (- complex_of_real r) (complex_of_real r) +++ part_circlepath 0 r 0 pi) = pathstart (linepath (- complex_of_real r) (complex_of_real r) +++ part_circlepath 0 r 0 pi)
 4. path_image (linepath (- complex_of_real r) (complex_of_real r) +++ part_circlepath 0 r 0 pi) \<subseteq> - proots p
 5. (\<Sum>x\<in>proots p. winding_number (linepath (- complex_of_real r) (complex_of_real r) +++ part_circlepath 0 r 0 pi) x * of_nat (order x p)) = 1 / (complex_of_real (2 * pi) * \<i>) * (2 * complex_of_real pi * \<i> * (\<Sum>x\<in>proots p. winding_number (linepath (- complex_of_real r) (complex_of_real r) +++ part_circlepath 0 r 0 pi) x * of_nat (order x p)))
[PROOF STEP]
by (auto simp add:path_image_join)
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>proots p. winding_number lr x * of_nat (order x p)) = 1 / (complex_of_real (2 * pi) * \<i>) * contour_integral lr (\<lambda>x. deriv (poly p) x / poly p x)

goal (1 subgoal):
 1. \<And>x. R \<le> x \<Longrightarrow> w1 x + w2 x + cp x / 2 - ci x / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>proots p. winding_number lr x * of_nat (order x p)) = 1 / (complex_of_real (2 * pi) * \<i>) * contour_integral lr (\<lambda>x. deriv (poly p) x / poly p x)

goal (1 subgoal):
 1. \<And>x. R \<le> x \<Longrightarrow> w1 x + w2 x + cp x / 2 - ci x / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
have "... = winding_number (poly p \<circ> lr) 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 / (complex_of_real (2 * pi) * \<i>) * contour_integral lr (\<lambda>x. deriv (poly p) x / poly p x) = winding_number (poly p \<circ> lr) 0
[PROOF STEP]
apply (subst winding_number_comp[of UNIV "poly p" lr 0])
[PROOF STATE]
proof (prove)
goal (6 subgoals):
 1. open UNIV
 2. poly p holomorphic_on UNIV
 3. path_image lr \<subseteq> UNIV
 4. valid_path lr
 5. 0 \<notin> path_image (poly p \<circ> lr)
 6. 1 / (complex_of_real (2 * pi) * \<i>) * contour_integral lr (\<lambda>x. deriv (poly p) x / poly p x) = 1 / (complex_of_real (2 * pi) * \<i>) * contour_integral lr (\<lambda>w. deriv (poly p) w / (poly p w - 0))
[PROOF STEP]
using \<open>p\<noteq>0\<close> img_ll img_rr
[PROOF STATE]
proof (prove)
using this:
p \<noteq> 0
path_image ll \<subseteq> - proots p
path_image rr \<subseteq> - proots p

goal (6 subgoals):
 1. open UNIV
 2. poly p holomorphic_on UNIV
 3. path_image lr \<subseteq> UNIV
 4. valid_path lr
 5. 0 \<notin> path_image (poly p \<circ> lr)
 6. 1 / (complex_of_real (2 * pi) * \<i>) * contour_integral lr (\<lambda>x. deriv (poly p) x / poly p x) = 1 / (complex_of_real (2 * pi) * \<i>) * contour_integral lr (\<lambda>w. deriv (poly p) w / (poly p w - 0))
[PROOF STEP]
unfolding lr_def ll_def rr_def
[PROOF STATE]
proof (prove)
using this:
p \<noteq> 0
path_image (linepath (- complex_of_real r) (complex_of_real r)) \<subseteq> - proots p
path_image (part_circlepath 0 r 0 pi) \<subseteq> - proots p

goal (6 subgoals):
 1. open UNIV
 2. poly p holomorphic_on UNIV
 3. path_image (linepath (- complex_of_real r) (complex_of_real r) +++ part_circlepath 0 r 0 pi) \<subseteq> UNIV
 4. valid_path (linepath (- complex_of_real r) (complex_of_real r) +++ part_circlepath 0 r 0 pi)
 5. 0 \<notin> path_image (poly p \<circ> linepath (- complex_of_real r) (complex_of_real r) +++ part_circlepath 0 r 0 pi)
 6. 1 / (complex_of_real (2 * pi) * \<i>) * contour_integral (linepath (- complex_of_real r) (complex_of_real r) +++ part_circlepath 0 r 0 pi) (\<lambda>x. deriv (poly p) x / poly p x) = 1 / (complex_of_real (2 * pi) * \<i>) * contour_integral (linepath (- complex_of_real r) (complex_of_real r) +++ part_circlepath 0 r 0 pi) (\<lambda>w. deriv (poly p) w / (poly p w - 0))
[PROOF STEP]
by (auto simp add:path_image_join path_image_compose)
[PROOF STATE]
proof (state)
this:
1 / (complex_of_real (2 * pi) * \<i>) * contour_integral lr (\<lambda>x. deriv (poly p) x / poly p x) = winding_number (poly p \<circ> lr) 0

goal (1 subgoal):
 1. \<And>x. R \<le> x \<Longrightarrow> w1 x + w2 x + cp x / 2 - ci x / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 / (complex_of_real (2 * pi) * \<i>) * contour_integral lr (\<lambda>x. deriv (poly p) x / poly p x) = winding_number (poly p \<circ> lr) 0

goal (1 subgoal):
 1. \<And>x. R \<le> x \<Longrightarrow> w1 x + w2 x + cp x / 2 - ci x / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
have "... = Re (winding_number (poly p \<circ> lr) 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. winding_number (poly p \<circ> lr) 0 = complex_of_real (Re (winding_number (poly p \<circ> lr) 0))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. winding_number (poly p \<circ> lr) 0 = complex_of_real (Re (winding_number (poly p \<circ> lr) 0))
[PROOF STEP]
have "winding_number (poly p \<circ> lr) 0 \<in> Ints"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. winding_number (poly p \<circ> lr) 0 \<in> \<int>
[PROOF STEP]
apply (rule integer_winding_number)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. path (poly p \<circ> lr)
 2. pathfinish (poly p \<circ> lr) = pathstart (poly p \<circ> lr)
 3. 0 \<notin> path_image (poly p \<circ> lr)
[PROOF STEP]
using \<open>p\<noteq>0\<close> img_ll img_rr
[PROOF STATE]
proof (prove)
using this:
p \<noteq> 0
path_image ll \<subseteq> - proots p
path_image rr \<subseteq> - proots p

goal (3 subgoals):
 1. path (poly p \<circ> lr)
 2. pathfinish (poly p \<circ> lr) = pathstart (poly p \<circ> lr)
 3. 0 \<notin> path_image (poly p \<circ> lr)
[PROOF STEP]
unfolding lr_def
[PROOF STATE]
proof (prove)
using this:
p \<noteq> 0
path_image ll \<subseteq> - proots p
path_image rr \<subseteq> - proots p

goal (3 subgoals):
 1. path (poly p \<circ> ll +++ rr)
 2. pathfinish (poly p \<circ> ll +++ rr) = pathstart (poly p \<circ> ll +++ rr)
 3. 0 \<notin> path_image (poly p \<circ> ll +++ rr)
[PROOF STEP]
by (auto simp add:path_image_join path_image_compose path_compose_join
            pathstart_compose pathfinish_compose valid_path_imp_path)
[PROOF STATE]
proof (state)
this:
winding_number (poly p \<circ> lr) 0 \<in> \<int>

goal (1 subgoal):
 1. winding_number (poly p \<circ> lr) 0 = complex_of_real (Re (winding_number (poly p \<circ> lr) 0))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
winding_number (poly p \<circ> lr) 0 \<in> \<int>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
winding_number (poly p \<circ> lr) 0 \<in> \<int>

goal (1 subgoal):
 1. winding_number (poly p \<circ> lr) 0 = complex_of_real (Re (winding_number (poly p \<circ> lr) 0))
[PROOF STEP]
by (simp add: complex_eqI complex_is_Int_iff)
[PROOF STATE]
proof (state)
this:
winding_number (poly p \<circ> lr) 0 = complex_of_real (Re (winding_number (poly p \<circ> lr) 0))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
winding_number (poly p \<circ> lr) 0 = complex_of_real (Re (winding_number (poly p \<circ> lr) 0))

goal (1 subgoal):
 1. \<And>x. R \<le> x \<Longrightarrow> w1 x + w2 x + cp x / 2 - ci x / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
winding_number (poly p \<circ> lr) 0 = complex_of_real (Re (winding_number (poly p \<circ> lr) 0))

goal (1 subgoal):
 1. \<And>x. R \<le> x \<Longrightarrow> w1 x + w2 x + cp x / 2 - ci x / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
have "... =  Re (winding_number (poly p \<circ> ll) 0) + Re (winding_number (poly p \<circ> rr) 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. complex_of_real (Re (winding_number (poly p \<circ> lr) 0)) = complex_of_real (Re (winding_number (poly p \<circ> ll) 0) + Re (winding_number (poly p \<circ> rr) 0))
[PROOF STEP]
unfolding lr_def path_compose_join
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. complex_of_real (Re (winding_number ((poly p \<circ> ll) +++ (poly p \<circ> rr)) 0)) = complex_of_real (Re (winding_number (poly p \<circ> ll) 0) + Re (winding_number (poly p \<circ> rr) 0))
[PROOF STEP]
using img_ll img_rr
[PROOF STATE]
proof (prove)
using this:
path_image ll \<subseteq> - proots p
path_image rr \<subseteq> - proots p

goal (1 subgoal):
 1. complex_of_real (Re (winding_number ((poly p \<circ> ll) +++ (poly p \<circ> rr)) 0)) = complex_of_real (Re (winding_number (poly p \<circ> ll) 0) + Re (winding_number (poly p \<circ> rr) 0))
[PROOF STEP]
apply (subst winding_number_join)
[PROOF STATE]
proof (prove)
goal (6 subgoals):
 1. \<lbrakk>path_image ll \<subseteq> - proots p; path_image rr \<subseteq> - proots p\<rbrakk> \<Longrightarrow> path (poly p \<circ> ll)
 2. \<lbrakk>path_image ll \<subseteq> - proots p; path_image rr \<subseteq> - proots p\<rbrakk> \<Longrightarrow> 0 \<notin> path_image (poly p \<circ> ll)
 3. \<lbrakk>path_image ll \<subseteq> - proots p; path_image rr \<subseteq> - proots p\<rbrakk> \<Longrightarrow> path (poly p \<circ> rr)
 4. \<lbrakk>path_image ll \<subseteq> - proots p; path_image rr \<subseteq> - proots p\<rbrakk> \<Longrightarrow> 0 \<notin> path_image (poly p \<circ> rr)
 5. \<lbrakk>path_image ll \<subseteq> - proots p; path_image rr \<subseteq> - proots p\<rbrakk> \<Longrightarrow> pathfinish (poly p \<circ> ll) = pathstart (poly p \<circ> rr)
 6. \<lbrakk>path_image ll \<subseteq> - proots p; path_image rr \<subseteq> - proots p\<rbrakk> \<Longrightarrow> complex_of_real (Re (winding_number (poly p \<circ> ll) 0 + winding_number (poly p \<circ> rr) 0)) = complex_of_real (Re (winding_number (poly p \<circ> ll) 0) + Re (winding_number (poly p \<circ> rr) 0))
[PROOF STEP]
by (auto simp add:valid_path_imp_path path_image_compose pathstart_compose pathfinish_compose)
[PROOF STATE]
proof (state)
this:
complex_of_real (Re (winding_number (poly p \<circ> lr) 0)) = complex_of_real (Re (winding_number (poly p \<circ> ll) 0) + Re (winding_number (poly p \<circ> rr) 0))

goal (1 subgoal):
 1. \<And>x. R \<le> x \<Longrightarrow> w1 x + w2 x + cp x / 2 - ci x / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
complex_of_real (Re (winding_number (poly p \<circ> lr) 0)) = complex_of_real (Re (winding_number (poly p \<circ> ll) 0) + Re (winding_number (poly p \<circ> rr) 0))

goal (1 subgoal):
 1. \<And>x. R \<le> x \<Longrightarrow> w1 x + w2 x + cp x / 2 - ci x / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
have "... = w1 r  +w2 r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. complex_of_real (Re (winding_number (poly p \<circ> ll) 0) + Re (winding_number (poly p \<circ> rr) 0)) = complex_of_real (w1 r + w2 r)
[PROOF STEP]
unfolding w1_def w2_def ll_def rr_def of_real_linepath
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. complex_of_real (Re (winding_number (poly p \<circ> linepath (- complex_of_real r) (complex_of_real r)) 0) + Re (winding_number (poly p \<circ> part_circlepath 0 r 0 pi) 0)) = complex_of_real (Re (winding_number (poly p \<circ> linepath (complex_of_real (- r)) (complex_of_real (of_real r))) 0) + Re (winding_number (poly p \<circ> part_circlepath 0 r 0 pi) 0))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
complex_of_real (Re (winding_number (poly p \<circ> ll) 0) + Re (winding_number (poly p \<circ> rr) 0)) = complex_of_real (w1 r + w2 r)

goal (1 subgoal):
 1. \<And>x. R \<le> x \<Longrightarrow> w1 x + w2 x + cp x / 2 - ci x / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
of_nat (proots_count p {x. 0 < Im x}) = complex_of_real (w1 r + w2 r)
[PROOF STEP]
have "of_nat (proots_count p {x. 0 < Im x}) = complex_of_real (w1 r + w2 r)"
[PROOF STATE]
proof (prove)
using this:
of_nat (proots_count p {x. 0 < Im x}) = complex_of_real (w1 r + w2 r)

goal (1 subgoal):
 1. of_nat (proots_count p {x. 0 < Im x}) = complex_of_real (w1 r + w2 r)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
of_nat (proots_count p {x. 0 < Im x}) = complex_of_real (w1 r + w2 r)

goal (1 subgoal):
 1. \<And>x. R \<le> x \<Longrightarrow> w1 x + w2 x + cp x / 2 - ci x / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
of_nat (proots_count p {x. 0 < Im x}) = complex_of_real (w1 r + w2 r)
[PROOF STEP]
have "proots_count p {x. 0 < Im x} = w1 r + w2 r"
[PROOF STATE]
proof (prove)
using this:
of_nat (proots_count p {x. 0 < Im x}) = complex_of_real (w1 r + w2 r)

goal (1 subgoal):
 1. real (proots_count p {x. 0 < Im x}) = w1 r + w2 r
[PROOF STEP]
using of_real_eq_iff
[PROOF STATE]
proof (prove)
using this:
of_nat (proots_count p {x. 0 < Im x}) = complex_of_real (w1 r + w2 r)
(of_real ?x = of_real ?y) = (?x = ?y)

goal (1 subgoal):
 1. real (proots_count p {x. 0 < Im x}) = w1 r + w2 r
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
real (proots_count p {x. 0 < Im x}) = w1 r + w2 r

goal (1 subgoal):
 1. \<And>x. R \<le> x \<Longrightarrow> w1 x + w2 x + cp x / 2 - ci x / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
real (proots_count p {x. 0 < Im x}) = w1 r + w2 r

goal (1 subgoal):
 1. \<And>x. R \<le> x \<Longrightarrow> w1 x + w2 x + cp x / 2 - ci x / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
have "cp r = ci r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cp r = ci r
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. cp r = ci r
[PROOF STEP]
define f where "f=(\<lambda>x. Im (poly p (of_real x)) / Re (poly p x))"
[PROOF STATE]
proof (state)
this:
f = (\<lambda>x. Im (poly p (complex_of_real x)) / Re (poly p (complex_of_real x)))

goal (1 subgoal):
 1. cp r = ci r
[PROOF STEP]
have "cp r = cindex_pathE (poly p \<circ> (\<lambda>x. 2*r*x - r)) 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cp r = cindex_pathE (poly p \<circ> (\<lambda>x. complex_of_real (2 * r * x - r))) 0
[PROOF STEP]
unfolding cp_def linepath_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cindex_pathE (poly p \<circ> (\<lambda>x. complex_of_real ((1 - x) *\<^sub>R - r + x *\<^sub>R of_real r))) 0 = cindex_pathE (poly p \<circ> (\<lambda>x. complex_of_real (2 * r * x - r))) 0
[PROOF STEP]
by (auto simp add:algebra_simps)
[PROOF STATE]
proof (state)
this:
cp r = cindex_pathE (poly p \<circ> (\<lambda>x. complex_of_real (2 * r * x - r))) 0

goal (1 subgoal):
 1. cp r = ci r
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
cp r = cindex_pathE (poly p \<circ> (\<lambda>x. complex_of_real (2 * r * x - r))) 0

goal (1 subgoal):
 1. cp r = ci r
[PROOF STEP]
have "... = cindexE 0 1 (f o (\<lambda>x. 2*r*x - r))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cindex_pathE (poly p \<circ> (\<lambda>x. complex_of_real (2 * r * x - r))) 0 = cindexE 0 1 (f \<circ> (\<lambda>x. 2 * r * x - r))
[PROOF STEP]
unfolding cp_def ci_def cindex_pathE_def f_def comp_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cindexE 0 1 (\<lambda>t. Im (poly p (complex_of_real (2 * r * t - r)) - 0) / Re (poly p (complex_of_real (2 * r * t - r)) - 0)) = cindexE 0 1 (\<lambda>x. Im (poly p (complex_of_real (2 * r * x - r))) / Re (poly p (complex_of_real (2 * r * x - r))))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
cindex_pathE (poly p \<circ> (\<lambda>x. complex_of_real (2 * r * x - r))) 0 = cindexE 0 1 (f \<circ> (\<lambda>x. 2 * r * x - r))

goal (1 subgoal):
 1. cp r = ci r
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
cindex_pathE (poly p \<circ> (\<lambda>x. complex_of_real (2 * r * x - r))) 0 = cindexE 0 1 (f \<circ> (\<lambda>x. 2 * r * x - r))

goal (1 subgoal):
 1. cp r = ci r
[PROOF STEP]
have "... = cindexE (-r) r f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cindexE 0 1 (f \<circ> (\<lambda>x. 2 * r * x - r)) = cindexE (- r) r f
[PROOF STEP]
apply (subst cindexE_linear_comp[of "2*r" 0 1 f "-r",simplified])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. r \<noteq> 0
 2. (if 0 < r then cindexE (2 * r * 0 + - r) (2 * r * 1 + - r) f else - cindexE (2 * r * 1 + - r) (2 * r * 0 + - r) f) = cindexE (- r) r f
[PROOF STEP]
using \<open>r>0\<close>
[PROOF STATE]
proof (prove)
using this:
0 < r

goal (2 subgoals):
 1. r \<noteq> 0
 2. (if 0 < r then cindexE (2 * r * 0 + - r) (2 * r * 1 + - r) f else - cindexE (2 * r * 1 + - r) (2 * r * 0 + - r) f) = cindexE (- r) r f
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
cindexE 0 1 (f \<circ> (\<lambda>x. 2 * r * x - r)) = cindexE (- r) r f

goal (1 subgoal):
 1. cp r = ci r
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
cindexE 0 1 (f \<circ> (\<lambda>x. 2 * r * x - r)) = cindexE (- r) r f

goal (1 subgoal):
 1. cp r = ci r
[PROOF STEP]
have "... = ci r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cindexE (- r) r f = ci r
[PROOF STEP]
unfolding ci_def f_def Im_poly_of_real Re_poly_of_real
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cindexE (- r) r (\<lambda>x. poly (map_poly Im p) x / poly (map_poly Re p) x) = cindexE (- r) r (\<lambda>x. poly (map_poly Im p) x / poly (map_poly Re p) x)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
cindexE (- r) r f = ci r

goal (1 subgoal):
 1. cp r = ci r
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
cp r = ci r
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
cp r = ci r

goal (1 subgoal):
 1. cp r = ci r
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
cp r = ci r

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
cp r = ci r

goal (1 subgoal):
 1. \<And>x. R \<le> x \<Longrightarrow> w1 x + w2 x + cp x / 2 - ci x / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
real (proots_count p {x. 0 < Im x}) = w1 r + w2 r
cp r = ci r
[PROOF STEP]
show "w1 r + w2 r + cp r / 2 - ci r / 2 = real (proots_count p {x. 0 < Im x})"
[PROOF STATE]
proof (prove)
using this:
real (proots_count p {x. 0 < Im x}) = w1 r + w2 r
cp r = ci r

goal (1 subgoal):
 1. w1 r + w2 r + cp r / 2 - ci r / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
w1 r + w2 r + cp r / 2 - ci r / 2 = real (proots_count p {x. 0 < Im x})

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F r in at_top. w1 r + w2 r + cp r / 2 - ci r / 2 = real (proots_count p {x. 0 < Im x})

goal (1 subgoal):
 1. degree p \<noteq> 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
((\<lambda>r. w1 r + w2 r + cp r / 2 - ci r / 2) \<longlongrightarrow> real (degree p) / 2 - real_of_int cubd / 2) at_top
\<forall>\<^sub>F r in at_top. w1 r + w2 r + cp r / 2 - ci r / 2 = real (proots_count p {x. 0 < Im x})
[PROOF STEP]
have "((\<lambda>r::real. real (proots_count p {x. 0 < Im x}))
      \<longlongrightarrow> real (degree p) / 2 - of_int cubd / 2) at_top"
[PROOF STATE]
proof (prove)
using this:
((\<lambda>r. w1 r + w2 r + cp r / 2 - ci r / 2) \<longlongrightarrow> real (degree p) / 2 - real_of_int cubd / 2) at_top
\<forall>\<^sub>F r in at_top. w1 r + w2 r + cp r / 2 - ci r / 2 = real (proots_count p {x. 0 < Im x})

goal (1 subgoal):
 1. ((\<lambda>r. real (proots_count p {x. 0 < Im x})) \<longlongrightarrow> real (degree p) / 2 - real_of_int cubd / 2) at_top
[PROOF STEP]
by (auto dest: tendsto_cong)
[PROOF STATE]
proof (state)
this:
((\<lambda>r. real (proots_count p {x. 0 < Im x})) \<longlongrightarrow> real (degree p) / 2 - real_of_int cubd / 2) at_top

goal (1 subgoal):
 1. degree p \<noteq> 0 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
((\<lambda>r. real (proots_count p {x. 0 < Im x})) \<longlongrightarrow> real (degree p) / 2 - real_of_int cubd / 2) at_top
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
((\<lambda>r. real (proots_count p {x. 0 < Im x})) \<longlongrightarrow> real (degree p) / 2 - real_of_int cubd / 2) at_top

goal (1 subgoal):
 1. real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
apply (subst (asm) tendsto_const_iff)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. at_top \<noteq> bot
 2. real (proots_count p {x. 0 < Im x}) = real (degree p) / 2 - real_of_int cubd / 2 \<Longrightarrow> real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
unfolding cubd_def proots_upper_def
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. at_top \<noteq> bot
 2. real (proots_count p {x. 0 < Im x}) = real (degree p) / 2 - real_of_int (cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2 \<Longrightarrow> real (proots_count p {z. 0 < Im z}) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
real (proots_upper p) = real_of_int (int (degree p) - cindex_poly_ubd (map_poly Im p) (map_poly Re p)) / 2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma efficient_code_aux:
  assumes "n > 0" "set ps = (\<lambda>p. (p, multiplicity p n - 1)) ` prime_factors n" "distinct ps"
  shows   "f n = (\<Prod>(p,d) \<leftarrow> ps. f_prime_power p (Suc d))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f n = (\<Prod>(p, d)\<leftarrow>ps. f_prime_power p (Suc d))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. f n = (\<Prod>(p, d)\<leftarrow>ps. f_prime_power p (Suc d))
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
0 < n
set ps = (\<lambda>p. (p, multiplicity p n - 1)) ` prime_factors n
distinct ps
[PROOF STEP]
have
    "(\<Prod>(p,d) \<leftarrow> ps. f_prime_power p (Suc d)) =
       (\<Prod>(p,d)\<in>(\<lambda>p. (p, multiplicity p n - 1)) ` prime_factors n. f_prime_power p (Suc d))"
[PROOF STATE]
proof (prove)
using this:
0 < n
set ps = (\<lambda>p. (p, multiplicity p n - 1)) ` prime_factors n
distinct ps

goal (1 subgoal):
 1. (\<Prod>(p, d)\<leftarrow>ps. f_prime_power p (Suc d)) = (\<Prod>(p, d)\<in>(\<lambda>p. (p, multiplicity p n - 1)) ` prime_factors n. f_prime_power p (Suc d))
[PROOF STEP]
by (subst prod.distinct_set_conv_list [symmetric]) simp_all
[PROOF STATE]
proof (state)
this:
(\<Prod>(p, d)\<leftarrow>ps. f_prime_power p (Suc d)) = (\<Prod>(p, d)\<in>(\<lambda>p. (p, multiplicity p n - 1)) ` prime_factors n. f_prime_power p (Suc d))

goal (1 subgoal):
 1. f n = (\<Prod>(p, d)\<leftarrow>ps. f_prime_power p (Suc d))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Prod>(p, d)\<leftarrow>ps. f_prime_power p (Suc d)) = (\<Prod>(p, d)\<in>(\<lambda>p. (p, multiplicity p n - 1)) ` prime_factors n. f_prime_power p (Suc d))

goal (1 subgoal):
 1. f n = (\<Prod>(p, d)\<leftarrow>ps. f_prime_power p (Suc d))
[PROOF STEP]
have "\<dots> = (\<Prod>x\<in>prime_factors n. f_prime_power x (multiplicity x n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>(p, d)\<in>(\<lambda>p. (p, multiplicity p n - 1)) ` prime_factors n. f_prime_power p (Suc d)) = (\<Prod>x\<in>prime_factors n. f_prime_power x (multiplicity x n))
[PROOF STEP]
by (subst prod.reindex) (auto simp: inj_on_def prime_factors_multiplicity intro!: prod.cong)
[PROOF STATE]
proof (state)
this:
(\<Prod>(p, d)\<in>(\<lambda>p. (p, multiplicity p n - 1)) ` prime_factors n. f_prime_power p (Suc d)) = (\<Prod>x\<in>prime_factors n. f_prime_power x (multiplicity x n))

goal (1 subgoal):
 1. f n = (\<Prod>(p, d)\<leftarrow>ps. f_prime_power p (Suc d))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Prod>(p, d)\<in>(\<lambda>p. (p, multiplicity p n - 1)) ` prime_factors n. f_prime_power p (Suc d)) = (\<Prod>x\<in>prime_factors n. f_prime_power x (multiplicity x n))

goal (1 subgoal):
 1. f n = (\<Prod>(p, d)\<leftarrow>ps. f_prime_power p (Suc d))
[PROOF STEP]
have "\<dots> = f n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>x\<in>prime_factors n. f_prime_power x (multiplicity x n)) = f n
[PROOF STEP]
by (rule prod_prime_factors' [symmetric]) fact+
[PROOF STATE]
proof (state)
this:
(\<Prod>x\<in>prime_factors n. f_prime_power x (multiplicity x n)) = f n

goal (1 subgoal):
 1. f n = (\<Prod>(p, d)\<leftarrow>ps. f_prime_power p (Suc d))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Prod>(p, d)\<leftarrow>ps. f_prime_power p (Suc d)) = f n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Prod>(p, d)\<leftarrow>ps. f_prime_power p (Suc d)) = f n

goal (1 subgoal):
 1. f n = (\<Prod>(p, d)\<leftarrow>ps. f_prime_power p (Suc d))
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
f n = (\<Prod>(p, d)\<leftarrow>ps. f_prime_power p (Suc d))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma LessThan_bounded_induct:
     "!!l::nat. \<forall>m \<in> greaterThan l.
                   F \<in> (A \<inter> f-`{m}) LeadsTo ((A \<inter> f-`(lessThan m)) \<union> B)
            ==> F \<in> A LeadsTo ((A \<inter> (f-`(atMost l))) \<union> B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>l. \<forall>m\<in>{l<..}. F \<in> A \<inter> f -` {m} \<longmapsto>w A \<inter> f -` {..<m} \<union> B \<Longrightarrow> F \<in> A \<longmapsto>w A \<inter> f -` {..l} \<union> B
[PROOF STEP]
apply (simp only: Diff_eq [symmetric] vimage_Compl
                  Compl_greaterThan [symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>l. \<forall>m\<in>{l<..}. F \<in> A \<inter> f -` {m} \<longmapsto>w A \<inter> f -` {..<m} \<union> B \<Longrightarrow> F \<in> A \<longmapsto>w A - f -` {l<..} \<union> B
[PROOF STEP]
apply (rule wf_less_than [THEN Bounded_induct], simp)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma nat_of_natural_min [simp]:
  "nat_of_natural (min k l) = min (nat_of_natural k) (nat_of_natural l)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nat_of_natural (min k l) = min (nat_of_natural k) (nat_of_natural l)
[PROOF STEP]
by transfer rule


[STATEMENT]
lemma lessThan_subset_Collect: "{..<x} \<subseteq> Collect P \<longleftrightarrow> (\<forall>y<x. P y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ({..<x} \<subseteq> Collect P) = (\<forall>y<x. P y)
[PROOF STEP]
by(auto simp add: lessThan_def)


[STATEMENT]
lemma Borsuk_maps_homotopic_in_connected_component_eq:
  fixes a :: "'a :: euclidean_space"
  assumes S: "compact S" "a \<notin> S" "b \<notin> S" and 2: "2 \<le> DIM('a)"
    shows "(homotopic_with_canon (\<lambda>x. True) S (sphere 0 1)
                   (\<lambda>x. (x - a) /\<^sub>R norm (x - a))
                   (\<lambda>x. (x - b) /\<^sub>R norm (x - b)) \<longleftrightarrow>
           connected_component (- S) a b)"
         (is "?lhs = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. homotopic_with_canon (\<lambda>x. True) S (sphere (0::'a) 1) (\<lambda>x. (x - a) /\<^sub>R norm (x - a)) (\<lambda>x. (x - b) /\<^sub>R norm (x - b)) = connected_component (- S) a b
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. homotopic_with_canon (\<lambda>x. True) S (sphere (0::'a) 1) (\<lambda>x. (x - a) /\<^sub>R norm (x - a)) (\<lambda>x. (x - b) /\<^sub>R norm (x - b)) \<Longrightarrow> connected_component (- S) a b
 2. connected_component (- S) a b \<Longrightarrow> homotopic_with_canon (\<lambda>x. True) S (sphere (0::'a) 1) (\<lambda>x. (x - a) /\<^sub>R norm (x - a)) (\<lambda>x. (x - b) /\<^sub>R norm (x - b))
[PROOF STEP]
assume L: ?lhs
[PROOF STATE]
proof (state)
this:
homotopic_with_canon (\<lambda>x. True) S (sphere (0::'a) 1) (\<lambda>x. (x - a) /\<^sub>R norm (x - a)) (\<lambda>x. (x - b) /\<^sub>R norm (x - b))

goal (2 subgoals):
 1. homotopic_with_canon (\<lambda>x. True) S (sphere (0::'a) 1) (\<lambda>x. (x - a) /\<^sub>R norm (x - a)) (\<lambda>x. (x - b) /\<^sub>R norm (x - b)) \<Longrightarrow> connected_component (- S) a b
 2. connected_component (- S) a b \<Longrightarrow> homotopic_with_canon (\<lambda>x. True) S (sphere (0::'a) 1) (\<lambda>x. (x - a) /\<^sub>R norm (x - a)) (\<lambda>x. (x - b) /\<^sub>R norm (x - b))
[PROOF STEP]
show ?rhs
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. connected_component (- S) a b
[PROOF STEP]
proof (cases "bounded(connected_component_set (- S) a)")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. bounded (connected_component_set (- S) a) \<Longrightarrow> connected_component (- S) a b
 2. \<not> bounded (connected_component_set (- S) a) \<Longrightarrow> connected_component (- S) a b
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
bounded (connected_component_set (- S) a)

goal (2 subgoals):
 1. bounded (connected_component_set (- S) a) \<Longrightarrow> connected_component (- S) a b
 2. \<not> bounded (connected_component_set (- S) a) \<Longrightarrow> connected_component (- S) a b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. connected_component (- S) a b
[PROOF STEP]
by (rule homotopic_Borsuk_maps_in_bounded_component [OF S True L])
[PROOF STATE]
proof (state)
this:
connected_component (- S) a b

goal (1 subgoal):
 1. \<not> bounded (connected_component_set (- S) a) \<Longrightarrow> connected_component (- S) a b
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> bounded (connected_component_set (- S) a) \<Longrightarrow> connected_component (- S) a b
[PROOF STEP]
case not_bo_a: False
[PROOF STATE]
proof (state)
this:
\<not> bounded (connected_component_set (- S) a)

goal (1 subgoal):
 1. \<not> bounded (connected_component_set (- S) a) \<Longrightarrow> connected_component (- S) a b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. connected_component (- S) a b
[PROOF STEP]
proof (cases "bounded(connected_component_set (- S) b)")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. bounded (connected_component_set (- S) b) \<Longrightarrow> connected_component (- S) a b
 2. \<not> bounded (connected_component_set (- S) b) \<Longrightarrow> connected_component (- S) a b
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
bounded (connected_component_set (- S) b)

goal (2 subgoals):
 1. bounded (connected_component_set (- S) b) \<Longrightarrow> connected_component (- S) a b
 2. \<not> bounded (connected_component_set (- S) b) \<Longrightarrow> connected_component (- S) a b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. connected_component (- S) a b
[PROOF STEP]
using homotopic_Borsuk_maps_in_bounded_component [OF S]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>bounded (connected_component_set (- S) a); homotopic_with_canon (\<lambda>x. True) S (sphere (0::'a) 1) (\<lambda>x. (x - a) /\<^sub>R norm (x - a)) (\<lambda>x. (x - b) /\<^sub>R norm (x - b))\<rbrakk> \<Longrightarrow> connected_component (- S) a b

goal (1 subgoal):
 1. connected_component (- S) a b
[PROOF STEP]
by (simp add: L True assms connected_component_sym homotopic_Borsuk_maps_in_bounded_component homotopic_with_sym)
[PROOF STATE]
proof (state)
this:
connected_component (- S) a b

goal (1 subgoal):
 1. \<not> bounded (connected_component_set (- S) b) \<Longrightarrow> connected_component (- S) a b
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> bounded (connected_component_set (- S) b) \<Longrightarrow> connected_component (- S) a b
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> bounded (connected_component_set (- S) b)

goal (1 subgoal):
 1. \<not> bounded (connected_component_set (- S) b) \<Longrightarrow> connected_component (- S) a b
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> bounded (connected_component_set (- S) b)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> bounded (connected_component_set (- S) b)

goal (1 subgoal):
 1. connected_component (- S) a b
[PROOF STEP]
using cobounded_unique_unbounded_component [of "-S" a b] \<open>compact S\<close> not_bo_a
[PROOF STATE]
proof (prove)
using this:
\<not> bounded (connected_component_set (- S) b)
\<lbrakk>bounded (- (- S)); 2 \<le> DIM('a); \<not> bounded (connected_component_set (- S) a); \<not> bounded (connected_component_set (- S) b)\<rbrakk> \<Longrightarrow> connected_component_set (- S) a = connected_component_set (- S) b
compact S
\<not> bounded (connected_component_set (- S) a)

goal (1 subgoal):
 1. connected_component (- S) a b
[PROOF STEP]
by (auto simp: compact_eq_bounded_closed assms connected_component_eq_eq)
[PROOF STATE]
proof (state)
this:
connected_component (- S) a b

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
connected_component (- S) a b

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
connected_component (- S) a b

goal (1 subgoal):
 1. connected_component (- S) a b \<Longrightarrow> homotopic_with_canon (\<lambda>x. True) S (sphere (0::'a) 1) (\<lambda>x. (x - a) /\<^sub>R norm (x - a)) (\<lambda>x. (x - b) /\<^sub>R norm (x - b))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. connected_component (- S) a b \<Longrightarrow> homotopic_with_canon (\<lambda>x. True) S (sphere (0::'a) 1) (\<lambda>x. (x - a) /\<^sub>R norm (x - a)) (\<lambda>x. (x - b) /\<^sub>R norm (x - b))
[PROOF STEP]
assume R: ?rhs
[PROOF STATE]
proof (state)
this:
connected_component (- S) a b

goal (1 subgoal):
 1. connected_component (- S) a b \<Longrightarrow> homotopic_with_canon (\<lambda>x. True) S (sphere (0::'a) 1) (\<lambda>x. (x - a) /\<^sub>R norm (x - a)) (\<lambda>x. (x - b) /\<^sub>R norm (x - b))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
connected_component (- S) a b
[PROOF STEP]
have "path_component (- S) a b"
[PROOF STATE]
proof (prove)
using this:
connected_component (- S) a b

goal (1 subgoal):
 1. path_component (- S) a b
[PROOF STEP]
using assms(1) compact_eq_bounded_closed open_Compl open_path_connected_component_set
[PROOF STATE]
proof (prove)
using this:
connected_component (- S) a b
compact S
compact ?S = (bounded ?S \<and> closed ?S)
closed ?S \<Longrightarrow> open (- ?S)
open ?S \<Longrightarrow> path_component_set ?S ?x = connected_component_set ?S ?x

goal (1 subgoal):
 1. path_component (- S) a b
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
path_component (- S) a b

goal (1 subgoal):
 1. connected_component (- S) a b \<Longrightarrow> homotopic_with_canon (\<lambda>x. True) S (sphere (0::'a) 1) (\<lambda>x. (x - a) /\<^sub>R norm (x - a)) (\<lambda>x. (x - b) /\<^sub>R norm (x - b))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
path_component (- S) a b
[PROOF STEP]
show ?lhs
[PROOF STATE]
proof (prove)
using this:
path_component (- S) a b

goal (1 subgoal):
 1. homotopic_with_canon (\<lambda>x. True) S (sphere (0::'a) 1) (\<lambda>x. (x - a) /\<^sub>R norm (x - a)) (\<lambda>x. (x - b) /\<^sub>R norm (x - b))
[PROOF STEP]
by (simp add: Borsuk_maps_homotopic_in_path_component)
[PROOF STATE]
proof (state)
this:
homotopic_with_canon (\<lambda>x. True) S (sphere (0::'a) 1) (\<lambda>x. (x - a) /\<^sub>R norm (x - a)) (\<lambda>x. (x - b) /\<^sub>R norm (x - b))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Qp_res_mult:
  assumes "x \<in> \<O>\<^sub>p"
  assumes "y \<in> \<O>\<^sub>p"
  shows "Qp_res (x \<otimes> y) n = Qp_res x n \<otimes>\<^bsub>Zp_res_ring n\<^esub> Qp_res y n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Qp_res (x \<otimes> y) n = Qp_res x n \<otimes>\<^bsub>residue_ring (p ^ n)\<^esub> Qp_res y n
[PROOF STEP]
unfolding Qp_res_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. to_Zp (x \<otimes> y) n = to_Zp x n \<otimes>\<^bsub>residue_ring (p ^ n)\<^esub> to_Zp y n
[PROOF STEP]
using assms residue_of_prod to_Zp_mult
[PROOF STATE]
proof (prove)
using this:
x \<in> \<O>\<^sub>p
y \<in> \<O>\<^sub>p
(?a \<otimes>\<^bsub>Z\<^sub>p\<^esub> ?b) ?k = ?a ?k \<otimes>\<^bsub>residue_ring (p ^ ?k)\<^esub> ?b ?k
\<lbrakk>?a \<in> \<O>\<^sub>p; ?b \<in> \<O>\<^sub>p\<rbrakk> \<Longrightarrow> to_Zp (?a \<otimes> ?b) = to_Zp ?a \<otimes>\<^bsub>Z\<^sub>p\<^esub> to_Zp ?b

goal (1 subgoal):
 1. to_Zp (x \<otimes> y) n = to_Zp x n \<otimes>\<^bsub>residue_ring (p ^ n)\<^esub> to_Zp y n
[PROOF STEP]
by presburger


[STATEMENT]
lemma "ad = 1/(c-1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ad = 1 / (c - 1)
[PROOF STEP]
unfolding ad_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f2 / (e * c) / (f2 / e - f2 / (e * c)) = 1 / (c - 1)
[PROOF STEP]
by(simp add: field_simps)


[STATEMENT]
lemma unat_add_lem:
  "unat x + unat y < 2 ^ LENGTH('a) \<longleftrightarrow> unat (x + y) = unat x + unat y"
  for x y :: "'a::len word"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (unat x + unat y < 2 ^ LENGTH('a)) = (unat (x + y) = unat x + unat y)
[PROOF STEP]
by (metis mod_less unat_word_ariths(1) unsigned_less)


[STATEMENT]
lemma mpoly_to_mpoly_poly_add [simp]:
  "mpoly_to_mpoly_poly x (p + q) = mpoly_to_mpoly_poly x p + mpoly_to_mpoly_poly x q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mpoly_to_mpoly_poly x (p + q) = mpoly_to_mpoly_poly x p + mpoly_to_mpoly_poly x q
[PROOF STEP]
unfolding mpoly_to_mpoly_poly_def  More_MPoly_Type.coeff_add[symmetric]  MPoly_Type.monom_add add_monom[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m. Polynomial.monom (MPoly_Type.monom (remove_key x m) (MPoly_Type.coeff p m)) (lookup m x) + Polynomial.monom (MPoly_Type.monom (remove_key x m) (MPoly_Type.coeff q m)) (lookup m x)) = (\<Sum>m. Polynomial.monom (MPoly_Type.monom (remove_key x m) (MPoly_Type.coeff p m)) (lookup m x)) + (\<Sum>m. Polynomial.monom (MPoly_Type.monom (remove_key x m) (MPoly_Type.coeff q m)) (lookup m x))
[PROOF STEP]
by (rule Sum_any.distrib) auto