[STATEMENT]
theorem ntt_correct:
  assumes n_def: "length numbers = n"
  shows "INTT (NTT numbers) = map (\<lambda> x. (of_int_mod_ring n) * x ) numbers"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. INTT (NTT numbers) = map ((*) (of_int_mod_ring (int n))) numbers
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. INTT (NTT numbers) = map ((*) (of_int_mod_ring (int n))) numbers
[PROOF STEP]
have 0:"\<And> i. i < n \<Longrightarrow> (INTT (NTT numbers)) ! i = intt (NTT numbers) i "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> INTT (NTT numbers) ! i = intt (NTT numbers) i
[PROOF STEP]
using n_def length_NTT
[PROOF STATE]
proof (prove)
using this:
length numbers = n
length ?numbers = n \<Longrightarrow> length (NTT ?numbers) = n

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> INTT (NTT numbers) ! i = intt (NTT numbers) i
[PROOF STEP]
unfolding INTT_def NTT_def intt_def
[PROOF STATE]
proof (prove)
using this:
length numbers = n
length ?numbers = n \<Longrightarrow> length (map (local.ntt ?numbers) [0..<n]) = n

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> map (\<lambda>i. \<Sum>j = 0..<n. map (local.ntt numbers) [0..<n] ! j * \<mu> ^ (i * j)) [0..<n] ! i = (\<Sum>j = 0..<n. map (local.ntt numbers) [0..<n] ! j * \<mu> ^ (i * j))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
?i < n \<Longrightarrow> INTT (NTT numbers) ! ?i = intt (NTT numbers) ?i

goal (1 subgoal):
 1. INTT (NTT numbers) = map ((*) (of_int_mod_ring (int n))) numbers
[PROOF STEP]
text \<open>Major sublemma.\<close>
[PROOF STATE]
proof (state)
this:
?i < n \<Longrightarrow> INTT (NTT numbers) ! ?i = intt (NTT numbers) ?i

goal (1 subgoal):
 1. INTT (NTT numbers) = map ((*) (of_int_mod_ring (int n))) numbers
[PROOF STEP]
have 1:"\<And> i. i < n \<Longrightarrow>intt (NTT numbers) i = (of_int_mod_ring n)*numbers ! i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
assume i_assms:"i < n"
[PROOF STATE]
proof (state)
this:
i < n

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
text \<open>First, simplify by some chains of equations.\<close>
[PROOF STATE]
proof (state)
this:
i < n

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
hence 1:"intt (NTT numbers) i  =
            (\<Sum>l = 0..<n.
              (\<Sum>j = 0..<n. numbers ! j * \<omega> ^ (l * j)) * \<mu> ^ (i * l))"
[PROOF STATE]
proof (prove)
using this:
i < n

goal (1 subgoal):
 1. intt (NTT numbers) i = (\<Sum>l = 0..<n. (\<Sum>j = 0..<n. numbers ! j * \<omega> ^ (l * j)) * \<mu> ^ (i * l))
[PROOF STEP]
unfolding NTT_def intt_def ntt_def
[PROOF STATE]
proof (prove)
using this:
i < n

goal (1 subgoal):
 1. (\<Sum>j = 0..<n. map (\<lambda>i. \<Sum>j = 0..<n. numbers ! j * \<omega> ^ (i * j)) [0..<n] ! j * \<mu> ^ (i * j)) = (\<Sum>l = 0..<n. (\<Sum>j = 0..<n. numbers ! j * \<omega> ^ (l * j)) * \<mu> ^ (i * l))
[PROOF STEP]
using n_def length_map nth_map
[PROOF STATE]
proof (prove)
using this:
i < n
length numbers = n
length (map ?f ?xs) = length ?xs
?n < length ?xs \<Longrightarrow> map ?f ?xs ! ?n = ?f (?xs ! ?n)

goal (1 subgoal):
 1. (\<Sum>j = 0..<n. map (\<lambda>i. \<Sum>j = 0..<n. numbers ! j * \<omega> ^ (i * j)) [0..<n] ! j * \<mu> ^ (i * j)) = (\<Sum>l = 0..<n. (\<Sum>j = 0..<n. numbers ! j * \<omega> ^ (l * j)) * \<mu> ^ (i * l))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
intt (NTT numbers) i = (\<Sum>l = 0..<n. (\<Sum>j = 0..<n. numbers ! j * \<omega> ^ (l * j)) * \<mu> ^ (i * l))

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
intt (NTT numbers) i = (\<Sum>l = 0..<n. (\<Sum>j = 0..<n. numbers ! j * \<omega> ^ (l * j)) * \<mu> ^ (i * l))

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
have 2:"\<dots> =
            (\<Sum>l = 0..<n.
              (\<Sum>j = 0..<n. (numbers ! j * \<omega> ^ (l * j)) * \<mu> ^ (i * l)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>l = 0..<n. (\<Sum>j = 0..<n. numbers ! j * \<omega> ^ (l * j)) * \<mu> ^ (i * l)) = (\<Sum>l = 0..<n. \<Sum>j = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l))
[PROOF STEP]
using sum_in
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i = 0..<?x. ?f i * ?y) = sum ?f {0..<?x} * ?y

goal (1 subgoal):
 1. (\<Sum>l = 0..<n. (\<Sum>j = 0..<n. numbers ! j * \<omega> ^ (l * j)) * \<mu> ^ (i * l)) = (\<Sum>l = 0..<n. \<Sum>j = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l))
[PROOF STEP]
by (simp add: sum_distrib_right)
[PROOF STATE]
proof (state)
this:
(\<Sum>l = 0..<n. (\<Sum>j = 0..<n. numbers ! j * \<omega> ^ (l * j)) * \<mu> ^ (i * l)) = (\<Sum>l = 0..<n. \<Sum>j = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l))

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>l = 0..<n. (\<Sum>j = 0..<n. numbers ! j * \<omega> ^ (l * j)) * \<mu> ^ (i * l)) = (\<Sum>l = 0..<n. \<Sum>j = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l))

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
have 3:"\<dots> =
            (\<Sum>j = 0..<n.
              (\<Sum>l = 0..<n. (numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>l = 0..<n. \<Sum>j = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = (\<Sum>j = 0..<n. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l))
[PROOF STEP]
using sum_swap
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i = 0..<?x. sum (?f i) {0..<?y}) = (\<Sum>j = 0..<?y. \<Sum>i = 0..<?x. ?f i j)

goal (1 subgoal):
 1. (\<Sum>l = 0..<n. \<Sum>j = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = (\<Sum>j = 0..<n. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l))
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
(\<Sum>l = 0..<n. \<Sum>j = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = (\<Sum>j = 0..<n. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l))

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
text \<open>As in the informal proof, we consider three cases. First $j = i$.\<close>
[PROOF STATE]
proof (state)
this:
(\<Sum>l = 0..<n. \<Sum>j = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = (\<Sum>j = 0..<n. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l))

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
have iisj:"\<And> j. j = i \<Longrightarrow> (\<Sum>l = 0..<n. (numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l))) = (numbers ! j)* (of_int_mod_ring n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>j. j = i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = numbers ! j * of_int_mod_ring (int n)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>j. j = i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = numbers ! j * of_int_mod_ring (int n)
[PROOF STEP]
fix j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>j. j = i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = numbers ! j * of_int_mod_ring (int n)
[PROOF STEP]
assume "j=i"
[PROOF STATE]
proof (state)
this:
j = i

goal (1 subgoal):
 1. \<And>j. j = i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = numbers ! j * of_int_mod_ring (int n)
[PROOF STEP]
hence "\<And> l. l < n \<Longrightarrow> (numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l))= (numbers ! j)"
[PROOF STATE]
proof (prove)
using this:
j = i

goal (1 subgoal):
 1. \<And>l. l < n \<Longrightarrow> numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l) = numbers ! j
[PROOF STEP]
by (simp add: left_right_inverse_power mult.commute mu_properties(1))
[PROOF STATE]
proof (state)
this:
?l < n \<Longrightarrow> numbers ! j * \<omega> ^ (?l * j) * \<mu> ^ (i * ?l) = numbers ! j

goal (1 subgoal):
 1. \<And>j. j = i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = numbers ! j * of_int_mod_ring (int n)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
?l < n \<Longrightarrow> numbers ! j * \<omega> ^ (?l * j) * \<mu> ^ (i * ?l) = numbers ! j

goal (1 subgoal):
 1. \<And>j. j = i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = numbers ! j * of_int_mod_ring (int n)
[PROOF STEP]
have "\<And> l. l < n  \<Longrightarrow> numbers ! j *  \<omega> ^ (l * j) * \<mu> ^ (i * l) = numbers ! j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>l. l < n \<Longrightarrow> numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l) = numbers ! j
[PROOF STEP]
using calculation
[PROOF STATE]
proof (prove)
using this:
?l < n \<Longrightarrow> numbers ! j * \<omega> ^ (?l * j) * \<mu> ^ (i * ?l) = numbers ! j

goal (1 subgoal):
 1. \<And>l. l < n \<Longrightarrow> numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l) = numbers ! j
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
?l < n \<Longrightarrow> numbers ! j * \<omega> ^ (?l * j) * \<mu> ^ (i * ?l) = numbers ! j

goal (1 subgoal):
 1. \<And>j. j = i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = numbers ! j * of_int_mod_ring (int n)
[PROOF STEP]
text \<open>$\omega^{il}\cdot \omega^{jl} = 1$. Thus, we sum over $1$ $n$ times, which gives the goal.\<close>
[PROOF STATE]
proof (state)
this:
?l < n \<Longrightarrow> numbers ! j * \<omega> ^ (?l * j) * \<mu> ^ (i * ?l) = numbers ! j

goal (1 subgoal):
 1. \<And>j. j = i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = numbers ! j * of_int_mod_ring (int n)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
?l < n \<Longrightarrow> numbers ! j * \<omega> ^ (?l * j) * \<mu> ^ (i * ?l) = numbers ! j
?l < n \<Longrightarrow> numbers ! j * \<omega> ^ (?l * j) * \<mu> ^ (i * ?l) = numbers ! j
[PROOF STEP]
show "(\<Sum>l = 0..<n. (numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l))) =
        (numbers ! j)* (of_int_mod_ring n)"
[PROOF STATE]
proof (prove)
using this:
?l < n \<Longrightarrow> numbers ! j * \<omega> ^ (?l * j) * \<mu> ^ (i * ?l) = numbers ! j
?l < n \<Longrightarrow> numbers ! j * \<omega> ^ (?l * j) * \<mu> ^ (i * ?l) = numbers ! j

goal (1 subgoal):
 1. (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = numbers ! j * of_int_mod_ring (int n)
[PROOF STEP]
using n_def sum_const[of "numbers ! j" n] exp_rule[of \<omega> \<mu>] mu_properties(1)
[PROOF STATE]
proof (prove)
using this:
?l < n \<Longrightarrow> numbers ! j * \<omega> ^ (?l * j) * \<mu> ^ (i * ?l) = numbers ! j
?l < n \<Longrightarrow> numbers ! j * \<omega> ^ (?l * j) * \<mu> ^ (i * ?l) = numbers ! j
length numbers = n
(\<Sum>i = 0..<n. numbers ! j) = of_int_mod_ring (int n) * numbers ! j
(\<omega> * \<mu>) ^ ?e = \<omega> ^ ?e * \<mu> ^ ?e
\<mu> * \<omega> = 1

goal (1 subgoal):
 1. (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = numbers ! j * of_int_mod_ring (int n)
[PROOF STEP]
by (metis (no_types, lifting) atLeastLessThan_iff mult.commute sum.cong)
[PROOF STATE]
proof (state)
this:
(\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = numbers ! j * of_int_mod_ring (int n)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?j = i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! ?j * \<omega> ^ (l * ?j) * \<mu> ^ (i * l)) = numbers ! ?j * of_int_mod_ring (int n)

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
text \<open>Case $j < i$.\<close>
[PROOF STATE]
proof (state)
this:
?j = i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! ?j * \<omega> ^ (l * ?j) * \<mu> ^ (i * l)) = numbers ! ?j * of_int_mod_ring (int n)

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
have jlsi:"\<And> j. j < i \<Longrightarrow> (\<Sum>l = 0..<n. (numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l))) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>j. j < i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>j. j < i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
fix j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>j. j < i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
assume j_assms:"j < i"
[PROOF STATE]
proof (state)
this:
j < i

goal (1 subgoal):
 1. \<And>j. j < i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
hence 00:"\<And>  (c::('a::prime_card) mod_ring) a b. c * a^j*b^i  = (a*b)^j*(c * b^(i-j))"
[PROOF STATE]
proof (prove)
using this:
j < i

goal (1 subgoal):
 1. \<And>c a b. c * a ^ j * b ^ i = (a * b) ^ j * (c * b ^ (i - j))
[PROOF STEP]
using  algebra_simps
[PROOF STATE]
proof (prove)
using this:
j < i
?a + ?b + ?c = ?a + (?b + ?c)
?a + ?b = ?b + ?a
?b + (?a + ?c) = ?a + (?b + ?c)
?a * ?b * ?c = ?a * (?b * ?c)
?a * ?b = ?b * ?a
?b * (?a * ?c) = ?a * (?b * ?c)
?a - ?b - ?c = ?a - (?b + ?c)
?a + (?b - ?c) = ?a + ?b - ?c
(?a - ?b = ?c) = (?a = ?c + ?b)
(?a = ?c - ?b) = (?a + ?b = ?c)
?a - (?b - ?c) = ?a + ?c - ?b
?a - ?b + ?c = ?a + ?c - ?b
(?a - ?b < ?c) = (?a < ?c + ?b)
(?a < ?c - ?b) = (?a + ?b < ?c)
(?a - ?b \<le> ?c) = (?a \<le> ?c + ?b)
(?a \<le> ?c - ?b) = (?a + ?b \<le> ?c)
(?a + ?b) * ?c = ?a * ?c + ?b * ?c
?a * (?b + ?c) = ?a * ?b + ?a * ?c
?a * (?b - ?c) = ?a * ?b - ?a * ?c
(?b - ?c) * ?a = ?b * ?a - ?c * ?a
?a * (?b - ?c) = ?a * ?b - ?a * ?c
(?a - ?b) * ?c = ?a * ?c - ?b * ?c
(?a * ?b) ^ ?n = ?a ^ ?n * ?b ^ ?n
?a *\<^sub>R (?x + ?y) = ?a *\<^sub>R ?x + ?a *\<^sub>R ?y
(?a + ?b) *\<^sub>R ?x = ?a *\<^sub>R ?x + ?b *\<^sub>R ?x
(?a - ?b) *\<^sub>R ?x = ?a *\<^sub>R ?x - ?b *\<^sub>R ?x
?a *\<^sub>R (?x - ?y) = ?a *\<^sub>R ?x - ?a *\<^sub>R ?y

goal (1 subgoal):
 1. \<And>c a b. c * a ^ j * b ^ i = (a * b) ^ j * (c * b ^ (i - j))
[PROOF STEP]
by (smt (z3) le_less ordered_cancel_comm_monoid_diff_class.add_diff_inverse power_add)
[PROOF STATE]
proof (state)
this:
?c * ?a ^ j * ?b ^ i = (?a * ?b) ^ j * (?c * ?b ^ (i - j))

goal (1 subgoal):
 1. \<And>j. j < i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
text \<open>A geometric sum over $\mu^l$ remains.\<close>
[PROOF STATE]
proof (state)
this:
?c * ?a ^ j * ?b ^ i = (?a * ?b) ^ j * (?c * ?b ^ (i - j))

goal (1 subgoal):
 1. \<And>j. j < i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
have 01:" (\<Sum>l = 0..<n. (numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l))) =
                (\<Sum>l = 0..<n. (numbers ! j *  (\<mu>^l)^(i-j)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = (\<Sum>l = 0..<n. numbers ! j * (\<mu> ^ l) ^ (i - j))
[PROOF STEP]
apply(rule sum_eq)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>l. l < n \<Longrightarrow> numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l) = numbers ! j * (\<mu> ^ l) ^ (i - j)
[PROOF STEP]
using mu_properties(1) 00 algebra_simps(23)
[PROOF STATE]
proof (prove)
using this:
\<mu> * \<omega> = 1
?c * ?a ^ j * ?b ^ i = (?a * ?b) ^ j * (?c * ?b ^ (i - j))
(?a * ?b) ^ ?n = ?a ^ ?n * ?b ^ ?n

goal (1 subgoal):
 1. \<And>l. l < n \<Longrightarrow> numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l) = numbers ! j * (\<mu> ^ l) ^ (i - j)
[PROOF STEP]
by (smt (z3) mult.commute mult.left_neutral power_mult power_one)
[PROOF STATE]
proof (state)
this:
(\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = (\<Sum>l = 0..<n. numbers ! j * (\<mu> ^ l) ^ (i - j))

goal (1 subgoal):
 1. \<And>j. j < i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
have 02:"\<dots> = numbers ! j *(\<Sum>l = 0..<n. ((\<mu>^l)^(i-j))) "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>l = 0..<n. numbers ! j * (\<mu> ^ l) ^ (i - j)) = numbers ! j * (\<Sum>l = 0..<n. (\<mu> ^ l) ^ (i - j))
[PROOF STEP]
using sum_in[of "\<lambda> l. numbers ! j * (\<mu> ^ l) ^ (i - j)" " numbers ! j" n]
[PROOF STATE]
proof (prove)
using this:
(\<Sum>ia = 0..<n. numbers ! j * (\<mu> ^ ia) ^ (i - j) * numbers ! j) = (\<Sum>ia = 0..<n. numbers ! j * (\<mu> ^ ia) ^ (i - j)) * numbers ! j

goal (1 subgoal):
 1. (\<Sum>l = 0..<n. numbers ! j * (\<mu> ^ l) ^ (i - j)) = numbers ! j * (\<Sum>l = 0..<n. (\<mu> ^ l) ^ (i - j))
[PROOF STEP]
by (simp add: mult_hom.hom_sum)
[PROOF STATE]
proof (state)
this:
(\<Sum>l = 0..<n. numbers ! j * (\<mu> ^ l) ^ (i - j)) = numbers ! j * (\<Sum>l = 0..<n. (\<mu> ^ l) ^ (i - j))

goal (1 subgoal):
 1. \<And>j. j < i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<Sum>l = 0..<n. numbers ! j * (\<mu> ^ l) ^ (i - j)) = numbers ! j * (\<Sum>l = 0..<n. (\<mu> ^ l) ^ (i - j))

goal (1 subgoal):
 1. \<And>j. j < i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
have 03:"(\<Sum>l = 0..<n. ((\<mu>^l)^(i-j))) =
                     (\<Sum>l = 0..<n. ((\<mu>^(i-j))^l)) "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>l = 0..<n. (\<mu> ^ l) ^ (i - j)) = sum ((^) (\<mu> ^ (i - j))) {0..<n}
[PROOF STEP]
by(rule sum_eq) (metis mult.commute power_mult)
[PROOF STATE]
proof (state)
this:
(\<Sum>l = 0..<n. (\<mu> ^ l) ^ (i - j)) = sum ((^) (\<mu> ^ (i - j))) {0..<n}

goal (1 subgoal):
 1. \<And>j. j < i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
have "\<mu>^(i-j) \<noteq> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<mu> ^ (i - j) \<noteq> 1
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<mu> ^ (i - j) = 1 \<Longrightarrow> False
[PROOF STEP]
assume "\<mu> ^ (i - j) = 1"
[PROOF STATE]
proof (state)
this:
\<mu> ^ (i - j) = 1

goal (1 subgoal):
 1. \<mu> ^ (i - j) = 1 \<Longrightarrow> False
[PROOF STEP]
hence "ord p (to_int_mod_ring \<mu>) \<le> i-j"
[PROOF STATE]
proof (prove)
using this:
\<mu> ^ (i - j) = 1

goal (1 subgoal):
 1. ord (int p) (to_int_mod_ring \<mu>) \<le> i - j
[PROOF STEP]
by (simp add: j_assms not_le ord_max)
[PROOF STATE]
proof (state)
this:
ord (int p) (to_int_mod_ring \<mu>) \<le> i - j

goal (1 subgoal):
 1. \<mu> ^ (i - j) = 1 \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
ord (int p) (to_int_mod_ring \<mu>) \<le> i - j

goal (1 subgoal):
 1. \<mu> ^ (i - j) = 1 \<Longrightarrow> False
[PROOF STEP]
hence "ord p (to_int_mod_ring \<omega>) \<le> i-j"
[PROOF STATE]
proof (prove)
using this:
ord (int p) (to_int_mod_ring \<mu>) \<le> i - j

goal (1 subgoal):
 1. ord (int p) (to_int_mod_ring \<omega>) \<le> i - j
[PROOF STEP]
by (metis \<open>\<mu> ^ (i - j) = 1\<close> diff_is_0_eq exp_rule j_assms leD mult.comm_neutral mult.commute mu_properties(1) ord_max)
[PROOF STATE]
proof (state)
this:
ord (int p) (to_int_mod_ring \<omega>) \<le> i - j

goal (1 subgoal):
 1. \<mu> ^ (i - j) = 1 \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
ord (int p) (to_int_mod_ring \<omega>) \<le> i - j

goal (1 subgoal):
 1. \<mu> ^ (i - j) = 1 \<Longrightarrow> False
[PROOF STEP]
hence "i-j < n"
[PROOF STATE]
proof (prove)
using this:
ord (int p) (to_int_mod_ring \<omega>) \<le> i - j

goal (1 subgoal):
 1. i - j < n
[PROOF STEP]
using j_assms i_assms p_fact k_bound n_lst2
[PROOF STATE]
proof (prove)
using this:
ord (int p) (to_int_mod_ring \<omega>) \<le> i - j
j < i
i < n
p = k * n + 1
0 < k
2 \<le> n

goal (1 subgoal):
 1. i - j < n
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
i - j < n

goal (1 subgoal):
 1. \<mu> ^ (i - j) = 1 \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
i - j < n

goal (1 subgoal):
 1. \<mu> ^ (i - j) = 1 \<Longrightarrow> False
[PROOF STEP]
have "ord p (to_int_mod_ring \<omega>) = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ord (int p) (to_int_mod_ring \<omega>) = n
[PROOF STEP]
using omega_properties n_lst2
[PROOF STATE]
proof (prove)
using this:
\<omega> ^ n = 1
\<omega> \<noteq> 1
\<forall>m. \<omega> ^ m = 1 \<and> m \<noteq> 0 \<longrightarrow> n \<le> m
2 \<le> n

goal (1 subgoal):
 1. ord (int p) (to_int_mod_ring \<omega>) = n
[PROOF STEP]
unfolding ord_def
[PROOF STATE]
proof (prove)
using this:
\<omega> ^ n = 1
\<omega> \<noteq> 1
\<forall>m. \<omega> ^ m = 1 \<and> m \<noteq> 0 \<longrightarrow> n \<le> m
2 \<le> n

goal (1 subgoal):
 1. (if coprime (int p) (to_int_mod_ring \<omega>) then LEAST d. 0 < d \<and> [to_int_mod_ring \<omega> ^ d = 1] (mod int p) else 0) = n
[PROOF STEP]
by (metis (no_types) \<open>\<mu> ^ (i - j) = 1\<close> calculation(3) diff_is_0_eq j_assms leD left_right_inverse_power mult.comm_neutral mult_cancel_left mu_properties(1) omega_properties(3) zero_neq_one)
[PROOF STATE]
proof (state)
this:
ord (int p) (to_int_mod_ring \<omega>) = n

goal (1 subgoal):
 1. \<mu> ^ (i - j) = 1 \<Longrightarrow> False
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
ord (int p) (to_int_mod_ring \<mu>) \<le> i - j
ord (int p) (to_int_mod_ring \<omega>) \<le> i - j
i - j < n
ord (int p) (to_int_mod_ring \<omega>) = n
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
ord (int p) (to_int_mod_ring \<mu>) \<le> i - j
ord (int p) (to_int_mod_ring \<omega>) \<le> i - j
i - j < n
ord (int p) (to_int_mod_ring \<omega>) = n

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<mu> ^ (i - j) \<noteq> 1

goal (1 subgoal):
 1. \<And>j. j < i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
text \<open>Application of the lemma for geometric sums.\<close>
[PROOF STATE]
proof (state)
this:
\<mu> ^ (i - j) \<noteq> 1

goal (1 subgoal):
 1. \<And>j. j < i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>l = 0..<n. numbers ! j * (\<mu> ^ l) ^ (i - j)) = numbers ! j * (\<Sum>l = 0..<n. (\<mu> ^ l) ^ (i - j))
\<mu> ^ (i - j) \<noteq> 1
[PROOF STEP]
have "(1-\<mu>^(i-j))*(\<Sum>l = 0..<n. ((\<mu>^(i-j))^l)) = (1-(\<mu>^(i-j))^n)"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>l = 0..<n. numbers ! j * (\<mu> ^ l) ^ (i - j)) = numbers ! j * (\<Sum>l = 0..<n. (\<mu> ^ l) ^ (i - j))
\<mu> ^ (i - j) \<noteq> 1

goal (1 subgoal):
 1. (1 - \<mu> ^ (i - j)) * sum ((^) (\<mu> ^ (i - j))) {0..<n} = 1 - (\<mu> ^ (i - j)) ^ n
[PROOF STEP]
using geo_sum[of "\<mu> ^ (i - j)" n]
[PROOF STATE]
proof (prove)
using this:
(\<Sum>l = 0..<n. numbers ! j * (\<mu> ^ l) ^ (i - j)) = numbers ! j * (\<Sum>l = 0..<n. (\<mu> ^ l) ^ (i - j))
\<mu> ^ (i - j) \<noteq> 1
\<mu> ^ (i - j) \<noteq> 1 \<Longrightarrow> (1 - \<mu> ^ (i - j)) * sum ((^) (\<mu> ^ (i - j))) {0..<n} = 1 - (\<mu> ^ (i - j)) ^ n

goal (1 subgoal):
 1. (1 - \<mu> ^ (i - j)) * sum ((^) (\<mu> ^ (i - j))) {0..<n} = 1 - (\<mu> ^ (i - j)) ^ n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(1 - \<mu> ^ (i - j)) * sum ((^) (\<mu> ^ (i - j))) {0..<n} = 1 - (\<mu> ^ (i - j)) ^ n

goal (1 subgoal):
 1. \<And>j. j < i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(1 - \<mu> ^ (i - j)) * sum ((^) (\<mu> ^ (i - j))) {0..<n} = 1 - (\<mu> ^ (i - j)) ^ n

goal (1 subgoal):
 1. \<And>j. j < i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
have "(\<mu>^(i-j))^n = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<mu> ^ (i - j)) ^ n = 1
[PROOF STEP]
by (metis (no_types) left_right_inverse_power mult.commute mult.right_neutral mu_properties(1) omega_properties(1) power_mult power_one)
[PROOF STATE]
proof (state)
this:
(\<mu> ^ (i - j)) ^ n = 1

goal (1 subgoal):
 1. \<And>j. j < i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
text \<open>The sum for the current index is 0.\<close>
[PROOF STATE]
proof (state)
this:
(\<mu> ^ (i - j)) ^ n = 1

goal (1 subgoal):
 1. \<And>j. j < i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(1 - \<mu> ^ (i - j)) * sum ((^) (\<mu> ^ (i - j))) {0..<n} = 1 - (\<mu> ^ (i - j)) ^ n
(\<mu> ^ (i - j)) ^ n = 1
[PROOF STEP]
have "(\<Sum>l = 0..<n. ((\<mu>^(i-j))^l)) = 0"
[PROOF STATE]
proof (prove)
using this:
(1 - \<mu> ^ (i - j)) * sum ((^) (\<mu> ^ (i - j))) {0..<n} = 1 - (\<mu> ^ (i - j)) ^ n
(\<mu> ^ (i - j)) ^ n = 1

goal (1 subgoal):
 1. sum ((^) (\<mu> ^ (i - j))) {0..<n} = 0
[PROOF STEP]
by (metis \<open>\<mu> ^ (i - j) \<noteq> 1\<close> divisors_zero eq_iff_diff_eq_0)
[PROOF STATE]
proof (state)
this:
sum ((^) (\<mu> ^ (i - j))) {0..<n} = 0

goal (1 subgoal):
 1. \<And>j. j < i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
thus "(\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0"
[PROOF STATE]
proof (prove)
using this:
sum ((^) (\<mu> ^ (i - j))) {0..<n} = 0

goal (1 subgoal):
 1. (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
using  01 02 03
[PROOF STATE]
proof (prove)
using this:
sum ((^) (\<mu> ^ (i - j))) {0..<n} = 0
(\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = (\<Sum>l = 0..<n. numbers ! j * (\<mu> ^ l) ^ (i - j))
(\<Sum>l = 0..<n. numbers ! j * (\<mu> ^ l) ^ (i - j)) = numbers ! j * (\<Sum>l = 0..<n. (\<mu> ^ l) ^ (i - j))
(\<Sum>l = 0..<n. (\<mu> ^ l) ^ (i - j)) = sum ((^) (\<mu> ^ (i - j))) {0..<n}

goal (1 subgoal):
 1. (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?j < i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! ?j * \<omega> ^ (l * ?j) * \<mu> ^ (i * l)) = 0

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
text \<open>Case $i < j$.
       We also rewrite the whole summation until the lemma for geometric sums is applicable.
       From this, we conclude that the term is 0.\<close>
[PROOF STATE]
proof (state)
this:
?j < i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! ?j * \<omega> ^ (l * ?j) * \<mu> ^ (i * l)) = 0

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
have ilsj:"\<And> j. i < j \<and> j < n \<Longrightarrow> (\<Sum>l = 0..<n. (numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l))) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>j. i < j \<and> j < n \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>j. i < j \<and> j < n \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
fix j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>j. i < j \<and> j < n \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
assume ij_Assm: "i < j \<and> j < n"
[PROOF STATE]
proof (state)
this:
i < j \<and> j < n

goal (1 subgoal):
 1. \<And>j. i < j \<and> j < n \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
hence 00:"\<And>  (c::('a::prime_card) mod_ring) a b. (a*b)^i*(c * b^(j-i)) = c * a^i*b^j  "
[PROOF STATE]
proof (prove)
using this:
i < j \<and> j < n

goal (1 subgoal):
 1. \<And>c a b. (a * b) ^ i * (c * b ^ (j - i)) = c * a ^ i * b ^ j
[PROOF STEP]
by (auto simp: field_simps simp flip: power_add)
[PROOF STATE]
proof (state)
this:
(?a * ?b) ^ i * (?c * ?b ^ (j - i)) = ?c * ?a ^ i * ?b ^ j

goal (1 subgoal):
 1. \<And>j. i < j \<and> j < n \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
have 01:" (\<Sum>l = 0..<n. (numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l))) =
                (\<Sum>l = 0..<n. (numbers ! j *  (\<omega>^l)^(j-i))) "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = (\<Sum>l = 0..<n. numbers ! j * (\<omega> ^ l) ^ (j - i))
[PROOF STEP]
apply(rule sum_eq)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>l. l < n \<Longrightarrow> numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l) = numbers ! j * (\<omega> ^ l) ^ (j - i)
[PROOF STEP]
subgoal for l
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. l < n \<Longrightarrow> numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l) = numbers ! j * (\<omega> ^ l) ^ (j - i)
[PROOF STEP]
using mu_properties(1) 00[of "\<omega>^l" "\<mu>^l" "numbers ! j "] algebra_simps(23)
[PROOF STATE]
proof (prove)
using this:
\<mu> * \<omega> = 1
(\<omega> ^ l * \<mu> ^ l) ^ i * (numbers ! j * (\<mu> ^ l) ^ (j - i)) = numbers ! j * (\<omega> ^ l) ^ i * (\<mu> ^ l) ^ j
(?a * ?b) ^ ?n = ?a ^ ?n * ?b ^ ?n

goal (1 subgoal):
 1. l < n \<Longrightarrow> numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l) = numbers ! j * (\<omega> ^ l) ^ (j - i)
[PROOF STEP]
by (smt (z3) "00" left_right_inverse_power mult.assoc mult.commute mult.right_neutral power_mult)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
(\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = (\<Sum>l = 0..<n. numbers ! j * (\<omega> ^ l) ^ (j - i))

goal (1 subgoal):
 1. \<And>j. i < j \<and> j < n \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = (\<Sum>l = 0..<n. numbers ! j * (\<omega> ^ l) ^ (j - i))

goal (1 subgoal):
 1. \<And>j. i < j \<and> j < n \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
have 02:"(\<Sum>l = 0..<n. (numbers ! j *   (\<omega>^l)^(j-i)))  =
                         numbers ! j *(\<Sum>l = 0..<n. ( (\<omega>^l)^(j-i))) "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>l = 0..<n. numbers ! j * (\<omega> ^ l) ^ (j - i)) = numbers ! j * (\<Sum>l = 0..<n. (\<omega> ^ l) ^ (j - i))
[PROOF STEP]
by (simp add: mult_hom.hom_sum)
[PROOF STATE]
proof (state)
this:
(\<Sum>l = 0..<n. numbers ! j * (\<omega> ^ l) ^ (j - i)) = numbers ! j * (\<Sum>l = 0..<n. (\<omega> ^ l) ^ (j - i))

goal (1 subgoal):
 1. \<And>j. i < j \<and> j < n \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<Sum>l = 0..<n. numbers ! j * (\<omega> ^ l) ^ (j - i)) = numbers ! j * (\<Sum>l = 0..<n. (\<omega> ^ l) ^ (j - i))

goal (1 subgoal):
 1. \<And>j. i < j \<and> j < n \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
have 03:"(\<Sum>l = 0..<n. ( (\<omega>^l)^(j-i))) =
                     (\<Sum>l = 0..<n. (( (\<omega>^(j-i))^l))) "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>l = 0..<n. (\<omega> ^ l) ^ (j - i)) = sum ((^) (\<omega> ^ (j - i))) {0..<n}
[PROOF STEP]
by(rule sum_eq) (metis mult.commute power_mult)
[PROOF STATE]
proof (state)
this:
(\<Sum>l = 0..<n. (\<omega> ^ l) ^ (j - i)) = sum ((^) (\<omega> ^ (j - i))) {0..<n}

goal (1 subgoal):
 1. \<And>j. i < j \<and> j < n \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
have "\<omega>^(j-i) \<noteq> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<omega> ^ (j - i) \<noteq> 1
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<omega> ^ (j - i) = 1 \<Longrightarrow> False
[PROOF STEP]
assume " \<omega> ^ (j - i) = 1"
[PROOF STATE]
proof (state)
this:
\<omega> ^ (j - i) = 1

goal (1 subgoal):
 1. \<omega> ^ (j - i) = 1 \<Longrightarrow> False
[PROOF STEP]
hence "ord p (to_int_mod_ring  \<omega>) \<le> j-i"
[PROOF STATE]
proof (prove)
using this:
\<omega> ^ (j - i) = 1

goal (1 subgoal):
 1. ord (int p) (to_int_mod_ring \<omega>) \<le> j - i
[PROOF STEP]
using ord_max[of "j-i" \<omega>] ij_Assm
[PROOF STATE]
proof (prove)
using this:
\<omega> ^ (j - i) = 1
\<lbrakk>j - i \<noteq> 0; \<omega> ^ (j - i) = 1\<rbrakk> \<Longrightarrow> ord (int p) (to_int_mod_ring \<omega>) \<le> j - i
i < j \<and> j < n

goal (1 subgoal):
 1. ord (int p) (to_int_mod_ring \<omega>) \<le> j - i
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
ord (int p) (to_int_mod_ring \<omega>) \<le> j - i

goal (1 subgoal):
 1. \<omega> ^ (j - i) = 1 \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
ord (int p) (to_int_mod_ring \<omega>) \<le> j - i

goal (1 subgoal):
 1. \<omega> ^ (j - i) = 1 \<Longrightarrow> False
[PROOF STEP]
have "ord p (to_int_mod_ring \<omega>) =p-1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ord (int p) (to_int_mod_ring \<omega>) = p - 1
[PROOF STEP]
by (meson \<open>\<omega> ^ (j - i) = 1\<close> diff_is_0_eq diff_le_self ij_Assm leD le_trans omega_properties(3))
[PROOF STATE]
proof (state)
this:
ord (int p) (to_int_mod_ring \<omega>) = p - 1

goal (1 subgoal):
 1. \<omega> ^ (j - i) = 1 \<Longrightarrow> False
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
ord (int p) (to_int_mod_ring \<omega>) \<le> j - i
ord (int p) (to_int_mod_ring \<omega>) = p - 1
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
ord (int p) (to_int_mod_ring \<omega>) \<le> j - i
ord (int p) (to_int_mod_ring \<omega>) = p - 1

goal (1 subgoal):
 1. False
[PROOF STEP]
by (meson \<open>\<omega> ^ (j - i) = 1\<close> diff_is_0_eq diff_le_self ij_Assm leD le_trans omega_properties(3))
[PROOF STATE]
proof (state)
this:
False

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<omega> ^ (j - i) \<noteq> 1

goal (1 subgoal):
 1. \<And>j. i < j \<and> j < n \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
text \<open>Geometric sum.\<close>
[PROOF STATE]
proof (state)
this:
\<omega> ^ (j - i) \<noteq> 1

goal (1 subgoal):
 1. \<And>j. i < j \<and> j < n \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = (\<Sum>l = 0..<n. numbers ! j * (\<omega> ^ l) ^ (j - i))
(\<Sum>l = 0..<n. numbers ! j * (\<omega> ^ l) ^ (j - i)) = numbers ! j * (\<Sum>l = 0..<n. (\<omega> ^ l) ^ (j - i))
\<omega> ^ (j - i) \<noteq> 1
[PROOF STEP]
have "(1-\<omega>^(j-i))* (\<Sum>l = 0..<n. ((\<omega>^(j-i))^l)) = (1-(\<omega>^(j-i))^n)"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = (\<Sum>l = 0..<n. numbers ! j * (\<omega> ^ l) ^ (j - i))
(\<Sum>l = 0..<n. numbers ! j * (\<omega> ^ l) ^ (j - i)) = numbers ! j * (\<Sum>l = 0..<n. (\<omega> ^ l) ^ (j - i))
\<omega> ^ (j - i) \<noteq> 1

goal (1 subgoal):
 1. (1 - \<omega> ^ (j - i)) * sum ((^) (\<omega> ^ (j - i))) {0..<n} = 1 - (\<omega> ^ (j - i)) ^ n
[PROOF STEP]
using geo_sum[of "\<omega> ^ (j-i)" n]
[PROOF STATE]
proof (prove)
using this:
(\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = (\<Sum>l = 0..<n. numbers ! j * (\<omega> ^ l) ^ (j - i))
(\<Sum>l = 0..<n. numbers ! j * (\<omega> ^ l) ^ (j - i)) = numbers ! j * (\<Sum>l = 0..<n. (\<omega> ^ l) ^ (j - i))
\<omega> ^ (j - i) \<noteq> 1
\<omega> ^ (j - i) \<noteq> 1 \<Longrightarrow> (1 - \<omega> ^ (j - i)) * sum ((^) (\<omega> ^ (j - i))) {0..<n} = 1 - (\<omega> ^ (j - i)) ^ n

goal (1 subgoal):
 1. (1 - \<omega> ^ (j - i)) * sum ((^) (\<omega> ^ (j - i))) {0..<n} = 1 - (\<omega> ^ (j - i)) ^ n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(1 - \<omega> ^ (j - i)) * sum ((^) (\<omega> ^ (j - i))) {0..<n} = 1 - (\<omega> ^ (j - i)) ^ n

goal (1 subgoal):
 1. \<And>j. i < j \<and> j < n \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(1 - \<omega> ^ (j - i)) * sum ((^) (\<omega> ^ (j - i))) {0..<n} = 1 - (\<omega> ^ (j - i)) ^ n

goal (1 subgoal):
 1. \<And>j. i < j \<and> j < n \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
have "(\<omega>^(j-i))^n = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<omega> ^ (j - i)) ^ n = 1
[PROOF STEP]
by (metis (no_types) mult.commute  omega_properties(1) power_mult power_one)
[PROOF STATE]
proof (state)
this:
(\<omega> ^ (j - i)) ^ n = 1

goal (1 subgoal):
 1. \<And>j. i < j \<and> j < n \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(1 - \<omega> ^ (j - i)) * sum ((^) (\<omega> ^ (j - i))) {0..<n} = 1 - (\<omega> ^ (j - i)) ^ n
(\<omega> ^ (j - i)) ^ n = 1
[PROOF STEP]
have "(\<Sum>l = 0..<n. ((\<omega>^(j-i))^l)) = 0"
[PROOF STATE]
proof (prove)
using this:
(1 - \<omega> ^ (j - i)) * sum ((^) (\<omega> ^ (j - i))) {0..<n} = 1 - (\<omega> ^ (j - i)) ^ n
(\<omega> ^ (j - i)) ^ n = 1

goal (1 subgoal):
 1. sum ((^) (\<omega> ^ (j - i))) {0..<n} = 0
[PROOF STEP]
by (metis \<open>\<omega> ^ (j - i) \<noteq> 1\<close> eq_iff_diff_eq_0 no_zero_divisors)
[PROOF STATE]
proof (state)
this:
sum ((^) (\<omega> ^ (j - i))) {0..<n} = 0

goal (1 subgoal):
 1. \<And>j. i < j \<and> j < n \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
thus "(\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0"
[PROOF STATE]
proof (prove)
using this:
sum ((^) (\<omega> ^ (j - i))) {0..<n} = 0

goal (1 subgoal):
 1. (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
using  01 02 03
[PROOF STATE]
proof (prove)
using this:
sum ((^) (\<omega> ^ (j - i))) {0..<n} = 0
(\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = (\<Sum>l = 0..<n. numbers ! j * (\<omega> ^ l) ^ (j - i))
(\<Sum>l = 0..<n. numbers ! j * (\<omega> ^ l) ^ (j - i)) = numbers ! j * (\<Sum>l = 0..<n. (\<omega> ^ l) ^ (j - i))
(\<Sum>l = 0..<n. (\<omega> ^ l) ^ (j - i)) = sum ((^) (\<omega> ^ (j - i))) {0..<n}

goal (1 subgoal):
 1. (\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
i < ?j \<and> ?j < n \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! ?j * \<omega> ^ (l * ?j) * \<mu> ^ (i * l)) = 0

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
text \<open>We compose the cases $j <i$, $j = i$ and $j > i$ to a complete summation over index $j$.\<close>
[PROOF STATE]
proof (state)
this:
i < ?j \<and> ?j < n \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! ?j * \<omega> ^ (l * ?j) * \<mu> ^ (i * l)) = 0

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
have " (\<Sum>j = 0..<i. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j = 0..<i. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
using jlsi
[PROOF STATE]
proof (prove)
using this:
?j < i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! ?j * \<omega> ^ (l * ?j) * \<mu> ^ (i * l)) = 0

goal (1 subgoal):
 1. (\<Sum>j = 0..<i. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>j = 0..<i. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<Sum>j = 0..<i. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
have " (\<Sum>j = i..<i+1. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) =  numbers ! i * (of_int_mod_ring n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j = i..<i + 1. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = numbers ! i * of_int_mod_ring (int n)
[PROOF STEP]
using iisj
[PROOF STATE]
proof (prove)
using this:
?j = i \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! ?j * \<omega> ^ (l * ?j) * \<mu> ^ (i * l)) = numbers ! ?j * of_int_mod_ring (int n)

goal (1 subgoal):
 1. (\<Sum>j = i..<i + 1. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = numbers ! i * of_int_mod_ring (int n)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>j = i..<i + 1. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = numbers ! i * of_int_mod_ring (int n)

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<Sum>j = i..<i + 1. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = numbers ! i * of_int_mod_ring (int n)

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
have " (\<Sum>j = (i+1)..<n. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j = i + 1..<n. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
using ilsj
[PROOF STATE]
proof (prove)
using this:
i < ?j \<and> ?j < n \<Longrightarrow> (\<Sum>l = 0..<n. numbers ! ?j * \<omega> ^ (l * ?j) * \<mu> ^ (i * l)) = 0

goal (1 subgoal):
 1. (\<Sum>j = i + 1..<n. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>j = i + 1..<n. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
intt (NTT numbers) i = (\<Sum>l = 0..<n. \<Sum>j = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l))
(\<Sum>j = 0..<i. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
(\<Sum>j = i..<i + 1. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = numbers ! i * of_int_mod_ring (int n)
(\<Sum>j = i + 1..<n. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
[PROOF STEP]
have " (\<Sum>j = 0..<n. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) =
                        numbers ! i * (of_int_mod_ring n)"
[PROOF STATE]
proof (prove)
using this:
intt (NTT numbers) i = (\<Sum>l = 0..<n. \<Sum>j = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l))
(\<Sum>j = 0..<i. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
(\<Sum>j = i..<i + 1. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = numbers ! i * of_int_mod_ring (int n)
(\<Sum>j = i + 1..<n. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0

goal (1 subgoal):
 1. (\<Sum>j = 0..<n. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = numbers ! i * of_int_mod_ring (int n)
[PROOF STEP]
using i_assms sum_split
[PROOF STATE]
proof (prove)
using this:
intt (NTT numbers) i = (\<Sum>l = 0..<n. \<Sum>j = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l))
(\<Sum>j = 0..<i. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
(\<Sum>j = i..<i + 1. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = numbers ! i * of_int_mod_ring (int n)
(\<Sum>j = i + 1..<n. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = 0
i < n
?r1.0 < ?r2.0 \<Longrightarrow> sum ?f {0..<?r1.0} + sum ?f {?r1.0..<?r2.0} = sum ?f {0..<?r2.0}

goal (1 subgoal):
 1. (\<Sum>j = 0..<n. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = numbers ! i * of_int_mod_ring (int n)
[PROOF STEP]
by (smt (z3) add.commute add.left_neutral int_ops(2) less_imp_of_nat_less of_nat_add of_nat_eq_iff of_nat_less_imp_less)
[PROOF STATE]
proof (state)
this:
(\<Sum>j = 0..<n. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = numbers ! i * of_int_mod_ring (int n)

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
text \<open>Index-wise equality can be shown.\<close>
[PROOF STATE]
proof (state)
this:
(\<Sum>j = 0..<n. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = numbers ! i * of_int_mod_ring (int n)

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
thus "intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>j = 0..<n. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = numbers ! i * of_int_mod_ring (int n)

goal (1 subgoal):
 1. intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
using 1 2 3
[PROOF STATE]
proof (prove)
using this:
(\<Sum>j = 0..<n. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = numbers ! i * of_int_mod_ring (int n)
intt (NTT numbers) i = (\<Sum>l = 0..<n. (\<Sum>j = 0..<n. numbers ! j * \<omega> ^ (l * j)) * \<mu> ^ (i * l))
(\<Sum>l = 0..<n. (\<Sum>j = 0..<n. numbers ! j * \<omega> ^ (l * j)) * \<mu> ^ (i * l)) = (\<Sum>l = 0..<n. \<Sum>j = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l))
(\<Sum>l = 0..<n. \<Sum>j = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l)) = (\<Sum>j = 0..<n. \<Sum>l = 0..<n. numbers ! j * \<omega> ^ (l * j) * \<mu> ^ (i * l))

goal (1 subgoal):
 1. intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
by (metis mult.commute)
[PROOF STATE]
proof (state)
this:
intt (NTT numbers) i = of_int_mod_ring (int n) * numbers ! i

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?i < n \<Longrightarrow> intt (NTT numbers) ?i = of_int_mod_ring (int n) * numbers ! ?i

goal (1 subgoal):
 1. INTT (NTT numbers) = map ((*) (of_int_mod_ring (int n))) numbers
[PROOF STEP]
have 2: "\<And> i. i < n \<Longrightarrow> (map ((*) (of_int_mod_ring (int n))) numbers ) ! i = (of_int_mod_ring (int n)) * (numbers ! i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> map ((*) (of_int_mod_ring (int n))) numbers ! i = of_int_mod_ring (int n) * numbers ! i
[PROOF STEP]
by (simp add: n_def)
[PROOF STATE]
proof (state)
this:
?i < n \<Longrightarrow> map ((*) (of_int_mod_ring (int n))) numbers ! ?i = of_int_mod_ring (int n) * numbers ! ?i

goal (1 subgoal):
 1. INTT (NTT numbers) = map ((*) (of_int_mod_ring (int n))) numbers
[PROOF STEP]
text \<open>We relate index-wise equality to the function definition.\<close>
[PROOF STATE]
proof (state)
this:
?i < n \<Longrightarrow> map ((*) (of_int_mod_ring (int n))) numbers ! ?i = of_int_mod_ring (int n) * numbers ! ?i

goal (1 subgoal):
 1. INTT (NTT numbers) = map ((*) (of_int_mod_ring (int n))) numbers
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. INTT (NTT numbers) = map ((*) (of_int_mod_ring (int n))) numbers
[PROOF STEP]
apply(rule nth_equalityI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. length (INTT (NTT numbers)) = length (map ((*) (of_int_mod_ring (int n))) numbers)
 2. \<And>i. i < length (INTT (NTT numbers)) \<Longrightarrow> INTT (NTT numbers) ! i = map ((*) (of_int_mod_ring (int n))) numbers ! i
[PROOF STEP]
subgoal my_subgoal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (INTT (NTT numbers)) = length (map ((*) (of_int_mod_ring (int n))) numbers)
[PROOF STEP]
unfolding INTT_def NTT_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (map (intt (map (local.ntt numbers) [0..<n])) [0..<n]) = length (map ((*) (of_int_mod_ring (int n))) numbers)
[PROOF STEP]
apply (simp add: n_def)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i < length (INTT (NTT numbers)) \<Longrightarrow> INTT (NTT numbers) ! i = map ((*) (of_int_mod_ring (int n))) numbers ! i
[PROOF STEP]
subgoal for i
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i < length (INTT (NTT numbers)) \<Longrightarrow> INTT (NTT numbers) ! i = map ((*) (of_int_mod_ring (int n))) numbers ! i
[PROOF STEP]
using 0 1 2 n_def algebra_simps my_subgoal length_map
[PROOF STATE]
proof (prove)
using this:
?i < n \<Longrightarrow> INTT (NTT numbers) ! ?i = intt (NTT numbers) ?i
?i < n \<Longrightarrow> intt (NTT numbers) ?i = of_int_mod_ring (int n) * numbers ! ?i
?i < n \<Longrightarrow> map ((*) (of_int_mod_ring (int n))) numbers ! ?i = of_int_mod_ring (int n) * numbers ! ?i
length numbers = n
?a + ?b + ?c = ?a + (?b + ?c)
?a + ?b = ?b + ?a
?b + (?a + ?c) = ?a + (?b + ?c)
?a * ?b * ?c = ?a * (?b * ?c)
?a * ?b = ?b * ?a
?b * (?a * ?c) = ?a * (?b * ?c)
?a - ?b - ?c = ?a - (?b + ?c)
?a + (?b - ?c) = ?a + ?b - ?c
(?a - ?b = ?c) = (?a = ?c + ?b)
(?a = ?c - ?b) = (?a + ?b = ?c)
?a - (?b - ?c) = ?a + ?c - ?b
?a - ?b + ?c = ?a + ?c - ?b
(?a - ?b < ?c) = (?a < ?c + ?b)
(?a < ?c - ?b) = (?a + ?b < ?c)
(?a - ?b \<le> ?c) = (?a \<le> ?c + ?b)
(?a \<le> ?c - ?b) = (?a + ?b \<le> ?c)
(?a + ?b) * ?c = ?a * ?c + ?b * ?c
?a * (?b + ?c) = ?a * ?b + ?a * ?c
?a * (?b - ?c) = ?a * ?b - ?a * ?c
(?b - ?c) * ?a = ?b * ?a - ?c * ?a
?a * (?b - ?c) = ?a * ?b - ?a * ?c
(?a - ?b) * ?c = ?a * ?c - ?b * ?c
(?a * ?b) ^ ?n = ?a ^ ?n * ?b ^ ?n
?a *\<^sub>R (?x + ?y) = ?a *\<^sub>R ?x + ?a *\<^sub>R ?y
(?a + ?b) *\<^sub>R ?x = ?a *\<^sub>R ?x + ?b *\<^sub>R ?x
(?a - ?b) *\<^sub>R ?x = ?a *\<^sub>R ?x - ?b *\<^sub>R ?x
?a *\<^sub>R (?x - ?y) = ?a *\<^sub>R ?x - ?a *\<^sub>R ?y
length (INTT (NTT numbers)) = length (map ((*) (of_int_mod_ring (int n))) numbers)
length (map ?f ?xs) = length ?xs

goal (1 subgoal):
 1. i < length (INTT (NTT numbers)) \<Longrightarrow> INTT (NTT numbers) ! i = map ((*) (of_int_mod_ring (int n))) numbers ! i
[PROOF STEP]
apply  auto
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
INTT (NTT numbers) = map ((*) (of_int_mod_ring (int n))) numbers

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fls_mult_of_int_nth [simp]:
  shows "(of_int k * f) $$ n = of_int k * f$$n"
  and   "(f * of_int k ) $$ n = f$$n * of_int k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (of_int k * f) $$ n = of_int k * f $$ n &&& (f * of_int k) $$ n = f $$ n * of_int k
[PROOF STEP]
by    (simp_all add: fls_of_int)


[STATEMENT]
lemma (in abelian_group) a_l_coset_subset_G:
  "\<lbrakk> H \<subseteq> carrier G; x \<in> carrier G \<rbrakk> \<Longrightarrow> x <+ H \<subseteq> carrier G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>H \<subseteq> carrier G; x \<in> carrier G\<rbrakk> \<Longrightarrow> x <+ H \<subseteq> carrier G
[PROOF STEP]
by (rule group.l_coset_subset_G [OF a_group,
    folded a_l_coset_def, simplified monoid_record_simps])


[STATEMENT]
lemma mem_aforms_err_Cons_iff[simp]: "x#xs \<in> aforms_err e (X#XS) \<longleftrightarrow> x \<in> aform_err e X \<and> xs \<in> aforms_err e XS"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x # xs \<in> aforms_err e (X # XS)) = (x \<in> aform_err e X \<and> xs \<in> aforms_err e XS)
[PROOF STEP]
by (auto simp: aforms_err_Cons set_Cons_def)


[STATEMENT]
lemma diagonal_mat_mult_index:
  fixes B::"'a::{ring} Matrix.mat"
  assumes "diagonal_mat A"
  and "A\<in> carrier_mat n n"
  and "B \<in> carrier_mat n n"
  and "i < n"
  and "j < n"
  shows "(A * B) $$ (i,j) = A$$(i,i) * B$$(i,j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (A * B) $$ (i, j) = A $$ (i, i) * B $$ (i, j)
[PROOF STEP]
unfolding diagonal_mat_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (A * B) $$ (i, j) = A $$ (i, i) * B $$ (i, j)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (A * B) $$ (i, j) = A $$ (i, i) * B $$ (i, j)
[PROOF STEP]
have "dim_row (A * B) = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row (A * B) = n
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
diagonal_mat A
A \<in> carrier_mat n n
B \<in> carrier_mat n n
i < n
j < n

goal (1 subgoal):
 1. dim_row (A * B) = n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
dim_row (A * B) = n

goal (1 subgoal):
 1. (A * B) $$ (i, j) = A $$ (i, i) * B $$ (i, j)
[PROOF STEP]
have "dim_col (A * B) = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_col (A * B) = n
[PROOF STEP]
using  assms
[PROOF STATE]
proof (prove)
using this:
diagonal_mat A
A \<in> carrier_mat n n
B \<in> carrier_mat n n
i < n
j < n

goal (1 subgoal):
 1. dim_col (A * B) = n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
dim_col (A * B) = n

goal (1 subgoal):
 1. (A * B) $$ (i, j) = A $$ (i, i) * B $$ (i, j)
[PROOF STEP]
have jvec: "\<And>j. j < n \<Longrightarrow> dim_vec (Matrix.col B j) = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>j. j < n \<Longrightarrow> dim_vec (Matrix.col B j) = n
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
diagonal_mat A
A \<in> carrier_mat n n
B \<in> carrier_mat n n
i < n
j < n

goal (1 subgoal):
 1. \<And>j. j < n \<Longrightarrow> dim_vec (Matrix.col B j) = n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
?j < n \<Longrightarrow> dim_vec (Matrix.col B ?j) = n

goal (1 subgoal):
 1. (A * B) $$ (i, j) = A $$ (i, i) * B $$ (i, j)
[PROOF STEP]
have "(A * B) $$ (i,j) = Matrix.scalar_prod (Matrix.row A i) (Matrix.col B j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (A * B) $$ (i, j) = Matrix.row A i \<bullet> Matrix.col B j
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
diagonal_mat A
A \<in> carrier_mat n n
B \<in> carrier_mat n n
i < n
j < n

goal (1 subgoal):
 1. (A * B) $$ (i, j) = Matrix.row A i \<bullet> Matrix.col B j
[PROOF STEP]
by (metis carrier_matD(1) carrier_matD(2) index_mult_mat(1))
[PROOF STATE]
proof (state)
this:
(A * B) $$ (i, j) = Matrix.row A i \<bullet> Matrix.col B j

goal (1 subgoal):
 1. (A * B) $$ (i, j) = A $$ (i, i) * B $$ (i, j)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(A * B) $$ (i, j) = Matrix.row A i \<bullet> Matrix.col B j

goal (1 subgoal):
 1. (A * B) $$ (i, j) = A $$ (i, i) * B $$ (i, j)
[PROOF STEP]
have "... =
    (\<Sum> k \<in> {0 ..< n}. vec_index (Matrix.row A i) k *
      vec_index (Matrix.col B j) k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix.row A i \<bullet> Matrix.col B j = (\<Sum>k = 0..<n. Matrix.row A i $ k * Matrix.col B j $ k)
[PROOF STEP]
using assms  jvec
[PROOF STATE]
proof (prove)
using this:
diagonal_mat A
A \<in> carrier_mat n n
B \<in> carrier_mat n n
i < n
j < n
?j < n \<Longrightarrow> dim_vec (Matrix.col B ?j) = n

goal (1 subgoal):
 1. Matrix.row A i \<bullet> Matrix.col B j = (\<Sum>k = 0..<n. Matrix.row A i $ k * Matrix.col B j $ k)
[PROOF STEP]
unfolding Matrix.scalar_prod_def
[PROOF STATE]
proof (prove)
using this:
diagonal_mat A
A \<in> carrier_mat n n
B \<in> carrier_mat n n
i < n
j < n
?j < n \<Longrightarrow> dim_vec (Matrix.col B ?j) = n

goal (1 subgoal):
 1. (\<Sum>ia = 0..<dim_vec (Matrix.col B j). Matrix.row A i $ ia * Matrix.col B j $ ia) = (\<Sum>k = 0..<n. Matrix.row A i $ k * Matrix.col B j $ k)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Matrix.row A i \<bullet> Matrix.col B j = (\<Sum>k = 0..<n. Matrix.row A i $ k * Matrix.col B j $ k)

goal (1 subgoal):
 1. (A * B) $$ (i, j) = A $$ (i, i) * B $$ (i, j)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Matrix.row A i \<bullet> Matrix.col B j = (\<Sum>k = 0..<n. Matrix.row A i $ k * Matrix.col B j $ k)

goal (1 subgoal):
 1. (A * B) $$ (i, j) = A $$ (i, i) * B $$ (i, j)
[PROOF STEP]
have "... = vec_index (Matrix.row A i) i * vec_index (Matrix.col B j) i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k = 0..<n. Matrix.row A i $ k * Matrix.col B j $ k) = Matrix.row A i $ i * Matrix.col B j $ i
[PROOF STEP]
proof (rule sum_but_one)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<forall>k<n. k \<noteq> i \<longrightarrow> Matrix.row A i $ k = (0::'a)
 2. i < n
[PROOF STEP]
show "i < n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i < n
[PROOF STEP]
using assms \<open>dim_row (A * B) = n\<close>
[PROOF STATE]
proof (prove)
using this:
diagonal_mat A
A \<in> carrier_mat n n
B \<in> carrier_mat n n
i < n
j < n
dim_row (A * B) = n

goal (1 subgoal):
 1. i < n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
i < n

goal (1 subgoal):
 1. \<forall>k<n. k \<noteq> i \<longrightarrow> Matrix.row A i $ k = (0::'a)
[PROOF STEP]
show "\<forall>k<n. k \<noteq> i \<longrightarrow> vec_index (Matrix.row A i) k = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>k<n. k \<noteq> i \<longrightarrow> Matrix.row A i $ k = (0::'a)
[PROOF STEP]
using assms \<open>i < n\<close>
[PROOF STATE]
proof (prove)
using this:
diagonal_mat A
A \<in> carrier_mat n n
B \<in> carrier_mat n n
i < n
j < n
i < n

goal (1 subgoal):
 1. \<forall>k<n. k \<noteq> i \<longrightarrow> Matrix.row A i $ k = (0::'a)
[PROOF STEP]
unfolding diagonal_mat_def
[PROOF STATE]
proof (prove)
using this:
\<forall>i<dim_row A. \<forall>j<dim_col A. i \<noteq> j \<longrightarrow> A $$ (i, j) = (0::'a)
A \<in> carrier_mat n n
B \<in> carrier_mat n n
i < n
j < n
i < n

goal (1 subgoal):
 1. \<forall>k<n. k \<noteq> i \<longrightarrow> Matrix.row A i $ k = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>k<n. k \<noteq> i \<longrightarrow> Matrix.row A i $ k = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 0..<n. Matrix.row A i $ k * Matrix.col B j $ k) = Matrix.row A i $ i * Matrix.col B j $ i

goal (1 subgoal):
 1. (A * B) $$ (i, j) = A $$ (i, i) * B $$ (i, j)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 0..<n. Matrix.row A i $ k * Matrix.col B j $ k) = Matrix.row A i $ i * Matrix.col B j $ i

goal (1 subgoal):
 1. (A * B) $$ (i, j) = A $$ (i, i) * B $$ (i, j)
[PROOF STEP]
have "... = A$$(i,i) * B$$(i,j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix.row A i $ i * Matrix.col B j $ i = A $$ (i, i) * B $$ (i, j)
[PROOF STEP]
using  assms
[PROOF STATE]
proof (prove)
using this:
diagonal_mat A
A \<in> carrier_mat n n
B \<in> carrier_mat n n
i < n
j < n

goal (1 subgoal):
 1. Matrix.row A i $ i * Matrix.col B j $ i = A $$ (i, i) * B $$ (i, j)
[PROOF STEP]
by (metis carrier_matD(1) carrier_matD(2) index_col index_row(1))
[PROOF STATE]
proof (state)
this:
Matrix.row A i $ i * Matrix.col B j $ i = A $$ (i, i) * B $$ (i, j)

goal (1 subgoal):
 1. (A * B) $$ (i, j) = A $$ (i, i) * B $$ (i, j)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(A * B) $$ (i, j) = A $$ (i, i) * B $$ (i, j)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(A * B) $$ (i, j) = A $$ (i, i) * B $$ (i, j)

goal (1 subgoal):
 1. (A * B) $$ (i, j) = A $$ (i, i) * B $$ (i, j)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(A * B) $$ (i, j) = A $$ (i, i) * B $$ (i, j)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma leadsETo_induct:
  "[| F \<in> za leadsTo[CC] zb;
      !!A B. [| F \<in> A ensures B;  A-B \<in> insert {} CC |] ==> P A B;
      !!A B C. [| F \<in> A leadsTo[CC] B; P A B; F \<in> B leadsTo[CC] C; P B C |]
               ==> P A C;
      !!B S. \<forall>A\<in>S. F \<in> A leadsTo[CC] B & P A B ==> P (\<Union>S) B
   |] ==> P za zb"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>F \<in> za leadsTo[CC] zb; \<And>A B. \<lbrakk>F \<in> A ensures B; A - B \<in> insert {} CC\<rbrakk> \<Longrightarrow> P A B; \<And>A B C. \<lbrakk>F \<in> A leadsTo[CC] B; P A B; F \<in> B leadsTo[CC] C; P B C\<rbrakk> \<Longrightarrow> P A C; \<And>B S. \<forall>A\<in>S. F \<in> A leadsTo[CC] B \<and> P A B \<Longrightarrow> P (\<Union> S) B\<rbrakk> \<Longrightarrow> P za zb
[PROOF STEP]
apply (unfold leadsETo_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>F \<in> {F. (za, zb) \<in> elt CC F}; \<And>A B. \<lbrakk>F \<in> A ensures B; A - B \<in> insert {} CC\<rbrakk> \<Longrightarrow> P A B; \<And>A B C. \<lbrakk>F \<in> {F. (A, B) \<in> elt CC F}; P A B; F \<in> {F. (B, C) \<in> elt CC F}; P B C\<rbrakk> \<Longrightarrow> P A C; \<And>B S. \<forall>A\<in>S. F \<in> {F. (A, B) \<in> elt CC F} \<and> P A B \<Longrightarrow> P (\<Union> S) B\<rbrakk> \<Longrightarrow> P za zb
[PROOF STEP]
apply (drule CollectD)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<And>A B. \<lbrakk>F \<in> A ensures B; A - B \<in> insert {} CC\<rbrakk> \<Longrightarrow> P A B; \<And>A B C. \<lbrakk>F \<in> {F. (A, B) \<in> elt CC F}; P A B; F \<in> {F. (B, C) \<in> elt CC F}; P B C\<rbrakk> \<Longrightarrow> P A C; \<And>B S. \<forall>A\<in>S. F \<in> {F. (A, B) \<in> elt CC F} \<and> P A B \<Longrightarrow> P (\<Union> S) B; (za, zb) \<in> elt CC F\<rbrakk> \<Longrightarrow> P za zb
[PROOF STEP]
apply (erule elt.induct, blast+)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma hf_int_poly:
  fixes x::real
  shows "hf n = (\<lambda>x. (1 / fact n) * (\<Sum>i=0..2*n. real_of_int (cf n i) * x^i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. hf n = (\<lambda>x. 1 / fact n * (\<Sum>i = 0..2 * n. real_of_int (cf n i) * x ^ i))
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. hf n x = 1 / fact n * (\<Sum>i = 0..2 * n. real_of_int (cf n i) * x ^ i)
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. hf n x = 1 / fact n * (\<Sum>i = 0..2 * n. real_of_int (cf n i) * x ^ i)
[PROOF STEP]
have inj: "inj_on ((+)n) {..n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on ((+) n) {..n}
[PROOF STEP]
by (auto simp: inj_on_def)
[PROOF STATE]
proof (state)
this:
inj_on ((+) n) {..n}

goal (1 subgoal):
 1. \<And>x. hf n x = 1 / fact n * (\<Sum>i = 0..2 * n. real_of_int (cf n i) * x ^ i)
[PROOF STEP]
have [simp]: "((+)n) ` {..n} = {n..2*n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (+) n ` {..n} = {n..2 * n}
[PROOF STEP]
using nat_le_iff_add
[PROOF STATE]
proof (prove)
using this:
(?m \<le> ?n) = (\<exists>k. ?n = ?m + k)

goal (1 subgoal):
 1. (+) n ` {..n} = {n..2 * n}
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
(+) n ` {..n} = {n..2 * n}

goal (1 subgoal):
 1. \<And>x. hf n x = 1 / fact n * (\<Sum>i = 0..2 * n. real_of_int (cf n i) * x ^ i)
[PROOF STEP]
have "(x^n * (-x + 1)^n) = x ^ n * (\<Sum>k\<le>n. real (n choose k) * (- x) ^ k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x ^ n * (- x + 1) ^ n = x ^ n * (\<Sum>k\<le>n. real (n choose k) * (- x) ^ k)
[PROOF STEP]
unfolding binomial_ring
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x ^ n * (\<Sum>k\<le>n. real (n choose k) * (- x) ^ k * 1 ^ (n - k)) = x ^ n * (\<Sum>k\<le>n. real (n choose k) * (- x) ^ k)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
x ^ n * (- x + 1) ^ n = x ^ n * (\<Sum>k\<le>n. real (n choose k) * (- x) ^ k)

goal (1 subgoal):
 1. \<And>x. hf n x = 1 / fact n * (\<Sum>i = 0..2 * n. real_of_int (cf n i) * x ^ i)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
x ^ n * (- x + 1) ^ n = x ^ n * (\<Sum>k\<le>n. real (n choose k) * (- x) ^ k)

goal (1 subgoal):
 1. \<And>x. hf n x = 1 / fact n * (\<Sum>i = 0..2 * n. real_of_int (cf n i) * x ^ i)
[PROOF STEP]
have "\<dots> = x ^ n * (\<Sum>k\<le>n. real_of_int ((n choose k) * (-1)^k) * x ^ k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x ^ n * (\<Sum>k\<le>n. real (n choose k) * (- x) ^ k) = x ^ n * (\<Sum>k\<le>n. real_of_int (int (n choose k) * (- 1) ^ k) * x ^ k)
[PROOF STEP]
by (simp add: mult.assoc flip: power_minus)
[PROOF STATE]
proof (state)
this:
x ^ n * (\<Sum>k\<le>n. real (n choose k) * (- x) ^ k) = x ^ n * (\<Sum>k\<le>n. real_of_int (int (n choose k) * (- 1) ^ k) * x ^ k)

goal (1 subgoal):
 1. \<And>x. hf n x = 1 / fact n * (\<Sum>i = 0..2 * n. real_of_int (cf n i) * x ^ i)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
x ^ n * (\<Sum>k\<le>n. real (n choose k) * (- x) ^ k) = x ^ n * (\<Sum>k\<le>n. real_of_int (int (n choose k) * (- 1) ^ k) * x ^ k)

goal (1 subgoal):
 1. \<And>x. hf n x = 1 / fact n * (\<Sum>i = 0..2 * n. real_of_int (cf n i) * x ^ i)
[PROOF STEP]
have "\<dots> = (\<Sum>k\<le>n. real_of_int ((n choose k) * (-1)^k) * x ^ (n+k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x ^ n * (\<Sum>k\<le>n. real_of_int (int (n choose k) * (- 1) ^ k) * x ^ k) = (\<Sum>k\<le>n. real_of_int (int (n choose k) * (- 1) ^ k) * x ^ (n + k))
[PROOF STEP]
by (simp add: sum_distrib_left mult_ac power_add)
[PROOF STATE]
proof (state)
this:
x ^ n * (\<Sum>k\<le>n. real_of_int (int (n choose k) * (- 1) ^ k) * x ^ k) = (\<Sum>k\<le>n. real_of_int (int (n choose k) * (- 1) ^ k) * x ^ (n + k))

goal (1 subgoal):
 1. \<And>x. hf n x = 1 / fact n * (\<Sum>i = 0..2 * n. real_of_int (cf n i) * x ^ i)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
x ^ n * (\<Sum>k\<le>n. real_of_int (int (n choose k) * (- 1) ^ k) * x ^ k) = (\<Sum>k\<le>n. real_of_int (int (n choose k) * (- 1) ^ k) * x ^ (n + k))

goal (1 subgoal):
 1. \<And>x. hf n x = 1 / fact n * (\<Sum>i = 0..2 * n. real_of_int (cf n i) * x ^ i)
[PROOF STEP]
have "\<dots> = (\<Sum>i=n..2*n. real_of_int (cf n i) * x^i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k\<le>n. real_of_int (int (n choose k) * (- 1) ^ k) * x ^ (n + k)) = (\<Sum>i = n..2 * n. real_of_int (cf n i) * x ^ i)
[PROOF STEP]
by (simp add: sum.reindex [OF inj, simplified] cf_def)
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<le>n. real_of_int (int (n choose k) * (- 1) ^ k) * x ^ (n + k)) = (\<Sum>i = n..2 * n. real_of_int (cf n i) * x ^ i)

goal (1 subgoal):
 1. \<And>x. hf n x = 1 / fact n * (\<Sum>i = 0..2 * n. real_of_int (cf n i) * x ^ i)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
x ^ n * (- x + 1) ^ n = (\<Sum>i = n..2 * n. real_of_int (cf n i) * x ^ i)
[PROOF STEP]
have "hf n x = (1 / fact n) * (\<Sum>i = n..2 * n. real_of_int (cf n i) * x^i)"
[PROOF STATE]
proof (prove)
using this:
x ^ n * (- x + 1) ^ n = (\<Sum>i = n..2 * n. real_of_int (cf n i) * x ^ i)

goal (1 subgoal):
 1. hf n x = 1 / fact n * (\<Sum>i = n..2 * n. real_of_int (cf n i) * x ^ i)
[PROOF STEP]
by (simp add: hf_def)
[PROOF STATE]
proof (state)
this:
hf n x = 1 / fact n * (\<Sum>i = n..2 * n. real_of_int (cf n i) * x ^ i)

goal (1 subgoal):
 1. \<And>x. hf n x = 1 / fact n * (\<Sum>i = 0..2 * n. real_of_int (cf n i) * x ^ i)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
hf n x = 1 / fact n * (\<Sum>i = n..2 * n. real_of_int (cf n i) * x ^ i)

goal (1 subgoal):
 1. \<And>x. hf n x = 1 / fact n * (\<Sum>i = 0..2 * n. real_of_int (cf n i) * x ^ i)
[PROOF STEP]
have "(\<Sum>i = 0..<n. real_of_int (cf n i) * x^i) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<n. real_of_int (cf n i) * x ^ i) = 0
[PROOF STEP]
by (simp add: cf_def)
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<n. real_of_int (cf n i) * x ^ i) = 0

goal (1 subgoal):
 1. \<And>x. hf n x = 1 / fact n * (\<Sum>i = 0..2 * n. real_of_int (cf n i) * x ^ i)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
hf n x = 1 / fact n * (\<Sum>i = n..2 * n. real_of_int (cf n i) * x ^ i)
(\<Sum>i = 0..<n. real_of_int (cf n i) * x ^ i) = 0
[PROOF STEP]
show "hf n x = (1 / fact n) * (\<Sum>i = 0..2 * n. real_of_int (cf n i) * x^i)"
[PROOF STATE]
proof (prove)
using this:
hf n x = 1 / fact n * (\<Sum>i = n..2 * n. real_of_int (cf n i) * x ^ i)
(\<Sum>i = 0..<n. real_of_int (cf n i) * x ^ i) = 0

goal (1 subgoal):
 1. hf n x = 1 / fact n * (\<Sum>i = 0..2 * n. real_of_int (cf n i) * x ^ i)
[PROOF STEP]
using sum.union_disjoint [of "{0..<n}" "{n..2*n}" "\<lambda>i. real_of_int (cf n i) * x^i"]
[PROOF STATE]
proof (prove)
using this:
hf n x = 1 / fact n * (\<Sum>i = n..2 * n. real_of_int (cf n i) * x ^ i)
(\<Sum>i = 0..<n. real_of_int (cf n i) * x ^ i) = 0
\<lbrakk>finite {0..<n}; finite {n..2 * n}; {0..<n} \<inter> {n..2 * n} = {}\<rbrakk> \<Longrightarrow> (\<Sum>i\<in>{0..<n} \<union> {n..2 * n}. real_of_int (cf n i) * x ^ i) = (\<Sum>i = 0..<n. real_of_int (cf n i) * x ^ i) + (\<Sum>i = n..2 * n. real_of_int (cf n i) * x ^ i)

goal (1 subgoal):
 1. hf n x = 1 / fact n * (\<Sum>i = 0..2 * n. real_of_int (cf n i) * x ^ i)
[PROOF STEP]
by (simp add: ivl_disj_int_two(7) ivl_disj_un_two(7) mult_2)
[PROOF STATE]
proof (state)
this:
hf n x = 1 / fact n * (\<Sum>i = 0..2 * n. real_of_int (cf n i) * x ^ i)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma negligible_outer:
  "negligible S \<longleftrightarrow> (\<forall>e>0. \<exists>T. S \<subseteq> T \<and> T \<in> lmeasurable \<and> measure lebesgue T < e)" (is "_ = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. negligible S = (\<forall>e>0. \<exists>T. S \<subseteq> T \<and> T \<in> lmeasurable \<and> Sigma_Algebra.measure lebesgue T < e)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. negligible S \<Longrightarrow> \<forall>e>0. \<exists>T. S \<subseteq> T \<and> T \<in> lmeasurable \<and> Sigma_Algebra.measure lebesgue T < e
 2. \<forall>e>0. \<exists>T. S \<subseteq> T \<and> T \<in> lmeasurable \<and> Sigma_Algebra.measure lebesgue T < e \<Longrightarrow> negligible S
[PROOF STEP]
assume "negligible S"
[PROOF STATE]
proof (state)
this:
negligible S

goal (2 subgoals):
 1. negligible S \<Longrightarrow> \<forall>e>0. \<exists>T. S \<subseteq> T \<and> T \<in> lmeasurable \<and> Sigma_Algebra.measure lebesgue T < e
 2. \<forall>e>0. \<exists>T. S \<subseteq> T \<and> T \<in> lmeasurable \<and> Sigma_Algebra.measure lebesgue T < e \<Longrightarrow> negligible S
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
negligible S
[PROOF STEP]
show ?rhs
[PROOF STATE]
proof (prove)
using this:
negligible S

goal (1 subgoal):
 1. \<forall>e>0. \<exists>T. S \<subseteq> T \<and> T \<in> lmeasurable \<and> Sigma_Algebra.measure lebesgue T < e
[PROOF STEP]
by (metis negligible_iff_measure order_refl)
[PROOF STATE]
proof (state)
this:
\<forall>e>0. \<exists>T. S \<subseteq> T \<and> T \<in> lmeasurable \<and> Sigma_Algebra.measure lebesgue T < e

goal (1 subgoal):
 1. \<forall>e>0. \<exists>T. S \<subseteq> T \<and> T \<in> lmeasurable \<and> Sigma_Algebra.measure lebesgue T < e \<Longrightarrow> negligible S
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<forall>e>0. \<exists>T. S \<subseteq> T \<and> T \<in> lmeasurable \<and> Sigma_Algebra.measure lebesgue T < e \<Longrightarrow> negligible S
[PROOF STEP]
assume ?rhs
[PROOF STATE]
proof (state)
this:
\<forall>e>0. \<exists>T. S \<subseteq> T \<and> T \<in> lmeasurable \<and> Sigma_Algebra.measure lebesgue T < e

goal (1 subgoal):
 1. \<forall>e>0. \<exists>T. S \<subseteq> T \<and> T \<in> lmeasurable \<and> Sigma_Algebra.measure lebesgue T < e \<Longrightarrow> negligible S
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>e>0. \<exists>T. S \<subseteq> T \<and> T \<in> lmeasurable \<and> Sigma_Algebra.measure lebesgue T < e
[PROOF STEP]
show "negligible S"
[PROOF STATE]
proof (prove)
using this:
\<forall>e>0. \<exists>T. S \<subseteq> T \<and> T \<in> lmeasurable \<and> Sigma_Algebra.measure lebesgue T < e

goal (1 subgoal):
 1. negligible S
[PROOF STEP]
by (meson completion.null_sets_outer negligible_iff_null_sets)
[PROOF STATE]
proof (state)
this:
negligible S

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma isom_gch_unitsTr1_2:"\<lbrakk>Ugp E; f (Suc n) \<noteq> Suc n; inj_on f {i. i\<le>(Suc n)};
        \<forall>l \<le> (Suc n). f l \<le> (Suc n)\<rbrakk> \<Longrightarrow>
        (cmp (transpos (f (Suc n)) (Suc n)) f) (Suc n) = Suc n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Ugp E; f (Suc n) \<noteq> Suc n; inj_on f {i. i \<le> Suc n}; \<forall>l\<le>Suc n. f l \<le> Suc n\<rbrakk> \<Longrightarrow> cmp (transpos (f (Suc n)) (Suc n)) f (Suc n) = Suc n
[PROOF STEP]
apply (simp add:cmp_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Ugp E; f (Suc n) \<noteq> Suc n; inj_on f {i. i \<le> Suc n}; \<forall>l\<le>Suc n. f l \<le> Suc n\<rbrakk> \<Longrightarrow> transpos (f (Suc n)) (Suc n) (f (Suc n)) = Suc n
[PROOF STEP]
apply (cut_tac n_in_Nsetn[of "Suc n"], simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Ugp E; f (Suc n) \<noteq> Suc n; inj_on f {i. i \<le> Suc n}; \<forall>l\<le>Suc n. f l \<le> Suc n\<rbrakk> \<Longrightarrow> transpos (f (Suc n)) (Suc n) (f (Suc n)) = Suc n
[PROOF STEP]
apply (frule_tac a = "Suc n" in forall_spec,
      simp,
      thin_tac "\<forall>l\<le>Suc n. f l \<le> Suc n")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Ugp E; f (Suc n) \<noteq> Suc n; inj_on f {i. i \<le> Suc n}; f (Suc n) \<le> Suc n\<rbrakk> \<Longrightarrow> transpos (f (Suc n)) (Suc n) (f (Suc n)) = Suc n
[PROOF STEP]
apply (rule transpos_ij_1, assumption+, simp+)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma ltrm_of_X_minus:
  assumes "a \<in> carrier R"
  assumes "\<one> \<noteq>\<zero>"
  shows "ltrm (X_minus a) = X"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. monom P (X_poly_minus R a (deg R (X_poly_minus R a))) (deg R (X_poly_minus R a)) = X_poly R
[PROOF STEP]
using X_minus_plus[of a]  assms
[PROOF STATE]
proof (prove)
using this:
a \<in> carrier R \<Longrightarrow> X_poly_minus R a = X_poly_plus R (\<ominus> a)
a \<in> carrier R
\<one> \<noteq> \<zero>

goal (1 subgoal):
 1. monom P (X_poly_minus R a (deg R (X_poly_minus R a))) (deg R (X_poly_minus R a)) = X_poly R
[PROOF STEP]
by (simp add: ltrm_of_X_plus)


[STATEMENT]
lemma tendsto_mult [tendsto_intros]:
  fixes a b :: "'a::topological_semigroup_mult"
  shows "(f \<longlongrightarrow> a) F \<Longrightarrow> (g \<longlongrightarrow> b) F \<Longrightarrow> ((\<lambda>x. f x * g x) \<longlongrightarrow> a * b) F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(f \<longlongrightarrow> a) F; (g \<longlongrightarrow> b) F\<rbrakk> \<Longrightarrow> ((\<lambda>x. f x * g x) \<longlongrightarrow> a * b) F
[PROOF STEP]
using filterlim_compose[OF tendsto_mult_Pair, of "\<lambda>x. (f x, g x)" a b F]
[PROOF STATE]
proof (prove)
using this:
LIM x F. (f x, g x) :> nhds a \<times>\<^sub>F nhds b \<Longrightarrow> ((\<lambda>x. fst (f x, g x) * snd (f x, g x)) \<longlongrightarrow> a * b) F

goal (1 subgoal):
 1. \<lbrakk>(f \<longlongrightarrow> a) F; (g \<longlongrightarrow> b) F\<rbrakk> \<Longrightarrow> ((\<lambda>x. f x * g x) \<longlongrightarrow> a * b) F
[PROOF STEP]
by (simp add: nhds_prod[symmetric] tendsto_Pair)


[STATEMENT]
lemma mon_left_invertible:
   "\<lbrakk>f \<in> hom G H; \<And>x. x \<in> carrier G \<Longrightarrow> g(f x) = x\<rbrakk> \<Longrightarrow> f \<in> mon G H"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f \<in> hom G H; \<And>x. x \<in> carrier G \<Longrightarrow> g (f x) = x\<rbrakk> \<Longrightarrow> f \<in> mon G H
[PROOF STEP]
by (simp add: mon_def inj_on_def) metis


[STATEMENT]
lemma moebius_pt_moebius_rotation [simp]:
  shows "moebius_pt (moebius_rotation \<phi>) (of_complex z) = of_complex (cis \<phi> * z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. moebius_pt (moebius_rotation \<phi>) (of_complex z) = of_complex (cis \<phi> * z)
[PROOF STEP]
unfolding moebius_rotation_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. moebius_pt (moebius_similarity (cis \<phi>) 0) (of_complex z) = of_complex (cis \<phi> * z)
[PROOF STEP]
by simp


[STATEMENT]
lemma disjoint_var_prod[disjoint_vars]: "disjoint_var (P1 \<^bold>* P2) Q = (disjoint_var P1 Q \<and> disjoint_var P2 Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. disjoint_var (P1 \<^bold>* P2) Q = (disjoint_var P1 Q \<and> disjoint_var P2 Q)
[PROOF STEP]
unfolding disjoint_var_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (var_set (P1 \<^bold>* P2) \<inter> var_set Q = {}) = (var_set P1 \<inter> var_set Q = {} \<and> var_set P2 \<inter> var_set Q = {})
[PROOF STEP]
by auto


[STATEMENT]
lemma NR\<^sub>N_1:
  assumes "p \<in> {0<..<1}"
  shows "NR\<^sub>N 1 u l = (u * q + l * p) / p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. NR\<^sub>N 1 u l = ennreal ((real u * q + real l * p) / p)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. NR\<^sub>N 1 u l = ennreal ((real u * q + real l * p) / p)
[PROOF STEP]
have "NR\<^sub>N 1 u l = (ennreal p * of_nat l + ennreal q * of_nat u) / ennreal (1 - q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. NR\<^sub>N 1 u l = (ennreal p * of_nat l + ennreal q * of_nat u) / ennreal (1 - q)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
p \<in> {0<..<1}

goal (1 subgoal):
 1. NR\<^sub>N 1 u l = (ennreal p * of_nat l + ennreal q * of_nat u) / ennreal (1 - q)
[PROOF STEP]
by (subst NR\<^sub>N_recurrence) auto
[PROOF STATE]
proof (state)
this:
NR\<^sub>N 1 u l = (ennreal p * of_nat l + ennreal q * of_nat u) / ennreal (1 - q)

goal (1 subgoal):
 1. NR\<^sub>N 1 u l = ennreal ((real u * q + real l * p) / p)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
NR\<^sub>N 1 u l = (ennreal p * of_nat l + ennreal q * of_nat u) / ennreal (1 - q)

goal (1 subgoal):
 1. NR\<^sub>N 1 u l = ennreal ((real u * q + real l * p) / p)
[PROOF STEP]
have "(ennreal p * of_nat l + ennreal q * of_nat u) = (u * q + l * p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ennreal p * of_nat l + ennreal q * of_nat u = ennreal (real u * q + real l * p)
[PROOF STEP]
using assms q_def
[PROOF STATE]
proof (prove)
using this:
p \<in> {0<..<1}
q = 1 - p

goal (1 subgoal):
 1. ennreal p * of_nat l + ennreal q * of_nat u = ennreal (real u * q + real l * p)
[PROOF STEP]
by (subst ennreal_plus)
      (auto simp add: field_simps ennreal_mult' ennreal_of_nat_eq_real_of_nat)
[PROOF STATE]
proof (state)
this:
ennreal p * of_nat l + ennreal q * of_nat u = ennreal (real u * q + real l * p)

goal (1 subgoal):
 1. NR\<^sub>N 1 u l = ennreal ((real u * q + real l * p) / p)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ennreal p * of_nat l + ennreal q * of_nat u = ennreal (real u * q + real l * p)

goal (1 subgoal):
 1. NR\<^sub>N 1 u l = ennreal ((real u * q + real l * p) / p)
[PROOF STEP]
have "\<dots> / ennreal (1 - q) = ennreal ((u * q + l * p) / (1 - q))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ennreal (real u * q + real l * p) / ennreal (1 - q) = ennreal ((real u * q + real l * p) / (1 - q))
[PROOF STEP]
using q_def assms
[PROOF STATE]
proof (prove)
using this:
q = 1 - p
p \<in> {0<..<1}

goal (1 subgoal):
 1. ennreal (real u * q + real l * p) / ennreal (1 - q) = ennreal ((real u * q + real l * p) / (1 - q))
[PROOF STEP]
by (intro divide_ennreal) auto
[PROOF STATE]
proof (state)
this:
ennreal (real u * q + real l * p) / ennreal (1 - q) = ennreal ((real u * q + real l * p) / (1 - q))

goal (1 subgoal):
 1. NR\<^sub>N 1 u l = ennreal ((real u * q + real l * p) / p)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
NR\<^sub>N 1 u l = ennreal ((real u * q + real l * p) / (1 - q))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
NR\<^sub>N 1 u l = ennreal ((real u * q + real l * p) / (1 - q))

goal (1 subgoal):
 1. NR\<^sub>N 1 u l = ennreal ((real u * q + real l * p) / p)
[PROOF STEP]
unfolding q_def
[PROOF STATE]
proof (prove)
using this:
NR\<^sub>N 1 u l = ennreal ((real u * (1 - p) + real l * p) / (1 - (1 - p)))

goal (1 subgoal):
 1. NR\<^sub>N 1 u l = ennreal ((real u * (1 - p) + real l * p) / p)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
NR\<^sub>N 1 u l = ennreal ((real u * q + real l * p) / p)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in order_topology) nhds_order:
  "nhds x = inf (INF a\<in>{x <..}. principal {..< a}) (INF a\<in>{..< x}. principal {a <..})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nhds x = inf (INF a\<in>{x<..}. principal {..<a}) (INF a\<in>{..<x}. principal {a<..})
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. nhds x = inf (INF a\<in>{x<..}. principal {..<a}) (INF a\<in>{..<x}. principal {a<..})
[PROOF STEP]
have 1: "{S \<in> range lessThan \<union> range greaterThan. x \<in> S} =
      (\<lambda>a. {..< a}) ` {x <..} \<union> (\<lambda>a. {a <..}) ` {..< x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {S \<in> range lessThan \<union> range greaterThan. x \<in> S} = lessThan ` {x<..} \<union> greaterThan ` {..<x}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{S \<in> range lessThan \<union> range greaterThan. x \<in> S} = lessThan ` {x<..} \<union> greaterThan ` {..<x}

goal (1 subgoal):
 1. nhds x = inf (INF a\<in>{x<..}. principal {..<a}) (INF a\<in>{..<x}. principal {a<..})
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nhds x = inf (INF a\<in>{x<..}. principal {..<a}) (INF a\<in>{..<x}. principal {a<..})
[PROOF STEP]
by (simp only: nhds_generated_topology[OF open_generated_order] INF_union 1 INF_image comp_def)
[PROOF STATE]
proof (state)
this:
nhds x = inf (INF a\<in>{x<..}. principal {..<a}) (INF a\<in>{..<x}. principal {a<..})

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma is_edge_or_loop: "e \<in> E \<Longrightarrow> is_loop e \<or> is_sedge e"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. e \<in> E \<Longrightarrow> is_loop e \<or> is_sedge e
[PROOF STEP]
using alt_edge_size is_loop_def is_sedge_def
[PROOF STATE]
proof (prove)
using this:
?e \<in> E \<Longrightarrow> card ?e = 1 \<or> card ?e = 2
is_loop ?e \<equiv> card ?e = 1
is_sedge ?e \<equiv> card ?e = 2

goal (1 subgoal):
 1. e \<in> E \<Longrightarrow> is_loop e \<or> is_sedge e
[PROOF STEP]
by simp


[STATEMENT]
lemma lexext_rev_total:
  "(\<forall>y \<in> B. \<forall>x \<in> A. gt y x \<or> gt x y \<or> y = x) \<Longrightarrow> ys \<in> lists B \<Longrightarrow> xs \<in> lists A \<Longrightarrow>
   lexext_rev gt ys xs \<or> lexext_rev gt xs ys \<or> ys = xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>y\<in>B. \<forall>x\<in>A. gt y x \<or> gt x y \<or> y = x; ys \<in> lists B; xs \<in> lists A\<rbrakk> \<Longrightarrow> lexext_rev gt ys xs \<or> lexext_rev gt xs ys \<or> ys = xs
[PROOF STEP]
by (rule lexext_total[of _ _ _ "rev ys" "rev xs", simplified])


[STATEMENT]
lemma independent_is_basis:
  fixes B :: "('a::{field}^'n) set"
  shows "vec.independent B \<and> card B = CARD('n) \<longleftrightarrow> is_basis B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (vec.independent B \<and> card B = CARD('n)) = is_basis B
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. vec.independent B \<and> card B = CARD('n) \<Longrightarrow> is_basis B
 2. is_basis B \<Longrightarrow> vec.independent B \<and> card B = CARD('n)
[PROOF STEP]
assume "vec.independent B \<and> card B = CARD('n)"
[PROOF STATE]
proof (state)
this:
vec.independent B \<and> card B = CARD('n)

goal (2 subgoals):
 1. vec.independent B \<and> card B = CARD('n) \<Longrightarrow> is_basis B
 2. is_basis B \<Longrightarrow> vec.independent B \<and> card B = CARD('n)
[PROOF STEP]
hence "vec.independent B" and "card B = CARD('n)"
[PROOF STATE]
proof (prove)
using this:
vec.independent B \<and> card B = CARD('n)

goal (1 subgoal):
 1. vec.independent B &&& card B = CARD('n)
[PROOF STEP]
by simp+
[PROOF STATE]
proof (state)
this:
vec.independent B
card B = CARD('n)

goal (2 subgoals):
 1. vec.independent B \<and> card B = CARD('n) \<Longrightarrow> is_basis B
 2. is_basis B \<Longrightarrow> vec.independent B \<and> card B = CARD('n)
[PROOF STEP]
from card_finite [of B, where 'n = 'n] and \<open>card B = CARD('n)\<close>
[PROOF STATE]
proof (chain)
picking this:
card B = CARD('n) \<Longrightarrow> finite B
card B = CARD('n)
[PROOF STEP]
have "finite B"
[PROOF STATE]
proof (prove)
using this:
card B = CARD('n) \<Longrightarrow> finite B
card B = CARD('n)

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

goal (2 subgoals):
 1. vec.independent B \<and> card B = CARD('n) \<Longrightarrow> is_basis B
 2. is_basis B \<Longrightarrow> vec.independent B \<and> card B = CARD('n)
[PROOF STEP]
from \<open>card B = CARD('n)\<close>
[PROOF STATE]
proof (chain)
picking this:
card B = CARD('n)
[PROOF STEP]
have "card B = vec.dim (UNIV :: (('a^'n) set))"
[PROOF STATE]
proof (prove)
using this:
card B = CARD('n)

goal (1 subgoal):
 1. card B = vec.dim UNIV
[PROOF STEP]
unfolding vec_dim_card
[PROOF STATE]
proof (prove)
using this:
card B = CARD('n)

goal (1 subgoal):
 1. card B = CARD('n)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
card B = vec.dim UNIV

goal (2 subgoals):
 1. vec.independent B \<and> card B = CARD('n) \<Longrightarrow> is_basis B
 2. is_basis B \<Longrightarrow> vec.independent B \<and> card B = CARD('n)
[PROOF STEP]
with vec.card_eq_dim [of B UNIV] and \<open>finite B\<close> and \<open>vec.independent B\<close>
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>B \<subseteq> UNIV; card B = vec.dim UNIV; finite B\<rbrakk> \<Longrightarrow> vec.independent B = (UNIV \<subseteq> vec.span B)
finite B
vec.independent B
card B = vec.dim UNIV
[PROOF STEP]
have "vec.span B = UNIV"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>B \<subseteq> UNIV; card B = vec.dim UNIV; finite B\<rbrakk> \<Longrightarrow> vec.independent B = (UNIV \<subseteq> vec.span B)
finite B
vec.independent B
card B = vec.dim UNIV

goal (1 subgoal):
 1. vec.span B = UNIV
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
vec.span B = UNIV

goal (2 subgoals):
 1. vec.independent B \<and> card B = CARD('n) \<Longrightarrow> is_basis B
 2. is_basis B \<Longrightarrow> vec.independent B \<and> card B = CARD('n)
[PROOF STEP]
with \<open>vec.independent B\<close>
[PROOF STATE]
proof (chain)
picking this:
vec.independent B
vec.span B = UNIV
[PROOF STEP]
show "is_basis B"
[PROOF STATE]
proof (prove)
using this:
vec.independent B
vec.span B = UNIV

goal (1 subgoal):
 1. is_basis B
[PROOF STEP]
unfolding is_basis_def
[PROOF STATE]
proof (prove)
using this:
vec.independent B
vec.span B = UNIV

goal (1 subgoal):
 1. vec.independent B \<and> vec.span B = UNIV
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
is_basis B

goal (1 subgoal):
 1. is_basis B \<Longrightarrow> vec.independent B \<and> card B = CARD('n)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. is_basis B \<Longrightarrow> vec.independent B \<and> card B = CARD('n)
[PROOF STEP]
assume "is_basis B"
[PROOF STATE]
proof (state)
this:
is_basis B

goal (1 subgoal):
 1. is_basis B \<Longrightarrow> vec.independent B \<and> card B = CARD('n)
[PROOF STEP]
hence "vec.independent B"
[PROOF STATE]
proof (prove)
using this:
is_basis B

goal (1 subgoal):
 1. vec.independent B
[PROOF STEP]
unfolding is_basis_def
[PROOF STATE]
proof (prove)
using this:
vec.independent B \<and> vec.span B = UNIV

goal (1 subgoal):
 1. vec.independent B
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
vec.independent B

goal (1 subgoal):
 1. is_basis B \<Longrightarrow> vec.independent B \<and> card B = CARD('n)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
vec.independent B

goal (1 subgoal):
 1. is_basis B \<Longrightarrow> vec.independent B \<and> card B = CARD('n)
[PROOF STEP]
have "card B = CARD('n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card B = CARD('n)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card B = CARD('n)
[PROOF STEP]
have "B \<subseteq> UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B \<subseteq> UNIV
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
B \<subseteq> UNIV

goal (1 subgoal):
 1. card B = CARD('n)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
B \<subseteq> UNIV

goal (1 subgoal):
 1. card B = CARD('n)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
B \<subseteq> UNIV

goal (1 subgoal):
 1. card B = CARD('n)
[PROOF STEP]
from \<open>is_basis B\<close>
[PROOF STATE]
proof (chain)
picking this:
is_basis B
[PROOF STEP]
have "UNIV \<subseteq> vec.span B" and "vec.independent B"
[PROOF STATE]
proof (prove)
using this:
is_basis B

goal (1 subgoal):
 1. UNIV \<subseteq> vec.span B &&& vec.independent B
[PROOF STEP]
unfolding is_basis_def
[PROOF STATE]
proof (prove)
using this:
vec.independent B \<and> vec.span B = UNIV

goal (1 subgoal):
 1. UNIV \<subseteq> vec.span B &&& vec.independent B
[PROOF STEP]
by simp+
[PROOF STATE]
proof (state)
this:
UNIV \<subseteq> vec.span B
vec.independent B

goal (1 subgoal):
 1. card B = CARD('n)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
UNIV \<subseteq> vec.span B
vec.independent B

goal (1 subgoal):
 1. card B = CARD('n)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
B \<subseteq> UNIV
UNIV \<subseteq> vec.span B
vec.independent B
[PROOF STEP]
have "card B = vec.dim (UNIV::((real^'n) set))"
[PROOF STATE]
proof (prove)
using this:
B \<subseteq> UNIV
UNIV \<subseteq> vec.span B
vec.independent B

goal (1 subgoal):
 1. card B = vec.dim UNIV
[PROOF STEP]
using vec.basis_card_eq_dim [of B UNIV]
[PROOF STATE]
proof (prove)
using this:
B \<subseteq> UNIV
UNIV \<subseteq> vec.span B
vec.independent B
\<lbrakk>B \<subseteq> UNIV; UNIV \<subseteq> vec.span B; vec.independent B\<rbrakk> \<Longrightarrow> card B = vec.dim UNIV

goal (1 subgoal):
 1. card B = vec.dim UNIV
[PROOF STEP]
unfolding vec_dim_card
[PROOF STATE]
proof (prove)
using this:
B \<subseteq> UNIV
UNIV \<subseteq> vec.span B
vec.independent B
\<lbrakk>B \<subseteq> UNIV; UNIV \<subseteq> vec.span B; vec.independent B\<rbrakk> \<Longrightarrow> card B = CARD('n)

goal (1 subgoal):
 1. card B = CARD('n)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card B = vec.dim UNIV

goal (1 subgoal):
 1. card B = CARD('n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
card B = vec.dim UNIV
[PROOF STEP]
show "card B = CARD('n)"
[PROOF STATE]
proof (prove)
using this:
card B = vec.dim UNIV

goal (1 subgoal):
 1. card B = CARD('n)
[PROOF STEP]
by (metis vec_dim_card)
[PROOF STATE]
proof (state)
this:
card B = CARD('n)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
card B = CARD('n)

goal (1 subgoal):
 1. is_basis B \<Longrightarrow> vec.independent B \<and> card B = CARD('n)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
vec.independent B
card B = CARD('n)
[PROOF STEP]
show "vec.independent B \<and> card B = CARD('n)"
[PROOF STATE]
proof (prove)
using this:
vec.independent B
card B = CARD('n)

goal (1 subgoal):
 1. vec.independent B \<and> card B = CARD('n)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
vec.independent B \<and> card B = CARD('n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma extract_divide_middle:"(a::_::{field}) / (x * b) = inverse x * (a / b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a / (x * b) = inverse x * (a / b)
[PROOF STEP]
by (simp add: divide_inverse algebra_simps)


[STATEMENT]
lemma (in prob_space) sum_indep_random_variable_lborel:
  assumes ind: "indep_var borel X borel Y"
  assumes [simp, measurable]: "random_variable lborel X"
  assumes [simp, measurable]:"random_variable lborel Y"
  shows "distr M lborel (\<lambda>x. X x + Y x) = convolution (distr M lborel X)  (distr M lborel Y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distr M lborel (\<lambda>x. X x + Y x) = (distr M lborel X \<star> distr M lborel Y)
[PROOF STEP]
using ind
[PROOF STATE]
proof (prove)
using this:
indep_var borel X borel Y

goal (1 subgoal):
 1. distr M lborel (\<lambda>x. X x + Y x) = (distr M lborel X \<star> distr M lborel Y)
[PROOF STEP]
unfolding indep_var_distribution_eq convolution_def
[PROOF STATE]
proof (prove)
using this:
random_variable borel X \<and> random_variable borel Y \<and> distr M borel X \<Otimes>\<^sub>M distr M borel Y = distr M (borel \<Otimes>\<^sub>M borel) (\<lambda>x. (X x, Y x))

goal (1 subgoal):
 1. distr M lborel (\<lambda>x. X x + Y x) = distr (distr M lborel X \<Otimes>\<^sub>M distr M lborel Y) borel (\<lambda>(x, y). x + y)
[PROOF STEP]
by (auto simp: distr_distr o_def intro!: arg_cong[where f = "distr M borel"] cong: distr_cong)


[STATEMENT]
lemma (in wf_digraph) strongly_con_imp_sp_finite:
  "\<lbrakk> u \<in> verts G; v \<in> verts G; strongly_connected G \<rbrakk> \<Longrightarrow> \<mu> w u v < \<infinity>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>u \<in> verts G; v \<in> verts G; strongly_connected G\<rbrakk> \<Longrightarrow> \<mu> w u v < \<infinity>
[PROOF STEP]
unfolding strongly_connected_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>u \<in> verts G; v \<in> verts G; verts G \<noteq> {} \<and> (\<forall>u\<in>verts G. \<forall>v\<in>verts G. u \<rightarrow>\<^sup>* v)\<rbrakk> \<Longrightarrow> \<mu> w u v < \<infinity>
[PROOF STEP]
using \<mu>_reach_conv
[PROOF STATE]
proof (prove)
using this:
(\<mu> ?f ?u ?v < \<infinity>) = (?u \<rightarrow>\<^sup>* ?v)

goal (1 subgoal):
 1. \<lbrakk>u \<in> verts G; v \<in> verts G; verts G \<noteq> {} \<and> (\<forall>u\<in>verts G. \<forall>v\<in>verts G. u \<rightarrow>\<^sup>* v)\<rbrakk> \<Longrightarrow> \<mu> w u v < \<infinity>
[PROOF STEP]
by auto