[STATEMENT]
theorem vonStaudt_Clausen:
  assumes "n > 0"
  shows   "bernoulli (2 * n) + (\<Sum>p | prime p \<and> (p - 1) dvd (2 * n). 1 / real p) \<in> \<int>"
    (is "_ + ?P \<in> \<int>")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bernoulli (2 * n) + (\<Sum>p | prime p \<and> p - 1 dvd 2 * n. 1 / real p) \<in> \<int>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. bernoulli (2 * n) + (\<Sum>p | prime p \<and> p - 1 dvd 2 * n. 1 / real p) \<in> \<int>
[PROOF STEP]
define P :: "nat \<Rightarrow> real"
    where "P = (\<lambda>m. if prime (m + 1) \<and> m dvd (2 * n) then 1 / (m + 1) else 0)"
[PROOF STATE]
proof (state)
this:
P = (\<lambda>m. if prime (m + 1) \<and> m dvd 2 * n then 1 / (real m + 1) else 0)

goal (1 subgoal):
 1. bernoulli (2 * n) + (\<Sum>p | prime p \<and> p - 1 dvd 2 * n. 1 / real p) \<in> \<int>
[PROOF STEP]
define P' :: "nat \<Rightarrow> int"
    where "P' = (\<lambda>m. if prime (m + 1) \<and> m dvd (2 * n) then 1 else 0)"
[PROOF STATE]
proof (state)
this:
P' = (\<lambda>m. if prime (m + 1) \<and> m dvd 2 * n then 1 else 0)

goal (1 subgoal):
 1. bernoulli (2 * n) + (\<Sum>p | prime p \<and> p - 1 dvd 2 * n. 1 / real p) \<in> \<int>
[PROOF STEP]
have "?P = (\<Sum>p | prime (p + 1) \<and> p dvd (2 * n). 1 / real (p + 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>p | prime p \<and> p - 1 dvd 2 * n. 1 / real p) = (\<Sum>p | prime (p + 1) \<and> p dvd 2 * n. 1 / real (p + 1))
[PROOF STEP]
by (rule sum.reindex_bij_witness[of _ "\<lambda>p. p + 1" "\<lambda>p. p - 1"])
       (use prime_gt_0_nat in auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>p | prime p \<and> p - 1 dvd 2 * n. 1 / real p) = (\<Sum>p | prime (p + 1) \<and> p dvd 2 * n. 1 / real (p + 1))

goal (1 subgoal):
 1. bernoulli (2 * n) + (\<Sum>p | prime p \<and> p - 1 dvd 2 * n. 1 / real p) \<in> \<int>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>p | prime p \<and> p - 1 dvd 2 * n. 1 / real p) = (\<Sum>p | prime (p + 1) \<and> p dvd 2 * n. 1 / real (p + 1))

goal (1 subgoal):
 1. bernoulli (2 * n) + (\<Sum>p | prime p \<and> p - 1 dvd 2 * n. 1 / real p) \<in> \<int>
[PROOF STEP]
have "\<dots> = (\<Sum>m\<le>2*n. P m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>p | prime (p + 1) \<and> p dvd 2 * n. 1 / real (p + 1)) = sum P {..2 * n}
[PROOF STEP]
using \<open>n > 0\<close>
[PROOF STATE]
proof (prove)
using this:
0 < n

goal (1 subgoal):
 1. (\<Sum>p | prime (p + 1) \<and> p dvd 2 * n. 1 / real (p + 1)) = sum P {..2 * n}
[PROOF STEP]
by (intro sum.mono_neutral_cong_left) (auto simp: P_def dest!: dvd_imp_le)
[PROOF STATE]
proof (state)
this:
(\<Sum>p | prime (p + 1) \<and> p dvd 2 * n. 1 / real (p + 1)) = sum P {..2 * n}

goal (1 subgoal):
 1. bernoulli (2 * n) + (\<Sum>p | prime p \<and> p - 1 dvd 2 * n. 1 / real p) \<in> \<int>
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>p | prime p \<and> p - 1 dvd 2 * n. 1 / real p) = sum P {..2 * n}
[PROOF STEP]
have "bernoulli (2 * n) + ?P =
                  (\<Sum>m\<le>2*n. (-1)^m * (of_int (fact m * Stirling (2*n) m) / (m + 1)) + P m)"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>p | prime p \<and> p - 1 dvd 2 * n. 1 / real p) = sum P {..2 * n}

goal (1 subgoal):
 1. bernoulli (2 * n) + (\<Sum>p | prime p \<and> p - 1 dvd 2 * n. 1 / real p) = (\<Sum>m\<le>2 * n. (- 1) ^ m * (real_of_int (int (fact m * Stirling (2 * n) m)) / real (m + 1)) + P m)
[PROOF STEP]
by (simp add: sum.distrib bernoulli_conv_Stirling sum_divide_distrib algebra_simps)
[PROOF STATE]
proof (state)
this:
bernoulli (2 * n) + (\<Sum>p | prime p \<and> p - 1 dvd 2 * n. 1 / real p) = (\<Sum>m\<le>2 * n. (- 1) ^ m * (real_of_int (int (fact m * Stirling (2 * n) m)) / real (m + 1)) + P m)

goal (1 subgoal):
 1. bernoulli (2 * n) + (\<Sum>p | prime p \<and> p - 1 dvd 2 * n. 1 / real p) \<in> \<int>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
bernoulli (2 * n) + (\<Sum>p | prime p \<and> p - 1 dvd 2 * n. 1 / real p) = (\<Sum>m\<le>2 * n. (- 1) ^ m * (real_of_int (int (fact m * Stirling (2 * n) m)) / real (m + 1)) + P m)

goal (1 subgoal):
 1. bernoulli (2 * n) + (\<Sum>p | prime p \<and> p - 1 dvd 2 * n. 1 / real p) \<in> \<int>
[PROOF STEP]
have "\<dots> = (\<Sum>m\<le>2*n. of_int ((-1)^m * fact m * Stirling (2*n) m + P' m) / (m + 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m\<le>2 * n. (- 1) ^ m * (real_of_int (int (fact m * Stirling (2 * n) m)) / real (m + 1)) + P m) = (\<Sum>m\<le>2 * n. real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1))
[PROOF STEP]
by (intro sum.cong) (auto simp: P'_def P_def field_simps)
[PROOF STATE]
proof (state)
this:
(\<Sum>m\<le>2 * n. (- 1) ^ m * (real_of_int (int (fact m * Stirling (2 * n) m)) / real (m + 1)) + P m) = (\<Sum>m\<le>2 * n. real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1))

goal (1 subgoal):
 1. bernoulli (2 * n) + (\<Sum>p | prime p \<and> p - 1 dvd 2 * n. 1 / real p) \<in> \<int>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>m\<le>2 * n. (- 1) ^ m * (real_of_int (int (fact m * Stirling (2 * n) m)) / real (m + 1)) + P m) = (\<Sum>m\<le>2 * n. real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1))

goal (1 subgoal):
 1. bernoulli (2 * n) + (\<Sum>p | prime p \<and> p - 1 dvd 2 * n. 1 / real p) \<in> \<int>
[PROOF STEP]
have "\<dots> \<in> \<int>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m\<le>2 * n. real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1)) \<in> \<int>
[PROOF STEP]
proof (rule sum_in_Ints, goal_cases)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {..2 * n} \<Longrightarrow> real_of_int ((- 1) ^ x * fact x * int (Stirling (2 * n) x) + P' x) / real (x + 1) \<in> \<int>
[PROOF STEP]
case (1 m)
[PROOF STATE]
proof (state)
this:
m \<in> {..2 * n}

goal (1 subgoal):
 1. \<And>x. x \<in> {..2 * n} \<Longrightarrow> real_of_int ((- 1) ^ x * fact x * int (Stirling (2 * n) x) + P' x) / real (x + 1) \<in> \<int>
[PROOF STEP]
have "m = 0 \<or> m = 3 \<or> prime (m + 1) \<or> (\<not>prime (m + 1) \<and> m > 3)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m = 0 \<or> m = 3 \<or> prime (m + 1) \<or> \<not> prime (m + 1) \<and> 3 < m
[PROOF STEP]
by (cases "m = 1"; cases "m = 2") (auto simp flip: numeral_2_eq_2)
[PROOF STATE]
proof (state)
this:
m = 0 \<or> m = 3 \<or> prime (m + 1) \<or> \<not> prime (m + 1) \<and> 3 < m

goal (1 subgoal):
 1. \<And>x. x \<in> {..2 * n} \<Longrightarrow> real_of_int ((- 1) ^ x * fact x * int (Stirling (2 * n) x) + P' x) / real (x + 1) \<in> \<int>
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
m = 0 \<or> m = 3 \<or> prime (m + 1) \<or> \<not> prime (m + 1) \<and> 3 < m
[PROOF STEP]
consider "m = 0" | "m = 3" | "prime (m + 1)" | "\<not>prime (m + 1)" "m > 3"
[PROOF STATE]
proof (prove)
using this:
m = 0 \<or> m = 3 \<or> prime (m + 1) \<or> \<not> prime (m + 1) \<and> 3 < m

goal (1 subgoal):
 1. \<lbrakk>m = 0 \<Longrightarrow> thesis; m = 3 \<Longrightarrow> thesis; prime (m + 1) \<Longrightarrow> thesis; \<lbrakk>\<not> prime (m + 1); 3 < m\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<lbrakk>m = 0 \<Longrightarrow> ?thesis; m = 3 \<Longrightarrow> ?thesis; prime (m + 1) \<Longrightarrow> ?thesis; \<lbrakk>\<not> prime (m + 1); 3 < m\<rbrakk> \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. \<And>x. x \<in> {..2 * n} \<Longrightarrow> real_of_int ((- 1) ^ x * fact x * int (Stirling (2 * n) x) + P' x) / real (x + 1) \<in> \<int>
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>m = 0 \<Longrightarrow> ?thesis; m = 3 \<Longrightarrow> ?thesis; prime (m + 1) \<Longrightarrow> ?thesis; \<lbrakk>\<not> prime (m + 1); 3 < m\<rbrakk> \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
proof cases
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. m = 0 \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 2. m = 3 \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 3. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 4. \<lbrakk>\<not> prime (m + 1); 3 < m\<rbrakk> \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
assume "m = 0"
[PROOF STATE]
proof (state)
this:
m = 0

goal (4 subgoals):
 1. m = 0 \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 2. m = 3 \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 3. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 4. \<lbrakk>\<not> prime (m + 1); 3 < m\<rbrakk> \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
m = 0

goal (1 subgoal):
 1. real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>

goal (3 subgoals):
 1. m = 3 \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 2. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 3. \<lbrakk>\<not> prime (m + 1); 3 < m\<rbrakk> \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. m = 3 \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 2. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 3. \<lbrakk>\<not> prime (m + 1); 3 < m\<rbrakk> \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
assume [simp]: "m = 3"
[PROOF STATE]
proof (state)
this:
m = 3

goal (3 subgoals):
 1. m = 3 \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 2. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 3. \<lbrakk>\<not> prime (m + 1); 3 < m\<rbrakk> \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
have "real_of_int (fact m * Stirling (2 * n) m) =
              real_of_int (9 ^ n + 3 - 3 * 4 ^ n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_of_int (int (fact m * Stirling (2 * n) m)) = real_of_int (9 ^ n + 3 - 3 * 4 ^ n)
[PROOF STEP]
using \<open>n > 0\<close>
[PROOF STATE]
proof (prove)
using this:
0 < n

goal (1 subgoal):
 1. real_of_int (int (fact m * Stirling (2 * n) m)) = real_of_int (9 ^ n + 3 - 3 * 4 ^ n)
[PROOF STEP]
by (auto simp: P'_def fact_numeral Stirling_closed_form power_mult
                                     atMost_nat_numeral binomial_fact zero_power)
[PROOF STATE]
proof (state)
this:
real_of_int (int (fact m * Stirling (2 * n) m)) = real_of_int (9 ^ n + 3 - 3 * 4 ^ n)

goal (3 subgoals):
 1. m = 3 \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 2. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 3. \<lbrakk>\<not> prime (m + 1); 3 < m\<rbrakk> \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
hence "int (fact m * Stirling (2 * n) m) = 9 ^ n + 3 - 3 * 4 ^ n"
[PROOF STATE]
proof (prove)
using this:
real_of_int (int (fact m * Stirling (2 * n) m)) = real_of_int (9 ^ n + 3 - 3 * 4 ^ n)

goal (1 subgoal):
 1. int (fact m * Stirling (2 * n) m) = 9 ^ n + 3 - 3 * 4 ^ n
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
int (fact m * Stirling (2 * n) m) = 9 ^ n + 3 - 3 * 4 ^ n

goal (3 subgoals):
 1. m = 3 \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 2. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 3. \<lbrakk>\<not> prime (m + 1); 3 < m\<rbrakk> \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
int (fact m * Stirling (2 * n) m) = 9 ^ n + 3 - 3 * 4 ^ n

goal (3 subgoals):
 1. m = 3 \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 2. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 3. \<lbrakk>\<not> prime (m + 1); 3 < m\<rbrakk> \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
have "[\<dots> = 1 ^ n + (-1) - 3 * 0 ^ n] (mod 4)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [9 ^ n + 3 - 3 * 4 ^ n = 1 ^ n + - 1 - 3 * 0 ^ n] (mod 4)
[PROOF STEP]
by (intro cong_add cong_diff cong_mult cong_pow) (auto simp: cong_def)
[PROOF STATE]
proof (state)
this:
[9 ^ n + 3 - 3 * 4 ^ n = 1 ^ n + - 1 - 3 * 0 ^ n] (mod 4)

goal (3 subgoals):
 1. m = 3 \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 2. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 3. \<lbrakk>\<not> prime (m + 1); 3 < m\<rbrakk> \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
[int (fact m * Stirling (2 * n) m) = 1 ^ n + - 1 - 3 * 0 ^ n] (mod 4)
[PROOF STEP]
have dvd: "4 dvd int (fact m * Stirling (2 * n) m)"
[PROOF STATE]
proof (prove)
using this:
[int (fact m * Stirling (2 * n) m) = 1 ^ n + - 1 - 3 * 0 ^ n] (mod 4)

goal (1 subgoal):
 1. 4 dvd int (fact m * Stirling (2 * n) m)
[PROOF STEP]
using \<open>n > 0\<close>
[PROOF STATE]
proof (prove)
using this:
[int (fact m * Stirling (2 * n) m) = 1 ^ n + - 1 - 3 * 0 ^ n] (mod 4)
0 < n

goal (1 subgoal):
 1. 4 dvd int (fact m * Stirling (2 * n) m)
[PROOF STEP]
by (simp add: cong_0_iff zero_power)
[PROOF STATE]
proof (state)
this:
4 dvd int (fact m * Stirling (2 * n) m)

goal (3 subgoals):
 1. m = 3 \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 2. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 3. \<lbrakk>\<not> prime (m + 1); 3 < m\<rbrakk> \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
have "real_of_int ((- 1) ^ m * fact m * Stirling (2 * n) m + P' m) / (m + 1) =
              -(real_of_int (int (fact m * Stirling (2 * n) m)) / real_of_int 4)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) = - (real_of_int (int (fact m * Stirling (2 * n) m)) / real_of_int 4)
[PROOF STEP]
using \<open>n > 0\<close>
[PROOF STATE]
proof (prove)
using this:
0 < n

goal (1 subgoal):
 1. real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) = - (real_of_int (int (fact m * Stirling (2 * n) m)) / real_of_int 4)
[PROOF STEP]
by (auto simp: P'_def)
[PROOF STATE]
proof (state)
this:
real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) = - (real_of_int (int (fact m * Stirling (2 * n) m)) / real_of_int 4)

goal (3 subgoals):
 1. m = 3 \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 2. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 3. \<lbrakk>\<not> prime (m + 1); 3 < m\<rbrakk> \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) = - (real_of_int (int (fact m * Stirling (2 * n) m)) / real_of_int 4)

goal (3 subgoals):
 1. m = 3 \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 2. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 3. \<lbrakk>\<not> prime (m + 1); 3 < m\<rbrakk> \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
have "\<dots> \<in> \<int>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. - (real_of_int (int (fact m * Stirling (2 * n) m)) / real_of_int 4) \<in> \<int>
[PROOF STEP]
by (intro Ints_minus of_int_divide_in_Ints dvd)
[PROOF STATE]
proof (state)
this:
- (real_of_int (int (fact m * Stirling (2 * n) m)) / real_of_int 4) \<in> \<int>

goal (3 subgoals):
 1. m = 3 \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 2. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 3. \<lbrakk>\<not> prime (m + 1); 3 < m\<rbrakk> \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>

goal (1 subgoal):
 1. real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>

goal (2 subgoals):
 1. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 2. \<lbrakk>\<not> prime (m + 1); 3 < m\<rbrakk> \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 2. \<lbrakk>\<not> prime (m + 1); 3 < m\<rbrakk> \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
assume composite: "\<not>prime (m + 1)" and "m > 3"
[PROOF STATE]
proof (state)
this:
\<not> prime (m + 1)
3 < m

goal (2 subgoals):
 1. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 2. \<lbrakk>\<not> prime (m + 1); 3 < m\<rbrakk> \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
obtain a b where ab: "a * b = m + 1" "a > 1" "b > 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>a b. \<lbrakk>a * b = m + 1; 1 < a; 1 < b\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using \<open>m > 3\<close> composite composite_imp_factors_nat[of "m + 1"]
[PROOF STATE]
proof (prove)
using this:
3 < m
\<not> prime (m + 1)
\<lbrakk>1 < m + 1; \<not> prime (m + 1)\<rbrakk> \<Longrightarrow> \<exists>n k. m + 1 = n * k \<and> 1 < n \<and> n < m + 1 \<and> 1 < k \<and> k < m + 1

goal (1 subgoal):
 1. (\<And>a b. \<lbrakk>a * b = m + 1; 1 < a; 1 < b\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a * b = m + 1
1 < a
1 < b

goal (2 subgoals):
 1. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 2. \<lbrakk>\<not> prime (m + 1); 3 < m\<rbrakk> \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
have "a = b \<longrightarrow> a > 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a = b \<longrightarrow> 2 < a
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a = b \<Longrightarrow> 2 < a
[PROOF STEP]
assume "a = b"
[PROOF STATE]
proof (state)
this:
a = b

goal (1 subgoal):
 1. a = b \<Longrightarrow> 2 < a
[PROOF STEP]
hence "a ^ 2 > 2 ^ 2"
[PROOF STATE]
proof (prove)
using this:
a = b

goal (1 subgoal):
 1. 2\<^sup>2 < a\<^sup>2
[PROOF STEP]
using \<open>m > 3\<close> and ab
[PROOF STATE]
proof (prove)
using this:
a = b
3 < m
a * b = m + 1
1 < a
1 < b

goal (1 subgoal):
 1. 2\<^sup>2 < a\<^sup>2
[PROOF STEP]
by (auto simp: power2_eq_square)
[PROOF STATE]
proof (state)
this:
2\<^sup>2 < a\<^sup>2

goal (1 subgoal):
 1. a = b \<Longrightarrow> 2 < a
[PROOF STEP]
thus "a > 2"
[PROOF STATE]
proof (prove)
using this:
2\<^sup>2 < a\<^sup>2

goal (1 subgoal):
 1. 2 < a
[PROOF STEP]
using power_less_imp_less_base
[PROOF STATE]
proof (prove)
using this:
2\<^sup>2 < a\<^sup>2
\<lbrakk>?a ^ ?n < ?b ^ ?n; (0::?'a) \<le> ?b\<rbrakk> \<Longrightarrow> ?a < ?b

goal (1 subgoal):
 1. 2 < a
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
2 < a

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
a = b \<longrightarrow> 2 < a

goal (2 subgoals):
 1. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 2. \<lbrakk>\<not> prime (m + 1); 3 < m\<rbrakk> \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
hence dvd: "(m + 1) dvd fact m"
[PROOF STATE]
proof (prove)
using this:
a = b \<longrightarrow> 2 < a

goal (1 subgoal):
 1. m + 1 dvd fact m
[PROOF STEP]
using product_dvd_fact[of a b] ab
[PROOF STATE]
proof (prove)
using this:
a = b \<longrightarrow> 2 < a
\<lbrakk>1 < a; 1 < b; a = b \<longrightarrow> 2 < a\<rbrakk> \<Longrightarrow> a * b dvd fact (a * b - 1)
a * b = m + 1
1 < a
1 < b

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

goal (2 subgoals):
 1. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 2. \<lbrakk>\<not> prime (m + 1); 3 < m\<rbrakk> \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
have "real_of_int ((- 1) ^ m * fact m * Stirling (2 * n) m + P' m) / real (m + 1) =
              real_of_int ((- 1) ^ m * Stirling (2 * n) m) * (real (fact m) / (m + 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) = real_of_int ((- 1) ^ m * int (Stirling (2 * n) m)) * (real (fact m) / real (m + 1))
[PROOF STEP]
using composite
[PROOF STATE]
proof (prove)
using this:
\<not> prime (m + 1)

goal (1 subgoal):
 1. real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) = real_of_int ((- 1) ^ m * int (Stirling (2 * n) m)) * (real (fact m) / real (m + 1))
[PROOF STEP]
by (auto simp: P'_def)
[PROOF STATE]
proof (state)
this:
real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) = real_of_int ((- 1) ^ m * int (Stirling (2 * n) m)) * (real (fact m) / real (m + 1))

goal (2 subgoals):
 1. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 2. \<lbrakk>\<not> prime (m + 1); 3 < m\<rbrakk> \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) = real_of_int ((- 1) ^ m * int (Stirling (2 * n) m)) * (real (fact m) / real (m + 1))

goal (2 subgoals):
 1. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 2. \<lbrakk>\<not> prime (m + 1); 3 < m\<rbrakk> \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
have "\<dots> \<in> \<int>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_of_int ((- 1) ^ m * int (Stirling (2 * n) m)) * (real (fact m) / real (m + 1)) \<in> \<int>
[PROOF STEP]
by (intro Ints_mult Ints_real_of_nat_divide dvd) auto
[PROOF STATE]
proof (state)
this:
real_of_int ((- 1) ^ m * int (Stirling (2 * n) m)) * (real (fact m) / real (m + 1)) \<in> \<int>

goal (2 subgoals):
 1. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
 2. \<lbrakk>\<not> prime (m + 1); 3 < m\<rbrakk> \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>

goal (1 subgoal):
 1. real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>

goal (1 subgoal):
 1. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
assume prime: "prime (m + 1)"
[PROOF STATE]
proof (state)
this:
prime (m + 1)

goal (1 subgoal):
 1. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
have "real_of_int ((-1) ^ m * fact m * int (Stirling (2 * n) m)) =
              (\<Sum>j\<le>m. (-1) ^ m * (-1) ^ (m - j) * (m choose j) * real_of_int j ^ (2 * n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m)) = (\<Sum>j\<le>m. real_of_int ((- 1) ^ m * (- 1) ^ (m - j) * int (m choose j)) * real_of_int (int j) ^ (2 * n))
[PROOF STEP]
by (simp add: Stirling_closed_form sum_divide_distrib sum_distrib_left mult_ac)
[PROOF STATE]
proof (state)
this:
real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m)) = (\<Sum>j\<le>m. real_of_int ((- 1) ^ m * (- 1) ^ (m - j) * int (m choose j)) * real_of_int (int j) ^ (2 * n))

goal (1 subgoal):
 1. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m)) = (\<Sum>j\<le>m. real_of_int ((- 1) ^ m * (- 1) ^ (m - j) * int (m choose j)) * real_of_int (int j) ^ (2 * n))

goal (1 subgoal):
 1. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
have "\<dots> = real_of_int (\<Sum>j\<le>m. (-1) ^ j * (m choose j) * j ^ (2 * n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j\<le>m. real_of_int ((- 1) ^ m * (- 1) ^ (m - j) * int (m choose j)) * real_of_int (int j) ^ (2 * n)) = real_of_int (\<Sum>j\<le>m. (- 1) ^ j * int (m choose j) * int (j ^ (2 * n)))
[PROOF STEP]
unfolding of_int_sum
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j\<le>m. real_of_int ((- 1) ^ m * (- 1) ^ (m - j) * int (m choose j)) * real_of_int (int j) ^ (2 * n)) = (\<Sum>x\<le>m. real_of_int ((- 1) ^ x * int (m choose x) * int (x ^ (2 * n))))
[PROOF STEP]
by (intro sum.cong) (auto simp: uminus_power_if)
[PROOF STATE]
proof (state)
this:
(\<Sum>j\<le>m. real_of_int ((- 1) ^ m * (- 1) ^ (m - j) * int (m choose j)) * real_of_int (int j) ^ (2 * n)) = real_of_int (\<Sum>j\<le>m. (- 1) ^ j * int (m choose j) * int (j ^ (2 * n)))

goal (1 subgoal):
 1. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m)) = real_of_int (\<Sum>j\<le>m. (- 1) ^ j * int (m choose j) * int (j ^ (2 * n)))
[PROOF STEP]
have "(-1) ^ m * fact m * int (Stirling (2 * n) m) =
                      (\<Sum>j\<le>m. (-1) ^ j * (m choose j) * j ^ (2 * n))"
[PROOF STATE]
proof (prove)
using this:
real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m)) = real_of_int (\<Sum>j\<le>m. (- 1) ^ j * int (m choose j) * int (j ^ (2 * n)))

goal (1 subgoal):
 1. (- 1) ^ m * fact m * int (Stirling (2 * n) m) = (\<Sum>j\<le>m. (- 1) ^ j * int (m choose j) * int (j ^ (2 * n)))
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
(- 1) ^ m * fact m * int (Stirling (2 * n) m) = (\<Sum>j\<le>m. (- 1) ^ j * int (m choose j) * int (j ^ (2 * n)))

goal (1 subgoal):
 1. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(- 1) ^ m * fact m * int (Stirling (2 * n) m) = (\<Sum>j\<le>m. (- 1) ^ j * int (m choose j) * int (j ^ (2 * n)))

goal (1 subgoal):
 1. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
have "\<dots> = (\<Sum>j<m+1. (-1) ^ j * (m choose j) * j ^ (2 * n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j\<le>m. (- 1) ^ j * int (m choose j) * int (j ^ (2 * n))) = (\<Sum>j<m + 1. (- 1) ^ j * int (m choose j) * int (j ^ (2 * n)))
[PROOF STEP]
by (intro sum.cong) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>j\<le>m. (- 1) ^ j * int (m choose j) * int (j ^ (2 * n))) = (\<Sum>j<m + 1. (- 1) ^ j * int (m choose j) * int (j ^ (2 * n)))

goal (1 subgoal):
 1. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>j\<le>m. (- 1) ^ j * int (m choose j) * int (j ^ (2 * n))) = (\<Sum>j<m + 1. (- 1) ^ j * int (m choose j) * int (j ^ (2 * n)))

goal (1 subgoal):
 1. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
have "[\<dots> = (if m dvd 2 * n then - 1 else 0)] (mod (m + 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [\<Sum>j<m + 1. (- 1) ^ j * int (m choose j) * int (j ^ (2 * n)) = if m dvd 2 * n then - 1 else 0] (mod int (m + 1))
[PROOF STEP]
using vonStaudt_Clausen_lemma[of n "m + 1"] prime \<open>n > 0\<close>
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 < n; prime (m + 1)\<rbrakk> \<Longrightarrow> [\<Sum>ma<m + 1. (- 1) ^ ma * int (m + 1 - 1 choose ma) * int ma ^ (2 * n) = if m + 1 - 1 dvd 2 * n then - 1 else 0] (mod int (m + 1))
prime (m + 1)
0 < n

goal (1 subgoal):
 1. [\<Sum>j<m + 1. (- 1) ^ j * int (m choose j) * int (j ^ (2 * n)) = if m dvd 2 * n then - 1 else 0] (mod int (m + 1))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
[\<Sum>j<m + 1. (- 1) ^ j * int (m choose j) * int (j ^ (2 * n)) = if m dvd 2 * n then - 1 else 0] (mod int (m + 1))

goal (1 subgoal):
 1. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
[\<Sum>j<m + 1. (- 1) ^ j * int (m choose j) * int (j ^ (2 * n)) = if m dvd 2 * n then - 1 else 0] (mod int (m + 1))

goal (1 subgoal):
 1. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
have "(if m dvd 2 * n then - 1 else 0) = - P' m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if m dvd 2 * n then - 1 else 0) = - P' m
[PROOF STEP]
using prime
[PROOF STATE]
proof (prove)
using this:
prime (m + 1)

goal (1 subgoal):
 1. (if m dvd 2 * n then - 1 else 0) = - P' m
[PROOF STEP]
by (simp add: P'_def)
[PROOF STATE]
proof (state)
this:
(if m dvd 2 * n then - 1 else 0) = - P' m

goal (1 subgoal):
 1. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
[(- 1) ^ m * fact m * int (Stirling (2 * n) m) = - P' m] (mod int (m + 1))
[PROOF STEP]
have "int (m + 1) dvd ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m)"
[PROOF STATE]
proof (prove)
using this:
[(- 1) ^ m * fact m * int (Stirling (2 * n) m) = - P' m] (mod int (m + 1))

goal (1 subgoal):
 1. int (m + 1) dvd (- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m
[PROOF STEP]
by (simp add: cong_iff_dvd_diff)
[PROOF STATE]
proof (state)
this:
int (m + 1) dvd (- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m

goal (1 subgoal):
 1. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
hence "real_of_int ((-1)^m * fact m * int (Stirling (2*n) m) + P' m) / of_int (int (m+1)) \<in> \<int>"
[PROOF STATE]
proof (prove)
using this:
int (m + 1) dvd (- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m

goal (1 subgoal):
 1. real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real_of_int (int (m + 1)) \<in> \<int>
[PROOF STEP]
by (intro of_int_divide_in_Ints)
[PROOF STATE]
proof (state)
this:
real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real_of_int (int (m + 1)) \<in> \<int>

goal (1 subgoal):
 1. prime (m + 1) \<Longrightarrow> real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real_of_int (int (m + 1)) \<in> \<int>

goal (1 subgoal):
 1. real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1) \<in> \<int>

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>m\<le>2 * n. real_of_int ((- 1) ^ m * fact m * int (Stirling (2 * n) m) + P' m) / real (m + 1)) \<in> \<int>

goal (1 subgoal):
 1. bernoulli (2 * n) + (\<Sum>p | prime p \<and> p - 1 dvd 2 * n. 1 / real p) \<in> \<int>
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
bernoulli (2 * n) + (\<Sum>p | prime p \<and> p - 1 dvd 2 * n. 1 / real p) \<in> \<int>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
bernoulli (2 * n) + (\<Sum>p | prime p \<and> p - 1 dvd 2 * n. 1 / real p) \<in> \<int>

goal (1 subgoal):
 1. bernoulli (2 * n) + (\<Sum>p | prime p \<and> p - 1 dvd 2 * n. 1 / real p) \<in> \<int>
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
bernoulli (2 * n) + (\<Sum>p | prime p \<and> p - 1 dvd 2 * n. 1 / real p) \<in> \<int>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma encode12_inv1:
  assumes "i < d1" "j < d2"
  shows "encode1 (encode12 (i, j)) = i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. encode1 (encode12 (i, j)) = i
[PROOF STEP]
unfolding encode12.simps encode1_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. digit_decode dims1 (nths (digit_encode dims (digit_decode dims (weave vars (digit_encode dims1 i) (digit_encode dims2 j)))) vars) = i
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
i < d1
j < d2

goal (1 subgoal):
 1. digit_decode dims1 (nths (digit_encode dims (digit_decode dims (weave vars (digit_encode dims1 i) (digit_encode dims2 j)))) vars) = i
[PROOF STEP]
unfolding d1_def d2_def dims1_def dims2_def
[PROOF STATE]
proof (prove)
using this:
i < prod_list (nths dims vars)
j < prod_list (nths dims (- vars))

goal (1 subgoal):
 1. digit_decode (nths dims vars) (nths (digit_encode dims (digit_decode dims (weave vars (digit_encode (nths dims vars) i) (digit_encode (nths dims (- vars)) j)))) vars) = i
[PROOF STEP]
by (metis digit_decode_encode_lt digit_encode_decode digit_encode_valid_index valid_index_weave(1,2))


[STATEMENT]
lemma vector_derivative_of_real_left:
  assumes "f differentiable at x"
  shows   "vector_derivative (\<lambda>x. of_real (f x)) (at x) = of_real (deriv f x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vector_derivative (\<lambda>x. of_real (f x)) (at x) = of_real (deriv f x)
[PROOF STEP]
by (metis DERIV_deriv_iff_real_differentiable assms has_vector_derivative_of_real vector_derivative_at)


[STATEMENT]
lemma relf_congruent_rel: "refl (congruent_rel b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. refl (congruent_rel b)
[PROOF STEP]
unfolding refl_on_def congruent_rel_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(a, c). cong a c b} \<subseteq> UNIV \<times> UNIV \<and> (\<forall>x\<in>UNIV. (x, x) \<in> {(a, c). cong a c b})
[PROOF STEP]
unfolding cong_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(a, c). \<exists>k. a - c = b * k} \<subseteq> UNIV \<times> UNIV \<and> (\<forall>x\<in>UNIV. (x, x) \<in> {(a, c). \<exists>k. a - c = b * k})
[PROOF STEP]
by (auto, metis mult_zero_right)


[STATEMENT]
lemma list_assn_aux_append2[simp]:
  assumes "length l2=length l2'"
  shows "list_assn P (l1@l2) (l1'@l2')
    = list_assn P l1 l1' * list_assn P l2 l2'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. list_assn P (l1 @ l2) (l1' @ l2') = list_assn P l1 l1' * list_assn P l2 l2'
[PROOF STEP]
apply (cases "length l1 = length l1'")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. length l1 = length l1' \<Longrightarrow> list_assn P (l1 @ l2) (l1' @ l2') = list_assn P l1 l1' * list_assn P l2 l2'
 2. length l1 \<noteq> length l1' \<Longrightarrow> list_assn P (l1 @ l2) (l1' @ l2') = list_assn P l1 l1' * list_assn P l2 l2'
[PROOF STEP]
apply (erule list_assn_aux_append)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length l1 \<noteq> length l1' \<Longrightarrow> list_assn P (l1 @ l2) (l1' @ l2') = list_assn P l1 l1' * list_assn P l2 l2'
[PROOF STEP]
apply (simp add: list_assn_aux_ineq_len assms)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma poly_pos_leq:
  "(\<forall>x::real. x \<le> a \<longrightarrow> poly p x > 0) \<longleftrightarrow>
    poly_neg_inf p = 1 \<and> (\<forall>x. x \<le> a \<longrightarrow> poly p x \<noteq> 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x\<le>a. 0 < poly p x) = (poly_neg_inf p = 1 \<and> (\<forall>x\<le>a. poly p x \<noteq> 0))
[PROOF STEP]
proof (intro iffI conjI)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<forall>x\<le>a. 0 < poly p x \<Longrightarrow> poly_neg_inf p = 1
 2. \<forall>x\<le>a. 0 < poly p x \<Longrightarrow> \<forall>x\<le>a. poly p x \<noteq> 0
 3. poly_neg_inf p = 1 \<and> (\<forall>x\<le>a. poly p x \<noteq> 0) \<Longrightarrow> \<forall>x\<le>a. 0 < poly p x
[PROOF STEP]
assume A: "\<forall>x::real. x \<le> a \<longrightarrow> poly p x > 0"
[PROOF STATE]
proof (state)
this:
\<forall>x\<le>a. 0 < poly p x

goal (3 subgoals):
 1. \<forall>x\<le>a. 0 < poly p x \<Longrightarrow> poly_neg_inf p = 1
 2. \<forall>x\<le>a. 0 < poly p x \<Longrightarrow> \<forall>x\<le>a. poly p x \<noteq> 0
 3. poly_neg_inf p = 1 \<and> (\<forall>x\<le>a. poly p x \<noteq> 0) \<Longrightarrow> \<forall>x\<le>a. 0 < poly p x
[PROOF STEP]
hence "\<forall>x::real. x < a \<longrightarrow> poly p x > 0"
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<le>a. 0 < poly p x

goal (1 subgoal):
 1. \<forall>x<a. 0 < poly p x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<forall>x<a. 0 < poly p x

goal (3 subgoals):
 1. \<forall>x\<le>a. 0 < poly p x \<Longrightarrow> poly_neg_inf p = 1
 2. \<forall>x\<le>a. 0 < poly p x \<Longrightarrow> \<forall>x\<le>a. poly p x \<noteq> 0
 3. poly_neg_inf p = 1 \<and> (\<forall>x\<le>a. poly p x \<noteq> 0) \<Longrightarrow> \<forall>x\<le>a. 0 < poly p x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<forall>x<a. 0 < poly p x

goal (3 subgoals):
 1. \<forall>x\<le>a. 0 < poly p x \<Longrightarrow> poly_neg_inf p = 1
 2. \<forall>x\<le>a. 0 < poly p x \<Longrightarrow> \<forall>x\<le>a. poly p x \<noteq> 0
 3. poly_neg_inf p = 1 \<and> (\<forall>x\<le>a. poly p x \<noteq> 0) \<Longrightarrow> \<forall>x\<le>a. 0 < poly p x
[PROOF STEP]
note poly_pos_less
[PROOF STATE]
proof (state)
this:
(\<forall>x<?a. 0 < poly ?p x) = (poly_neg_inf ?p = 1 \<and> (\<forall>x<?a. poly ?p x \<noteq> 0))

goal (3 subgoals):
 1. \<forall>x\<le>a. 0 < poly p x \<Longrightarrow> poly_neg_inf p = 1
 2. \<forall>x\<le>a. 0 < poly p x \<Longrightarrow> \<forall>x\<le>a. poly p x \<noteq> 0
 3. poly_neg_inf p = 1 \<and> (\<forall>x\<le>a. poly p x \<noteq> 0) \<Longrightarrow> \<forall>x\<le>a. 0 < poly p x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
poly_neg_inf p = 1 \<and> (\<forall>x<a. poly p x \<noteq> 0)
[PROOF STEP]
have "poly_neg_inf p = 1" "(\<forall>x<a. poly p x \<noteq> 0)"
[PROOF STATE]
proof (prove)
using this:
poly_neg_inf p = 1 \<and> (\<forall>x<a. poly p x \<noteq> 0)

goal (1 subgoal):
 1. poly_neg_inf p = 1 &&& \<forall>x<a. poly p x \<noteq> 0
[PROOF STEP]
by simp_all
[PROOF STATE]
proof (state)
this:
poly_neg_inf p = 1
\<forall>x<a. poly p x \<noteq> 0

goal (3 subgoals):
 1. \<forall>x\<le>a. 0 < poly p x \<Longrightarrow> poly_neg_inf p = 1
 2. \<forall>x\<le>a. 0 < poly p x \<Longrightarrow> \<forall>x\<le>a. poly p x \<noteq> 0
 3. poly_neg_inf p = 1 \<and> (\<forall>x\<le>a. poly p x \<noteq> 0) \<Longrightarrow> \<forall>x\<le>a. 0 < poly p x
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
poly_neg_inf p = 1
\<forall>x<a. poly p x \<noteq> 0

goal (3 subgoals):
 1. \<forall>x\<le>a. 0 < poly p x \<Longrightarrow> poly_neg_inf p = 1
 2. \<forall>x\<le>a. 0 < poly p x \<Longrightarrow> \<forall>x\<le>a. poly p x \<noteq> 0
 3. poly_neg_inf p = 1 \<and> (\<forall>x\<le>a. poly p x \<noteq> 0) \<Longrightarrow> \<forall>x\<le>a. 0 < poly p x
[PROOF STEP]
from A
[PROOF STATE]
proof (chain)
picking this:
\<forall>x\<le>a. 0 < poly p x
[PROOF STEP]
have "poly p a > 0"
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<le>a. 0 < poly p x

goal (1 subgoal):
 1. 0 < poly p a
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 < poly p a

goal (3 subgoals):
 1. \<forall>x\<le>a. 0 < poly p x \<Longrightarrow> poly_neg_inf p = 1
 2. \<forall>x\<le>a. 0 < poly p x \<Longrightarrow> \<forall>x\<le>a. poly p x \<noteq> 0
 3. poly_neg_inf p = 1 \<and> (\<forall>x\<le>a. poly p x \<noteq> 0) \<Longrightarrow> \<forall>x\<le>a. 0 < poly p x
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
poly_neg_inf p = 1
\<forall>x<a. poly p x \<noteq> 0
0 < poly p a
[PROOF STEP]
show "poly_neg_inf p = 1" "\<forall>x\<le>a. poly p x \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
poly_neg_inf p = 1
\<forall>x<a. poly p x \<noteq> 0
0 < poly p a

goal (1 subgoal):
 1. poly_neg_inf p = 1 &&& \<forall>x\<le>a. poly p x \<noteq> 0
[PROOF STEP]
by (auto simp: less_eq_real_def)
[PROOF STATE]
proof (state)
this:
poly_neg_inf p = 1
\<forall>x\<le>a. poly p x \<noteq> 0

goal (1 subgoal):
 1. poly_neg_inf p = 1 \<and> (\<forall>x\<le>a. poly p x \<noteq> 0) \<Longrightarrow> \<forall>x\<le>a. 0 < poly p x
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. poly_neg_inf p = 1 \<and> (\<forall>x\<le>a. poly p x \<noteq> 0) \<Longrightarrow> \<forall>x\<le>a. 0 < poly p x
[PROOF STEP]
assume "poly_neg_inf p = 1 \<and> (\<forall>x. x \<le> a \<longrightarrow> poly p x \<noteq> 0)"
[PROOF STATE]
proof (state)
this:
poly_neg_inf p = 1 \<and> (\<forall>x\<le>a. poly p x \<noteq> 0)

goal (1 subgoal):
 1. poly_neg_inf p = 1 \<and> (\<forall>x\<le>a. poly p x \<noteq> 0) \<Longrightarrow> \<forall>x\<le>a. 0 < poly p x
[PROOF STEP]
hence A: "poly_neg_inf p = 1" and
        B: "poly p a \<noteq> 0" and C: "\<forall>x<a. poly p x \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
poly_neg_inf p = 1 \<and> (\<forall>x\<le>a. poly p x \<noteq> 0)

goal (1 subgoal):
 1. poly_neg_inf p = 1 &&& poly p a \<noteq> 0 &&& \<forall>x<a. poly p x \<noteq> 0
[PROOF STEP]
by simp_all
[PROOF STATE]
proof (state)
this:
poly_neg_inf p = 1
poly p a \<noteq> 0
\<forall>x<a. poly p x \<noteq> 0

goal (1 subgoal):
 1. poly_neg_inf p = 1 \<and> (\<forall>x\<le>a. poly p x \<noteq> 0) \<Longrightarrow> \<forall>x\<le>a. 0 < poly p x
[PROOF STEP]
from A and C and poly_pos_less
[PROOF STATE]
proof (chain)
picking this:
poly_neg_inf p = 1
\<forall>x<a. poly p x \<noteq> 0
(\<forall>x<?a. 0 < poly ?p x) = (poly_neg_inf ?p = 1 \<and> (\<forall>x<?a. poly ?p x \<noteq> 0))
[PROOF STEP]
have "\<forall>x<a. poly p x > 0"
[PROOF STATE]
proof (prove)
using this:
poly_neg_inf p = 1
\<forall>x<a. poly p x \<noteq> 0
(\<forall>x<?a. 0 < poly ?p x) = (poly_neg_inf ?p = 1 \<and> (\<forall>x<?a. poly ?p x \<noteq> 0))

goal (1 subgoal):
 1. \<forall>x<a. 0 < poly p x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<forall>x<a. 0 < poly p x

goal (1 subgoal):
 1. poly_neg_inf p = 1 \<and> (\<forall>x\<le>a. poly p x \<noteq> 0) \<Longrightarrow> \<forall>x\<le>a. 0 < poly p x
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<forall>x<a. 0 < poly p x

goal (1 subgoal):
 1. poly_neg_inf p = 1 \<and> (\<forall>x\<le>a. poly p x \<noteq> 0) \<Longrightarrow> \<forall>x\<le>a. 0 < poly p x
[PROOF STEP]
with B C poly_IVT_neg[of "a - 1" a p]
[PROOF STATE]
proof (chain)
picking this:
poly p a \<noteq> 0
\<forall>x<a. poly p x \<noteq> 0
\<lbrakk>a - 1 < a; 0 < poly p (a - 1); poly p a < 0\<rbrakk> \<Longrightarrow> \<exists>x>a - 1. x < a \<and> poly p x = 0
\<forall>x<a. 0 < poly p x
[PROOF STEP]
have "poly p a > 0"
[PROOF STATE]
proof (prove)
using this:
poly p a \<noteq> 0
\<forall>x<a. poly p x \<noteq> 0
\<lbrakk>a - 1 < a; 0 < poly p (a - 1); poly p a < 0\<rbrakk> \<Longrightarrow> \<exists>x>a - 1. x < a \<and> poly p x = 0
\<forall>x<a. 0 < poly p x

goal (1 subgoal):
 1. 0 < poly p a
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
0 < poly p a

goal (1 subgoal):
 1. poly_neg_inf p = 1 \<and> (\<forall>x\<le>a. poly p x \<noteq> 0) \<Longrightarrow> \<forall>x\<le>a. 0 < poly p x
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<forall>x<a. 0 < poly p x
0 < poly p a
[PROOF STEP]
show "\<forall>x\<le>a. poly p x > 0"
[PROOF STATE]
proof (prove)
using this:
\<forall>x<a. 0 < poly p x
0 < poly p a

goal (1 subgoal):
 1. \<forall>x\<le>a. 0 < poly p x
[PROOF STEP]
by (auto simp: less_eq_real_def)
[PROOF STATE]
proof (state)
this:
\<forall>x\<le>a. 0 < poly p x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma inverse_prod_list_field:
  "prod_list (map (\<lambda>x. inverse (f x)) xs) = inverse (prod_list (map f xs :: _ :: field list))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>x\<leftarrow>xs. inverse (f x)) = inverse (prod_list (map f xs))
[PROOF STEP]
by (induction xs) simp_all


[STATEMENT]
lemma (in padic_integers) residue_1_unit:
  assumes "m > 0"
  shows "1 \<in> Units (Zp_res_ring m)"
        "\<one>\<^bsub>Zp_res_ring m\<^esub> \<in> Units (Zp_res_ring m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 \<in> Units (residue_ring (p ^ m)) &&& \<one>\<^bsub>residue_ring (p ^ m)\<^esub> \<in> Units (residue_ring (p ^ m))
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 1 \<in> Units (residue_ring (p ^ m))
 2. \<one>\<^bsub>residue_ring (p ^ m)\<^esub> \<in> Units (residue_ring (p ^ m))
[PROOF STEP]
have 0: "group (units_of (Zp_res_ring m))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Group.group (units_of (residue_ring (p ^ m)))
[PROOF STEP]
using assms(1) cring_def monoid.units_group padic_integers.R_cring
          padic_integers_axioms ring_def
[PROOF STATE]
proof (prove)
using this:
0 < m
cring ?R \<equiv> ring ?R \<and> Group.comm_monoid ?R
Group.monoid ?G \<Longrightarrow> Group.group (units_of ?G)
\<lbrakk>padic_integers ?p; 0 < ?m\<rbrakk> \<Longrightarrow> cring (residue_ring (?p ^ ?m))
padic_integers p
ring ?R \<equiv> abelian_group ?R \<and> Group.monoid ?R \<and> ring_axioms ?R

goal (1 subgoal):
 1. Group.group (units_of (residue_ring (p ^ m)))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
Group.group (units_of (residue_ring (p ^ m)))

goal (2 subgoals):
 1. 1 \<in> Units (residue_ring (p ^ m))
 2. \<one>\<^bsub>residue_ring (p ^ m)\<^esub> \<in> Units (residue_ring (p ^ m))
[PROOF STEP]
have 1: "1 = \<one>\<^bsub>units_of (Zp_res_ring m)\<^esub>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 = \<one>\<^bsub>units_of (residue_ring (p ^ m))\<^esub>
[PROOF STEP]
by (simp add: residue_ring_def units_of_def)
[PROOF STATE]
proof (state)
this:
1 = \<one>\<^bsub>units_of (residue_ring (p ^ m))\<^esub>

goal (2 subgoals):
 1. 1 \<in> Units (residue_ring (p ^ m))
 2. \<one>\<^bsub>residue_ring (p ^ m)\<^esub> \<in> Units (residue_ring (p ^ m))
[PROOF STEP]
have "\<one>\<^bsub>units_of (Zp_res_ring m)\<^esub> \<in> carrier (units_of (Zp_res_ring m))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<one>\<^bsub>units_of (residue_ring (p ^ m))\<^esub> \<in> carrier (units_of (residue_ring (p ^ m)))
[PROOF STEP]
using 0 Group.monoid.intro[of "units_of (Zp_res_ring m)"]
[PROOF STATE]
proof (prove)
using this:
Group.group (units_of (residue_ring (p ^ m)))
\<lbrakk>\<And>x y. \<lbrakk>x \<in> carrier (units_of (residue_ring (p ^ m))); y \<in> carrier (units_of (residue_ring (p ^ m)))\<rbrakk> \<Longrightarrow> x \<otimes>\<^bsub>units_of (residue_ring (p ^ m))\<^esub> y \<in> carrier (units_of (residue_ring (p ^ m))); \<And>x y z. \<lbrakk>x \<in> carrier (units_of (residue_ring (p ^ m))); y \<in> carrier (units_of (residue_ring (p ^ m))); z \<in> carrier (units_of (residue_ring (p ^ m)))\<rbrakk> \<Longrightarrow> x \<otimes>\<^bsub>units_of (residue_ring (p ^ m))\<^esub> y \<otimes>\<^bsub>units_of (residue_ring (p ^ m))\<^esub> z = x \<otimes>\<^bsub>units_of (residue_ring (p ^ m))\<^esub> (y \<otimes>\<^bsub>units_of (residue_ring (p ^ m))\<^esub> z); \<one>\<^bsub>units_of (residue_ring (p ^ m))\<^esub> \<in> carrier (units_of (residue_ring (p ^ m))); \<And>x. x \<in> carrier (units_of (residue_ring (p ^ m))) \<Longrightarrow> \<one>\<^bsub>units_of (residue_ring (p ^ m))\<^esub> \<otimes>\<^bsub>units_of (residue_ring (p ^ m))\<^esub> x = x; \<And>x. x \<in> carrier (units_of (residue_ring (p ^ m))) \<Longrightarrow> x \<otimes>\<^bsub>units_of (residue_ring (p ^ m))\<^esub> \<one>\<^bsub>units_of (residue_ring (p ^ m))\<^esub> = x\<rbrakk> \<Longrightarrow> Group.monoid (units_of (residue_ring (p ^ m)))

goal (1 subgoal):
 1. \<one>\<^bsub>units_of (residue_ring (p ^ m))\<^esub> \<in> carrier (units_of (residue_ring (p ^ m)))
[PROOF STEP]
by (simp add: group.is_monoid)
[PROOF STATE]
proof (state)
this:
\<one>\<^bsub>units_of (residue_ring (p ^ m))\<^esub> \<in> carrier (units_of (residue_ring (p ^ m)))

goal (2 subgoals):
 1. 1 \<in> Units (residue_ring (p ^ m))
 2. \<one>\<^bsub>residue_ring (p ^ m)\<^esub> \<in> Units (residue_ring (p ^ m))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<one>\<^bsub>units_of (residue_ring (p ^ m))\<^esub> \<in> carrier (units_of (residue_ring (p ^ m)))
[PROOF STEP]
show "1 \<in> Units (Zp_res_ring m)"
[PROOF STATE]
proof (prove)
using this:
\<one>\<^bsub>units_of (residue_ring (p ^ m))\<^esub> \<in> carrier (units_of (residue_ring (p ^ m)))

goal (1 subgoal):
 1. 1 \<in> Units (residue_ring (p ^ m))
[PROOF STEP]
using 1
[PROOF STATE]
proof (prove)
using this:
\<one>\<^bsub>units_of (residue_ring (p ^ m))\<^esub> \<in> carrier (units_of (residue_ring (p ^ m)))
1 = \<one>\<^bsub>units_of (residue_ring (p ^ m))\<^esub>

goal (1 subgoal):
 1. 1 \<in> Units (residue_ring (p ^ m))
[PROOF STEP]
by (simp add: units_of_carrier)
[PROOF STATE]
proof (state)
this:
1 \<in> Units (residue_ring (p ^ m))

goal (1 subgoal):
 1. \<one>\<^bsub>residue_ring (p ^ m)\<^esub> \<in> Units (residue_ring (p ^ m))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
1 \<in> Units (residue_ring (p ^ m))
[PROOF STEP]
show " \<one>\<^bsub>Zp_res_ring m\<^esub> \<in> Units (Zp_res_ring m) "
[PROOF STATE]
proof (prove)
using this:
1 \<in> Units (residue_ring (p ^ m))

goal (1 subgoal):
 1. \<one>\<^bsub>residue_ring (p ^ m)\<^esub> \<in> Units (residue_ring (p ^ m))
[PROOF STEP]
by (simp add: "1" units_of_one)
[PROOF STATE]
proof (state)
this:
\<one>\<^bsub>residue_ring (p ^ m)\<^esub> \<in> Units (residue_ring (p ^ m))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fds_of_real_0 [simp]: "fds_of_real 0 = 0"
  and fds_of_real_1 [simp]: "fds_of_real 1 = 1"
  and fds_of_real_const [simp]: "fds_of_real (fds_const c) = fds_const (of_real c)"
  and fds_of_real_minus [simp]: "fds_of_real (-f) = -fds_of_real f"
  and fds_of_real_add [simp]: "fds_of_real (f + g) = fds_of_real f + fds_of_real g"
  and fds_of_real_mult [simp]: "fds_of_real (f * g) = fds_of_real f * fds_of_real g"
  and fds_of_real_deriv [simp]: "fds_of_real (fds_deriv f) = fds_deriv (fds_of_real f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (fds_of_real 0 = 0 &&& fds_of_real 1 = 1 &&& fds_of_real (fds_const c) = fds_const (of_real c)) &&& (fds_of_real (- f) = - fds_of_real f &&& fds_of_real (f + g) = fds_of_real f + fds_of_real g) &&& fds_of_real (f * g) = fds_of_real f * fds_of_real g &&& fds_of_real (fds_deriv f) = fds_deriv (fds_of_real f)
[PROOF STEP]
by (simp_all add: fds_eq_iff one_fds_def fds_const_def fds_nth_mult
                    dirichlet_prod_def fds_deriv_def scaleR_conv_of_real)


[STATEMENT]
lemma not_UINF_ind: "(\<not> (\<Sqinter> i \<bullet> P(i))) = (\<Squnion> i \<bullet> \<not> P(i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<not> (\<Sqinter> i \<bullet> P i)) = (\<Squnion> i \<bullet> \<not> P i)
[PROOF STEP]
by (pred_auto)


[STATEMENT]
lemma has_derivative_at2: "(f has_derivative f') (at x) \<longleftrightarrow>
    bounded_linear f' \<and> ((\<lambda>y. (1 / (norm(y - x))) *\<^sub>R (f y - (f x + f' (y - x)))) \<longlongrightarrow> 0) (at x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f has_derivative f') (at x) = (bounded_linear f' \<and> (\<lambda>y. (1 / norm (y - x)) *\<^sub>R (f y - (f x + f' (y - x)))) \<midarrow>x\<rightarrow> (0::'b))
[PROOF STEP]
using has_derivative_within [of f f' x UNIV]
[PROOF STATE]
proof (prove)
using this:
(f has_derivative f') (at x) = (bounded_linear f' \<and> (\<lambda>y. (1 / norm (y - x)) *\<^sub>R (f y - (f x + f' (y - x)))) \<midarrow>x\<rightarrow> (0::'b))

goal (1 subgoal):
 1. (f has_derivative f') (at x) = (bounded_linear f' \<and> (\<lambda>y. (1 / norm (y - x)) *\<^sub>R (f y - (f x + f' (y - x)))) \<midarrow>x\<rightarrow> (0::'b))
[PROOF STEP]
by simp


[STATEMENT]
lemma frac_idempotent: "frac (frac x) = frac x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. frac (frac x) = frac x
[PROOF STEP]
by (simp add: frac_eq frac_lt_1)


[STATEMENT]
lemma subset_imp_less_mset: "A \<subset># B \<Longrightarrow> A < B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<subset># B \<Longrightarrow> A < B
[PROOF STEP]
by (simp add: order.not_eq_order_implies_strict subset_eq_imp_le_multiset)


[STATEMENT]
lemma filterlim_at_top_mult_tendsto_pos:
  assumes f: "(f \<longlongrightarrow> c) F"
    and c: "0 < c"
    and g: "LIM x F. g x :> at_top"
  shows "LIM x F. (g x * f x:: real) :> at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LIM x F. g x * f x :> at_top
[PROOF STEP]
by (auto simp: mult.commute intro!: filterlim_tendsto_pos_mult_at_top f c g)


[STATEMENT]
lemma unionImage:
  assumes "runiq a"
  shows "{(x, {y})| x y. y \<in> \<Union> (a``{x}) & x \<in> Domain a} =
         {(x, {y})| x y. y \<in> a,,x & x \<in> Domain a}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(x, {y}) |x y. y \<in> a ,,, x \<and> x \<in> Domain a} = {(x, {y}) |x y. y \<in> a ,, x \<and> x \<in> Domain a}
[PROOF STEP]
using assms Image_runiq_eq_eval
[PROOF STATE]
proof (prove)
using this:
runiq a
\<lbrakk>?x \<in> Domain ?R; runiq ?R\<rbrakk> \<Longrightarrow> ?R `` {?x} = {?R ,, ?x}

goal (1 subgoal):
 1. {(x, {y}) |x y. y \<in> a ,,, x \<and> x \<in> Domain a} = {(x, {y}) |x y. y \<in> a ,, x \<and> x \<in> Domain a}
[PROOF STEP]
by (metis (lifting, no_types) cSup_singleton)


[STATEMENT]
theorem states_of_se_assign :
  assumes "se c (Assign v e) c'"
  shows   "states c' = {\<sigma> (v := e \<sigma>) | \<sigma>. \<sigma> \<in> states c}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. states c' = {\<sigma>(v := e \<sigma>) |\<sigma>. \<sigma> \<in> states c}
[PROOF STEP]
using assms states_of_se_assign1 states_of_se_assign2
[PROOF STATE]
proof (prove)
using this:
se c (Assign v e) c'
\<lbrakk>se ?c (Assign ?v ?e) ?c'; ?\<sigma>' \<in> states ?c'\<rbrakk> \<Longrightarrow> \<exists>\<sigma>\<in>states ?c. ?\<sigma>' = \<sigma>(?v := ?e \<sigma>)
\<lbrakk>se ?c (Assign ?v ?e) ?c'; \<exists>\<sigma>\<in>states ?c. ?\<sigma>' = \<sigma>(?v := ?e \<sigma>)\<rbrakk> \<Longrightarrow> ?\<sigma>' \<in> states ?c'

goal (1 subgoal):
 1. states c' = {\<sigma>(v := e \<sigma>) |\<sigma>. \<sigma> \<in> states c}
[PROOF STEP]
by fast


[STATEMENT]
lemma fset_eq_empty_iff: "M = {||} \<longleftrightarrow> (\<forall>x. x |\<notin>| M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (M = {||}) = (\<forall>x. x |\<notin>| M)
[PROOF STEP]
by auto


[STATEMENT]
lemma space_pair_measure:
  "space (A \<Otimes>\<^sub>M B) = space A \<times> space B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. space (A \<Otimes>\<^sub>M B) = space A \<times> space B
[PROOF STEP]
unfolding pair_measure_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. space (measure_of (space A \<times> space B) {a \<times> b |a b. a \<in> sets A \<and> b \<in> sets B} (\<lambda>X. \<integral>\<^sup>+ x. \<integral>\<^sup>+ y. indicator X (x, y) \<partial>B \<partial>A)) = space A \<times> space B
[PROOF STEP]
using pair_measure_closed[of A B]
[PROOF STATE]
proof (prove)
using this:
{a \<times> b |a b. a \<in> sets A \<and> b \<in> sets B} \<subseteq> Pow (space A \<times> space B)

goal (1 subgoal):
 1. space (measure_of (space A \<times> space B) {a \<times> b |a b. a \<in> sets A \<and> b \<in> sets B} (\<lambda>X. \<integral>\<^sup>+ x. \<integral>\<^sup>+ y. indicator X (x, y) \<partial>B \<partial>A)) = space A \<times> space B
[PROOF STEP]
by (rule space_measure_of)


[STATEMENT]
lemma inv_join:
  "\<lbrakk> invh l; invh r; bheight l = bheight r; invc l; invc r \<rbrakk>
  \<Longrightarrow> invh (join l r) \<and> bheight (join l r) = bheight l
  \<and> invc2 (join l r) \<and> (color l = Black \<and> color r = Black \<longrightarrow> invc (join l r))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>invh l; invh r; bheight l = bheight r; invc l; invc r\<rbrakk> \<Longrightarrow> invh (join l r) \<and> bheight (join l r) = bheight l \<and> invc2 (join l r) \<and> (color l = Black \<and> color r = Black \<longrightarrow> invc (join l r))
[PROOF STEP]
by (induct l r rule: join.induct)
   (auto simp: invh_baldL_Black inv_baldL invc2I split: tree.splits color.splits)


[STATEMENT]
lemma C_to_CValue_reach: "(\<Squnion> n. C_to_CValue_take n\<cdot>x) = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Squnion>n. C_to_CValue_take n\<cdot>x) = x
[PROOF STEP]
by (auto intro:  cfun_eqI simp add: contlub_cfun_fun[OF ch2ch_Rep_cfunL[OF C_to_CValue_chain_take]]  CValue.reach)


[STATEMENT]
theorem p15: "(p \<longrightarrow> q) \<longleftrightarrow> (\<not>p \<or> q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (p \<longrightarrow> q) = (\<not> p \<or> q)
[PROOF STEP]
by auto2


[STATEMENT]
lemma "10000001 mod 2 = (1::int)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 10000001 mod 2 = 1
[PROOF STEP]
by simp