[STATEMENT]
theorem ramanujan_sum_dirichlet_form:
  fixes k n :: nat
  assumes "k > 0"
  shows "c k n = (\<Sum>d | d dvd gcd n k. d * moebius_mu (k div d))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))
[PROOF STEP]
define a :: "nat \<Rightarrow> nat \<Rightarrow> complex"
    where "a  =  (\<lambda>k m.
   1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d))"
[PROOF STATE]
proof (state)
this:
a = (\<lambda>k m. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d))

goal (1 subgoal):
 1. c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
a = (\<lambda>k m. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d))

goal (1 subgoal):
 1. c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))
[PROOF STEP]
fix m
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))
[PROOF STEP]
have "a k m = (if gcd m k = 1 then 1 else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a k m = (if gcd m k = 1 then 1 else 0)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a k m = (if gcd m k = 1 then 1 else 0)
[PROOF STEP]
have "a k m = 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a k m = 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d)
[PROOF STEP]
unfolding a_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d) = 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
a k m = 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d)

goal (1 subgoal):
 1. a k m = (if gcd m k = 1 then 1 else 0)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
a k m = 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d)

goal (1 subgoal):
 1. a k m = (if gcd m k = 1 then 1 else 0)
[PROOF STEP]
have 2: "\<dots> = 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d) = 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat k)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d) = 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat k)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d) = 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat k)
[PROOF STEP]
fix d :: nat
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d) = 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat k)
[PROOF STEP]
assume dvd: "d dvd gcd m k"
[PROOF STATE]
proof (state)
this:
d dvd gcd m k

goal (1 subgoal):
 1. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d) = 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat k)
[PROOF STEP]
have "moebius_mu d * of_nat (k div d) * of_nat d = moebius_mu d * of_nat k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. moebius_mu d * of_nat (k div d) * of_nat d = moebius_mu d * of_nat k
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. moebius_mu d * of_nat (k div d) * of_nat d = moebius_mu d * of_nat k
[PROOF STEP]
have "(k div d) * d = k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k div d * d = k
[PROOF STEP]
using dvd
[PROOF STATE]
proof (prove)
using this:
d dvd gcd m k

goal (1 subgoal):
 1. k div d * d = k
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
k div d * d = k

goal (1 subgoal):
 1. moebius_mu d * of_nat (k div d) * of_nat d = moebius_mu d * of_nat k
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
k div d * d = k
[PROOF STEP]
show "moebius_mu d * of_nat (k div d) * of_nat d = moebius_mu d * of_nat k"
[PROOF STATE]
proof (prove)
using this:
k div d * d = k

goal (1 subgoal):
 1. moebius_mu d * of_nat (k div d) * of_nat d = moebius_mu d * of_nat k
[PROOF STEP]
by (simp add: algebra_simps,subst of_nat_mult[symmetric],simp)
[PROOF STATE]
proof (state)
this:
moebius_mu d * of_nat (k div d) * of_nat d = moebius_mu d * of_nat k

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
moebius_mu d * of_nat (k div d) * of_nat d = moebius_mu d * of_nat k

goal (1 subgoal):
 1. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d) = 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat k)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?d4 dvd gcd m k \<Longrightarrow> moebius_mu ?d4 * of_nat (k div ?d4) * of_nat ?d4 = moebius_mu ?d4 * of_nat k

goal (1 subgoal):
 1. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d) = 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat k)
[PROOF STEP]
note eq = this
[PROOF STATE]
proof (state)
this:
?d4 dvd gcd m k \<Longrightarrow> moebius_mu ?d4 * of_nat (k div ?d4) * of_nat ?d4 = moebius_mu ?d4 * of_nat k

goal (1 subgoal):
 1. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d) = 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat k)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d) = 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat k)
[PROOF STEP]
using sum.cong
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?A = ?B; \<And>x. x \<in> ?B \<Longrightarrow> ?g x = ?h x\<rbrakk> \<Longrightarrow> sum ?g ?A = sum ?h ?B

goal (1 subgoal):
 1. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d) = 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat k)
[PROOF STEP]
by (simp add: eq)
[PROOF STATE]
proof (state)
this:
1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d) = 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat k)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d) = 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat k)

goal (1 subgoal):
 1. a k m = (if gcd m k = 1 then 1 else 0)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d) = 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat k)

goal (1 subgoal):
 1. a k m = (if gcd m k = 1 then 1 else 0)
[PROOF STEP]
have 3: "\<dots> = (\<Sum>d | d dvd gcd m k. moebius_mu d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat k) = (\<Sum>d | d dvd gcd m k. moebius_mu d)
[PROOF STEP]
by (simp add: sum_distrib_left assms)
[PROOF STATE]
proof (state)
this:
1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat k) = (\<Sum>d | d dvd gcd m k. moebius_mu d)

goal (1 subgoal):
 1. a k m = (if gcd m k = 1 then 1 else 0)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat k) = (\<Sum>d | d dvd gcd m k. moebius_mu d)

goal (1 subgoal):
 1. a k m = (if gcd m k = 1 then 1 else 0)
[PROOF STEP]
have 4: "\<dots> =  (if gcd m k = 1 then 1 else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>d | d dvd gcd m k. moebius_mu d) = (if gcd m k = 1 then 1 else 0)
[PROOF STEP]
using sum_moebius_mu_divisors'
[PROOF STATE]
proof (prove)
using this:
(\<Sum>d | d dvd ?n. moebius_mu d) = (if ?n = 1 then 1::?'a else (0::?'a))

goal (1 subgoal):
 1. (\<Sum>d | d dvd gcd m k. moebius_mu d) = (if gcd m k = 1 then 1 else 0)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd gcd m k. moebius_mu d) = (if gcd m k = 1 then 1 else 0)

goal (1 subgoal):
 1. a k m = (if gcd m k = 1 then 1 else 0)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
a k m = (if gcd m k = 1 then 1 else 0)
[PROOF STEP]
show "a k m  = (if gcd m k = 1 then 1 else 0)"
[PROOF STATE]
proof (prove)
using this:
a k m = (if gcd m k = 1 then 1 else 0)

goal (1 subgoal):
 1. a k m = (if gcd m k = 1 then 1 else 0)
[PROOF STEP]
using coprime_def
[PROOF STATE]
proof (prove)
using this:
a k m = (if gcd m k = 1 then 1 else 0)
coprime ?a ?b = (\<forall>c. c dvd ?a \<longrightarrow> c dvd ?b \<longrightarrow> is_unit c)

goal (1 subgoal):
 1. a k m = (if gcd m k = 1 then 1 else 0)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
a k m = (if gcd m k = 1 then 1 else 0)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
a k m = (if gcd m k = 1 then 1 else 0)

goal (1 subgoal):
 1. c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
a k ?m2 = (if gcd ?m2 k = 1 then 1 else 0)

goal (1 subgoal):
 1. c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))
[PROOF STEP]
note a_expr = this
[PROOF STATE]
proof (state)
this:
a k ?m2 = (if gcd ?m2 k = 1 then 1 else 0)

goal (1 subgoal):
 1. c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))
[PROOF STEP]
let ?f = "(\<lambda>m. (if gcd m k = 1 then 1 else 0) *
                 unity_root k (int m * n))"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))
[PROOF STEP]
from gen_ramanujan_sum_fourier_expansion[of k id moebius_mu n] assms
[PROOF STATE]
proof (chain)
picking this:
0 < k \<Longrightarrow> s (\<lambda>x. of_nat (id x)) moebius_mu k n = (\<Sum>m\<le>k - 1. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (id (k div d)) * of_nat d) * unity_root k (int m * int n))
0 < k
[PROOF STEP]
have "s (\<lambda>x. of_nat (id x)) moebius_mu k n =
  (\<Sum>m\<le>k - 1.
      1 / of_nat k *
      (\<Sum>d | d dvd gcd m k.
         moebius_mu d * of_nat (k div d) * of_nat d) *
      unity_root k (int m * n))"
[PROOF STATE]
proof (prove)
using this:
0 < k \<Longrightarrow> s (\<lambda>x. of_nat (id x)) moebius_mu k n = (\<Sum>m\<le>k - 1. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (id (k div d)) * of_nat d) * unity_root k (int m * int n))
0 < k

goal (1 subgoal):
 1. s (\<lambda>x. of_nat (id x)) moebius_mu k n = (\<Sum>m\<le>k - 1. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d) * unity_root k (int m * int n))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
s (\<lambda>x. of_nat (id x)) moebius_mu k n = (\<Sum>m\<le>k - 1. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d) * unity_root k (int m * int n))

goal (1 subgoal):
 1. c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
s (\<lambda>x. of_nat (id x)) moebius_mu k n = (\<Sum>m\<le>k - 1. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d) * unity_root k (int m * int n))

goal (1 subgoal):
 1. c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))
[PROOF STEP]
have "\<dots> = (\<Sum>m\<le>k - 1.
      a k m *
      unity_root k (int m * n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m\<le>k - 1. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d) * unity_root k (int m * int n)) = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
using a_def
[PROOF STATE]
proof (prove)
using this:
a = (\<lambda>k m. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d))

goal (1 subgoal):
 1. (\<Sum>m\<le>k - 1. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d) * unity_root k (int m * int n)) = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(\<Sum>m\<le>k - 1. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d) * unity_root k (int m * int n)) = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))

goal (1 subgoal):
 1. c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>m\<le>k - 1. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. moebius_mu d * of_nat (k div d) * of_nat d) * unity_root k (int m * int n)) = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))

goal (1 subgoal):
 1. c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))
[PROOF STEP]
have "\<dots> = (\<Sum>m\<le>k - 1.
      (if gcd m k = 1 then 1 else 0) *
      unity_root k (int m * n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n)) = (\<Sum>m\<le>k - 1. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n))
[PROOF STEP]
using a_expr
[PROOF STATE]
proof (prove)
using this:
a k ?m2 = (if gcd ?m2 k = 1 then 1 else 0)

goal (1 subgoal):
 1. (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n)) = (\<Sum>m\<le>k - 1. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n)) = (\<Sum>m\<le>k - 1. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n))

goal (1 subgoal):
 1. c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n)) = (\<Sum>m\<le>k - 1. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n))

goal (1 subgoal):
 1. c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))
[PROOF STEP]
have "\<dots> = (\<Sum>m \<in> {1..k}.
      (if gcd m k = 1 then 1 else 0) *
      unity_root k (int m * n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m\<le>k - 1. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) = (\<Sum>m = 1..k. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>m\<le>k - 1. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) = (\<Sum>m = 1..k. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n))
[PROOF STEP]
have "periodic_arithmetic (\<lambda>m. (if gcd m k = 1 then 1 else 0) *
                 unity_root k (int m * n)) k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. periodic_arithmetic (\<lambda>m. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) k
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. periodic_arithmetic (\<lambda>m. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) k
[PROOF STEP]
have "periodic_arithmetic (\<lambda>m. if gcd m k = 1 then 1 else 0) k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. periodic_arithmetic (\<lambda>m. if gcd m k = 1 then 1 else 0) k
[PROOF STEP]
by (simp add: periodic_arithmetic_def)
[PROOF STATE]
proof (state)
this:
periodic_arithmetic (\<lambda>m. if gcd m k = 1 then 1 else 0) k

goal (1 subgoal):
 1. periodic_arithmetic (\<lambda>m. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) k
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
periodic_arithmetic (\<lambda>m. if gcd m k = 1 then 1 else 0) k

goal (1 subgoal):
 1. periodic_arithmetic (\<lambda>m. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) k
[PROOF STEP]
have "periodic_arithmetic (\<lambda>m. unity_root k (int m * n)) k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. periodic_arithmetic (\<lambda>m. unity_root k (int m * int n)) k
[PROOF STEP]
using unity_periodic_arithmetic_mult[of k n]
[PROOF STATE]
proof (prove)
using this:
periodic_arithmetic (\<lambda>na. unity_root k (int n * int na)) k

goal (1 subgoal):
 1. periodic_arithmetic (\<lambda>m. unity_root k (int m * int n)) k
[PROOF STEP]
by (subst mult.commute,simp)
[PROOF STATE]
proof (state)
this:
periodic_arithmetic (\<lambda>m. unity_root k (int m * int n)) k

goal (1 subgoal):
 1. periodic_arithmetic (\<lambda>m. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) k
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
periodic_arithmetic (\<lambda>m. if gcd m k = 1 then 1 else 0) k
periodic_arithmetic (\<lambda>m. unity_root k (int m * int n)) k
[PROOF STEP]
show "periodic_arithmetic ?f k"
[PROOF STATE]
proof (prove)
using this:
periodic_arithmetic (\<lambda>m. if gcd m k = 1 then 1 else 0) k
periodic_arithmetic (\<lambda>m. unity_root k (int m * int n)) k

goal (1 subgoal):
 1. periodic_arithmetic (\<lambda>m. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) k
[PROOF STEP]
using mult_periodic_arithmetic
[PROOF STATE]
proof (prove)
using this:
periodic_arithmetic (\<lambda>m. if gcd m k = 1 then 1 else 0) k
periodic_arithmetic (\<lambda>m. unity_root k (int m * int n)) k
\<lbrakk>periodic_arithmetic ?f ?k; periodic_arithmetic ?g ?k\<rbrakk> \<Longrightarrow> periodic_arithmetic (\<lambda>n. ?f n * ?g n) ?k

goal (1 subgoal):
 1. periodic_arithmetic (\<lambda>m. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) k
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
periodic_arithmetic (\<lambda>m. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) k

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
periodic_arithmetic (\<lambda>m. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) k

goal (1 subgoal):
 1. (\<Sum>m\<le>k - 1. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) = (\<Sum>m = 1..k. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
periodic_arithmetic (\<lambda>m. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) k
[PROOF STEP]
have "sum ?f {0..k - 1} = sum ?f {1..k}"
[PROOF STATE]
proof (prove)
using this:
periodic_arithmetic (\<lambda>m. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) k

goal (1 subgoal):
 1. (\<Sum>m = 0..k - 1. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) = (\<Sum>m = 1..k. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n))
[PROOF STEP]
using periodic_arithmetic_sum_periodic_arithmetic_shift[of ?f k 1]
[PROOF STATE]
proof (prove)
using this:
periodic_arithmetic (\<lambda>m. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) k
\<lbrakk>periodic_arithmetic (\<lambda>m. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) k; 0 < k; 0 < 1\<rbrakk> \<Longrightarrow> (\<Sum>l = 0..k - 1. (if gcd l k = 1 then 1 else 0) * unity_root k (int l * int n)) = (\<Sum>l = 1..1 + k - 1. (if gcd l k = 1 then 1 else 0) * unity_root k (int l * int n))

goal (1 subgoal):
 1. (\<Sum>m = 0..k - 1. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) = (\<Sum>m = 1..k. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n))
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
(\<Sum>m = 0..k - 1. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) = (\<Sum>m = 1..k. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n))

goal (1 subgoal):
 1. (\<Sum>m\<le>k - 1. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) = (\<Sum>m = 1..k. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>m = 0..k - 1. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) = (\<Sum>m = 1..k. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>m = 0..k - 1. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) = (\<Sum>m = 1..k. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n))

goal (1 subgoal):
 1. (\<Sum>m\<le>k - 1. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) = (\<Sum>m = 1..k. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n))
[PROOF STEP]
by (simp add: atMost_atLeast0)
[PROOF STATE]
proof (state)
this:
(\<Sum>m\<le>k - 1. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) = (\<Sum>m = 1..k. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>m\<le>k - 1. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) = (\<Sum>m = 1..k. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n))

goal (1 subgoal):
 1. c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>m\<le>k - 1. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) = (\<Sum>m = 1..k. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n))

goal (1 subgoal):
 1. c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))
[PROOF STEP]
have "\<dots> = (\<Sum>m | m \<in> {1..k} \<and> gcd m k = 1.
                  (if gcd m k = 1 then 1 else 0) *
                  unity_root k (int m * int n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m = 1..k. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) = (\<Sum>m | m \<in> {1..k} \<and> gcd m k = 1. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n))
[PROOF STEP]
by (intro sum.mono_neutral_right,auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>m = 1..k. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) = (\<Sum>m | m \<in> {1..k} \<and> gcd m k = 1. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n))

goal (1 subgoal):
 1. c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>m = 1..k. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) = (\<Sum>m | m \<in> {1..k} \<and> gcd m k = 1. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n))

goal (1 subgoal):
 1. c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))
[PROOF STEP]
have "\<dots> = (\<Sum>m | m \<in> {1..k} \<and> gcd m k = 1.
                  unity_root k (int m * int n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m | m \<in> {1..k} \<and> gcd m k = 1. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) = (\<Sum>m | m \<in> {1..k} \<and> gcd m k = 1. unity_root k (int m * int n))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>m | m \<in> {1..k} \<and> gcd m k = 1. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) = (\<Sum>m | m \<in> {1..k} \<and> gcd m k = 1. unity_root k (int m * int n))

goal (1 subgoal):
 1. c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>m | m \<in> {1..k} \<and> gcd m k = 1. (if gcd m k = 1 then 1 else 0) * unity_root k (int m * int n)) = (\<Sum>m | m \<in> {1..k} \<and> gcd m k = 1. unity_root k (int m * int n))

goal (1 subgoal):
 1. c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))
[PROOF STEP]
have "\<dots> = (\<Sum>m | m \<in> {1..k} \<and> coprime m k.
                  unity_root k (int m * int n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m | m \<in> {1..k} \<and> gcd m k = 1. unity_root k (int m * int n)) = (\<Sum>m | m \<in> {1..k} \<and> coprime m k. unity_root k (int m * int n))
[PROOF STEP]
using coprime_iff_gcd_eq_1
[PROOF STATE]
proof (prove)
using this:
coprime ?a ?b = (gcd ?a ?b = (1::?'a))

goal (1 subgoal):
 1. (\<Sum>m | m \<in> {1..k} \<and> gcd m k = 1. unity_root k (int m * int n)) = (\<Sum>m | m \<in> {1..k} \<and> coprime m k. unity_root k (int m * int n))
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
(\<Sum>m | m \<in> {1..k} \<and> gcd m k = 1. unity_root k (int m * int n)) = (\<Sum>m | m \<in> {1..k} \<and> coprime m k. unity_root k (int m * int n))

goal (1 subgoal):
 1. c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>m | m \<in> {1..k} \<and> gcd m k = 1. unity_root k (int m * int n)) = (\<Sum>m | m \<in> {1..k} \<and> coprime m k. unity_root k (int m * int n))

goal (1 subgoal):
 1. c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))
[PROOF STEP]
have "\<dots> = c k n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m | m \<in> {1..k} \<and> coprime m k. unity_root k (int m * int n)) = c k n
[PROOF STEP]
unfolding ramanujan_sum_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m | m \<in> {1..k} \<and> coprime m k. unity_root k (int m * int n)) = (\<Sum>m | m \<in> {1..k} \<and> coprime m k. unity_root k (int (m * n)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>m | m \<in> {1..k} \<and> coprime m k. unity_root k (int m * int n)) = c k n

goal (1 subgoal):
 1. c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
s (\<lambda>x. of_nat (id x)) moebius_mu k n = c k n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
s (\<lambda>x. of_nat (id x)) moebius_mu k n = c k n

goal (1 subgoal):
 1. c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))
[PROOF STEP]
unfolding gen_ramanujan_sum_def
[PROOF STATE]
proof (prove)
using this:
(\<Sum>d | d dvd gcd n k. of_nat (id d) * moebius_mu (k div d)) = c k n

goal (1 subgoal):
 1. c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
c k n = (\<Sum>d | d dvd gcd n k. of_nat d * moebius_mu (k div d))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma univ_for_pr_lm_0: "c_fst (c_fst key) mod 7 = 0 \<Longrightarrow> univ_for_pr key = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c_fst (c_fst key) mod 7 = 0 \<Longrightarrow> univ_for_pr key = 0
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. c_fst (c_fst key) mod 7 = 0 \<Longrightarrow> univ_for_pr key = 0
[PROOF STEP]
assume A: "c_fst (c_fst key) mod 7 = 0"
[PROOF STATE]
proof (state)
this:
c_fst (c_fst key) mod 7 = 0

goal (1 subgoal):
 1. c_fst (c_fst key) mod 7 = 0 \<Longrightarrow> univ_for_pr key = 0
[PROOF STEP]
have S1: "univ_for_pr key = nat_to_pr (c_fst key) (c_snd key)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. univ_for_pr key = nat_to_pr (c_fst key) (c_snd key)
[PROOF STEP]
by (simp add: univ_for_pr_def pr_conv_2_to_1_def)
[PROOF STATE]
proof (state)
this:
univ_for_pr key = nat_to_pr (c_fst key) (c_snd key)

goal (1 subgoal):
 1. c_fst (c_fst key) mod 7 = 0 \<Longrightarrow> univ_for_pr key = 0
[PROOF STEP]
with A
[PROOF STATE]
proof (chain)
picking this:
c_fst (c_fst key) mod 7 = 0
univ_for_pr key = nat_to_pr (c_fst key) (c_snd key)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
c_fst (c_fst key) mod 7 = 0
univ_for_pr key = nat_to_pr (c_fst key) (c_snd key)

goal (1 subgoal):
 1. univ_for_pr key = 0
[PROOF STEP]
by (simp add: nat_to_pr_lm_0)
[PROOF STATE]
proof (state)
this:
univ_for_pr key = 0

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma concat_parts_eq:
assumes "a * d = length v"
shows "concat (map (fixed_length_sublist v d) [0..<a]) = v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. concat (map (fixed_length_sublist v d) [0..<a]) = v
[PROOF STEP]
by (simp add: concat_parts_leq assms)


[STATEMENT]
lemma convex_rel_interior_iff2:
  fixes S :: "'n::euclidean_space set"
  assumes "convex S"
    and "S \<noteq> {}"
  shows "z \<in> rel_interior S \<longleftrightarrow> (\<forall>x\<in>affine hull S. \<exists>e. e > 1 \<and> (1 - e) *\<^sub>R x + e *\<^sub>R z \<in> S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (z \<in> rel_interior S) = (\<forall>x\<in>affine hull S. \<exists>e>1. (1 - e) *\<^sub>R x + e *\<^sub>R z \<in> S)
[PROOF STEP]
using assms hull_subset[of S] convex_rel_interior_if2[of S z] convex_rel_interior_only_if[of S z]
[PROOF STATE]
proof (prove)
using this:
convex S
S \<noteq> {}
S \<subseteq> ?S hull S
\<lbrakk>convex S; z \<in> rel_interior S\<rbrakk> \<Longrightarrow> \<forall>x\<in>affine hull S. \<exists>e>1. (1 - e) *\<^sub>R x + e *\<^sub>R z \<in> S
\<lbrakk>convex S; S \<noteq> {}; \<forall>x\<in>S. \<exists>e>1. (1 - e) *\<^sub>R x + e *\<^sub>R z \<in> S\<rbrakk> \<Longrightarrow> z \<in> rel_interior S

goal (1 subgoal):
 1. (z \<in> rel_interior S) = (\<forall>x\<in>affine hull S. \<exists>e>1. (1 - e) *\<^sub>R x + e *\<^sub>R z \<in> S)
[PROOF STEP]
by auto


[STATEMENT]
lemma union_diff_assoc: "C-B={#} \<Longrightarrow> (A+B)-C = A + (B-C)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. C - B = {#} \<Longrightarrow> A + B - C = A + (B - C)
[PROOF STEP]
by (simp add: multiset_eq_iff)


[STATEMENT]
lemma Ln_times_unwinding:
    "w \<noteq> 0 \<Longrightarrow> z \<noteq> 0 \<Longrightarrow> Ln(w * z) = Ln(w) + Ln(z) - (2*pi) * \<i> * unwinding(Ln w + Ln z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>w \<noteq> 0; z \<noteq> 0\<rbrakk> \<Longrightarrow> Ln (w * z) = Ln w + Ln z - complex_of_real (2 * pi) * \<i> * of_int (unwinding (Ln w + Ln z))
[PROOF STEP]
using unwinding_2pi
[PROOF STATE]
proof (prove)
using this:
complex_of_real (2 * pi) * \<i> * of_int (unwinding ?z) = ?z - Ln (exp ?z)

goal (1 subgoal):
 1. \<lbrakk>w \<noteq> 0; z \<noteq> 0\<rbrakk> \<Longrightarrow> Ln (w * z) = Ln w + Ln z - complex_of_real (2 * pi) * \<i> * of_int (unwinding (Ln w + Ln z))
[PROOF STEP]
by (simp add: exp_add)