[STATEMENT]
lemma monic_irreducible_factorization: fixes p :: "'a :: field poly"
  shows "monic p \<Longrightarrow>
  \<exists> as f. finite as \<and> p = prod (\<lambda> a. a ^ Suc (f a)) as \<and> as \<subseteq> {q. irreducible q \<and> monic q}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. monic p \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
proof (induct "degree p" arbitrary: p rule: less_induct)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>p. \<lbrakk>\<And>pa. \<lbrakk>degree pa < degree p; monic pa\<rbrakk> \<Longrightarrow> \<exists>as f. finite as \<and> pa = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}; monic p\<rbrakk> \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
case (less p)
[PROOF STATE]
proof (state)
this:
\<lbrakk>degree ?p < degree p; monic ?p\<rbrakk> \<Longrightarrow> \<exists>as f. finite as \<and> ?p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
monic p

goal (1 subgoal):
 1. \<And>p. \<lbrakk>\<And>pa. \<lbrakk>degree pa < degree p; monic pa\<rbrakk> \<Longrightarrow> \<exists>as f. finite as \<and> pa = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}; monic p\<rbrakk> \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
proof (cases "degree p > 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 < degree p \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
 2. \<not> 0 < degree p \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> 0 < degree p

goal (2 subgoals):
 1. 0 < degree p \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
 2. \<not> 0 < degree p \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
with less(2)
[PROOF STATE]
proof (chain)
picking this:
monic p
\<not> 0 < degree p
[PROOF STEP]
have "p = 1"
[PROOF STATE]
proof (prove)
using this:
monic p
\<not> 0 < degree p

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

goal (2 subgoals):
 1. 0 < degree p \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
 2. \<not> 0 < degree p \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
p = 1

goal (1 subgoal):
 1. \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
by (intro exI[of _ "{}"], auto)
[PROOF STATE]
proof (state)
this:
\<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}

goal (1 subgoal):
 1. 0 < degree p \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 0 < degree p \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
0 < degree p

goal (1 subgoal):
 1. 0 < degree p \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
from irreducible\<^sub>d_factor[OF this]
[PROOF STATE]
proof (chain)
picking this:
\<exists>q r. irreducible\<^sub>d q \<and> p = q * r \<and> degree r < degree p
[PROOF STEP]
obtain q r where p: "p = q * r"
      and q: "irreducible q" and deg: "degree r < degree p"
[PROOF STATE]
proof (prove)
using this:
\<exists>q r. irreducible\<^sub>d q \<and> p = q * r \<and> degree r < degree p

goal (1 subgoal):
 1. (\<And>q r. \<lbrakk>p = q * r; irreducible q; degree r < degree p\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
p = q * r
irreducible q
degree r < degree p

goal (1 subgoal):
 1. 0 < degree p \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
hence q0: "q \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
p = q * r
irreducible q
degree r < degree p

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

goal (1 subgoal):
 1. 0 < degree p \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
define c where "c = coeff q (degree q)"
[PROOF STATE]
proof (state)
this:
c = lead_coeff q

goal (1 subgoal):
 1. 0 < degree p \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
let ?q = "smult (1/c) q"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 0 < degree p \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
let ?r = "smult c r"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 0 < degree p \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
from q0
[PROOF STATE]
proof (chain)
picking this:
q \<noteq> 0
[PROOF STEP]
have c: "c \<noteq> 0" "1 / c \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
q \<noteq> 0

goal (1 subgoal):
 1. c \<noteq> (0::'a) &&& (1::'a) / c \<noteq> (0::'a)
[PROOF STEP]
unfolding c_def
[PROOF STATE]
proof (prove)
using this:
q \<noteq> 0

goal (1 subgoal):
 1. lead_coeff q \<noteq> (0::'a) &&& (1::'a) / lead_coeff q \<noteq> (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
c \<noteq> (0::'a)
(1::'a) / c \<noteq> (0::'a)

goal (1 subgoal):
 1. 0 < degree p \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
hence p: "p = ?q * ?r"
[PROOF STATE]
proof (prove)
using this:
c \<noteq> (0::'a)
(1::'a) / c \<noteq> (0::'a)

goal (1 subgoal):
 1. p = smult ((1::'a) / c) q * smult c r
[PROOF STEP]
unfolding p
[PROOF STATE]
proof (prove)
using this:
c \<noteq> (0::'a)
(1::'a) / c \<noteq> (0::'a)

goal (1 subgoal):
 1. q * r = smult ((1::'a) / c) q * smult c r
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
p = smult ((1::'a) / c) q * smult c r

goal (1 subgoal):
 1. 0 < degree p \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
have deg: "degree ?r < degree p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. degree (smult c r) < degree p
[PROOF STEP]
using c deg
[PROOF STATE]
proof (prove)
using this:
c \<noteq> (0::'a)
(1::'a) / c \<noteq> (0::'a)
degree r < degree p

goal (1 subgoal):
 1. degree (smult c r) < degree p
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
degree (smult c r) < degree p

goal (1 subgoal):
 1. 0 < degree p \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
let ?Q = "{q. irreducible q \<and> monic (q :: 'a poly)}"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 0 < degree p \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
have mon: "monic ?q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. monic (smult ((1::'a) / c) q)
[PROOF STEP]
unfolding c_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. monic (smult ((1::'a) / lead_coeff q) q)
[PROOF STEP]
using q0
[PROOF STATE]
proof (prove)
using this:
q \<noteq> 0

goal (1 subgoal):
 1. monic (smult ((1::'a) / lead_coeff q) q)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
monic (smult ((1::'a) / c) q)

goal (1 subgoal):
 1. 0 < degree p \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
from monic_factor[OF \<open>monic p\<close>[unfolded p] this]
[PROOF STATE]
proof (chain)
picking this:
monic (smult c r)
[PROOF STEP]
have "monic ?r"
[PROOF STATE]
proof (prove)
using this:
monic (smult c r)

goal (1 subgoal):
 1. monic (smult c r)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
monic (smult c r)

goal (1 subgoal):
 1. 0 < degree p \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
from less(1)[OF deg this]
[PROOF STATE]
proof (chain)
picking this:
\<exists>as f. finite as \<and> smult c r = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
obtain f as
      where as: "finite as" "?r = (\<Prod> a \<in>as. a ^ Suc (f a))"
        "as \<subseteq> ?Q"
[PROOF STATE]
proof (prove)
using this:
\<exists>as f. finite as \<and> smult c r = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}

goal (1 subgoal):
 1. (\<And>as f. \<lbrakk>finite as; smult c r = (\<Prod>a\<in>as. a ^ Suc (f a)); as \<subseteq> {q. irreducible q \<and> monic q}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
finite as
smult c r = (\<Prod>a\<in>as. a ^ Suc (f a))
as \<subseteq> {q. irreducible q \<and> monic q}

goal (1 subgoal):
 1. 0 < degree p \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
from q c
[PROOF STATE]
proof (chain)
picking this:
irreducible q
c \<noteq> (0::'a)
(1::'a) / c \<noteq> (0::'a)
[PROOF STEP]
have irred: "irreducible ?q"
[PROOF STATE]
proof (prove)
using this:
irreducible q
c \<noteq> (0::'a)
(1::'a) / c \<noteq> (0::'a)

goal (1 subgoal):
 1. irreducible (smult ((1::'a) / c) q)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
irreducible (smult ((1::'a) / c) q)

goal (1 subgoal):
 1. 0 < degree p \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
proof (cases "?q \<in> as")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. smult ((1::'a) / c) q \<in> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
 2. smult ((1::'a) / c) q \<notin> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
smult ((1::'a) / c) q \<notin> as

goal (2 subgoals):
 1. smult ((1::'a) / c) q \<in> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
 2. smult ((1::'a) / c) q \<notin> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
let ?as = "insert ?q as"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. smult ((1::'a) / c) q \<in> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
 2. smult ((1::'a) / c) q \<notin> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
let ?f = "\<lambda> a. if a = ?q then 0 else f a"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. smult ((1::'a) / c) q \<in> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
 2. smult ((1::'a) / c) q \<notin> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
have "p = ?q * (\<Prod> a \<in>as. a ^ Suc (f a))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p = smult ((1::'a) / c) q * (\<Prod>a\<in>as. a ^ Suc (f a))
[PROOF STEP]
unfolding p as
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. smult ((1::'a) / c) q * (\<Prod>a\<in>as. a ^ Suc (f a)) = smult ((1::'a) / c) q * (\<Prod>a\<in>as. a ^ Suc (f a))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
p = smult ((1::'a) / c) q * (\<Prod>a\<in>as. a ^ Suc (f a))

goal (2 subgoals):
 1. smult ((1::'a) / c) q \<in> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
 2. smult ((1::'a) / c) q \<notin> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
p = smult ((1::'a) / c) q * (\<Prod>a\<in>as. a ^ Suc (f a))

goal (2 subgoals):
 1. smult ((1::'a) / c) q \<in> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
 2. smult ((1::'a) / c) q \<notin> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
have "(\<Prod> a \<in>as. a ^ Suc (f a)) = (\<Prod> a \<in>as. a ^ Suc (?f a))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>a\<in>as. a ^ Suc (f a)) = (\<Prod>a\<in>as. a ^ Suc (if a = smult ((1::'a) / c) q then 0 else f a))
[PROOF STEP]
by (rule prod.cong, insert False, auto)
[PROOF STATE]
proof (state)
this:
(\<Prod>a\<in>as. a ^ Suc (f a)) = (\<Prod>a\<in>as. a ^ Suc (if a = smult ((1::'a) / c) q then 0 else f a))

goal (2 subgoals):
 1. smult ((1::'a) / c) q \<in> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
 2. smult ((1::'a) / c) q \<notin> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Prod>a\<in>as. a ^ Suc (f a)) = (\<Prod>a\<in>as. a ^ Suc (if a = smult ((1::'a) / c) q then 0 else f a))

goal (2 subgoals):
 1. smult ((1::'a) / c) q \<in> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
 2. smult ((1::'a) / c) q \<notin> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
have "?q * \<dots> = (\<Prod> a \<in> ?as. a ^ Suc (?f a))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. smult ((1::'a) / c) q * (\<Prod>a\<in>as. a ^ Suc (if a = smult ((1::'a) / c) q then 0 else f a)) = (\<Prod>a\<in>insert (smult ((1::'a) / c) q) as. a ^ Suc (if a = smult ((1::'a) / c) q then 0 else f a))
[PROOF STEP]
by (subst prod.insert, insert as False, auto)
[PROOF STATE]
proof (state)
this:
smult ((1::'a) / c) q * (\<Prod>a\<in>as. a ^ Suc (if a = smult ((1::'a) / c) q then 0 else f a)) = (\<Prod>a\<in>insert (smult ((1::'a) / c) q) as. a ^ Suc (if a = smult ((1::'a) / c) q then 0 else f a))

goal (2 subgoals):
 1. smult ((1::'a) / c) q \<in> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
 2. smult ((1::'a) / c) q \<notin> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
p = (\<Prod>a\<in>insert (smult ((1::'a) / c) q) as. a ^ Suc (if a = smult ((1::'a) / c) q then 0 else f a))
[PROOF STEP]
have p: "p = (\<Prod> a \<in> ?as. a ^ Suc (?f a))"
[PROOF STATE]
proof (prove)
using this:
p = (\<Prod>a\<in>insert (smult ((1::'a) / c) q) as. a ^ Suc (if a = smult ((1::'a) / c) q then 0 else f a))

goal (1 subgoal):
 1. p = (\<Prod>a\<in>insert (smult ((1::'a) / c) q) as. a ^ Suc (if a = smult ((1::'a) / c) q then 0 else f a))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
p = (\<Prod>a\<in>insert (smult ((1::'a) / c) q) as. a ^ Suc (if a = smult ((1::'a) / c) q then 0 else f a))

goal (2 subgoals):
 1. smult ((1::'a) / c) q \<in> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
 2. smult ((1::'a) / c) q \<notin> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
from as(1)
[PROOF STATE]
proof (chain)
picking this:
finite as
[PROOF STEP]
have fin: "finite ?as"
[PROOF STATE]
proof (prove)
using this:
finite as

goal (1 subgoal):
 1. finite (insert (smult ((1::'a) / c) q) as)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite (insert (smult ((1::'a) / c) q) as)

goal (2 subgoals):
 1. smult ((1::'a) / c) q \<in> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
 2. smult ((1::'a) / c) q \<notin> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
from as mon irred
[PROOF STATE]
proof (chain)
picking this:
finite as
smult c r = (\<Prod>a\<in>as. a ^ Suc (f a))
as \<subseteq> {q. irreducible q \<and> monic q}
monic (smult ((1::'a) / c) q)
irreducible (smult ((1::'a) / c) q)
[PROOF STEP]
have Q: "?as \<subseteq> ?Q"
[PROOF STATE]
proof (prove)
using this:
finite as
smult c r = (\<Prod>a\<in>as. a ^ Suc (f a))
as \<subseteq> {q. irreducible q \<and> monic q}
monic (smult ((1::'a) / c) q)
irreducible (smult ((1::'a) / c) q)

goal (1 subgoal):
 1. insert (smult ((1::'a) / c) q) as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
insert (smult ((1::'a) / c) q) as \<subseteq> {q. irreducible q \<and> monic q}

goal (2 subgoals):
 1. smult ((1::'a) / c) q \<in> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
 2. smult ((1::'a) / c) q \<notin> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
from fin p Q
[PROOF STATE]
proof (chain)
picking this:
finite (insert (smult ((1::'a) / c) q) as)
p = (\<Prod>a\<in>insert (smult ((1::'a) / c) q) as. a ^ Suc (if a = smult ((1::'a) / c) q then 0 else f a))
insert (smult ((1::'a) / c) q) as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
finite (insert (smult ((1::'a) / c) q) as)
p = (\<Prod>a\<in>insert (smult ((1::'a) / c) q) as. a ^ Suc (if a = smult ((1::'a) / c) q then 0 else f a))
insert (smult ((1::'a) / c) q) as \<subseteq> {q. irreducible q \<and> monic q}

goal (1 subgoal):
 1. \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
by(intro exI[of _ ?as] exI[of _ ?f], auto)
[PROOF STATE]
proof (state)
this:
\<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}

goal (1 subgoal):
 1. smult ((1::'a) / c) q \<in> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. smult ((1::'a) / c) q \<in> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
smult ((1::'a) / c) q \<in> as

goal (1 subgoal):
 1. smult ((1::'a) / c) q \<in> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
let ?f = "\<lambda> a. if a = ?q then Suc (f a) else f a"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. smult ((1::'a) / c) q \<in> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
have "p = ?q * (\<Prod> a \<in>as. a ^ Suc (f a))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p = smult ((1::'a) / c) q * (\<Prod>a\<in>as. a ^ Suc (f a))
[PROOF STEP]
unfolding p as
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. smult ((1::'a) / c) q * (\<Prod>a\<in>as. a ^ Suc (f a)) = smult ((1::'a) / c) q * (\<Prod>a\<in>as. a ^ Suc (f a))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
p = smult ((1::'a) / c) q * (\<Prod>a\<in>as. a ^ Suc (f a))

goal (1 subgoal):
 1. smult ((1::'a) / c) q \<in> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
p = smult ((1::'a) / c) q * (\<Prod>a\<in>as. a ^ Suc (f a))

goal (1 subgoal):
 1. smult ((1::'a) / c) q \<in> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
have "(\<Prod> a \<in>as. a ^ Suc (f a)) = ?q ^ Suc (f ?q) * (\<Prod> a \<in>(as - {?q}). a ^ Suc (f a))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>a\<in>as. a ^ Suc (f a)) = smult ((1::'a) / c) q ^ Suc (f (smult ((1::'a) / c) q)) * (\<Prod>a\<in>as - {smult ((1::'a) / c) q}. a ^ Suc (f a))
[PROOF STEP]
by (subst prod.remove[OF _ True], insert as, auto)
[PROOF STATE]
proof (state)
this:
(\<Prod>a\<in>as. a ^ Suc (f a)) = smult ((1::'a) / c) q ^ Suc (f (smult ((1::'a) / c) q)) * (\<Prod>a\<in>as - {smult ((1::'a) / c) q}. a ^ Suc (f a))

goal (1 subgoal):
 1. smult ((1::'a) / c) q \<in> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Prod>a\<in>as. a ^ Suc (f a)) = smult ((1::'a) / c) q ^ Suc (f (smult ((1::'a) / c) q)) * (\<Prod>a\<in>as - {smult ((1::'a) / c) q}. a ^ Suc (f a))

goal (1 subgoal):
 1. smult ((1::'a) / c) q \<in> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
have "(\<Prod> a \<in>(as - {?q}). a ^ Suc (f a)) = (\<Prod> a \<in>(as - {?q}). a ^ Suc (?f a))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>a\<in>as - {smult ((1::'a) / c) q}. a ^ Suc (f a)) = (\<Prod>a\<in>as - {smult ((1::'a) / c) q}. a ^ Suc (if a = smult ((1::'a) / c) q then Suc (f a) else f a))
[PROOF STEP]
by (rule prod.cong, auto)
[PROOF STATE]
proof (state)
this:
(\<Prod>a\<in>as - {smult ((1::'a) / c) q}. a ^ Suc (f a)) = (\<Prod>a\<in>as - {smult ((1::'a) / c) q}. a ^ Suc (if a = smult ((1::'a) / c) q then Suc (f a) else f a))

goal (1 subgoal):
 1. smult ((1::'a) / c) q \<in> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Prod>a\<in>as - {smult ((1::'a) / c) q}. a ^ Suc (f a)) = (\<Prod>a\<in>as - {smult ((1::'a) / c) q}. a ^ Suc (if a = smult ((1::'a) / c) q then Suc (f a) else f a))

goal (1 subgoal):
 1. smult ((1::'a) / c) q \<in> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
have "?q * (?q ^ Suc (f ?q) * \<dots> ) = ?q ^ Suc (?f ?q) * \<dots>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. smult ((1::'a) / c) q * (smult ((1::'a) / c) q ^ Suc (f (smult ((1::'a) / c) q)) * (\<Prod>a\<in>as - {smult ((1::'a) / c) q}. a ^ Suc (if a = smult ((1::'a) / c) q then Suc (f a) else f a))) = smult ((1::'a) / c) q ^ Suc (if smult ((1::'a) / c) q = smult ((1::'a) / c) q then Suc (f (smult ((1::'a) / c) q)) else f (smult ((1::'a) / c) q)) * (\<Prod>a\<in>as - {smult ((1::'a) / c) q}. a ^ Suc (if a = smult ((1::'a) / c) q then Suc (f a) else f a))
[PROOF STEP]
by (simp add: ac_simps)
[PROOF STATE]
proof (state)
this:
smult ((1::'a) / c) q * (smult ((1::'a) / c) q ^ Suc (f (smult ((1::'a) / c) q)) * (\<Prod>a\<in>as - {smult ((1::'a) / c) q}. a ^ Suc (if a = smult ((1::'a) / c) q then Suc (f a) else f a))) = smult ((1::'a) / c) q ^ Suc (if smult ((1::'a) / c) q = smult ((1::'a) / c) q then Suc (f (smult ((1::'a) / c) q)) else f (smult ((1::'a) / c) q)) * (\<Prod>a\<in>as - {smult ((1::'a) / c) q}. a ^ Suc (if a = smult ((1::'a) / c) q then Suc (f a) else f a))

goal (1 subgoal):
 1. smult ((1::'a) / c) q \<in> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
smult ((1::'a) / c) q * (smult ((1::'a) / c) q ^ Suc (f (smult ((1::'a) / c) q)) * (\<Prod>a\<in>as - {smult ((1::'a) / c) q}. a ^ Suc (if a = smult ((1::'a) / c) q then Suc (f a) else f a))) = smult ((1::'a) / c) q ^ Suc (if smult ((1::'a) / c) q = smult ((1::'a) / c) q then Suc (f (smult ((1::'a) / c) q)) else f (smult ((1::'a) / c) q)) * (\<Prod>a\<in>as - {smult ((1::'a) / c) q}. a ^ Suc (if a = smult ((1::'a) / c) q then Suc (f a) else f a))

goal (1 subgoal):
 1. smult ((1::'a) / c) q \<in> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
have "\<dots> = (\<Prod> a \<in> as. a ^ Suc (?f a))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. smult ((1::'a) / c) q ^ Suc (if smult ((1::'a) / c) q = smult ((1::'a) / c) q then Suc (f (smult ((1::'a) / c) q)) else f (smult ((1::'a) / c) q)) * (\<Prod>a\<in>as - {smult ((1::'a) / c) q}. a ^ Suc (if a = smult ((1::'a) / c) q then Suc (f a) else f a)) = (\<Prod>a\<in>as. a ^ Suc (if a = smult ((1::'a) / c) q then Suc (f a) else f a))
[PROOF STEP]
by (subst prod.remove[OF _ True], insert as, auto)
[PROOF STATE]
proof (state)
this:
smult ((1::'a) / c) q ^ Suc (if smult ((1::'a) / c) q = smult ((1::'a) / c) q then Suc (f (smult ((1::'a) / c) q)) else f (smult ((1::'a) / c) q)) * (\<Prod>a\<in>as - {smult ((1::'a) / c) q}. a ^ Suc (if a = smult ((1::'a) / c) q then Suc (f a) else f a)) = (\<Prod>a\<in>as. a ^ Suc (if a = smult ((1::'a) / c) q then Suc (f a) else f a))

goal (1 subgoal):
 1. smult ((1::'a) / c) q \<in> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
p = (\<Prod>a\<in>as. a ^ Suc (if a = smult ((1::'a) / c) q then Suc (f a) else f a))
[PROOF STEP]
have "p = (\<Prod> a \<in> as. a ^ Suc (?f a))"
[PROOF STATE]
proof (prove)
using this:
p = (\<Prod>a\<in>as. a ^ Suc (if a = smult ((1::'a) / c) q then Suc (f a) else f a))

goal (1 subgoal):
 1. p = (\<Prod>a\<in>as. a ^ Suc (if a = smult ((1::'a) / c) q then Suc (f a) else f a))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
p = (\<Prod>a\<in>as. a ^ Suc (if a = smult ((1::'a) / c) q then Suc (f a) else f a))

goal (1 subgoal):
 1. smult ((1::'a) / c) q \<in> as \<Longrightarrow> \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
with as
[PROOF STATE]
proof (chain)
picking this:
finite as
smult c r = (\<Prod>a\<in>as. a ^ Suc (f a))
as \<subseteq> {q. irreducible q \<and> monic q}
p = (\<Prod>a\<in>as. a ^ Suc (if a = smult ((1::'a) / c) q then Suc (f a) else f a))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
finite as
smult c r = (\<Prod>a\<in>as. a ^ Suc (f a))
as \<subseteq> {q. irreducible q \<and> monic q}
p = (\<Prod>a\<in>as. a ^ Suc (if a = smult ((1::'a) / c) q then Suc (f a) else f a))

goal (1 subgoal):
 1. \<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}
[PROOF STEP]
by (intro exI[of _ as] exI[of _ ?f], auto)
[PROOF STATE]
proof (state)
this:
\<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>as f. finite as \<and> p = (\<Prod>a\<in>as. a ^ Suc (f a)) \<and> as \<subseteq> {q. irreducible q \<and> monic q}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma poincare_collinear3_poincare_lines_equal_general:
  assumes "poincare_collinear {a, a1, a2}" "a \<noteq> a1" "a \<noteq> a2" "a \<noteq> inversion a1" "a \<noteq> inversion a2"
  shows "poincare_line a a1 = poincare_line a a2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poincare_line a a1 = poincare_line a a2
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
poincare_collinear {a, a1, a2}
a \<noteq> a1
a \<noteq> a2
a \<noteq> inversion a1
a \<noteq> inversion a2

goal (1 subgoal):
 1. poincare_line a a1 = poincare_line a a2
[PROOF STEP]
using unique_poincare_line_general[of a a2 "poincare_line a a1"]
[PROOF STATE]
proof (prove)
using this:
poincare_collinear {a, a1, a2}
a \<noteq> a1
a \<noteq> a2
a \<noteq> inversion a1
a \<noteq> inversion a2
\<lbrakk>a \<noteq> a2; a \<noteq> inversion a2; a \<in> circline_set (poincare_line a a1); a2 \<in> circline_set (poincare_line a a1); is_poincare_line (poincare_line a a1)\<rbrakk> \<Longrightarrow> poincare_line a a1 = poincare_line a a2

goal (1 subgoal):
 1. poincare_line a a1 = poincare_line a a2
[PROOF STEP]
by (simp add: insert_commute poincare_collinear3_poincare_line_general)


[STATEMENT]
lemma poly2_poly_x_mult_y:
  fixes p :: "'a :: comm_ring_1 poly"
  shows "poly2 (poly_x_mult_y p) x y = poly p (x * y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly2 (poly_x_mult_y p) x y = poly p (x * y)
[PROOF STEP]
apply (subst(3) poly_as_sum_of_monoms[symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly2 (poly_x_mult_y p) x y = poly (\<Sum>i\<le>degree p. monom (coeff p i) i) (x * y)
[PROOF STEP]
apply (unfold poly_x_mult_y_def hom_distribs)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>xa\<le>degree p. poly2 (monom (monom (coeff p xa) xa) xa) x y) = (\<Sum>xa\<le>degree p. poly (monom (coeff p xa) xa) (x * y))
[PROOF STEP]
by (auto simp: poly2_monom poly_monom power_mult_distrib ac_simps)


[STATEMENT]
lemma Suc_card_1_eq_card[intro]: "Suc (card (verts G) - 1) = card (verts G)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc (card (verts G) - 1) = card (verts G)
[PROOF STEP]
using card_gt0
[PROOF STATE]
proof (prove)
using this:
0 < card (verts G)

goal (1 subgoal):
 1. Suc (card (verts G) - 1) = card (verts G)
[PROOF STEP]
by simp


[STATEMENT]
lemma has_integral_norm_bound_integral_component:
  fixes f :: "'n::euclidean_space \<Rightarrow> 'a::banach"
  fixes g :: "'n \<Rightarrow> 'b::euclidean_space"
  assumes f: "(f has_integral i) S"
    and g: "(g has_integral j) S"
    and "\<And>x. x \<in> S \<Longrightarrow> norm (f x) \<le> (g x)\<bullet>k"
  shows "norm i \<le> j\<bullet>k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm i \<le> j \<bullet> k
[PROOF STEP]
using integral_norm_bound_integral_component[of f S g k]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>f integrable_on S; g integrable_on S; \<And>x. x \<in> S \<Longrightarrow> norm (f x) \<le> g x \<bullet> k\<rbrakk> \<Longrightarrow> norm (integral S f) \<le> integral S g \<bullet> k

goal (1 subgoal):
 1. norm i \<le> j \<bullet> k
[PROOF STEP]
unfolding integral_unique[OF f] integral_unique[OF g]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>f integrable_on S; g integrable_on S; \<And>x. x \<in> S \<Longrightarrow> norm (f x) \<le> g x \<bullet> k\<rbrakk> \<Longrightarrow> norm i \<le> j \<bullet> k

goal (1 subgoal):
 1. norm i \<le> j \<bullet> k
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>f integrable_on S; g integrable_on S; \<And>x. x \<in> S \<Longrightarrow> norm (f x) \<le> g x \<bullet> k\<rbrakk> \<Longrightarrow> norm i \<le> j \<bullet> k
(f has_integral i) S
(g has_integral j) S
?x \<in> S \<Longrightarrow> norm (f ?x) \<le> g ?x \<bullet> k

goal (1 subgoal):
 1. norm i \<le> j \<bullet> k
[PROOF STEP]
by auto


[STATEMENT]
theorem has_field_derivative_Polygamma [derivative_intros]:
  fixes z :: "'a :: {real_normed_field,euclidean_space}"
  assumes z: "z \<notin> \<int>\<^sub>\<le>\<^sub>0"
  shows "(Polygamma n has_field_derivative Polygamma (Suc n) z) (at z within A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z within A)
[PROOF STEP]
proof (rule has_field_derivative_at_within, cases "n = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
 2. n \<noteq> 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
[PROOF STEP]
assume n: "n = 0"
[PROOF STATE]
proof (state)
this:
n = 0

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
 2. n \<noteq> 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
[PROOF STEP]
let ?f = "\<lambda>k z. inverse (of_nat (Suc k)) - inverse (z + of_nat k)"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
 2. n \<noteq> 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
[PROOF STEP]
let ?F = "\<lambda>z. \<Sum>k. ?f k z" and ?f' = "\<lambda>k z. inverse ((z + of_nat k)\<^sup>2)"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
 2. n \<noteq> 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
[PROOF STEP]
from no_nonpos_Int_in_ball'[OF z]
[PROOF STATE]
proof (chain)
picking this:
(\<And>d. \<lbrakk>0 < d; \<And>t. t \<in> ball z d \<Longrightarrow> t \<notin> \<int>\<^sub>\<le>\<^sub>0\<rbrakk> \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis
[PROOF STEP]
obtain d where d: "0 < d" "\<And>t. t \<in> ball z d \<Longrightarrow> t \<notin> \<int>\<^sub>\<le>\<^sub>0"
[PROOF STATE]
proof (prove)
using this:
(\<And>d. \<lbrakk>0 < d; \<And>t. t \<in> ball z d \<Longrightarrow> t \<notin> \<int>\<^sub>\<le>\<^sub>0\<rbrakk> \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. (\<And>d. \<lbrakk>0 < d; \<And>t. t \<in> ball z d \<Longrightarrow> t \<notin> \<int>\<^sub>\<le>\<^sub>0\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < d
?t2 \<in> ball z d \<Longrightarrow> ?t2 \<notin> \<int>\<^sub>\<le>\<^sub>0

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
 2. n \<noteq> 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
[PROOF STEP]
from z
[PROOF STATE]
proof (chain)
picking this:
z \<notin> \<int>\<^sub>\<le>\<^sub>0
[PROOF STEP]
have summable: "summable (\<lambda>k. inverse (of_nat (Suc k)) - inverse (z + of_nat k))"
[PROOF STATE]
proof (prove)
using this:
z \<notin> \<int>\<^sub>\<le>\<^sub>0

goal (1 subgoal):
 1. summable (\<lambda>k. inverse (of_nat (Suc k)) - inverse (z + of_nat k))
[PROOF STEP]
by (intro summable_Digamma) force
[PROOF STATE]
proof (state)
this:
summable (\<lambda>k. inverse (of_nat (Suc k)) - inverse (z + of_nat k))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
 2. n \<noteq> 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
[PROOF STEP]
from z
[PROOF STATE]
proof (chain)
picking this:
z \<notin> \<int>\<^sub>\<le>\<^sub>0
[PROOF STEP]
have conv: "uniformly_convergent_on (ball z d) (\<lambda>k z. \<Sum>i<k. inverse ((z + of_nat i)\<^sup>2))"
[PROOF STATE]
proof (prove)
using this:
z \<notin> \<int>\<^sub>\<le>\<^sub>0

goal (1 subgoal):
 1. uniformly_convergent_on (ball z d) (\<lambda>k z. \<Sum>i<k. inverse ((z + of_nat i)\<^sup>2))
[PROOF STEP]
by (intro Polygamma_converges) auto
[PROOF STATE]
proof (state)
this:
uniformly_convergent_on (ball z d) (\<lambda>k z. \<Sum>i<k. inverse ((z + of_nat i)\<^sup>2))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
 2. n \<noteq> 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
[PROOF STEP]
with d
[PROOF STATE]
proof (chain)
picking this:
0 < d
?t2 \<in> ball z d \<Longrightarrow> ?t2 \<notin> \<int>\<^sub>\<le>\<^sub>0
uniformly_convergent_on (ball z d) (\<lambda>k z. \<Sum>i<k. inverse ((z + of_nat i)\<^sup>2))
[PROOF STEP]
have "summable (\<lambda>k. inverse ((z + of_nat k)\<^sup>2))"
[PROOF STATE]
proof (prove)
using this:
0 < d
?t2 \<in> ball z d \<Longrightarrow> ?t2 \<notin> \<int>\<^sub>\<le>\<^sub>0
uniformly_convergent_on (ball z d) (\<lambda>k z. \<Sum>i<k. inverse ((z + of_nat i)\<^sup>2))

goal (1 subgoal):
 1. summable (\<lambda>k. inverse ((z + of_nat k)\<^sup>2))
[PROOF STEP]
unfolding summable_iff_convergent
[PROOF STATE]
proof (prove)
using this:
0 < d
?t2 \<in> ball z d \<Longrightarrow> ?t2 \<notin> \<int>\<^sub>\<le>\<^sub>0
uniformly_convergent_on (ball z d) (\<lambda>k z. \<Sum>i<k. inverse ((z + of_nat i)\<^sup>2))

goal (1 subgoal):
 1. convergent (\<lambda>n. \<Sum>k<n. inverse ((z + of_nat k)\<^sup>2))
[PROOF STEP]
by (auto dest!: uniformly_convergent_imp_convergent simp: summable_iff_convergent )
[PROOF STATE]
proof (state)
this:
summable (\<lambda>k. inverse ((z + of_nat k)\<^sup>2))

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
 2. n \<noteq> 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
[PROOF STEP]
have "(?F has_field_derivative (\<Sum>k. ?f' k z)) (at z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>z. \<Sum>k. inverse (of_nat (Suc k)) - inverse (z + of_nat k)) has_field_derivative (\<Sum>k. inverse ((z + of_nat k)\<^sup>2))) (at z)
[PROOF STEP]
proof (rule has_field_derivative_series'[of "ball z d" _ _ z])
[PROOF STATE]
proof (state)
goal (6 subgoals):
 1. convex (ball z d)
 2. \<And>k za. za \<in> ball z d \<Longrightarrow> ((\<lambda>a. inverse (of_nat (Suc k)) - inverse (a + of_nat k)) has_field_derivative inverse ((za + of_nat k)\<^sup>2)) (at za within ball z d)
 3. uniformly_convergent_on (ball z d) (\<lambda>k z. \<Sum>i<k. inverse ((z + of_nat i)\<^sup>2))
 4. z \<in> ball z d
 5. summable (\<lambda>k. inverse (of_nat (Suc k)) - inverse (z + of_nat k))
 6. z \<in> interior (ball z d)
[PROOF STEP]
fix k :: nat and t :: 'a
[PROOF STATE]
proof (state)
goal (6 subgoals):
 1. convex (ball z d)
 2. \<And>k za. za \<in> ball z d \<Longrightarrow> ((\<lambda>a. inverse (of_nat (Suc k)) - inverse (a + of_nat k)) has_field_derivative inverse ((za + of_nat k)\<^sup>2)) (at za within ball z d)
 3. uniformly_convergent_on (ball z d) (\<lambda>k z. \<Sum>i<k. inverse ((z + of_nat i)\<^sup>2))
 4. z \<in> ball z d
 5. summable (\<lambda>k. inverse (of_nat (Suc k)) - inverse (z + of_nat k))
 6. z \<in> interior (ball z d)
[PROOF STEP]
assume t: "t \<in> ball z d"
[PROOF STATE]
proof (state)
this:
t \<in> ball z d

goal (6 subgoals):
 1. convex (ball z d)
 2. \<And>k za. za \<in> ball z d \<Longrightarrow> ((\<lambda>a. inverse (of_nat (Suc k)) - inverse (a + of_nat k)) has_field_derivative inverse ((za + of_nat k)\<^sup>2)) (at za within ball z d)
 3. uniformly_convergent_on (ball z d) (\<lambda>k z. \<Sum>i<k. inverse ((z + of_nat i)\<^sup>2))
 4. z \<in> ball z d
 5. summable (\<lambda>k. inverse (of_nat (Suc k)) - inverse (z + of_nat k))
 6. z \<in> interior (ball z d)
[PROOF STEP]
from t d(2)[of t]
[PROOF STATE]
proof (chain)
picking this:
t \<in> ball z d
t \<in> ball z d \<Longrightarrow> t \<notin> \<int>\<^sub>\<le>\<^sub>0
[PROOF STEP]
show "((\<lambda>z. ?f k z) has_field_derivative ?f' k t) (at t within ball z d)"
[PROOF STATE]
proof (prove)
using this:
t \<in> ball z d
t \<in> ball z d \<Longrightarrow> t \<notin> \<int>\<^sub>\<le>\<^sub>0

goal (1 subgoal):
 1. ((\<lambda>z. inverse (of_nat (Suc k)) - inverse (z + of_nat k)) has_field_derivative inverse ((t + of_nat k)\<^sup>2)) (at t within ball z d)
[PROOF STEP]
by (auto intro!: derivative_eq_intros simp: power2_eq_square simp del: of_nat_Suc
               dest!: plus_of_nat_eq_0_imp elim!: nonpos_Ints_cases)
[PROOF STATE]
proof (state)
this:
((\<lambda>z. inverse (of_nat (Suc k)) - inverse (z + of_nat k)) has_field_derivative inverse ((t + of_nat k)\<^sup>2)) (at t within ball z d)

goal (5 subgoals):
 1. convex (ball z d)
 2. uniformly_convergent_on (ball z d) (\<lambda>k z. \<Sum>i<k. inverse ((z + of_nat i)\<^sup>2))
 3. z \<in> ball z d
 4. summable (\<lambda>k. inverse (of_nat (Suc k)) - inverse (z + of_nat k))
 5. z \<in> interior (ball z d)
[PROOF STEP]
qed (insert d(1) summable conv, (assumption|simp)+)
[PROOF STATE]
proof (state)
this:
((\<lambda>z. \<Sum>k. inverse (of_nat (Suc k)) - inverse (z + of_nat k)) has_field_derivative (\<Sum>k. inverse ((z + of_nat k)\<^sup>2))) (at z)

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
 2. n \<noteq> 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
[PROOF STEP]
with z
[PROOF STATE]
proof (chain)
picking this:
z \<notin> \<int>\<^sub>\<le>\<^sub>0
((\<lambda>z. \<Sum>k. inverse (of_nat (Suc k)) - inverse (z + of_nat k)) has_field_derivative (\<Sum>k. inverse ((z + of_nat k)\<^sup>2))) (at z)
[PROOF STEP]
show "(Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)"
[PROOF STATE]
proof (prove)
using this:
z \<notin> \<int>\<^sub>\<le>\<^sub>0
((\<lambda>z. \<Sum>k. inverse (of_nat (Suc k)) - inverse (z + of_nat k)) has_field_derivative (\<Sum>k. inverse ((z + of_nat k)\<^sup>2))) (at z)

goal (1 subgoal):
 1. (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
[PROOF STEP]
unfolding Digamma_def [abs_def] Polygamma_def [abs_def]
[PROOF STATE]
proof (prove)
using this:
z \<notin> \<int>\<^sub>\<le>\<^sub>0
((\<lambda>z. \<Sum>k. inverse (of_nat (Suc k)) - inverse (z + of_nat k)) has_field_derivative (\<Sum>k. inverse ((z + of_nat k)\<^sup>2))) (at z)

goal (1 subgoal):
 1. ((\<lambda>z. if n = 0 then (\<Sum>k. inverse (of_nat (Suc k)) - inverse (z + of_nat k)) - euler_mascheroni else (- (1::'a)) ^ Suc n * fact n * (\<Sum>k. inverse ((z + of_nat k) ^ Suc n))) has_field_derivative (if Suc n = 0 then (\<Sum>k. inverse (of_nat (Suc k)) - inverse (z + of_nat k)) - euler_mascheroni else (- (1::'a)) ^ Suc (Suc n) * fact (Suc n) * (\<Sum>k. inverse ((z + of_nat k) ^ Suc (Suc n))))) (at z)
[PROOF STEP]
using n
[PROOF STATE]
proof (prove)
using this:
z \<notin> \<int>\<^sub>\<le>\<^sub>0
((\<lambda>z. \<Sum>k. inverse (of_nat (Suc k)) - inverse (z + of_nat k)) has_field_derivative (\<Sum>k. inverse ((z + of_nat k)\<^sup>2))) (at z)
n = 0

goal (1 subgoal):
 1. ((\<lambda>z. if n = 0 then (\<Sum>k. inverse (of_nat (Suc k)) - inverse (z + of_nat k)) - euler_mascheroni else (- (1::'a)) ^ Suc n * fact n * (\<Sum>k. inverse ((z + of_nat k) ^ Suc n))) has_field_derivative (if Suc n = 0 then (\<Sum>k. inverse (of_nat (Suc k)) - inverse (z + of_nat k)) - euler_mascheroni else (- (1::'a)) ^ Suc (Suc n) * fact (Suc n) * (\<Sum>k. inverse ((z + of_nat k) ^ Suc (Suc n))))) (at z)
[PROOF STEP]
by (force simp: power2_eq_square intro!: derivative_eq_intros)
[PROOF STATE]
proof (state)
this:
(Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
[PROOF STEP]
assume n: "n \<noteq> 0"
[PROOF STATE]
proof (state)
this:
n \<noteq> 0

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
[PROOF STEP]
from z
[PROOF STATE]
proof (chain)
picking this:
z \<notin> \<int>\<^sub>\<le>\<^sub>0
[PROOF STEP]
have z': "z \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
z \<notin> \<int>\<^sub>\<le>\<^sub>0

goal (1 subgoal):
 1. z \<noteq> (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
z \<noteq> (0::'a)

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
[PROOF STEP]
from no_nonpos_Int_in_ball'[OF z]
[PROOF STATE]
proof (chain)
picking this:
(\<And>d. \<lbrakk>0 < d; \<And>t. t \<in> ball z d \<Longrightarrow> t \<notin> \<int>\<^sub>\<le>\<^sub>0\<rbrakk> \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis
[PROOF STEP]
obtain d where d: "0 < d" "\<And>t. t \<in> ball z d \<Longrightarrow> t \<notin> \<int>\<^sub>\<le>\<^sub>0"
[PROOF STATE]
proof (prove)
using this:
(\<And>d. \<lbrakk>0 < d; \<And>t. t \<in> ball z d \<Longrightarrow> t \<notin> \<int>\<^sub>\<le>\<^sub>0\<rbrakk> \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. (\<And>d. \<lbrakk>0 < d; \<And>t. t \<in> ball z d \<Longrightarrow> t \<notin> \<int>\<^sub>\<le>\<^sub>0\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < d
?t \<in> ball z d \<Longrightarrow> ?t \<notin> \<int>\<^sub>\<le>\<^sub>0

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
[PROOF STEP]
define n' where "n' = Suc n"
[PROOF STATE]
proof (state)
this:
n' = Suc n

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
[PROOF STEP]
from n
[PROOF STATE]
proof (chain)
picking this:
n \<noteq> 0
[PROOF STEP]
have n': "n' \<ge> 2"
[PROOF STATE]
proof (prove)
using this:
n \<noteq> 0

goal (1 subgoal):
 1. 2 \<le> n'
[PROOF STEP]
by (simp add: n'_def)
[PROOF STATE]
proof (state)
this:
2 \<le> n'

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
[PROOF STEP]
have "((\<lambda>z. \<Sum>k. inverse ((z + of_nat k) ^ n')) has_field_derivative
                (\<Sum>k. - of_nat n' * inverse ((z + of_nat k) ^ (n'+1)))) (at z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>z. \<Sum>k. inverse ((z + of_nat k) ^ n')) has_field_derivative (\<Sum>k. - of_nat n' * inverse ((z + of_nat k) ^ (n' + 1)))) (at z)
[PROOF STEP]
proof (rule has_field_derivative_series'[of "ball z d" _ _ z])
[PROOF STATE]
proof (state)
goal (6 subgoals):
 1. convex (ball z d)
 2. \<And>k za. za \<in> ball z d \<Longrightarrow> ((\<lambda>a. inverse ((a + of_nat k) ^ n')) has_field_derivative - of_nat n' * inverse ((za + of_nat k) ^ (n' + 1))) (at za within ball z d)
 3. uniformly_convergent_on (ball z d) (\<lambda>k z. \<Sum>i<k. - of_nat n' * inverse ((z + of_nat i) ^ (n' + 1)))
 4. z \<in> ball z d
 5. summable (\<lambda>k. inverse ((z + of_nat k) ^ n'))
 6. z \<in> interior (ball z d)
[PROOF STEP]
fix k :: nat and t :: 'a
[PROOF STATE]
proof (state)
goal (6 subgoals):
 1. convex (ball z d)
 2. \<And>k za. za \<in> ball z d \<Longrightarrow> ((\<lambda>a. inverse ((a + of_nat k) ^ n')) has_field_derivative - of_nat n' * inverse ((za + of_nat k) ^ (n' + 1))) (at za within ball z d)
 3. uniformly_convergent_on (ball z d) (\<lambda>k z. \<Sum>i<k. - of_nat n' * inverse ((z + of_nat i) ^ (n' + 1)))
 4. z \<in> ball z d
 5. summable (\<lambda>k. inverse ((z + of_nat k) ^ n'))
 6. z \<in> interior (ball z d)
[PROOF STEP]
assume t: "t \<in> ball z d"
[PROOF STATE]
proof (state)
this:
t \<in> ball z d

goal (6 subgoals):
 1. convex (ball z d)
 2. \<And>k za. za \<in> ball z d \<Longrightarrow> ((\<lambda>a. inverse ((a + of_nat k) ^ n')) has_field_derivative - of_nat n' * inverse ((za + of_nat k) ^ (n' + 1))) (at za within ball z d)
 3. uniformly_convergent_on (ball z d) (\<lambda>k z. \<Sum>i<k. - of_nat n' * inverse ((z + of_nat i) ^ (n' + 1)))
 4. z \<in> ball z d
 5. summable (\<lambda>k. inverse ((z + of_nat k) ^ n'))
 6. z \<in> interior (ball z d)
[PROOF STEP]
with d
[PROOF STATE]
proof (chain)
picking this:
0 < d
?t \<in> ball z d \<Longrightarrow> ?t \<notin> \<int>\<^sub>\<le>\<^sub>0
t \<in> ball z d
[PROOF STEP]
have t': "t \<notin> \<int>\<^sub>\<le>\<^sub>0" "t \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
0 < d
?t \<in> ball z d \<Longrightarrow> ?t \<notin> \<int>\<^sub>\<le>\<^sub>0
t \<in> ball z d

goal (1 subgoal):
 1. t \<notin> \<int>\<^sub>\<le>\<^sub>0 &&& t \<noteq> (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
t \<notin> \<int>\<^sub>\<le>\<^sub>0
t \<noteq> (0::'a)

goal (6 subgoals):
 1. convex (ball z d)
 2. \<And>k za. za \<in> ball z d \<Longrightarrow> ((\<lambda>a. inverse ((a + of_nat k) ^ n')) has_field_derivative - of_nat n' * inverse ((za + of_nat k) ^ (n' + 1))) (at za within ball z d)
 3. uniformly_convergent_on (ball z d) (\<lambda>k z. \<Sum>i<k. - of_nat n' * inverse ((z + of_nat i) ^ (n' + 1)))
 4. z \<in> ball z d
 5. summable (\<lambda>k. inverse ((z + of_nat k) ^ n'))
 6. z \<in> interior (ball z d)
[PROOF STEP]
show "((\<lambda>a. inverse ((a + of_nat k) ^ n')) has_field_derivative
                - of_nat n' * inverse ((t + of_nat k) ^ (n'+1))) (at t within ball z d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>a. inverse ((a + of_nat k) ^ n')) has_field_derivative - of_nat n' * inverse ((t + of_nat k) ^ (n' + 1))) (at t within ball z d)
[PROOF STEP]
using t'
[PROOF STATE]
proof (prove)
using this:
t \<notin> \<int>\<^sub>\<le>\<^sub>0
t \<noteq> (0::'a)

goal (1 subgoal):
 1. ((\<lambda>a. inverse ((a + of_nat k) ^ n')) has_field_derivative - of_nat n' * inverse ((t + of_nat k) ^ (n' + 1))) (at t within ball z d)
[PROOF STEP]
by (fastforce intro!: derivative_eq_intros simp: divide_simps power_diff dest: plus_of_nat_eq_0_imp)
[PROOF STATE]
proof (state)
this:
((\<lambda>a. inverse ((a + of_nat k) ^ n')) has_field_derivative - of_nat n' * inverse ((t + of_nat k) ^ (n' + 1))) (at t within ball z d)

goal (5 subgoals):
 1. convex (ball z d)
 2. uniformly_convergent_on (ball z d) (\<lambda>k z. \<Sum>i<k. - of_nat n' * inverse ((z + of_nat i) ^ (n' + 1)))
 3. z \<in> ball z d
 4. summable (\<lambda>k. inverse ((z + of_nat k) ^ n'))
 5. z \<in> interior (ball z d)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (5 subgoals):
 1. convex (ball z d)
 2. uniformly_convergent_on (ball z d) (\<lambda>k z. \<Sum>i<k. - of_nat n' * inverse ((z + of_nat i) ^ (n' + 1)))
 3. z \<in> ball z d
 4. summable (\<lambda>k. inverse ((z + of_nat k) ^ n'))
 5. z \<in> interior (ball z d)
[PROOF STEP]
have "uniformly_convergent_on (ball z d)
              (\<lambda>k z. (- of_nat n' :: 'a) * (\<Sum>i<k. inverse ((z + of_nat i) ^ (n'+1))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. uniformly_convergent_on (ball z d) (\<lambda>k z. - of_nat n' * (\<Sum>i<k. inverse ((z + of_nat i) ^ (n' + 1))))
[PROOF STEP]
using z' n
[PROOF STATE]
proof (prove)
using this:
z \<noteq> (0::'a)
n \<noteq> 0

goal (1 subgoal):
 1. uniformly_convergent_on (ball z d) (\<lambda>k z. - of_nat n' * (\<Sum>i<k. inverse ((z + of_nat i) ^ (n' + 1))))
[PROOF STEP]
by (intro uniformly_convergent_mult Polygamma_converges) (simp_all add: n'_def)
[PROOF STATE]
proof (state)
this:
uniformly_convergent_on (ball z d) (\<lambda>k z. - of_nat n' * (\<Sum>i<k. inverse ((z + of_nat i) ^ (n' + 1))))

goal (5 subgoals):
 1. convex (ball z d)
 2. uniformly_convergent_on (ball z d) (\<lambda>k z. \<Sum>i<k. - of_nat n' * inverse ((z + of_nat i) ^ (n' + 1)))
 3. z \<in> ball z d
 4. summable (\<lambda>k. inverse ((z + of_nat k) ^ n'))
 5. z \<in> interior (ball z d)
[PROOF STEP]
thus "uniformly_convergent_on (ball z d)
              (\<lambda>k z. \<Sum>i<k. - of_nat n' * inverse ((z + of_nat i :: 'a) ^ (n'+1)))"
[PROOF STATE]
proof (prove)
using this:
uniformly_convergent_on (ball z d) (\<lambda>k z. - of_nat n' * (\<Sum>i<k. inverse ((z + of_nat i) ^ (n' + 1))))

goal (1 subgoal):
 1. uniformly_convergent_on (ball z d) (\<lambda>k z. \<Sum>i<k. - of_nat n' * inverse ((z + of_nat i) ^ (n' + 1)))
[PROOF STEP]
by (subst (asm) sum_distrib_left) simp
[PROOF STATE]
proof (state)
this:
uniformly_convergent_on (ball z d) (\<lambda>k z. \<Sum>i<k. - of_nat n' * inverse ((z + of_nat i) ^ (n' + 1)))

goal (4 subgoals):
 1. convex (ball z d)
 2. z \<in> ball z d
 3. summable (\<lambda>k. inverse ((z + of_nat k) ^ n'))
 4. z \<in> interior (ball z d)
[PROOF STEP]
qed (insert Polygamma_converges'[OF z' n'] d, simp_all)
[PROOF STATE]
proof (state)
this:
((\<lambda>z. \<Sum>k. inverse ((z + of_nat k) ^ n')) has_field_derivative (\<Sum>k. - of_nat n' * inverse ((z + of_nat k) ^ (n' + 1)))) (at z)

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
((\<lambda>z. \<Sum>k. inverse ((z + of_nat k) ^ n')) has_field_derivative (\<Sum>k. - of_nat n' * inverse ((z + of_nat k) ^ (n' + 1)))) (at z)

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
[PROOF STEP]
have "(\<Sum>k. - of_nat n' * inverse ((z + of_nat k) ^ (n' + 1))) =
               (- of_nat n') * (\<Sum>k. inverse ((z + of_nat k) ^ (n' + 1)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k. - of_nat n' * inverse ((z + of_nat k) ^ (n' + 1))) = - of_nat n' * (\<Sum>k. inverse ((z + of_nat k) ^ (n' + 1)))
[PROOF STEP]
using Polygamma_converges'[OF z', of "n'+1"] n'
[PROOF STATE]
proof (prove)
using this:
2 \<le> n' + 1 \<Longrightarrow> summable (\<lambda>k. inverse ((z + of_nat k) ^ (n' + 1)))
2 \<le> n'

goal (1 subgoal):
 1. (\<Sum>k. - of_nat n' * inverse ((z + of_nat k) ^ (n' + 1))) = - of_nat n' * (\<Sum>k. inverse ((z + of_nat k) ^ (n' + 1)))
[PROOF STEP]
by (subst suminf_mult) simp_all
[PROOF STATE]
proof (state)
this:
(\<Sum>k. - of_nat n' * inverse ((z + of_nat k) ^ (n' + 1))) = - of_nat n' * (\<Sum>k. inverse ((z + of_nat k) ^ (n' + 1)))

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
((\<lambda>z. \<Sum>k. inverse ((z + of_nat k) ^ n')) has_field_derivative - of_nat n' * (\<Sum>k. inverse ((z + of_nat k) ^ (n' + 1)))) (at z)
[PROOF STEP]
have "((\<lambda>z. \<Sum>k. inverse ((z + of_nat k) ^ n')) has_field_derivative
                    - of_nat n' * (\<Sum>k. inverse ((z + of_nat k) ^ (n' + 1)))) (at z)"
[PROOF STATE]
proof (prove)
using this:
((\<lambda>z. \<Sum>k. inverse ((z + of_nat k) ^ n')) has_field_derivative - of_nat n' * (\<Sum>k. inverse ((z + of_nat k) ^ (n' + 1)))) (at z)

goal (1 subgoal):
 1. ((\<lambda>z. \<Sum>k. inverse ((z + of_nat k) ^ n')) has_field_derivative - of_nat n' * (\<Sum>k. inverse ((z + of_nat k) ^ (n' + 1)))) (at z)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
((\<lambda>z. \<Sum>k. inverse ((z + of_nat k) ^ n')) has_field_derivative - of_nat n' * (\<Sum>k. inverse ((z + of_nat k) ^ (n' + 1)))) (at z)

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
[PROOF STEP]
from DERIV_cmult[OF this, of "(-1)^Suc n * fact n :: 'a"]
[PROOF STATE]
proof (chain)
picking this:
((\<lambda>x. (- (1::'a)) ^ Suc n * fact n * (\<Sum>k. inverse ((x + of_nat k) ^ n'))) has_field_derivative (- (1::'a)) ^ Suc n * fact n * (- of_nat n' * (\<Sum>k. inverse ((z + of_nat k) ^ (n' + 1))))) (at z)
[PROOF STEP]
show "(Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)"
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. (- (1::'a)) ^ Suc n * fact n * (\<Sum>k. inverse ((x + of_nat k) ^ n'))) has_field_derivative (- (1::'a)) ^ Suc n * fact n * (- of_nat n' * (\<Sum>k. inverse ((z + of_nat k) ^ (n' + 1))))) (at z)

goal (1 subgoal):
 1. (Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)
[PROOF STEP]
unfolding n'_def Polygamma_def[abs_def]
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. (- (1::'a)) ^ Suc n * fact n * (\<Sum>k. inverse ((x + of_nat k) ^ Suc n))) has_field_derivative (- (1::'a)) ^ Suc n * fact n * (- of_nat (Suc n) * (\<Sum>k. inverse ((z + of_nat k) ^ (Suc n + 1))))) (at z)

goal (1 subgoal):
 1. ((\<lambda>z. if n = 0 then (\<Sum>k. inverse (of_nat (Suc k)) - inverse (z + of_nat k)) - euler_mascheroni else (- (1::'a)) ^ Suc n * fact n * (\<Sum>k. inverse ((z + of_nat k) ^ Suc n))) has_field_derivative (if Suc n = 0 then (\<Sum>k. inverse (of_nat (Suc k)) - inverse (z + of_nat k)) - euler_mascheroni else (- (1::'a)) ^ Suc (Suc n) * fact (Suc n) * (\<Sum>k. inverse ((z + of_nat k) ^ Suc (Suc n))))) (at z)
[PROOF STEP]
using n
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. (- (1::'a)) ^ Suc n * fact n * (\<Sum>k. inverse ((x + of_nat k) ^ Suc n))) has_field_derivative (- (1::'a)) ^ Suc n * fact n * (- of_nat (Suc n) * (\<Sum>k. inverse ((z + of_nat k) ^ (Suc n + 1))))) (at z)
n \<noteq> 0

goal (1 subgoal):
 1. ((\<lambda>z. if n = 0 then (\<Sum>k. inverse (of_nat (Suc k)) - inverse (z + of_nat k)) - euler_mascheroni else (- (1::'a)) ^ Suc n * fact n * (\<Sum>k. inverse ((z + of_nat k) ^ Suc n))) has_field_derivative (if Suc n = 0 then (\<Sum>k. inverse (of_nat (Suc k)) - inverse (z + of_nat k)) - euler_mascheroni else (- (1::'a)) ^ Suc (Suc n) * fact (Suc n) * (\<Sum>k. inverse ((z + of_nat k) ^ Suc (Suc n))))) (at z)
[PROOF STEP]
by (simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
(Polygamma n has_field_derivative Polygamma (Suc n) z) (at z)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma poly_IVT_neg: "a < b \<Longrightarrow> 0 < poly p a \<Longrightarrow> poly p b < 0 \<Longrightarrow> \<exists>x. a < x \<and> x < b \<and> poly p x = 0"
  for a b :: real
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a < b; 0 < poly p a; poly p b < 0\<rbrakk> \<Longrightarrow> \<exists>x>a. x < b \<and> poly p x = 0
[PROOF STEP]
using poly_IVT_pos [where p = "- p"]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?a < ?b; poly (- p) ?a < 0; 0 < poly (- p) ?b\<rbrakk> \<Longrightarrow> \<exists>x>?a. x < ?b \<and> poly (- p) x = 0

goal (1 subgoal):
 1. \<lbrakk>a < b; 0 < poly p a; poly p b < 0\<rbrakk> \<Longrightarrow> \<exists>x>a. x < b \<and> poly p x = 0
[PROOF STEP]
by simp