[STATEMENT]
lemma coeff_pcompose_monom: fixes f :: "'a :: comm_ring_1 poly"
  assumes n: "j < n"
  shows "coeff (f \<circ>\<^sub>p monom 1 n) (n * i + j) = (if j = 0 then coeff f i else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff (f \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff f i else (0::'a))
[PROOF STEP]
proof (induct f arbitrary: i)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i. coeff (0 \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff 0 i else (0::'a))
 2. \<And>a f i. \<lbrakk>a \<noteq> (0::'a) \<or> f \<noteq> 0; \<And>i. coeff (f \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff f i else (0::'a))\<rbrakk> \<Longrightarrow> coeff (pCons a f \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff (pCons a f) i else (0::'a))
[PROOF STEP]
case (pCons a f i)
[PROOF STATE]
proof (state)
this:
a \<noteq> (0::'a) \<or> f \<noteq> 0
coeff (f \<circ>\<^sub>p monom (1::'a) n) (n * ?i + j) = (if j = 0 then coeff f ?i else (0::'a))

goal (2 subgoals):
 1. \<And>i. coeff (0 \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff 0 i else (0::'a))
 2. \<And>a f i. \<lbrakk>a \<noteq> (0::'a) \<or> f \<noteq> 0; \<And>i. coeff (f \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff f i else (0::'a))\<rbrakk> \<Longrightarrow> coeff (pCons a f \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff (pCons a f) i else (0::'a))
[PROOF STEP]
note d = pcompose_pCons coeff_add coeff_monom_mult coeff_pCons
[PROOF STATE]
proof (state)
this:
pCons ?a ?p \<circ>\<^sub>p ?q = [:?a:] + ?q * ?p \<circ>\<^sub>p ?q
coeff (?p + ?q) ?n = coeff ?p ?n + coeff ?q ?n
coeff (monom ?a ?d * ?p) ?i = (if ?d \<le> ?i then ?a * coeff ?p (?i - ?d) else (0::?'a))
coeff (pCons ?x ?xa) = case_nat ?x (coeff ?xa)

goal (2 subgoals):
 1. \<And>i. coeff (0 \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff 0 i else (0::'a))
 2. \<And>a f i. \<lbrakk>a \<noteq> (0::'a) \<or> f \<noteq> 0; \<And>i. coeff (f \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff f i else (0::'a))\<rbrakk> \<Longrightarrow> coeff (pCons a f \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff (pCons a f) i else (0::'a))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff (pCons a f \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff (pCons a f) i else (0::'a))
[PROOF STEP]
proof (cases i)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i = 0 \<Longrightarrow> coeff (pCons a f \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff (pCons a f) i else (0::'a))
 2. \<And>nat. i = Suc nat \<Longrightarrow> coeff (pCons a f \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff (pCons a f) i else (0::'a))
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
i = 0

goal (2 subgoals):
 1. i = 0 \<Longrightarrow> coeff (pCons a f \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff (pCons a f) i else (0::'a))
 2. \<And>nat. i = Suc nat \<Longrightarrow> coeff (pCons a f \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff (pCons a f) i else (0::'a))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff (pCons a f \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff (pCons a f) i else (0::'a))
[PROOF STEP]
unfolding d 0
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (case n * 0 + j of 0 \<Rightarrow> a | Suc x \<Rightarrow> coeff 0 x) + (if n \<le> n * 0 + j then (1::'a) * coeff (f \<circ>\<^sub>p monom (1::'a) n) (n * 0 + j - n) else (0::'a)) = (if j = 0 then case 0 of 0 \<Rightarrow> a | Suc x \<Rightarrow> coeff f x else (0::'a))
[PROOF STEP]
using n
[PROOF STATE]
proof (prove)
using this:
j < n

goal (1 subgoal):
 1. (case n * 0 + j of 0 \<Rightarrow> a | Suc x \<Rightarrow> coeff 0 x) + (if n \<le> n * 0 + j then (1::'a) * coeff (f \<circ>\<^sub>p monom (1::'a) n) (n * 0 + j - n) else (0::'a)) = (if j = 0 then case 0 of 0 \<Rightarrow> a | Suc x \<Rightarrow> coeff f x else (0::'a))
[PROOF STEP]
by (cases j, auto)
[PROOF STATE]
proof (state)
this:
coeff (pCons a f \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff (pCons a f) i else (0::'a))

goal (1 subgoal):
 1. \<And>nat. i = Suc nat \<Longrightarrow> coeff (pCons a f \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff (pCons a f) i else (0::'a))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>nat. i = Suc nat \<Longrightarrow> coeff (pCons a f \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff (pCons a f) i else (0::'a))
[PROOF STEP]
case (Suc ii)
[PROOF STATE]
proof (state)
this:
i = Suc ii

goal (1 subgoal):
 1. \<And>nat. i = Suc nat \<Longrightarrow> coeff (pCons a f \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff (pCons a f) i else (0::'a))
[PROOF STEP]
have id: "n * Suc ii + j - n = n * ii + j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n * Suc ii + j - n = n * ii + j
[PROOF STEP]
using n
[PROOF STATE]
proof (prove)
using this:
j < n

goal (1 subgoal):
 1. n * Suc ii + j - n = n * ii + j
[PROOF STEP]
by (simp add: diff_mult_distrib2)
[PROOF STATE]
proof (state)
this:
n * Suc ii + j - n = n * ii + j

goal (1 subgoal):
 1. \<And>nat. i = Suc nat \<Longrightarrow> coeff (pCons a f \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff (pCons a f) i else (0::'a))
[PROOF STEP]
have id1: "(n \<le> n * Suc ii + j) = True"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (n \<le> n * Suc ii + j) = True
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(n \<le> n * Suc ii + j) = True

goal (1 subgoal):
 1. \<And>nat. i = Suc nat \<Longrightarrow> coeff (pCons a f \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff (pCons a f) i else (0::'a))
[PROOF STEP]
have id2: "(case n * Suc ii + j of 0 \<Rightarrow> a | Suc x \<Rightarrow> coeff 0 x) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (case n * Suc ii + j of 0 \<Rightarrow> a | Suc x \<Rightarrow> coeff 0 x) = (0::'a)
[PROOF STEP]
using n
[PROOF STATE]
proof (prove)
using this:
j < n

goal (1 subgoal):
 1. (case n * Suc ii + j of 0 \<Rightarrow> a | Suc x \<Rightarrow> coeff 0 x) = (0::'a)
[PROOF STEP]
by (cases "n * Suc ii + j", auto)
[PROOF STATE]
proof (state)
this:
(case n * Suc ii + j of 0 \<Rightarrow> a | Suc x \<Rightarrow> coeff 0 x) = (0::'a)

goal (1 subgoal):
 1. \<And>nat. i = Suc nat \<Longrightarrow> coeff (pCons a f \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff (pCons a f) i else (0::'a))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff (pCons a f \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff (pCons a f) i else (0::'a))
[PROOF STEP]
unfolding d Suc id id1 id2 pCons(2) if_True
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0::'a) + (1::'a) * (if j = 0 then coeff f ii else (0::'a)) = (if j = 0 then case Suc ii of 0 \<Rightarrow> a | Suc x \<Rightarrow> coeff f x else (0::'a))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
coeff (pCons a f \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff (pCons a f) i else (0::'a))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
coeff (pCons a f \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff (pCons a f) i else (0::'a))

goal (1 subgoal):
 1. \<And>i. coeff (0 \<circ>\<^sub>p monom (1::'a) n) (n * i + j) = (if j = 0 then coeff 0 i else (0::'a))
[PROOF STEP]
qed auto


[STATEMENT]
lemma Bounded_vec_vec_set: "v \<in> Bounded_vec b \<longleftrightarrow> (\<forall> x \<in> vec_set v. abs x \<le> b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (v \<in> Bounded_vec b) = (\<forall>x\<in>set\<^sub>v v. \<bar>x\<bar> \<le> b)
[PROOF STEP]
unfolding Bounded_vec_def vec_set_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (v \<in> {x. \<forall>i<dim_vec x. \<bar>x $ i\<bar> \<le> b}) = (\<forall>x\<in>($) v ` {..<dim_vec v}. \<bar>x\<bar> \<le> b)
[PROOF STEP]
by auto


[STATEMENT]
lemma transp_rel_generatI:
  assumes "transp A" "transp B" "transp C"
  shows "transp (rel_generat A B C)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. transp (rel_generat A B C)
[PROOF STEP]
by(rule transpI)(auto 6 5 dest: rel_generatD' intro!: rel_generatI intro: assms[THEN transpD] simp add: rel_fun_def)


[STATEMENT]
lemma scalar_product: fixes v :: "'a :: semiring_1 ^ 'n "
  shows "scalar_prod (from_hma\<^sub>v v) (from_hma\<^sub>v w) = scalar_product v w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. from_hma\<^sub>v v \<bullet> from_hma\<^sub>v w = scalar_product v w
[PROOF STEP]
unfolding scalar_product_def scalar_prod_def from_hma\<^sub>v_def dim_vec
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<CARD('n). Matrix.vec CARD('n) (\<lambda>i. v $h Bij_Nat.from_nat i) $v i * Matrix.vec CARD('n) (\<lambda>i. w $h Bij_Nat.from_nat i) $v i) = (\<Sum>i\<in>UNIV. v $h i * w $h i)
[PROOF STEP]
by (simp add: sum.reindex[OF inj_to_nat, unfolded range_to_nat])


[STATEMENT]
lemma rev_lang:
  shows "rev ` (lang r) = lang (Rev r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rev ` lang r = lang (Rev r)
[PROOF STEP]
by (induct r) (simp_all add: image_Un)


[STATEMENT]
lemma matrix_vector_mult_diff_rdistrib [algebra_simps]:
  fixes A :: "'a :: ring_1^'n^'m"
  shows "(A - B) *v x = (A *v x) - (B *v x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (A - B) *v x = A *v x - B *v x
[PROOF STEP]
by (vector matrix_vector_mult_def sum_subtractf left_diff_distrib)


[STATEMENT]
lemma Max_atLeastAtMost: "m \<le> n \<Longrightarrow> Max {m..(n::nat)} = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m \<le> n \<Longrightarrow> Max {m..n} = n
[PROOF STEP]
by (rule Max_equality[OF _ finite_atLeastAtMost], simp_all)


[STATEMENT]
lemma tendsto_at_top_eq_left:
  fixes f g::"'a::linorder_topology \<Rightarrow> 'b::metric_space"
  assumes "(f \<longlongrightarrow> l) at_top"
  assumes "\<And>x. x \<ge> x0 \<Longrightarrow> f x = g x"
  shows "(g \<longlongrightarrow> l) at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (g \<longlongrightarrow> l) at_top
[PROOF STEP]
unfolding tendsto_at_top_iff
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>e>0. \<exists>x0. \<forall>x\<ge>x0. dist (g x) l < e
[PROOF STEP]
by (metis (no_types, opaque_lifting) assms(1) assms(2) linear order_trans tendsto_at_topE)


[STATEMENT]
theorem gen_ramanujan_sum_fourier_expansion:
  fixes f g :: "nat \<Rightarrow> complex" and a :: "nat \<Rightarrow> nat \<Rightarrow> complex"
  assumes "k > 0"
  defines "a \<equiv> (\<lambda>k m. (1/k) * (\<Sum>d| d dvd (gcd m k). g d * f (k div d) * d))"
  shows "s f g k n = (\<Sum>m\<le>k-1. a k m * unity_root k (m*n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
let ?g = "(\<lambda>x. 1 / of_nat k * (\<Sum>m<k. s f g k m * unity_root k (-x*m)))"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
fix m :: nat
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
let ?h = "\<lambda>n d. f d * g (k div d) * unity_root k (- m * int n)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
have "(\<Sum>l<k. s f g k l * unity_root k (-m*l)) =
               (\<Sum>l \<in> {0..k-1}. s f g k l * unity_root k (-m*l))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>l<k. s f g k l * unity_root k (- int m * int l)) = (\<Sum>l = 0..k - 1. s f g k l * unity_root k (- int m * int l))
[PROOF STEP]
using \<open>k > 0\<close>
[PROOF STATE]
proof (prove)
using this:
0 < k

goal (1 subgoal):
 1. (\<Sum>l<k. s f g k l * unity_root k (- int m * int l)) = (\<Sum>l = 0..k - 1. s f g k l * unity_root k (- int m * int l))
[PROOF STEP]
by (intro sum.cong) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>l<k. s f g k l * unity_root k (- int m * int l)) = (\<Sum>l = 0..k - 1. s f g k l * unity_root k (- int m * int l))

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>l<k. s f g k l * unity_root k (- int m * int l)) = (\<Sum>l = 0..k - 1. s f g k l * unity_root k (- int m * int l))

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
have "\<dots> = (\<Sum>l \<in> {1..k}. s f g k l * unity_root k (-m*l))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>l = 0..k - 1. s f g k l * unity_root k (- int m * int l)) = (\<Sum>l = 1..k. s f g k l * unity_root k (- int m * int l))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>l = 0..k - 1. s f g k l * unity_root k (- int m * int l)) = (\<Sum>l = 1..k. s f g k l * unity_root k (- int m * int l))
[PROOF STEP]
have "periodic_arithmetic (\<lambda>l. unity_root k (-m*l)) k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. periodic_arithmetic (\<lambda>l. unity_root k (- int m * int l)) k
[PROOF STEP]
using unity_periodic_arithmetic_mult
[PROOF STATE]
proof (prove)
using this:
periodic_arithmetic (\<lambda>n. unity_root ?k (?m * int n)) ?k

goal (1 subgoal):
 1. periodic_arithmetic (\<lambda>l. unity_root k (- int m * int l)) k
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
periodic_arithmetic (\<lambda>l. unity_root k (- int m * int l)) k

goal (1 subgoal):
 1. (\<Sum>l = 0..k - 1. s f g k l * unity_root k (- int m * int l)) = (\<Sum>l = 1..k. s f g k l * unity_root k (- int m * int l))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
periodic_arithmetic (\<lambda>l. unity_root k (- int m * int l)) k
[PROOF STEP]
have "periodic_arithmetic (\<lambda>l. s f g k l * unity_root k (-m*l)) k"
[PROOF STATE]
proof (prove)
using this:
periodic_arithmetic (\<lambda>l. unity_root k (- int m * int l)) k

goal (1 subgoal):
 1. periodic_arithmetic (\<lambda>l. s f g k l * unity_root k (- int m * int l)) k
[PROOF STEP]
using gen_ramanujan_sum_periodic mult_periodic_arithmetic
[PROOF STATE]
proof (prove)
using this:
periodic_arithmetic (\<lambda>l. unity_root k (- int m * int l)) k
periodic_arithmetic (s ?f ?g ?k) ?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>l. s f g k l * unity_root k (- int m * int l)) k
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
periodic_arithmetic (\<lambda>l. s f g k l * unity_root k (- int m * int l)) k

goal (1 subgoal):
 1. (\<Sum>l = 0..k - 1. s f g k l * unity_root k (- int m * int l)) = (\<Sum>l = 1..k. s f g k l * unity_root k (- int m * int l))
[PROOF STEP]
from this periodic_arithmetic_sum_periodic_arithmetic_shift[of _ k 1  ]
[PROOF STATE]
proof (chain)
picking this:
periodic_arithmetic (\<lambda>l. s f g k l * unity_root k (- int m * int l)) k
\<lbrakk>periodic_arithmetic ?f k; 0 < k; 0 < 1\<rbrakk> \<Longrightarrow> sum ?f {0..k - 1} = sum ?f {1..1 + k - 1}
[PROOF STEP]
have "sum (\<lambda>l. s f g k l * unity_root k (-m*l)) {0..k - 1} =
          sum (\<lambda>l. s f g k l * unity_root k (-m*l)) {1..k}"
[PROOF STATE]
proof (prove)
using this:
periodic_arithmetic (\<lambda>l. s f g k l * unity_root k (- int m * int l)) k
\<lbrakk>periodic_arithmetic ?f k; 0 < k; 0 < 1\<rbrakk> \<Longrightarrow> sum ?f {0..k - 1} = sum ?f {1..1 + k - 1}

goal (1 subgoal):
 1. (\<Sum>l = 0..k - 1. s f g k l * unity_root k (- int m * int l)) = (\<Sum>l = 1..k. s f g k l * unity_root k (- int m * int l))
[PROOF STEP]
using assms(1) zero_less_one
[PROOF STATE]
proof (prove)
using this:
periodic_arithmetic (\<lambda>l. s f g k l * unity_root k (- int m * int l)) k
\<lbrakk>periodic_arithmetic ?f k; 0 < k; 0 < 1\<rbrakk> \<Longrightarrow> sum ?f {0..k - 1} = sum ?f {1..1 + k - 1}
0 < k
(0::?'a) < (1::?'a)

goal (1 subgoal):
 1. (\<Sum>l = 0..k - 1. s f g k l * unity_root k (- int m * int l)) = (\<Sum>l = 1..k. s f g k l * unity_root k (- int m * int l))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>l = 0..k - 1. s f g k l * unity_root k (- int m * int l)) = (\<Sum>l = 1..k. s f g k l * unity_root k (- int m * int l))

goal (1 subgoal):
 1. (\<Sum>l = 0..k - 1. s f g k l * unity_root k (- int m * int l)) = (\<Sum>l = 1..k. s f g k l * unity_root k (- int m * int l))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>l = 0..k - 1. s f g k l * unity_root k (- int m * int l)) = (\<Sum>l = 1..k. s f g k l * unity_root k (- int m * int l))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>l = 0..k - 1. s f g k l * unity_root k (- int m * int l)) = (\<Sum>l = 1..k. s f g k l * unity_root k (- int m * int l))

goal (1 subgoal):
 1. (\<Sum>l = 0..k - 1. s f g k l * unity_root k (- int m * int l)) = (\<Sum>l = 1..k. s f g k l * unity_root k (- int m * int l))
[PROOF STEP]
by argo
[PROOF STATE]
proof (state)
this:
(\<Sum>l = 0..k - 1. s f g k l * unity_root k (- int m * int l)) = (\<Sum>l = 1..k. s f g k l * unity_root k (- int m * int l))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>l = 0..k - 1. s f g k l * unity_root k (- int m * int l)) = (\<Sum>l = 1..k. s f g k l * unity_root k (- int m * int l))

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>l = 0..k - 1. s f g k l * unity_root k (- int m * int l)) = (\<Sum>l = 1..k. s f g k l * unity_root k (- int m * int l))

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
have "\<dots> = (\<Sum>n\<in>{1..k}. (\<Sum>d | d dvd (gcd n k). f(d) * g(k div d)) * unity_root k (-m*n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>l = 1..k. s f g k l * unity_root k (- int m * int l)) = (\<Sum>n = 1..k. (\<Sum>d | d dvd gcd n k. f d * g (k div d)) * unity_root k (- int m * int n))
[PROOF STEP]
by (simp add: gen_ramanujan_sum_def)
[PROOF STATE]
proof (state)
this:
(\<Sum>l = 1..k. s f g k l * unity_root k (- int m * int l)) = (\<Sum>n = 1..k. (\<Sum>d | d dvd gcd n k. f d * g (k div d)) * unity_root k (- int m * int n))

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

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
have "\<dots> = (\<Sum>n\<in>{1..k}. (\<Sum>d | d dvd (gcd n k). f(d) * g(k div d) * unity_root k (-m*n)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>n = 1..k. (\<Sum>d | d dvd gcd n k. f d * g (k div d)) * unity_root k (- int m * int n)) = (\<Sum>n = 1..k. \<Sum>d | d dvd gcd n k. f d * g (k div d) * unity_root k (- int m * int n))
[PROOF STEP]
by (simp add: sum_distrib_right)
[PROOF STATE]
proof (state)
this:
(\<Sum>n = 1..k. (\<Sum>d | d dvd gcd n k. f d * g (k div d)) * unity_root k (- int m * int n)) = (\<Sum>n = 1..k. \<Sum>d | d dvd gcd n k. f d * g (k div d) * unity_root k (- int m * int n))

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

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
have "\<dots> = (\<Sum>d | d dvd k. \<Sum>n | n \<in> {1..k} \<and> d dvd n. ?h n d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>n = 1..k. \<Sum>d | d dvd gcd n k. f d * g (k div d) * unity_root k (- int m * int n)) = (\<Sum>d | d dvd k. \<Sum>n | n \<in> {1..k} \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>n = 1..k. \<Sum>d | d dvd gcd n k. f d * g (k div d) * unity_root k (- int m * int n)) = (\<Sum>d | d dvd k. \<Sum>n | n \<in> {1..k} \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n))
[PROOF STEP]
have "(\<Sum>n = 1..k. \<Sum>d | d dvd gcd n k. ?h n d) =
          (\<Sum>n = 1..k. \<Sum>d | d dvd k \<and> d dvd n . ?h n d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>n = 1..k. \<Sum>d | d dvd gcd n k. f d * g (k div d) * unity_root k (- int m * int n)) = (\<Sum>n = 1..k. \<Sum>d | d dvd k \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n))
[PROOF STEP]
using gcd.commute[of _ k]
[PROOF STATE]
proof (prove)
using this:
gcd ?a k = gcd k ?a

goal (1 subgoal):
 1. (\<Sum>n = 1..k. \<Sum>d | d dvd gcd n k. f d * g (k div d) * unity_root k (- int m * int n)) = (\<Sum>n = 1..k. \<Sum>d | d dvd k \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>n = 1..k. \<Sum>d | d dvd gcd n k. f d * g (k div d) * unity_root k (- int m * int n)) = (\<Sum>n = 1..k. \<Sum>d | d dvd k \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n))

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

goal (1 subgoal):
 1. (\<Sum>n = 1..k. \<Sum>d | d dvd gcd n k. f d * g (k div d) * unity_root k (- int m * int n)) = (\<Sum>d | d dvd k. \<Sum>n | n \<in> {1..k} \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n))
[PROOF STEP]
have "\<dots> = (\<Sum>d | d dvd k. \<Sum>n | n \<in> {1..k} \<and> d dvd n. ?h n d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>n = 1..k. \<Sum>d | d dvd k \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n)) = (\<Sum>d | d dvd k. \<Sum>n | n \<in> {1..k} \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n))
[PROOF STEP]
using sum.swap_restrict[of "{1..k}" "{d. d dvd k}"
                            _ "\<lambda>n d. d dvd n"] assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>finite {1..k}; finite {d. d dvd k}\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..k. sum (?g x) {y \<in> {d. d dvd k}. y dvd x}) = (\<Sum>y\<in>{d. d dvd k}. \<Sum>x | x \<in> {1..k} \<and> y dvd x. ?g x y)
0 < k
a \<equiv> \<lambda>k m. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. g d * f (k div d) * of_nat d)

goal (1 subgoal):
 1. (\<Sum>n = 1..k. \<Sum>d | d dvd k \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n)) = (\<Sum>d | d dvd k. \<Sum>n | n \<in> {1..k} \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n))
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
(\<Sum>n = 1..k. \<Sum>d | d dvd k \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n)) = (\<Sum>d | d dvd k. \<Sum>n | n \<in> {1..k} \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n))

goal (1 subgoal):
 1. (\<Sum>n = 1..k. \<Sum>d | d dvd gcd n k. f d * g (k div d) * unity_root k (- int m * int n)) = (\<Sum>d | d dvd k. \<Sum>n | n \<in> {1..k} \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>n = 1..k. \<Sum>d | d dvd gcd n k. f d * g (k div d) * unity_root k (- int m * int n)) = (\<Sum>d | d dvd k. \<Sum>n | n \<in> {1..k} \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n))
[PROOF STEP]
have "
      (\<Sum>n = 1..k. \<Sum>d | d dvd gcd n k. ?h n d) =
      (\<Sum>d | d dvd k. \<Sum>n | n \<in> {1..k} \<and> d dvd n. ?h n d)"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>n = 1..k. \<Sum>d | d dvd gcd n k. f d * g (k div d) * unity_root k (- int m * int n)) = (\<Sum>d | d dvd k. \<Sum>n | n \<in> {1..k} \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n))

goal (1 subgoal):
 1. (\<Sum>n = 1..k. \<Sum>d | d dvd gcd n k. f d * g (k div d) * unity_root k (- int m * int n)) = (\<Sum>d | d dvd k. \<Sum>n | n \<in> {1..k} \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(\<Sum>n = 1..k. \<Sum>d | d dvd gcd n k. f d * g (k div d) * unity_root k (- int m * int n)) = (\<Sum>d | d dvd k. \<Sum>n | n \<in> {1..k} \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n))

goal (1 subgoal):
 1. (\<Sum>n = 1..k. \<Sum>d | d dvd gcd n k. f d * g (k div d) * unity_root k (- int m * int n)) = (\<Sum>d | d dvd k. \<Sum>n | n \<in> {1..k} \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>n = 1..k. \<Sum>d | d dvd gcd n k. f d * g (k div d) * unity_root k (- int m * int n)) = (\<Sum>d | d dvd k. \<Sum>n | n \<in> {1..k} \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>n = 1..k. \<Sum>d | d dvd gcd n k. f d * g (k div d) * unity_root k (- int m * int n)) = (\<Sum>d | d dvd k. \<Sum>n | n \<in> {1..k} \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n))

goal (1 subgoal):
 1. (\<Sum>n = 1..k. \<Sum>d | d dvd gcd n k. f d * g (k div d) * unity_root k (- int m * int n)) = (\<Sum>d | d dvd k. \<Sum>n | n \<in> {1..k} \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>n = 1..k. \<Sum>d | d dvd gcd n k. f d * g (k div d) * unity_root k (- int m * int n)) = (\<Sum>d | d dvd k. \<Sum>n | n \<in> {1..k} \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>n = 1..k. \<Sum>d | d dvd gcd n k. f d * g (k div d) * unity_root k (- int m * int n)) = (\<Sum>d | d dvd k. \<Sum>n | n \<in> {1..k} \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n))

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>n = 1..k. \<Sum>d | d dvd gcd n k. f d * g (k div d) * unity_root k (- int m * int n)) = (\<Sum>d | d dvd k. \<Sum>n | n \<in> {1..k} \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n))

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
have "\<dots> = (\<Sum>d | d dvd k. f(d)*g(k div d)*
             (\<Sum>n | n \<in> {1..k} \<and> d dvd n. unity_root k (- m * int n)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>d | d dvd k. \<Sum>n | n \<in> {1..k} \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n)) = (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>n | n \<in> {1..k} \<and> d dvd n. unity_root k (- int m * int n)))
[PROOF STEP]
by (simp add: sum_distrib_left)
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd k. \<Sum>n | n \<in> {1..k} \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n)) = (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>n | n \<in> {1..k} \<and> d dvd n. unity_root k (- int m * int n)))

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd k. \<Sum>n | n \<in> {1..k} \<and> d dvd n. f d * g (k div d) * unity_root k (- int m * int n)) = (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>n | n \<in> {1..k} \<and> d dvd n. unity_root k (- int m * int n)))

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
have "\<dots> = (\<Sum>d | d dvd k. f(d)*g(k div d)*
             (\<Sum>e \<in> {1..k div d}. unity_root k (- m * (e*d))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>n | n \<in> {1..k} \<and> d dvd n. unity_root k (- int m * int n))) = (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root k (- int m * int (e * d))))
[PROOF STEP]
using assms(1) sum_div_reduce div_greater_zero_iff dvd_div_gt0
[PROOF STATE]
proof (prove)
using this:
0 < k
\<lbrakk>?d dvd ?k; 0 < ?d\<rbrakk> \<Longrightarrow> (\<Sum>n | n \<in> {1..?k} \<and> ?d dvd n. ?f n) = (\<Sum>c = 1..?k div ?d. ?f (c * ?d))
(0 < ?m div ?n) = (?n \<le> ?m \<and> 0 < ?n)
\<lbrakk>?d dvd ?n; 0 < ?n\<rbrakk> \<Longrightarrow> 0 < ?n div ?d

goal (1 subgoal):
 1. (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>n | n \<in> {1..k} \<and> d dvd n. unity_root k (- int m * int n))) = (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root k (- int m * int (e * d))))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>n | n \<in> {1..k} \<and> d dvd n. unity_root k (- int m * int n))) = (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root k (- int m * int (e * d))))

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>n | n \<in> {1..k} \<and> d dvd n. unity_root k (- int m * int n))) = (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root k (- int m * int (e * d))))

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
have "\<dots> = (\<Sum>d | d dvd k. f(d)*g(k div d)*
             (\<Sum>e \<in> {1..k div d}. unity_root (k div d) (- m * e)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root k (- int m * int (e * d)))) = (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root (k div d) (- int m * int e)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root k (- int m * int (e * d)))) = (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root (k div d) (- int m * int e)))
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root k (- int m * int (e * d)))) = (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root (k div d) (- int m * int e)))
[PROOF STEP]
fix d e
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root k (- int m * int (e * d)))) = (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root (k div d) (- int m * int e)))
[PROOF STEP]
assume "d dvd k"
[PROOF STATE]
proof (state)
this:
d dvd k

goal (1 subgoal):
 1. (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root k (- int m * int (e * d)))) = (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root (k div d) (- int m * int e)))
[PROOF STEP]
hence "2 * pi * real_of_int (- int m * int (e * d)) / real k =
              2 * pi * real_of_int (- int m * int e) / real (k div d)"
[PROOF STATE]
proof (prove)
using this:
d dvd k

goal (1 subgoal):
 1. 2 * pi * real_of_int (- int m * int (e * d)) / real k = 2 * pi * real_of_int (- int m * int e) / real (k div d)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
2 * pi * real_of_int (- int m * int (e * d)) / real k = 2 * pi * real_of_int (- int m * int e) / real (k div d)

goal (1 subgoal):
 1. (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root k (- int m * int (e * d)))) = (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root (k div d) (- int m * int e)))
[PROOF STEP]
hence "unity_root k (- m * (e * d)) = unity_root (k div d) (- m * e)"
[PROOF STATE]
proof (prove)
using this:
2 * pi * real_of_int (- int m * int (e * d)) / real k = 2 * pi * real_of_int (- int m * int e) / real (k div d)

goal (1 subgoal):
 1. unity_root k (- int m * int (e * d)) = unity_root (k div d) (- int m * int e)
[PROOF STEP]
unfolding unity_root_def
[PROOF STATE]
proof (prove)
using this:
2 * pi * real_of_int (- int m * int (e * d)) / real k = 2 * pi * real_of_int (- int m * int e) / real (k div d)

goal (1 subgoal):
 1. cis (2 * pi * real_of_int (- int m * int (e * d)) / real k) = cis (2 * pi * real_of_int (- int m * int e) / real (k div d))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
unity_root k (- int m * int (e * d)) = unity_root (k div d) (- int m * int e)

goal (1 subgoal):
 1. (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root k (- int m * int (e * d)))) = (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root (k div d) (- int m * int e)))
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?d2 dvd k \<Longrightarrow> unity_root k (- int m * int (?e2 * ?d2)) = unity_root (k div ?d2) (- int m * int ?e2)

goal (1 subgoal):
 1. (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root k (- int m * int (e * d)))) = (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root (k div d) (- int m * int e)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?d2 dvd k \<Longrightarrow> unity_root k (- int m * int (?e2 * ?d2)) = unity_root (k div ?d2) (- int m * int ?e2)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
?d2 dvd k \<Longrightarrow> unity_root k (- int m * int (?e2 * ?d2)) = unity_root (k div ?d2) (- int m * int ?e2)

goal (1 subgoal):
 1. (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root k (- int m * int (e * d)))) = (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root (k div d) (- int m * int e)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root k (- int m * int (e * d)))) = (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root (k div d) (- int m * int e)))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root k (- int m * int (e * d)))) = (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root (k div d) (- int m * int e)))

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root k (- int m * int (e * d)))) = (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root (k div d) (- int m * int e)))

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
have "\<dots> = dirichlet_prod (\<lambda>d. f(d)*g(k div d))
                    (\<lambda>d. (\<Sum>e \<in> {1..d}. unity_root d (- m * e))) k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root (k div d) (- int m * int e))) = dirichlet_prod (\<lambda>d. f d * g (k div d)) (\<lambda>d. \<Sum>e = 1..d. unity_root d (- int m * int e)) k
[PROOF STEP]
unfolding dirichlet_prod_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root (k div d) (- int m * int e))) = (\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root (k div d) (- int m * int e)))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root (k div d) (- int m * int e))) = dirichlet_prod (\<lambda>d. f d * g (k div d)) (\<lambda>d. \<Sum>e = 1..d. unity_root d (- int m * int e)) k

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd k. f d * g (k div d) * (\<Sum>e = 1..k div d. unity_root (k div d) (- int m * int e))) = dirichlet_prod (\<lambda>d. f d * g (k div d)) (\<lambda>d. \<Sum>e = 1..d. unity_root d (- int m * int e)) k

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
have "\<dots> = dirichlet_prod (\<lambda>d. (\<Sum>e \<in> {1..d}. unity_root d (- m * e)))
                    (\<lambda>d. f(d)*g(k div d)) k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dirichlet_prod (\<lambda>d. f d * g (k div d)) (\<lambda>d. \<Sum>e = 1..d. unity_root d (- int m * int e)) k = dirichlet_prod (\<lambda>d. \<Sum>e = 1..d. unity_root d (- int m * int e)) (\<lambda>d. f d * g (k div d)) k
[PROOF STEP]
using dirichlet_prod_commutes[of
            "(\<lambda>d. f(d)*g(k div d))"
            "(\<lambda>d. (\<Sum>e \<in> {1..d}. unity_root d (- m * e)))"]
[PROOF STATE]
proof (prove)
using this:
dirichlet_prod (\<lambda>d. f d * g (k div d)) (\<lambda>d. \<Sum>e = 1..d. unity_root d (- int m * int e)) = dirichlet_prod (\<lambda>d. \<Sum>e = 1..d. unity_root d (- int m * int e)) (\<lambda>d. f d * g (k div d))

goal (1 subgoal):
 1. dirichlet_prod (\<lambda>d. f d * g (k div d)) (\<lambda>d. \<Sum>e = 1..d. unity_root d (- int m * int e)) k = dirichlet_prod (\<lambda>d. \<Sum>e = 1..d. unity_root d (- int m * int e)) (\<lambda>d. f d * g (k div d)) k
[PROOF STEP]
by argo
[PROOF STATE]
proof (state)
this:
dirichlet_prod (\<lambda>d. f d * g (k div d)) (\<lambda>d. \<Sum>e = 1..d. unity_root d (- int m * int e)) k = dirichlet_prod (\<lambda>d. \<Sum>e = 1..d. unity_root d (- int m * int e)) (\<lambda>d. f d * g (k div d)) k

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
dirichlet_prod (\<lambda>d. f d * g (k div d)) (\<lambda>d. \<Sum>e = 1..d. unity_root d (- int m * int e)) k = dirichlet_prod (\<lambda>d. \<Sum>e = 1..d. unity_root d (- int m * int e)) (\<lambda>d. f d * g (k div d)) k

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
have "\<dots> = (\<Sum>d | d dvd k.
             (\<Sum>e \<in> {1..(d::nat)}. unity_root d (- m * e))*(f(k div d)*g(k div (k div d))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dirichlet_prod (\<lambda>d. \<Sum>e = 1..d. unity_root d (- int m * int e)) (\<lambda>d. f d * g (k div d)) k = (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g (k div (k div d))))
[PROOF STEP]
unfolding dirichlet_prod_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g (k div (k div d)))) = (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g (k div (k div d))))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
dirichlet_prod (\<lambda>d. \<Sum>e = 1..d. unity_root d (- int m * int e)) (\<lambda>d. f d * g (k div d)) k = (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g (k div (k div d))))

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
dirichlet_prod (\<lambda>d. \<Sum>e = 1..d. unity_root d (- int m * int e)) (\<lambda>d. f d * g (k div d)) k = (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g (k div (k div d))))

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
have "\<dots> = (\<Sum>d | d dvd k. (\<Sum>e \<in> {1..(d::nat)}.
                      unity_root d (- m * e))*(f(k div d)*g(d)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g (k div (k div d)))) = (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g (k div (k div d)))) = (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d))
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g (k div (k div d)))) = (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d))
[PROOF STEP]
fix d :: nat
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g (k div (k div d)))) = (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d))
[PROOF STEP]
assume "d dvd k"
[PROOF STATE]
proof (state)
this:
d dvd k

goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g (k div (k div d)))) = (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
d dvd k
[PROOF STEP]
have "k div (k div d) = d"
[PROOF STATE]
proof (prove)
using this:
d dvd k

goal (1 subgoal):
 1. k div (k div d) = d
[PROOF STEP]
by (simp add: assms(1) div_div_eq_right)
[PROOF STATE]
proof (state)
this:
k div (k div d) = d

goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g (k div (k div d)))) = (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d))
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?d2 dvd k \<Longrightarrow> k div (k div ?d2) = ?d2

goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g (k div (k div d)))) = (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?d2 dvd k \<Longrightarrow> k div (k div ?d2) = ?d2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
?d2 dvd k \<Longrightarrow> k div (k div ?d2) = ?d2

goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g (k div (k div d)))) = (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g (k div (k div d)))) = (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g (k div (k div d)))) = (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d))

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g (k div (k div d)))) = (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d))

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
have "\<dots> = (\<Sum>(d::nat) | d dvd k \<and> d dvd m. d*(f(k div d)*g(d)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
fix d
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
assume "d dvd k"
[PROOF STATE]
proof (state)
this:
d dvd k

goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
0 < k
a \<equiv> \<lambda>k m. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. g d * f (k div d) * of_nat d)
d dvd k
[PROOF STEP]
have "d > 0"
[PROOF STATE]
proof (prove)
using this:
0 < k
a \<equiv> \<lambda>k m. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. g d * f (k div d) * of_nat d)
d dvd k

goal (1 subgoal):
 1. 0 < d
[PROOF STEP]
by (intro Nat.gr0I) auto
[PROOF STATE]
proof (state)
this:
0 < d

goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
have "periodic_arithmetic (\<lambda>x. unity_root d (- m * int x)) d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. periodic_arithmetic (\<lambda>x. unity_root d (- int m * int x)) d
[PROOF STEP]
using unity_periodic_arithmetic_mult
[PROOF STATE]
proof (prove)
using this:
periodic_arithmetic (\<lambda>n. unity_root ?k (?m * int n)) ?k

goal (1 subgoal):
 1. periodic_arithmetic (\<lambda>x. unity_root d (- int m * int x)) d
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
periodic_arithmetic (\<lambda>x. unity_root d (- int m * int x)) d

goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
periodic_arithmetic (\<lambda>x. unity_root d (- int m * int x)) d
[PROOF STEP]
have "(\<Sum>e \<in> {1..d}. unity_root d (- m * e)) =
            (\<Sum>e \<in> {0..d-1}. unity_root d (- m * e))"
[PROOF STATE]
proof (prove)
using this:
periodic_arithmetic (\<lambda>x. unity_root d (- int m * int x)) d

goal (1 subgoal):
 1. (\<Sum>e = 1..d. unity_root d (- int m * int e)) = (\<Sum>e = 0..d - 1. unity_root d (- int m * int e))
[PROOF STEP]
using periodic_arithmetic_sum_periodic_arithmetic_shift[of "\<lambda>e. unity_root d (- m * e)"  d 1] assms \<open>d dvd k\<close>
[PROOF STATE]
proof (prove)
using this:
periodic_arithmetic (\<lambda>x. unity_root d (- int m * int x)) d
\<lbrakk>periodic_arithmetic (\<lambda>e. unity_root d (- int m * int e)) d; 0 < d; 0 < 1\<rbrakk> \<Longrightarrow> (\<Sum>l = 0..d - 1. unity_root d (- int m * int l)) = (\<Sum>l = 1..1 + d - 1. unity_root d (- int m * int l))
0 < k
a \<equiv> \<lambda>k m. 1 / of_nat k * (\<Sum>d | d dvd gcd m k. g d * f (k div d) * of_nat d)
d dvd k

goal (1 subgoal):
 1. (\<Sum>e = 1..d. unity_root d (- int m * int e)) = (\<Sum>e = 0..d - 1. unity_root d (- int m * int e))
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
(\<Sum>e = 1..d. unity_root d (- int m * int e)) = (\<Sum>e = 0..d - 1. unity_root d (- int m * int e))

goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>e = 1..d. unity_root d (- int m * int e)) = (\<Sum>e = 0..d - 1. unity_root d (- int m * int e))

goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
have "\<dots> = unity_root_sum d (-m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>e = 0..d - 1. unity_root d (- int m * int e)) = unity_root_sum d (- int m)
[PROOF STEP]
unfolding unity_root_sum_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>e = 0..d - 1. unity_root d (- int m * int e)) = (\<Sum>ma<d. unity_root d (- int m * int ma))
[PROOF STEP]
using \<open>d > 0\<close>
[PROOF STATE]
proof (prove)
using this:
0 < d

goal (1 subgoal):
 1. (\<Sum>e = 0..d - 1. unity_root d (- int m * int e)) = (\<Sum>ma<d. unity_root d (- int m * int ma))
[PROOF STEP]
by (intro sum.cong) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>e = 0..d - 1. unity_root d (- int m * int e)) = unity_root_sum d (- int m)

goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>e = 1..d. unity_root d (- int m * int e)) = unity_root_sum d (- int m)
[PROOF STEP]
have
        "(\<Sum>e \<in> {1..d}. unity_root d (- m * e)) = unity_root_sum d (-m)"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>e = 1..d. unity_root d (- int m * int e)) = unity_root_sum d (- int m)

goal (1 subgoal):
 1. (\<Sum>e = 1..d. unity_root d (- int m * int e)) = unity_root_sum d (- int m)
[PROOF STEP]
by argo
[PROOF STATE]
proof (state)
this:
(\<Sum>e = 1..d. unity_root d (- int m * int e)) = unity_root_sum d (- int m)

goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?d2 dvd k \<Longrightarrow> (\<Sum>e = 1..?d2. unity_root ?d2 (- int m * int e)) = unity_root_sum ?d2 (- int m)

goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?d2 dvd k \<Longrightarrow> (\<Sum>e = 1..?d2. unity_root ?d2 (- int m * int e)) = unity_root_sum ?d2 (- int m)
[PROOF STEP]
have "
      (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- m * int e)) * (f (k div d) * g d)) =
      (\<Sum>d | d dvd k. unity_root_sum d (-m) * (f (k div d) * g d))"
[PROOF STATE]
proof (prove)
using this:
?d2 dvd k \<Longrightarrow> (\<Sum>e = 1..?d2. unity_root ?d2 (- int m * int e)) = unity_root_sum ?d2 (- int m)

goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d)) = (\<Sum>d | d dvd k. unity_root_sum d (- int m) * (f (k div d) * g d))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d)) = (\<Sum>d | d dvd k. unity_root_sum d (- int m) * (f (k div d) * g d))

goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d)) = (\<Sum>d | d dvd k. unity_root_sum d (- int m) * (f (k div d) * g d))

goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
have "\<dots> = (\<Sum>d | d dvd k \<and> d dvd m. unity_root_sum d (-m) * (f (k div d) * g d))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>d | d dvd k. unity_root_sum d (- int m) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. unity_root_sum d (- int m) * (f (k div d) * g d))
[PROOF STEP]
proof (intro sum.mono_neutral_right,simp add: \<open>k > 0\<close>,blast,standard)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i \<in> {d. d dvd k} - {d. d dvd k \<and> d dvd m} \<Longrightarrow> unity_root_sum i (- int m) * (f (k div i) * g i) = 0
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i \<in> {d. d dvd k} - {d. d dvd k \<and> d dvd m} \<Longrightarrow> unity_root_sum i (- int m) * (f (k div i) * g i) = 0
[PROOF STEP]
assume as: "i \<in> {d. d dvd k} - {d. d dvd k \<and> d dvd m}"
[PROOF STATE]
proof (state)
this:
i \<in> {d. d dvd k} - {d. d dvd k \<and> d dvd m}

goal (1 subgoal):
 1. \<And>i. i \<in> {d. d dvd k} - {d. d dvd k \<and> d dvd m} \<Longrightarrow> unity_root_sum i (- int m) * (f (k div i) * g i) = 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i \<in> {d. d dvd k} - {d. d dvd k \<and> d dvd m}
[PROOF STEP]
have "i \<ge> 1"
[PROOF STATE]
proof (prove)
using this:
i \<in> {d. d dvd k} - {d. d dvd k \<and> d dvd m}

goal (1 subgoal):
 1. 1 \<le> i
[PROOF STEP]
using \<open>k > 0\<close>
[PROOF STATE]
proof (prove)
using this:
i \<in> {d. d dvd k} - {d. d dvd k \<and> d dvd m}
0 < k

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

goal (1 subgoal):
 1. \<And>i. i \<in> {d. d dvd k} - {d. d dvd k \<and> d dvd m} \<Longrightarrow> unity_root_sum i (- int m) * (f (k div i) * g i) = 0
[PROOF STEP]
have "k \<ge> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 \<le> k
[PROOF STEP]
using \<open>k > 0\<close>
[PROOF STATE]
proof (prove)
using this:
0 < k

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

goal (1 subgoal):
 1. \<And>i. i \<in> {d. d dvd k} - {d. d dvd k \<and> d dvd m} \<Longrightarrow> unity_root_sum i (- int m) * (f (k div i) * g i) = 0
[PROOF STEP]
have "\<not> i dvd (-m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> int i dvd - int m
[PROOF STEP]
using as
[PROOF STATE]
proof (prove)
using this:
i \<in> {d. d dvd k} - {d. d dvd k \<and> d dvd m}

goal (1 subgoal):
 1. \<not> int i dvd - int m
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<not> int i dvd - int m

goal (1 subgoal):
 1. \<And>i. i \<in> {d. d dvd k} - {d. d dvd k \<and> d dvd m} \<Longrightarrow> unity_root_sum i (- int m) * (f (k div i) * g i) = 0
[PROOF STEP]
thus "unity_root_sum i (- int m) * (f (k div i) * g i) = 0"
[PROOF STATE]
proof (prove)
using this:
\<not> int i dvd - int m

goal (1 subgoal):
 1. unity_root_sum i (- int m) * (f (k div i) * g i) = 0
[PROOF STEP]
using \<open>i \<ge> 1\<close>
[PROOF STATE]
proof (prove)
using this:
\<not> int i dvd - int m
1 \<le> i

goal (1 subgoal):
 1. unity_root_sum i (- int m) * (f (k div i) * g i) = 0
[PROOF STEP]
by (subst unity_root_sum(2)) auto
[PROOF STATE]
proof (state)
this:
unity_root_sum i (- int m) * (f (k div i) * g i) = 0

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd k. unity_root_sum d (- int m) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. unity_root_sum d (- int m) * (f (k div d) * g d))

goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd k. unity_root_sum d (- int m) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. unity_root_sum d (- int m) * (f (k div d) * g d))

goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
have "\<dots> = (\<Sum>d | d dvd k \<and> d dvd m. d * (f (k div d) * g d))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>d | d dvd k \<and> d dvd m. unity_root_sum d (- int m) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>d | d dvd k \<and> d dvd m. unity_root_sum d (- int m) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>d | d dvd k \<and> d dvd m. unity_root_sum d (- int m) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
fix d :: nat
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>d | d dvd k \<and> d dvd m. unity_root_sum d (- int m) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
assume 1: "d dvd m"
[PROOF STATE]
proof (state)
this:
d dvd m

goal (1 subgoal):
 1. (\<Sum>d | d dvd k \<and> d dvd m. unity_root_sum d (- int m) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
assume 2: "d dvd k"
[PROOF STATE]
proof (state)
this:
d dvd k

goal (1 subgoal):
 1. (\<Sum>d | d dvd k \<and> d dvd m. unity_root_sum d (- int m) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
d dvd k
[PROOF STEP]
have "unity_root_sum d (-m) = d"
[PROOF STATE]
proof (prove)
using this:
d dvd k

goal (1 subgoal):
 1. unity_root_sum d (- int m) = of_nat d
[PROOF STEP]
using unity_root_sum[of d "(-m)"] assms(1) 1 2
[PROOF STATE]
proof (prove)
using this:
d dvd k
\<lbrakk>1 \<le> d; int d dvd - int m\<rbrakk> \<Longrightarrow> unity_root_sum d (- int m) = of_nat d
\<lbrakk>1 \<le> d; \<not> int d dvd - int m\<rbrakk> \<Longrightarrow> unity_root_sum d (- int m) = 0
0 < k
d dvd m
d dvd k

goal (1 subgoal):
 1. unity_root_sum d (- int m) = of_nat d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
unity_root_sum d (- int m) = of_nat d

goal (1 subgoal):
 1. (\<Sum>d | d dvd k \<and> d dvd m. unity_root_sum d (- int m) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>?d2 dvd m; ?d2 dvd k\<rbrakk> \<Longrightarrow> unity_root_sum ?d2 (- int m) = of_nat ?d2

goal (1 subgoal):
 1. (\<Sum>d | d dvd k \<and> d dvd m. unity_root_sum d (- int m) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>?d2 dvd m; ?d2 dvd k\<rbrakk> \<Longrightarrow> unity_root_sum ?d2 (- int m) = of_nat ?d2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?d2 dvd m; ?d2 dvd k\<rbrakk> \<Longrightarrow> unity_root_sum ?d2 (- int m) = of_nat ?d2

goal (1 subgoal):
 1. (\<Sum>d | d dvd k \<and> d dvd m. unity_root_sum d (- int m) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd k \<and> d dvd m. unity_root_sum d (- int m) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd k \<and> d dvd m. unity_root_sum d (- int m) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))

goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))

goal (1 subgoal):
 1. (\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))
[PROOF STEP]
by argo
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd k. (\<Sum>e = 1..d. unity_root d (- int m * int e)) * (f (k div d) * g d)) = (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d))

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
have "\<dots> = (\<Sum>d | d dvd gcd m k. of_nat d * (f (k div d) * g d))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d)) = (\<Sum>d | d dvd gcd m k. of_nat d * (f (k div d) * g d))
[PROOF STEP]
by (simp add: gcd.commute)
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd k \<and> d dvd m. of_nat d * (f (k div d) * g d)) = (\<Sum>d | d dvd gcd m k. of_nat d * (f (k div d) * g d))

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

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
have "\<dots> = (\<Sum>d | d dvd gcd m k. g d * f (k div d) * d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>d | d dvd gcd m k. of_nat d * (f (k div d) * g d)) = (\<Sum>d | d dvd gcd m k. g d * f (k div d) * of_nat d)
[PROOF STEP]
by (simp add: algebra_simps sum_distrib_left)
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd gcd m k. of_nat d * (f (k div d) * g d)) = (\<Sum>d | d dvd gcd m k. g d * f (k div d) * of_nat d)

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

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

goal (1 subgoal):
 1. complex_of_real (1 / real k) * (\<Sum>d | d dvd gcd m k. g d * f (k div d) * of_nat d) = a k m
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
complex_of_real (1 / real k) * (\<Sum>d | d dvd gcd m k. g d * f (k div d) * of_nat d) = a k m

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
complex_of_real (1 / real k) * (\<Sum>l<k. s f g k l * unity_root k (- int m * int l)) = a k m
[PROOF STEP]
have "?g m = a k m"
[PROOF STATE]
proof (prove)
using this:
complex_of_real (1 / real k) * (\<Sum>l<k. s f g k l * unity_root k (- int m * int l)) = a k m

goal (1 subgoal):
 1. 1 / of_nat k * (\<Sum>ma<k. s f g k ma * unity_root k (- int m * int ma)) = a k m
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 / of_nat k * (\<Sum>ma<k. s f g k ma * unity_root k (- int m * int ma)) = a k m

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
1 / of_nat k * (\<Sum>m<k. s f g k m * unity_root k (- int ?m2 * int m)) = a k ?m2

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
note a_eq_g = this
[PROOF STATE]
proof (state)
this:
1 / of_nat k * (\<Sum>m<k. s f g k m * unity_root k (- int ?m2 * int m)) = a k ?m2

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
1 / of_nat k * (\<Sum>m<k. s f g k m * unity_root k (- int ?m2 * int m)) = a k ?m2

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
fix m
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
from fourier_expansion_periodic_arithmetic(2)[of k "s f g k" ] gen_ramanujan_sum_periodic assms(1)
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>0 < k; periodic_arithmetic (s f g k) k\<rbrakk> \<Longrightarrow> s f g k ?m = (\<Sum>n<k. 1 / of_nat k * (\<Sum>m<k. s f g k m * unity_root k (- int n * int m)) * unity_root k (int ?m * int n))
periodic_arithmetic (s ?f ?g ?k) ?k
0 < k
[PROOF STEP]
have "s f g k m = (\<Sum>n<k. ?g n * unity_root k (int m * n))"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 < k; periodic_arithmetic (s f g k) k\<rbrakk> \<Longrightarrow> s f g k ?m = (\<Sum>n<k. 1 / of_nat k * (\<Sum>m<k. s f g k m * unity_root k (- int n * int m)) * unity_root k (int ?m * int n))
periodic_arithmetic (s ?f ?g ?k) ?k
0 < k

goal (1 subgoal):
 1. s f g k m = (\<Sum>n<k. 1 / of_nat k * (\<Sum>m<k. s f g k m * unity_root k (- int n * int m)) * unity_root k (int m * int n))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
s f g k m = (\<Sum>n<k. 1 / of_nat k * (\<Sum>m<k. s f g k m * unity_root k (- int n * int m)) * unity_root k (int m * int n))

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
s f g k m = (\<Sum>n<k. 1 / of_nat k * (\<Sum>m<k. s f g k m * unity_root k (- int n * int m)) * unity_root k (int m * int n))

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
have "\<dots> = (\<Sum>n<k. a k n * unity_root k (int m * n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>n<k. 1 / of_nat k * (\<Sum>m<k. s f g k m * unity_root k (- int n * int m)) * unity_root k (int m * int n)) = (\<Sum>n<k. a k n * unity_root k (int m * int n))
[PROOF STEP]
using a_eq_g
[PROOF STATE]
proof (prove)
using this:
1 / of_nat k * (\<Sum>m<k. s f g k m * unity_root k (- int ?m2 * int m)) = a k ?m2

goal (1 subgoal):
 1. (\<Sum>n<k. 1 / of_nat k * (\<Sum>m<k. s f g k m * unity_root k (- int n * int m)) * unity_root k (int m * int n)) = (\<Sum>n<k. a k n * unity_root k (int m * int n))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>n<k. 1 / of_nat k * (\<Sum>m<k. s f g k m * unity_root k (- int n * int m)) * unity_root k (int m * int n)) = (\<Sum>n<k. a k n * unity_root k (int m * int n))

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>n<k. 1 / of_nat k * (\<Sum>m<k. s f g k m * unity_root k (- int n * int m)) * unity_root k (int m * int n)) = (\<Sum>n<k. a k n * unity_root k (int m * int n))

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
have "\<dots> = (\<Sum>n\<le>k-1. a k n * unity_root k (int m * n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>n<k. a k n * unity_root k (int m * int n)) = (\<Sum>n\<le>k - 1. a k n * unity_root k (int m * int n))
[PROOF STEP]
using \<open>k > 0\<close>
[PROOF STATE]
proof (prove)
using this:
0 < k

goal (1 subgoal):
 1. (\<Sum>n<k. a k n * unity_root k (int m * int n)) = (\<Sum>n\<le>k - 1. a k n * unity_root k (int m * int n))
[PROOF STEP]
by (intro sum.cong) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>n<k. a k n * unity_root k (int m * int n)) = (\<Sum>n\<le>k - 1. a k n * unity_root k (int m * int n))

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
s f g k m = (\<Sum>n\<le>k - 1. a k n * unity_root k (int m * int n))
[PROOF STEP]
have "s f g k m =
      (\<Sum>n\<le>k - 1. a k n * unity_root k (int n * int m))"
[PROOF STATE]
proof (prove)
using this:
s f g k m = (\<Sum>n\<le>k - 1. a k n * unity_root k (int m * int n))

goal (1 subgoal):
 1. s f g k m = (\<Sum>n\<le>k - 1. a k n * unity_root k (int n * int m))
[PROOF STEP]
by (simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
s f g k m = (\<Sum>n\<le>k - 1. a k n * unity_root k (int n * int m))

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
s f g k ?m2 = (\<Sum>n\<le>k - 1. a k n * unity_root k (int n * int ?m2))

goal (1 subgoal):
 1. s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
s f g k ?m2 = (\<Sum>n\<le>k - 1. a k n * unity_root k (int n * int ?m2))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
s f g k ?m2 = (\<Sum>n\<le>k - 1. a k n * unity_root k (int n * int ?m2))

goal (1 subgoal):
 1. s f g k 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:
s f g k n = (\<Sum>m\<le>k - 1. a k m * unity_root k (int m * int n))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in aGroup) ag_diff_minus:"\<lbrakk>a \<in> carrier A; b \<in> carrier A; c \<in> carrier A;
                   a \<plusminus> (-\<^sub>a b) = c\<rbrakk> \<Longrightarrow> b \<plusminus> (-\<^sub>a a) = (-\<^sub>a c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<in> carrier A; b \<in> carrier A; c \<in> carrier A; a \<plusminus> -\<^sub>a b = c\<rbrakk> \<Longrightarrow> b \<plusminus> -\<^sub>a a = -\<^sub>a c
[PROOF STEP]
apply (frule sym, thin_tac "a \<plusminus> -\<^sub>a b = c", simp, thin_tac "c = a \<plusminus> -\<^sub>a b")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<in> carrier A; b \<in> carrier A; a \<plusminus> -\<^sub>a b \<in> carrier A\<rbrakk> \<Longrightarrow> b \<plusminus> -\<^sub>a a = -\<^sub>a (a \<plusminus> -\<^sub>a b)
[PROOF STEP]
apply (frule ag_mOp_closed[of "b"], frule ag_mOp_closed[of "a"],
       subst ag_p_inv, assumption+, subst ag_inv_inv, assumption)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<in> carrier A; b \<in> carrier A; a \<plusminus> -\<^sub>a b \<in> carrier A; -\<^sub>a b \<in> carrier A; -\<^sub>a a \<in> carrier A\<rbrakk> \<Longrightarrow> b \<plusminus> -\<^sub>a a = -\<^sub>a a \<plusminus> b
[PROOF STEP]
apply (simp add:ag_pOp_commute)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
theorem bs_meld_correct:
  assumes I: "bs_invar h" "bs_invar h'"
  shows
  "bs_invar (bs_meld h h')"
  "bs_to_mset (bs_meld h h') = bs_to_mset h + bs_to_mset h'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bs_invar (bs_meld h h') &&& bs_to_mset (bs_meld h h') = bs_to_mset h + bs_to_mset h'
[PROOF STEP]
using I
[PROOF STATE]
proof (prove)
using this:
bs_invar h
bs_invar h'

goal (1 subgoal):
 1. bs_invar (bs_meld h h') &&& bs_to_mset (bs_meld h h') = bs_to_mset h + bs_to_mset h'
[PROOF STEP]
apply (case_tac [!] h, case_tac [!] h')
[PROOF STATE]
proof (prove)
goal (8 subgoals):
 1. \<And>a aa. \<lbrakk>bs_invar h; bs_invar h'; h = Inl a; bs_invar h; bs_invar h'; h' = Inl aa\<rbrakk> \<Longrightarrow> bs_invar (bs_meld h h')
 2. \<And>a b. \<lbrakk>bs_invar h; bs_invar h'; h = Inl a; bs_invar h; bs_invar h'; h' = Inr b\<rbrakk> \<Longrightarrow> bs_invar (bs_meld h h')
 3. \<And>b a. \<lbrakk>bs_invar h; bs_invar h'; h = Inr b; bs_invar h; bs_invar h'; h' = Inl a\<rbrakk> \<Longrightarrow> bs_invar (bs_meld h h')
 4. \<And>b ba. \<lbrakk>bs_invar h; bs_invar h'; h = Inr b; bs_invar h; bs_invar h'; h' = Inr ba\<rbrakk> \<Longrightarrow> bs_invar (bs_meld h h')
 5. \<And>a aa. \<lbrakk>bs_invar h; bs_invar h'; h = Inl a; bs_invar h; bs_invar h'; h' = Inl aa\<rbrakk> \<Longrightarrow> bs_to_mset (bs_meld h h') = bs_to_mset h + bs_to_mset h'
 6. \<And>a b. \<lbrakk>bs_invar h; bs_invar h'; h = Inl a; bs_invar h; bs_invar h'; h' = Inr b\<rbrakk> \<Longrightarrow> bs_to_mset (bs_meld h h') = bs_to_mset h + bs_to_mset h'
 7. \<And>b a. \<lbrakk>bs_invar h; bs_invar h'; h = Inr b; bs_invar h; bs_invar h'; h' = Inl a\<rbrakk> \<Longrightarrow> bs_to_mset (bs_meld h h') = bs_to_mset h + bs_to_mset h'
 8. \<And>b ba. \<lbrakk>bs_invar h; bs_invar h'; h = Inr b; bs_invar h; bs_invar h'; h' = Inr ba\<rbrakk> \<Longrightarrow> bs_to_mset (bs_meld h h') = bs_to_mset h + bs_to_mset h'
[PROOF STEP]
apply (auto simp add: meld_correct')
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma asymp_equiv_at_top_imp_at_right_0:
  "(\<lambda>x. f (inverse x)) \<sim>[at_top] (\<lambda>x. g (inverse x)) \<Longrightarrow> f \<sim>[at_right 0] g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. f (inverse x)) \<sim>[at_top] (\<lambda>x. g (inverse x)) \<Longrightarrow> f \<sim>[at_right 0] g
[PROOF STEP]
by (simp add: at_right_to_top asymp_equiv_filtermap_iff)


[STATEMENT]
lemma mat_of_cols_cons_mat_vec:
  fixes v ::"'a::comm_ring vec"
  assumes "v \<in> carrier_vec (length ls)"
  assumes "dim_vec a = nr"
  shows
    "mat_of_cols nr (a # ls) *\<^sub>v (vCons m v) =
   m \<cdot>\<^sub>v a + mat_of_cols nr ls *\<^sub>v v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_of_cols nr (a # ls) *\<^sub>v vCons m v = m \<cdot>\<^sub>v a + mat_of_cols nr ls *\<^sub>v v
[PROOF STEP]
unfolding mult_mat_vec_def vec_eq_iff
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec (vec (dim_row (mat_of_cols nr (a # ls))) (\<lambda>i. row (mat_of_cols nr (a # ls)) i \<bullet> vCons m v)) = dim_vec (m \<cdot>\<^sub>v a + vec (dim_row (mat_of_cols nr ls)) (\<lambda>i. row (mat_of_cols nr ls) i \<bullet> v)) \<and> (\<forall>i<dim_vec (m \<cdot>\<^sub>v a + vec (dim_row (mat_of_cols nr ls)) (\<lambda>i. row (mat_of_cols nr ls) i \<bullet> v)). vec (dim_row (mat_of_cols nr (a # ls))) (\<lambda>i. row (mat_of_cols nr (a # ls)) i \<bullet> vCons m v) $ i = (m \<cdot>\<^sub>v a + vec (dim_row (mat_of_cols nr ls)) (\<lambda>i. row (mat_of_cols nr ls) i \<bullet> v)) $ i)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
v \<in> carrier_vec (length ls)
dim_vec a = nr

goal (1 subgoal):
 1. dim_vec (vec (dim_row (mat_of_cols nr (a # ls))) (\<lambda>i. row (mat_of_cols nr (a # ls)) i \<bullet> vCons m v)) = dim_vec (m \<cdot>\<^sub>v a + vec (dim_row (mat_of_cols nr ls)) (\<lambda>i. row (mat_of_cols nr ls) i \<bullet> v)) \<and> (\<forall>i<dim_vec (m \<cdot>\<^sub>v a + vec (dim_row (mat_of_cols nr ls)) (\<lambda>i. row (mat_of_cols nr ls) i \<bullet> v)). vec (dim_row (mat_of_cols nr (a # ls))) (\<lambda>i. row (mat_of_cols nr (a # ls)) i \<bullet> vCons m v) $ i = (m \<cdot>\<^sub>v a + vec (dim_row (mat_of_cols nr ls)) (\<lambda>i. row (mat_of_cols nr ls) i \<bullet> v)) $ i)
[PROOF STEP]
by
    (auto simp add: row_mat_of_cols vec_Suc o_def mult.commute)


[STATEMENT]
lemma closure_interior: "closure S = - interior (- S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. closure S = - interior (- S)
[PROOF STEP]
by (simp add: interior_closure)


[STATEMENT]
lemma add_scaleR_degen:
  fixes a b ::"'a::real_vector"
  assumes  "(u *\<^sub>R b + v *\<^sub>R a) = (u *\<^sub>R a + v *\<^sub>R b)"  "u \<noteq> v"
  shows "a=b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a = b
[PROOF STEP]
by (metis (no_types, opaque_lifting) add.commute add_diff_eq diff_add_cancel real_vector.scale_cancel_left real_vector.scale_left_diff_distrib assms)


[STATEMENT]
lemma step_1_similar: "A \<in> carrier_mat n n \<Longrightarrow> similar_mat (step_1 A) A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<in> carrier_mat n n \<Longrightarrow> similar_mat (step_1 A) A
[PROOF STEP]
unfolding step_1_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<in> carrier_mat n n \<Longrightarrow> similar_mat (step_1_main (dim_row A) 0 0 A) A
[PROOF STEP]
by (rule step_1_main_similar, auto)


[STATEMENT]
lemma proj2_line_rep_dependent:
  assumes "i *\<^sub>R proj2_line_rep l + j *\<^sub>R proj2_line_rep m = 0"
  and "i \<noteq> 0 \<or> j \<noteq> 0"
  shows "l = m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. l = m
[PROOF STEP]
using proj2_rep_dependent [of i "L2P l" j "L2P m"] and assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>i *\<^sub>R proj2_rep (L2P l) + j *\<^sub>R proj2_rep (L2P m) = 0; i \<noteq> 0 \<or> j \<noteq> 0\<rbrakk> \<Longrightarrow> L2P l = L2P m
i *\<^sub>R proj2_line_rep l + j *\<^sub>R proj2_line_rep m = 0
i \<noteq> 0 \<or> j \<noteq> 0

goal (1 subgoal):
 1. l = m
[PROOF STEP]
unfolding proj2_line_rep_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>i *\<^sub>R proj2_rep (L2P l) + j *\<^sub>R proj2_rep (L2P m) = 0; i \<noteq> 0 \<or> j \<noteq> 0\<rbrakk> \<Longrightarrow> L2P l = L2P m
i *\<^sub>R proj2_rep (L2P l) + j *\<^sub>R proj2_rep (L2P m) = 0
i \<noteq> 0 \<or> j \<noteq> 0

goal (1 subgoal):
 1. l = m
[PROOF STEP]
by simp


[STATEMENT]
lemma totient_primorial:
  "real (totient (primorial x)) =
     real (primorial x) * (\<Prod>p | prime p \<and> real p \<le> x. 1 - 1 / real p)" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (totient (primorial x)) = real (primorial x) * (\<Prod>p\<in>{p. prime p \<and> real p \<le> x}. 1 - 1 / real p)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. real (totient (primorial x)) = real (primorial x) * (\<Prod>p\<in>{p. prime p \<and> real p \<le> x}. 1 - 1 / real p)
[PROOF STEP]
have "real (totient (primorial x)) =
          primorial x * (\<Prod>p\<in>prime_factors (primorial x). 1 - 1 / p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (totient (primorial x)) = real (primorial x) * (\<Prod>p\<in>prime_factors (primorial x). 1 - 1 / real p)
[PROOF STEP]
by (rule totient_formula2)
[PROOF STATE]
proof (state)
this:
real (totient (primorial x)) = real (primorial x) * (\<Prod>p\<in>prime_factors (primorial x). 1 - 1 / real p)

goal (1 subgoal):
 1. real (totient (primorial x)) = real (primorial x) * (\<Prod>p\<in>{p. prime p \<and> real p \<le> x}. 1 - 1 / real p)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
real (totient (primorial x)) = real (primorial x) * (\<Prod>p\<in>prime_factors (primorial x). 1 - 1 / real p)

goal (1 subgoal):
 1. real (totient (primorial x)) = real (primorial x) * (\<Prod>p\<in>{p. prime p \<and> real p \<le> x}. 1 - 1 / real p)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
real (totient (primorial x)) = real (primorial x) * (\<Prod>p\<in>{p. prime p \<and> real p \<le> x}. 1 - 1 / real p)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mahler_measure_poly_via_monic :
  "mahler_measure_poly p = cmod (lead_coeff p) * mahler_measure_monic p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mahler_measure_poly p = cmod (lead_coeff p) * mahler_measure_monic p
[PROOF STEP]
unfolding mahler_measure_poly_def mahler_measure_monic_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cmod (lead_coeff p) * (\<Prod>a\<leftarrow>complex_roots_complex p. max 1 (cmod a)) = cmod (lead_coeff p) * (\<Prod>a\<leftarrow>complex_roots_complex p. max 1 (cmod a))
[PROOF STEP]
by simp


[STATEMENT]
lemma (in euclidean_space) inner_not_same_Basis: "u \<in> Basis \<Longrightarrow> v \<in> Basis \<Longrightarrow> u \<noteq> v \<Longrightarrow> inner u v = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>u \<in> Basis; v \<in> Basis; u \<noteq> v\<rbrakk> \<Longrightarrow> inner u v = 0
[PROOF STEP]
by (simp add: inner_Basis)


[STATEMENT]
lemma rank_1_proj_dim[simp]:
  shows "dim_row (rank_1_proj v) = dim_vec v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row (rank_1_proj v) = dim_vec v
[PROOF STEP]
using outer_prod_dim
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?v \<in> carrier_vec ?n; ?w \<in> carrier_vec ?m\<rbrakk> \<Longrightarrow> outer_prod ?v ?w \<in> carrier_mat ?n ?m

goal (1 subgoal):
 1. dim_row (rank_1_proj v) = dim_vec v
[PROOF STEP]
unfolding rank_1_proj_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?v \<in> carrier_vec ?n; ?w \<in> carrier_vec ?m\<rbrakk> \<Longrightarrow> outer_prod ?v ?w \<in> carrier_mat ?n ?m

goal (1 subgoal):
 1. dim_row (outer_prod v v) = dim_vec v
[PROOF STEP]
using carrier_vecI
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?v \<in> carrier_vec ?n; ?w \<in> carrier_vec ?m\<rbrakk> \<Longrightarrow> outer_prod ?v ?w \<in> carrier_mat ?n ?m
dim_vec ?v = ?n \<Longrightarrow> ?v \<in> carrier_vec ?n

goal (1 subgoal):
 1. dim_row (outer_prod v v) = dim_vec v
[PROOF STEP]
by blast


[STATEMENT]
theorem backward1_conv: "(A \<Longrightarrow> B \<Longrightarrow> C) \<equiv> (\<not>C \<Longrightarrow> B \<Longrightarrow> \<not>A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lbrakk>A; B\<rbrakk> \<Longrightarrow> C) \<equiv> (\<lbrakk>\<not> C; B\<rbrakk> \<Longrightarrow> \<not> A)
[PROOF STEP]
by (rule equal_intr_rule) auto


[STATEMENT]
lemma max_balls_disjoint:
  assumes "U \<subseteq> carrier Q\<^sub>p"
  assumes "is_max_ball_of U B"
  assumes "is_max_ball_of U B'"
  assumes "B \<noteq>B'"
  shows "B \<inter> B' = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B \<inter> B' = {}
[PROOF STEP]
by (meson assms(2) assms(3) assms(4) nested_balls' is_max_ball_of_def
      padic_integers_axioms subset_antisym)


[STATEMENT]
lemma infsetsum_nat':
  assumes "f abs_summable_on UNIV"
  shows   "infsetsum f UNIV = (\<Sum>n. f n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infsetsum f UNIV = (\<Sum>n. f n)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f abs_summable_on UNIV

goal (1 subgoal):
 1. infsetsum f UNIV = (\<Sum>n. f n)
[PROOF STEP]
by (subst infsetsum_nat) auto


[STATEMENT]
lemma one_le_inverse_iff: "1 \<le> inverse x \<longleftrightarrow> 0 < x \<and> x \<le> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((1::'a) \<le> inverse x) = ((0::'a) < x \<and> x \<le> (1::'a))
[PROOF STEP]
by (metis local.dual_order.strict_trans1 local.inverse_1 local.inverse_le_imp_le local.inverse_positive_iff_positive local.one_le_inverse local.zero_less_one)


[STATEMENT]
lemma inverse_of_nat_tendsto_zero:
  "(\<lambda>x. inverse (of_nat x :: 'a :: real_normed_div_algebra)) \<longlonglongrightarrow> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. inverse (of_nat x)) \<longlonglongrightarrow> (0::'a)
[PROOF STEP]
using inverse_power_tendsto_zero[of 0]
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. inverse (of_nat x ^ Suc 0)) \<longlonglongrightarrow> (0::?'a)

goal (1 subgoal):
 1. (\<lambda>x. inverse (of_nat x)) \<longlonglongrightarrow> (0::'a)
[PROOF STEP]
by auto


[STATEMENT]
lemma starlike_imp_connected:
  fixes S :: "'a::real_normed_vector set"
  shows "starlike S \<Longrightarrow> connected S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. starlike S \<Longrightarrow> connected S
[PROOF STEP]
by (simp add: path_connected_imp_connected starlike_imp_path_connected)


[STATEMENT]
lemma complex_mod_rcis [simp]: "cmod (rcis r a) = \<bar>r\<bar>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cmod (rcis r a) = \<bar>r\<bar>
[PROOF STEP]
by (simp add: rcis_def norm_mult)


[STATEMENT]
lemma finite_neq_0_inv':
  assumes inf_A: "finite {x. h (f x) (g x) \<noteq> 0}" and fin_B: "finite {x. f x \<noteq> 0}" and "\<And>x. h 0 x = x"
  shows "finite {x. g x \<noteq> 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {x. g x \<noteq> (0::'b)}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite {x. h (f x) (g x) \<noteq> (0::'b)}
finite {x. f x \<noteq> (0::'c)}
h (0::'c) ?x = ?x

goal (1 subgoal):
 1. finite {x. g x \<noteq> (0::'b)}
[PROOF STEP]
by (rule finite_neq_0_inv)


[STATEMENT]
lemma ceiling_less_neg_numeral [simp]: "\<lceil>x\<rceil> < - numeral v \<longleftrightarrow> x \<le> - numeral v - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lceil>x\<rceil> < - numeral v) = (x \<le> - numeral v - (1::'a))
[PROOF STEP]
by (simp add: ceiling_less_iff)


[STATEMENT]
lemma zmset_subseteq_add_iff2:
  \<open>i \<le> j \<Longrightarrow> (repeat_zmset i u + m \<subseteq>#\<^sub>z repeat_zmset j u + n) = (m \<subseteq>#\<^sub>z repeat_zmset (j - i) u + n)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i \<le> j \<Longrightarrow> (repeat_zmset i u + m \<subseteq>#\<^sub>z repeat_zmset j u + n) = (m \<subseteq>#\<^sub>z repeat_zmset (j - i) u + n)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i \<le> j \<Longrightarrow> (repeat_zmset i u + m \<subseteq>#\<^sub>z repeat_zmset j u + n) = (m \<subseteq>#\<^sub>z repeat_zmset (j - i) u + n)
[PROOF STEP]
assume "i \<le> j"
[PROOF STATE]
proof (state)
this:
i \<le> j

goal (1 subgoal):
 1. i \<le> j \<Longrightarrow> (repeat_zmset i u + m \<subseteq>#\<^sub>z repeat_zmset j u + n) = (m \<subseteq>#\<^sub>z repeat_zmset (j - i) u + n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i \<le> j
[PROOF STEP]
have "\<And>z. repeat_zmset j (z::'a zmultiset) - repeat_zmset i z = repeat_zmset (j - i) z"
[PROOF STATE]
proof (prove)
using this:
i \<le> j

goal (1 subgoal):
 1. \<And>z. repeat_zmset j z - repeat_zmset i z = repeat_zmset (j - i) z
[PROOF STEP]
by (simp add: left_diff_repeat_zmset_distrib')
[PROOF STATE]
proof (state)
this:
repeat_zmset j ?z - repeat_zmset i ?z = repeat_zmset (j - i) ?z

goal (1 subgoal):
 1. i \<le> j \<Longrightarrow> (repeat_zmset i u + m \<subseteq>#\<^sub>z repeat_zmset j u + n) = (m \<subseteq>#\<^sub>z repeat_zmset (j - i) u + n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
repeat_zmset j ?z - repeat_zmset i ?z = repeat_zmset (j - i) ?z
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
repeat_zmset j ?z - repeat_zmset i ?z = repeat_zmset (j - i) ?z

goal (1 subgoal):
 1. (repeat_zmset i u + m \<subseteq>#\<^sub>z repeat_zmset j u + n) = (m \<subseteq>#\<^sub>z repeat_zmset (j - i) u + n)
[PROOF STEP]
by (metis add.commute diff_diff_eq2 subset_eq_diff_conv_zmset)
[PROOF STATE]
proof (state)
this:
(repeat_zmset i u + m \<subseteq>#\<^sub>z repeat_zmset j u + n) = (m \<subseteq>#\<^sub>z repeat_zmset (j - i) u + n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma insertion_fun_irrelevant_vars:
fixes p::"((nat \<Rightarrow>\<^sub>0 nat) \<Rightarrow> 'a::comm_ring_1)"
assumes "\<And>m v. p m \<noteq> 0 \<Longrightarrow> lookup m v \<noteq> 0 \<Longrightarrow> f v = g v"
shows "insertion_fun f p = insertion_fun g p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. insertion_fun f p = insertion_fun g p
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. insertion_fun f p = insertion_fun g p
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. insertion_fun f p = insertion_fun g p
[PROOF STEP]
fix m::"nat\<Rightarrow>\<^sub>0nat"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. insertion_fun f p = insertion_fun g p
[PROOF STEP]
assume "p m \<noteq> 0"
[PROOF STATE]
proof (state)
this:
p m \<noteq> (0::'a)

goal (1 subgoal):
 1. insertion_fun f p = insertion_fun g p
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
p m \<noteq> (0::'a)
[PROOF STEP]
have "(\<Prod>v. f v ^ lookup m v) = (\<Prod>v. g v ^ lookup m v)"
[PROOF STATE]
proof (prove)
using this:
p m \<noteq> (0::'a)

goal (1 subgoal):
 1. (\<Prod>v. f v ^ lookup m v) = (\<Prod>v. g v ^ lookup m v)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
p m \<noteq> (0::'a)
\<lbrakk>p ?m \<noteq> (0::'a); lookup ?m ?v \<noteq> 0\<rbrakk> \<Longrightarrow> f ?v = g ?v

goal (1 subgoal):
 1. (\<Prod>v. f v ^ lookup m v) = (\<Prod>v. g v ^ lookup m v)
[PROOF STEP]
by (metis power_0)
[PROOF STATE]
proof (state)
this:
(\<Prod>v. f v ^ lookup m v) = (\<Prod>v. g v ^ lookup m v)

goal (1 subgoal):
 1. insertion_fun f p = insertion_fun g p
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
p ?m2 \<noteq> (0::'a) \<Longrightarrow> (\<Prod>v. f v ^ lookup ?m2 v) = (\<Prod>v. g v ^ lookup ?m2 v)

goal (1 subgoal):
 1. insertion_fun f p = insertion_fun g p
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
p ?m2 \<noteq> (0::'a) \<Longrightarrow> (\<Prod>v. f v ^ lookup ?m2 v) = (\<Prod>v. g v ^ lookup ?m2 v)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
p ?m2 \<noteq> (0::'a) \<Longrightarrow> (\<Prod>v. f v ^ lookup ?m2 v) = (\<Prod>v. g v ^ lookup ?m2 v)

goal (1 subgoal):
 1. insertion_fun f p = insertion_fun g p
[PROOF STEP]
unfolding insertion_fun_def
[PROOF STATE]
proof (prove)
using this:
p ?m2 \<noteq> (0::'a) \<Longrightarrow> (\<Prod>v. f v ^ lookup ?m2 v) = (\<Prod>v. g v ^ lookup ?m2 v)

goal (1 subgoal):
 1. (\<Sum>m. p m * (\<Prod>v. f v ^ lookup m v)) = (\<Sum>m. p m * (\<Prod>v. g v ^ lookup m v))
[PROOF STEP]
by (metis (no_types, lifting) mult_not_zero)
[PROOF STATE]
proof (state)
this:
insertion_fun f p = insertion_fun g p

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma setprod_greater_zero:
  fixes f::"nat \<Rightarrow> nat"
  assumes "\<forall>i \<le> n. f i \<ge> 0"
  shows "(\<Prod>i \<le> n. f i) \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> prod f {..n}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<forall>i\<le>n. 0 \<le> f i

goal (1 subgoal):
 1. 0 \<le> prod f {..n}
[PROOF STEP]
by (induct n) (auto)


[STATEMENT]
lemma len_mult_pow2[simp]: "len (x * 2 ^ m) = (if x = 0 then 0 else len x + m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. len (x * 2 ^ m) = (if x = 0 then 0 else len x + m)
[PROOF STEP]
by (induct m arbitrary: x) (auto simp: div_mult2_eq mult.assoc[symmetric] mult.commute[of _ 2])


[STATEMENT]
lemma matrix_diff_vect_distrib: "(A - B) *v v = A *v v - B *v (v :: 'a :: ring_1 ^ 'n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (A - B) *v v = A *v v - B *v v
[PROOF STEP]
by (transfer_hma rule: minus_mult_distrib_mat_vec)


[STATEMENT]
lemma pos_minus_divide_less_eq [field_simps]: "0 < c \<Longrightarrow> - (b / c) < a \<longleftrightarrow> - b < a * c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0::'a) < c \<Longrightarrow> (- (b / c) < a) = (- b < a * c)
[PROOF STEP]
unfolding minus_divide_left
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0::'a) < c \<Longrightarrow> (- b / c < a) = (- b < a * c)
[PROOF STEP]
by (rule pos_divide_less_eq)


[STATEMENT]
lemma cos_expansion_lemma: "cos (x + real (Suc m) * pi / 2) = - sin (x + real m * pi / 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos (x + real (Suc m) * pi / 2) = - sin (x + real m * pi / 2)
[PROOF STEP]
by (auto simp: cos_add sin_add distrib_right add_divide_distrib)


[STATEMENT]
theorem backward2_conv: "(A \<Longrightarrow> B \<Longrightarrow> C) \<equiv> (\<not>C \<Longrightarrow> A \<Longrightarrow> \<not>B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lbrakk>A; B\<rbrakk> \<Longrightarrow> C) \<equiv> (\<lbrakk>\<not> C; A\<rbrakk> \<Longrightarrow> \<not> B)
[PROOF STEP]
by (rule equal_intr_rule) auto


[STATEMENT]
lemma greatest_ge_nonzero_row:
  fixes A::"'a::{zero}^'n::{mod_type}^'m::{finite,linorder}"
  assumes "\<not> is_zero_row_upt_k i k A"
  shows "i \<le> (GREATEST m. \<not> is_zero_row_upt_k m k A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i \<le> (GREATEST m. \<not> is_zero_row_upt_k m k A)
[PROOF STEP]
using Greatest_ge[of "(\<lambda>m. \<not> is_zero_row_upt_k m k A)", OF assms]
[PROOF STATE]
proof (prove)
using this:
i \<le> (GREATEST x. \<not> is_zero_row_upt_k x k A)

goal (1 subgoal):
 1. i \<le> (GREATEST m. \<not> is_zero_row_upt_k m k A)
[PROOF STEP]
.


[STATEMENT]
lemma proj_mult_scalar [term_simps]: "proj_poly k (p \<odot> q) = p * (proj_poly k q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proj_poly k (p \<odot> q) = p * proj_poly k q
[PROOF STEP]
unfolding mult_scalar_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proj_poly k (lift_poly_fun ((*) p) q) = p * proj_poly k q
[PROOF STEP]
by (rule proj_lift_poly_fun_homogenous, simp)


[STATEMENT]
lemma (in prob_space) exponential_distributedD_le:
  assumes D: "distributed M lborel X (exponential_density l)" and a: "0 \<le> a" and l: "0 < l"
  shows "\<P>(x in M. X x \<le> a) = 1 - exp (- a * l)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prob {x \<in> space M. X x \<le> a} = 1 - exp (- a * l)
[PROOF STEP]
using erlang_distributed_le[OF D l a] a
[PROOF STATE]
proof (prove)
using this:
prob {x \<in> space M. X x \<le> a} = erlang_CDF 0 l a
0 \<le> a

goal (1 subgoal):
 1. prob {x \<in> space M. X x \<le> a} = 1 - exp (- a * l)
[PROOF STEP]
by (simp add: erlang_CDF_def)


[STATEMENT]
lemma least_max_arg_max_list_snd_fst: "snd (least_max_arg_max_list f (x, f x) xs) = f (fst (least_max_arg_max_list f (x, f x) xs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. snd (least_max_arg_max_list f (x, f x) xs) = f (fst (least_max_arg_max_list f (x, f x) xs))
[PROOF STEP]
by (induction xs arbitrary: x) (auto simp: least_max_arg_max_list_def)


[STATEMENT]
lemma no_embedding_sphere_lowdim:
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
  assumes contf: "continuous_on (sphere a r) f" and injf: "inj_on f (sphere a r)" and "r > 0"
   shows "DIM('a) \<le> DIM('b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. DIM('a) \<le> DIM('b)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. DIM('a) \<le> DIM('b)
[PROOF STEP]
have "False" if "DIM('a) > DIM('b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. False
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. False
[PROOF STEP]
have "compact (f ` sphere a r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. compact (f ` sphere a r)
[PROOF STEP]
using compact_continuous_image
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>continuous_on ?s ?f; compact ?s\<rbrakk> \<Longrightarrow> compact (?f ` ?s)

goal (1 subgoal):
 1. compact (f ` sphere a r)
[PROOF STEP]
by (simp add: compact_continuous_image contf)
[PROOF STATE]
proof (state)
this:
compact (f ` sphere a r)

goal (1 subgoal):
 1. False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
compact (f ` sphere a r)
[PROOF STEP]
have "\<not> open (f ` sphere a r)"
[PROOF STATE]
proof (prove)
using this:
compact (f ` sphere a r)

goal (1 subgoal):
 1. \<not> open (f ` sphere a r)
[PROOF STEP]
using compact_open
[PROOF STATE]
proof (prove)
using this:
compact (f ` sphere a r)
(compact ?S \<and> open ?S) = (?S = {})

goal (1 subgoal):
 1. \<not> open (f ` sphere a r)
[PROOF STEP]
by (metis assms(3) image_is_empty not_less_iff_gr_or_eq sphere_eq_empty)
[PROOF STATE]
proof (state)
this:
\<not> open (f ` sphere a r)

goal (1 subgoal):
 1. False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> open (f ` sphere a r)
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
\<not> open (f ` sphere a r)

goal (1 subgoal):
 1. False
[PROOF STEP]
using invariance_of_domain_sphere_affine_set [OF contf injf subset_UNIV] \<open>r > 0\<close>
[PROOF STATE]
proof (prove)
using this:
\<not> open (f ` sphere a r)
\<lbrakk>?r \<noteq> 0; affine UNIV; aff_dim UNIV < int DIM('a); openin (top_of_set (sphere ?a ?r)) (sphere a r)\<rbrakk> \<Longrightarrow> openin (top_of_set UNIV) (f ` sphere a r)
0 < r

goal (1 subgoal):
 1. False
[PROOF STEP]
by (metis aff_dim_UNIV affine_UNIV less_irrefl of_nat_less_iff open_openin openin_subtopology_self subtopology_UNIV that)
[PROOF STATE]
proof (state)
this:
False

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
DIM('b) < DIM('a) \<Longrightarrow> False

goal (1 subgoal):
 1. DIM('a) \<le> DIM('b)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
DIM('b) < DIM('a) \<Longrightarrow> False
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
DIM('b) < DIM('a) \<Longrightarrow> False

goal (1 subgoal):
 1. DIM('a) \<le> DIM('b)
[PROOF STEP]
using not_less
[PROOF STATE]
proof (prove)
using this:
DIM('b) < DIM('a) \<Longrightarrow> False
(\<not> ?x < ?y) = (?y \<le> ?x)

goal (1 subgoal):
 1. DIM('a) \<le> DIM('b)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
DIM('a) \<le> DIM('b)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Gamma_seriesI:
  assumes "(\<lambda>n. g n / Gamma_series z n) \<longlonglongrightarrow> 1"
  shows   "g \<longlonglongrightarrow> Gamma z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g \<longlonglongrightarrow> Gamma z
[PROOF STEP]
proof (rule Lim_transform_eventually)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ?f \<longlonglongrightarrow> Gamma z
 2. \<forall>\<^sub>F x in sequentially. ?f x = g x
[PROOF STEP]
have "1/2 > (0::real)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < 1 / 2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 < 1 / 2

goal (2 subgoals):
 1. ?f \<longlonglongrightarrow> Gamma z
 2. \<forall>\<^sub>F x in sequentially. ?f x = g x
[PROOF STEP]
from tendstoD[OF assms, OF this]
[PROOF STATE]
proof (chain)
picking this:
\<forall>\<^sub>F x in sequentially. dist (g x / Gamma_series z x) (1::'a) < 1 / 2
[PROOF STEP]
show "eventually (\<lambda>n. g n / Gamma_series z n * Gamma_series z n = g n) sequentially"
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in sequentially. dist (g x / Gamma_series z x) (1::'a) < 1 / 2

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. g n / Gamma_series z n * Gamma_series z n = g n
[PROOF STEP]
by (force elim!: eventually_mono simp: dist_real_def)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F n in sequentially. g n / Gamma_series z n * Gamma_series z n = g n

goal (1 subgoal):
 1. (\<lambda>n. g n / Gamma_series z n * Gamma_series z n) \<longlonglongrightarrow> Gamma z
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>n. g n / Gamma_series z n) \<longlonglongrightarrow> (1::'a)
[PROOF STEP]
have "(\<lambda>n. g n / Gamma_series z n * Gamma_series z n) \<longlonglongrightarrow> 1 * Gamma z"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. g n / Gamma_series z n) \<longlonglongrightarrow> (1::'a)

goal (1 subgoal):
 1. (\<lambda>n. g n / Gamma_series z n * Gamma_series z n) \<longlonglongrightarrow> (1::'a) * Gamma z
[PROOF STEP]
by (intro tendsto_intros)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. g n / Gamma_series z n * Gamma_series z n) \<longlonglongrightarrow> (1::'a) * Gamma z

goal (1 subgoal):
 1. (\<lambda>n. g n / Gamma_series z n * Gamma_series z n) \<longlonglongrightarrow> Gamma z
[PROOF STEP]
thus "(\<lambda>n. g n / Gamma_series z n * Gamma_series z n) \<longlonglongrightarrow> Gamma z"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. g n / Gamma_series z n * Gamma_series z n) \<longlonglongrightarrow> (1::'a) * Gamma z

goal (1 subgoal):
 1. (\<lambda>n. g n / Gamma_series z n * Gamma_series z n) \<longlonglongrightarrow> Gamma z
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<lambda>n. g n / Gamma_series z n * Gamma_series z n) \<longlonglongrightarrow> Gamma z

goal:
No subgoals!
[PROOF STEP]
qed