[STATEMENT]
lemma ffact_monomial:
  "ffact n a = (\<Sum>k = 0..n. (- 1) ^ (n - k) * of_nat (stirling n k) * a ^ k)"
    for a :: "'a :: comm_ring_1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ffact n a = (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k)
[PROOF STEP]
proof (induct n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ffact 0 a = (\<Sum>k = 0..0. (- (1::'a)) ^ (0 - k) * of_nat (stirling 0 k) * a ^ k)
 2. \<And>n. ffact n a = (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k) \<Longrightarrow> ffact (Suc n) a = (\<Sum>k = 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. ffact 0 a = (\<Sum>k = 0..0. (- (1::'a)) ^ (0 - k) * of_nat (stirling 0 k) * a ^ k)
 2. \<And>n. ffact n a = (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k) \<Longrightarrow> ffact (Suc n) a = (\<Sum>k = 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ffact 0 a = (\<Sum>k = 0..0. (- (1::'a)) ^ (0 - k) * of_nat (stirling 0 k) * a ^ k)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
ffact 0 a = (\<Sum>k = 0..0. (- (1::'a)) ^ (0 - k) * of_nat (stirling 0 k) * a ^ k)

goal (1 subgoal):
 1. \<And>n. ffact n a = (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k) \<Longrightarrow> ffact (Suc n) a = (\<Sum>k = 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. ffact n a = (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k) \<Longrightarrow> ffact (Suc n) a = (\<Sum>k = 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
ffact n a = (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k)

goal (1 subgoal):
 1. \<And>n. ffact n a = (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k) \<Longrightarrow> ffact (Suc n) a = (\<Sum>k = 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
ffact n a = (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k)
[PROOF STEP]
have "ffact (Suc n) a = (a - of_nat n) * (\<Sum>k = 0..n. (- 1) ^ (n - k) * of_nat (stirling n k) * a ^ k)"
[PROOF STATE]
proof (prove)
using this:
ffact n a = (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k)

goal (1 subgoal):
 1. ffact (Suc n) a = (a - of_nat n) * (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k)
[PROOF STEP]
by (simp add: ffact_Suc_rev)
[PROOF STATE]
proof (state)
this:
ffact (Suc n) a = (a - of_nat n) * (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k)

goal (1 subgoal):
 1. \<And>n. ffact n a = (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k) \<Longrightarrow> ffact (Suc n) a = (\<Sum>k = 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ffact (Suc n) a = (a - of_nat n) * (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k)

goal (1 subgoal):
 1. \<And>n. ffact n a = (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k) \<Longrightarrow> ffact (Suc n) a = (\<Sum>k = 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)
[PROOF STEP]
have "\<dots> = (\<Sum>k = 0..n. (- 1) ^ (n - k) * of_nat (stirling n k) * a ^ (Suc k)) +
    (\<Sum>k = 0..n. (- 1) * (- 1) ^ (n - k) * of_nat (n * (stirling n k)) * a ^ k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a - of_nat n) * (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. - (1::'a) * (- (1::'a)) ^ (n - k) * of_nat (n * stirling n k) * a ^ k)
[PROOF STEP]
by (simp only: diff_conv_add_uminus distrib_right) (simp add: sum_distrib_left field_simps)
[PROOF STATE]
proof (state)
this:
(a - of_nat n) * (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. - (1::'a) * (- (1::'a)) ^ (n - k) * of_nat (n * stirling n k) * a ^ k)

goal (1 subgoal):
 1. \<And>n. ffact n a = (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k) \<Longrightarrow> ffact (Suc n) a = (\<Sum>k = 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(a - of_nat n) * (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. - (1::'a) * (- (1::'a)) ^ (n - k) * of_nat (n * stirling n k) * a ^ k)

goal (1 subgoal):
 1. \<And>n. ffact n a = (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k) \<Longrightarrow> ffact (Suc n) a = (\<Sum>k = 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)
[PROOF STEP]
have "\<dots> = (\<Sum>k = 0..n. (- 1) ^ (Suc n - Suc k) * of_nat (stirling n k) * a ^ Suc k) +
  (\<Sum>k = 0..n. (- 1) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k)) * a ^ Suc k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. - (1::'a) * (- (1::'a)) ^ (n - k) * of_nat (n * stirling n k) * a ^ k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k)) * a ^ Suc k)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. - (1::'a) * (- (1::'a)) ^ (n - k) * of_nat (n * stirling n k) * a ^ k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k)) * a ^ Suc k)
[PROOF STEP]
have "(\<Sum>k = 0..n. (- 1) * (- 1) ^ (n - k) * of_nat (n * stirling n k) * a ^ k) =
      (\<Sum>k = 0..n. (- 1) ^ (Suc n - k) * of_nat (n * stirling n k) * a ^ k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k = 0..n. - (1::'a) * (- (1::'a)) ^ (n - k) * of_nat (n * stirling n k) * a ^ k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - k) * of_nat (n * stirling n k) * a ^ k)
[PROOF STEP]
by (simp add: Suc_diff_le)
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 0..n. - (1::'a) * (- (1::'a)) ^ (n - k) * of_nat (n * stirling n k) * a ^ k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - k) * of_nat (n * stirling n k) * a ^ k)

goal (1 subgoal):
 1. (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. - (1::'a) * (- (1::'a)) ^ (n - k) * of_nat (n * stirling n k) * a ^ k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k)) * a ^ Suc k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 0..n. - (1::'a) * (- (1::'a)) ^ (n - k) * of_nat (n * stirling n k) * a ^ k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - k) * of_nat (n * stirling n k) * a ^ k)

goal (1 subgoal):
 1. (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. - (1::'a) * (- (1::'a)) ^ (n - k) * of_nat (n * stirling n k) * a ^ k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k)) * a ^ Suc k)
[PROOF STEP]
have "\<dots> = (\<Sum>k = Suc 0..Suc n. (- 1) ^ (Suc n - k) * of_nat (n * stirling n k) * a ^ k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - k) * of_nat (n * stirling n k) * a ^ k) = (\<Sum>k = Suc 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (n * stirling n k) * a ^ k)
[PROOF STEP]
by (simp add: sum.atLeast_Suc_atMost) (cases n; simp)
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - k) * of_nat (n * stirling n k) * a ^ k) = (\<Sum>k = Suc 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (n * stirling n k) * a ^ k)

goal (1 subgoal):
 1. (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. - (1::'a) * (- (1::'a)) ^ (n - k) * of_nat (n * stirling n k) * a ^ k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k)) * a ^ Suc k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - k) * of_nat (n * stirling n k) * a ^ k) = (\<Sum>k = Suc 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (n * stirling n k) * a ^ k)

goal (1 subgoal):
 1. (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. - (1::'a) * (- (1::'a)) ^ (n - k) * of_nat (n * stirling n k) * a ^ k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k)) * a ^ Suc k)
[PROOF STEP]
have "\<dots> = (\<Sum>k = 0..n. (- 1) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k)) * a ^ Suc k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k = Suc 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (n * stirling n k) * a ^ k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k)) * a ^ Suc k)
[PROOF STEP]
by (simp only: sum.shift_bounds_cl_Suc_ivl)
[PROOF STATE]
proof (state)
this:
(\<Sum>k = Suc 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (n * stirling n k) * a ^ k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k)) * a ^ Suc k)

goal (1 subgoal):
 1. (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. - (1::'a) * (- (1::'a)) ^ (n - k) * of_nat (n * stirling n k) * a ^ k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k)) * a ^ Suc k)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>k = 0..n. - (1::'a) * (- (1::'a)) ^ (n - k) * of_nat (n * stirling n k) * a ^ k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k)) * a ^ Suc k)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>k = 0..n. - (1::'a) * (- (1::'a)) ^ (n - k) * of_nat (n * stirling n k) * a ^ k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k)) * a ^ Suc k)

goal (1 subgoal):
 1. (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. - (1::'a) * (- (1::'a)) ^ (n - k) * of_nat (n * stirling n k) * a ^ k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k)) * a ^ Suc k)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. - (1::'a) * (- (1::'a)) ^ (n - k) * of_nat (n * stirling n k) * a ^ k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k)) * a ^ Suc k)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. - (1::'a) * (- (1::'a)) ^ (n - k) * of_nat (n * stirling n k) * a ^ k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k)) * a ^ Suc k)

goal (1 subgoal):
 1. \<And>n. ffact n a = (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k) \<Longrightarrow> ffact (Suc n) a = (\<Sum>k = 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. - (1::'a) * (- (1::'a)) ^ (n - k) * of_nat (n * stirling n k) * a ^ k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k)) * a ^ Suc k)

goal (1 subgoal):
 1. \<And>n. ffact n a = (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k) \<Longrightarrow> ffact (Suc n) a = (\<Sum>k = 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)
[PROOF STEP]
have "\<dots> = (\<Sum>k = 0..n. (- 1) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k) + stirling n k) * a ^ Suc k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k)) * a ^ Suc k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k) + stirling n k) * a ^ Suc k)
[PROOF STEP]
by (simp add: sum.distrib algebra_simps)
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k)) * a ^ Suc k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k) + stirling n k) * a ^ Suc k)

goal (1 subgoal):
 1. \<And>n. ffact n a = (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k) \<Longrightarrow> ffact (Suc n) a = (\<Sum>k = 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (stirling n k) * a ^ Suc k) + (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k)) * a ^ Suc k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k) + stirling n k) * a ^ Suc k)

goal (1 subgoal):
 1. \<And>n. ffact n a = (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k) \<Longrightarrow> ffact (Suc n) a = (\<Sum>k = 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)
[PROOF STEP]
have "\<dots> = (\<Sum>k = 0..n. (- 1) ^ (Suc n - Suc k) * of_nat (stirling (Suc n) (Suc k)) * a ^ Suc k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k) + stirling n k) * a ^ Suc k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (stirling (Suc n) (Suc k)) * a ^ Suc k)
[PROOF STEP]
by (simp only: stirling.simps)
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k) + stirling n k) * a ^ Suc k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (stirling (Suc n) (Suc k)) * a ^ Suc k)

goal (1 subgoal):
 1. \<And>n. ffact n a = (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k) \<Longrightarrow> ffact (Suc n) a = (\<Sum>k = 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (n * stirling n (Suc k) + stirling n k) * a ^ Suc k) = (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (stirling (Suc n) (Suc k)) * a ^ Suc k)

goal (1 subgoal):
 1. \<And>n. ffact n a = (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k) \<Longrightarrow> ffact (Suc n) a = (\<Sum>k = 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)
[PROOF STEP]
have "\<dots> = (\<Sum>k = Suc 0..Suc n. (- 1) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (stirling (Suc n) (Suc k)) * a ^ Suc k) = (\<Sum>k = Suc 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)
[PROOF STEP]
by (simp only: sum.shift_bounds_cl_Suc_ivl)
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (stirling (Suc n) (Suc k)) * a ^ Suc k) = (\<Sum>k = Suc 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)

goal (1 subgoal):
 1. \<And>n. ffact n a = (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k) \<Longrightarrow> ffact (Suc n) a = (\<Sum>k = 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 0..n. (- (1::'a)) ^ (Suc n - Suc k) * of_nat (stirling (Suc n) (Suc k)) * a ^ Suc k) = (\<Sum>k = Suc 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)

goal (1 subgoal):
 1. \<And>n. ffact n a = (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k) \<Longrightarrow> ffact (Suc n) a = (\<Sum>k = 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)
[PROOF STEP]
have "\<dots> = (\<Sum>k = 0..Suc n. (- 1) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k = Suc 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k) = (\<Sum>k = 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)
[PROOF STEP]
by (simp add: sum.atLeast_Suc_atMost)
[PROOF STATE]
proof (state)
this:
(\<Sum>k = Suc 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k) = (\<Sum>k = 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)

goal (1 subgoal):
 1. \<And>n. ffact n a = (\<Sum>k = 0..n. (- (1::'a)) ^ (n - k) * of_nat (stirling n k) * a ^ k) \<Longrightarrow> ffact (Suc n) a = (\<Sum>k = 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
ffact (Suc n) a = (\<Sum>k = 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
ffact (Suc n) a = (\<Sum>k = 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)

goal (1 subgoal):
 1. ffact (Suc n) a = (\<Sum>k = 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
ffact (Suc n) a = (\<Sum>k = 0..Suc n. (- (1::'a)) ^ (Suc n - k) * of_nat (stirling (Suc n) k) * a ^ k)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma cos_of_quarter_pi:
  fixes x:: real
  assumes "x = pi/2"
  shows "cos (x/2) = (sqrt 2)/2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos (x / 2) = sqrt 2 / 2
[PROOF STEP]
by (auto simp add: assms cos_45)


[STATEMENT]
lemma sin_cos_csqrt:
  assumes "0 < sin(Re z)  \<or>  sin(Re z) = 0 \<and> 0 \<le> Im z * cos(Re z)"
    shows "sin z = csqrt(1 - (cos z)\<^sup>2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin z = csqrt (1 - (cos z)\<^sup>2)
[PROOF STEP]
proof (rule csqrt_unique [THEN sym])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (sin z)\<^sup>2 = 1 - (cos z)\<^sup>2
 2. 0 < Re (sin z) \<or> Re (sin z) = 0 \<and> 0 \<le> Im (sin z)
[PROOF STEP]
show "(sin z)\<^sup>2 = 1 - (cos z)\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (sin z)\<^sup>2 = 1 - (cos z)\<^sup>2
[PROOF STEP]
by (simp add: sin_squared_eq)
[PROOF STATE]
proof (state)
this:
(sin z)\<^sup>2 = 1 - (cos z)\<^sup>2

goal (1 subgoal):
 1. 0 < Re (sin z) \<or> Re (sin z) = 0 \<and> 0 \<le> Im (sin z)
[PROOF STEP]
qed (use assms in \<open>auto simp: Re_sin Im_sin add_pos_pos mult_le_0_iff zero_le_mult_iff\<close>)


[STATEMENT]
lemma interchange_rows_transpose:
  shows "interchange_rows (transpose A) a b = transpose (interchange_columns A a b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. interchange_rows (Finite_Cartesian_Product.transpose A) a b = Finite_Cartesian_Product.transpose (interchange_columns A a b)
[PROOF STEP]
unfolding interchange_rows_def interchange_columns_def transpose_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i j. if i = a then (\<chi>i j. A $ j $ i) $ b $ j else if i = b then (\<chi>i j. A $ j $ i) $ a $ j else (\<chi>i j. A $ j $ i) $ i $ j) = (\<chi>i j. (\<chi>i j. if j = a then A $ i $ b else if j = b then A $ i $ a else A $ i $ j) $ j $ i)
[PROOF STEP]
by vector


[STATEMENT]
lemma length_filter_replace2:
 "\<lbrakk> x \<in> set xs; P x \<rbrakk> \<Longrightarrow>
  length(filter P (replace x ys xs)) =
  length(filter P xs) + length(filter P ys) - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x \<in> set xs; P x\<rbrakk> \<Longrightarrow> |filter P (replace x ys xs)| = |filter P xs| + |filter P ys| - 1
[PROOF STEP]
apply(induct xs)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>x \<in> set []; P x\<rbrakk> \<Longrightarrow> |filter P (replace x ys [])| = |filter P []| + |filter P ys| - 1
 2. \<And>a xs. \<lbrakk>\<lbrakk>x \<in> set xs; P x\<rbrakk> \<Longrightarrow> |filter P (replace x ys xs)| = |filter P xs| + |filter P ys| - 1; x \<in> set (a # xs); P x\<rbrakk> \<Longrightarrow> |filter P (replace x ys (a # xs))| = |filter P (a # xs)| + |filter P ys| - 1
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a xs. \<lbrakk>\<lbrakk>x \<in> set xs; P x\<rbrakk> \<Longrightarrow> |filter P (replace x ys xs)| = |filter P xs| + |filter P ys| - 1; x \<in> set (a # xs); P x\<rbrakk> \<Longrightarrow> |filter P (replace x ys (a # xs))| = |filter P (a # xs)| + |filter P ys| - 1
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a xs. \<lbrakk>|filter P (replace x ys xs)| = |filter P xs| + |filter P ys| - Suc 0; P x; x \<in> set xs; P a; a \<noteq> x\<rbrakk> \<Longrightarrow> Suc (|filter P xs| + |filter P ys| - Suc 0) = |filter P xs| + |filter P ys|
[PROOF STEP]
apply(drule split_list)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a xs. \<lbrakk>|filter P (replace x ys xs)| = |filter P xs| + |filter P ys| - Suc 0; P x; P a; a \<noteq> x; \<exists>ys zs. xs = ys @ x # zs\<rbrakk> \<Longrightarrow> Suc (|filter P xs| + |filter P ys| - Suc 0) = |filter P xs| + |filter P ys|
[PROOF STEP]
apply clarsimp
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma finite_mids: "finite (mids xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (mids xs)
[PROOF STEP]
by (induction xs) (simp add: mids_def, simp add: mids_cons finite_fronts)


[STATEMENT]
lemma inverse_eq1:
  assumes "eventually (\<lambda>x. g x \<noteq> 0) F"
  shows   "f \<in> L F (\<lambda>x. inverse (g x)) \<longleftrightarrow> (\<lambda>x. f x * g x) \<in> L F (\<lambda>_. 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f \<in> L F (\<lambda>x. inverse (g x))) = ((\<lambda>x. f x * g x) \<in> L F (\<lambda>_. 1::'b))
[PROOF STEP]
using divide_eq1[of g F f "\<lambda>_. 1"]
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in F. g x \<noteq> (0::'b) \<Longrightarrow> (f \<in> L F (\<lambda>x. (1::'b) / g x)) = ((\<lambda>x. f x * g x) \<in> L F (\<lambda>_. 1::'b))

goal (1 subgoal):
 1. (f \<in> L F (\<lambda>x. inverse (g x))) = ((\<lambda>x. f x * g x) \<in> L F (\<lambda>_. 1::'b))
[PROOF STEP]
by (simp add: divide_inverse assms)


[STATEMENT]
lemma path_image_circlepath_minus: "path_image (circlepath z (-r)) = path_image (circlepath z r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. path_image (circlepath z (- r)) = path_image (circlepath z r)
[PROOF STEP]
using path_image_circlepath_minus_subset
[PROOF STATE]
proof (prove)
using this:
path_image (circlepath ?z (- ?r)) \<subseteq> path_image (circlepath ?z ?r)

goal (1 subgoal):
 1. path_image (circlepath z (- r)) = path_image (circlepath z r)
[PROOF STEP]
by fastforce


[STATEMENT]
lemma finite_card_eq_imp_bij_betw:
  assumes "finite A"
    and "card (f ` A) = card A"
  shows "bij_betw f A (f ` A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij_betw f A (f ` A)
[PROOF STEP]
using \<open>card (f ` A) = card A\<close>
[PROOF STATE]
proof (prove)
using this:
card (f ` A) = card A

goal (1 subgoal):
 1. bij_betw f A (f ` A)
[PROOF STEP]
unfolding inj_on_iff_eq_card [OF \<open>finite A\<close>, symmetric]
[PROOF STATE]
proof (prove)
using this:
inj_on f A

goal (1 subgoal):
 1. bij_betw f A (f ` A)
[PROOF STEP]
by (rule inj_on_imp_bij_betw)


[STATEMENT]
lemma poly_of_vec_add:
  assumes "dim_vec a = dim_vec b"
  shows "poly_of_vec (a + b) = poly_of_vec a + poly_of_vec b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_of_vec (a + b) = poly_of_vec a + poly_of_vec b
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
dim_vec a = dim_vec b

goal (1 subgoal):
 1. poly_of_vec (a + b) = poly_of_vec a + poly_of_vec b
[PROOF STEP]
by (auto simp add: poly_eq_iff coeff_poly_of_vec)


[STATEMENT]
lemma "((\<forall>s t. (\<forall>z. P' z s \<longrightarrow> Q' z t) \<longrightarrow> (\<forall>z. P z s \<longrightarrow> Q z t)) \<and>
            (\<forall>s. (\<exists>z. P z s) \<longrightarrow> (\<exists>z. P' z s)))
        = (\<forall>z s. P z s \<longrightarrow> (\<forall>t.\<exists>z'. P' z' s \<and> (Q' z' t \<longrightarrow> Q z t)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<forall>s t. (\<forall>z. P' z s \<longrightarrow> Q' z t) \<longrightarrow> (\<forall>z. P z s \<longrightarrow> Q z t)) \<and> (\<forall>s. (\<exists>z. P z s) \<longrightarrow> (\<exists>z. P' z s))) = (\<forall>z s. P z s \<longrightarrow> (\<forall>t. \<exists>z'. P' z' s \<and> (Q' z' t \<longrightarrow> Q z t)))
[PROOF STEP]
by blast


[STATEMENT]
lemma isLub_dual_isGlb: "isLub S cl = isGlb S (dual cl)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. isLub S cl = isGlb S (dual cl)
[PROOF STEP]
by (simp add: isLub_def isGlb_def dual_def converse_unfold)


[STATEMENT]
lemma has_vderiv_on_sq_mtx_affine:
  fixes t\<^sub>0::real and A :: "('a::finite) sq_mtx"
  defines "lSol c t \<equiv> exp ((c * (t - t\<^sub>0)) *\<^sub>R A)"
  shows "D (\<lambda>t. lSol 1 t *\<^sub>V s + lSol 1 t *\<^sub>V (\<integral>\<^sub>t\<^sub>0\<^sup>t (lSol (-1) \<tau> *\<^sub>V B) \<partial>\<tau>)) =
  (\<lambda>t. A *\<^sub>V (lSol 1 t *\<^sub>V s + lSol 1 t *\<^sub>V (\<integral>\<^sub>t\<^sub>0\<^sup>t (lSol (-1) \<tau> *\<^sub>V B) \<partial>\<tau>)) + B) on {t\<^sub>0--t}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1.  D (\<lambda>t. lSol 1 t *\<^sub>V s + lSol 1 t *\<^sub>V (\<integral>\<^sub>t\<^sub>0\<^sup>t lSol (- 1) \<tau> *\<^sub>V B\<partial>\<tau>)) = (\<lambda>t. A *\<^sub>V (lSol 1 t *\<^sub>V s + lSol 1 t *\<^sub>V (\<integral>\<^sub>t\<^sub>0\<^sup>t lSol (- 1) \<tau> *\<^sub>V B\<partial>\<tau>)) + B) on {t\<^sub>0--t}
[PROOF STEP]
unfolding assms
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1.  D (\<lambda>t. exp ((1 * (t - t\<^sub>0)) *\<^sub>R A) *\<^sub>V s + exp ((1 * (t - t\<^sub>0)) *\<^sub>R A) *\<^sub>V (\<integral>\<^sub>t\<^sub>0\<^sup>t exp ((- 1 * (\<tau> - t\<^sub>0)) *\<^sub>R A) *\<^sub>V B\<partial>\<tau>)) = (\<lambda>t. A *\<^sub>V (exp ((1 * (t - t\<^sub>0)) *\<^sub>R A) *\<^sub>V s + exp ((1 * (t - t\<^sub>0)) *\<^sub>R A) *\<^sub>V (\<integral>\<^sub>t\<^sub>0\<^sup>t exp ((- 1 * (\<tau> - t\<^sub>0)) *\<^sub>R A) *\<^sub>V B\<partial>\<tau>)) + B) on {t\<^sub>0--t}
[PROOF STEP]
apply(simp only: mult.left_neutral mult_minus1)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1.  D (\<lambda>t. exp ((t - t\<^sub>0) *\<^sub>R A) *\<^sub>V s + exp ((t - t\<^sub>0) *\<^sub>R A) *\<^sub>V (\<integral>\<^sub>t\<^sub>0\<^sup>t exp (- (\<tau> - t\<^sub>0) *\<^sub>R A) *\<^sub>V B\<partial>\<tau>)) = (\<lambda>t. A *\<^sub>V (exp ((t - t\<^sub>0) *\<^sub>R A) *\<^sub>V s + exp ((t - t\<^sub>0) *\<^sub>R A) *\<^sub>V (\<integral>\<^sub>t\<^sub>0\<^sup>t exp (- (\<tau> - t\<^sub>0) *\<^sub>R A) *\<^sub>V B\<partial>\<tau>)) + B) on {t\<^sub>0--t}
[PROOF STEP]
apply(rule poly_derivatives, (force)?, (force)?, (force)?, (force)?)+
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>ta. ta \<in> {t\<^sub>0--t} \<Longrightarrow> (exp ((ta - t\<^sub>0) *\<^sub>R A) * A) *\<^sub>V s + (exp ((ta - t\<^sub>0) *\<^sub>R A) *\<^sub>V (exp ((t\<^sub>0 - ta) *\<^sub>R A) *\<^sub>V B) + (exp ((ta - t\<^sub>0) *\<^sub>R A) * A) *\<^sub>V (\<integral>\<^sub>t\<^sub>0\<^sup>ta exp ((t\<^sub>0 - \<tau>) *\<^sub>R A) *\<^sub>V B\<partial>\<tau>)) = A *\<^sub>V (exp ((ta - t\<^sub>0) *\<^sub>R A) *\<^sub>V s + exp ((ta - t\<^sub>0) *\<^sub>R A) *\<^sub>V (\<integral>\<^sub>t\<^sub>0\<^sup>ta exp (- (\<tau> - t\<^sub>0) *\<^sub>R A) *\<^sub>V B\<partial>\<tau>)) + B
[PROOF STEP]
by (simp add: mtx_vec_mult_add_rdistl sq_mtx_times_vec_assoc[symmetric]
      exp_minus_inverse exp_times_scaleR_commute mult_exp_exp  scale_left_distrib[symmetric])


[STATEMENT]
lemma compress_mod:
  assumes "x\<in>{\<lceil>q-(q/(2*2^d))\<rceil>..q-1}"
          "of_nat d < \<lceil>(log 2 q)::real\<rceil>"
  shows "compress d x = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. compress d x = 0
[PROOF STEP]
unfolding compress_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. round (real_of_int (2 ^ d * x) / real_of_int q) mod 2 ^ d = 0
[PROOF STEP]
using compress_2d[OF assms]
[PROOF STATE]
proof (prove)
using this:
round (real_of_int (2 ^ d * x) / real_of_int q) = 2 ^ d

goal (1 subgoal):
 1. round (real_of_int (2 ^ d * x) / real_of_int q) mod 2 ^ d = 0
[PROOF STEP]
by simp


[STATEMENT]
lemma trigonometric_set_mul_absolutely_integrable:
  assumes "f absolutely_integrable_on {-pi..pi}"
  shows "(\<lambda>x. trigonometric_set n x * f x) absolutely_integrable_on {-pi..pi}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. trigonometric_set n x * f x) absolutely_integrable_on {- pi..pi}
[PROOF STEP]
proof (rule absolutely_integrable_bounded_measurable_product_real)
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. trigonometric_set n \<in> borel_measurable (lebesgue_on {- pi..pi})
 2. {- pi..pi} \<in> sets lebesgue
 3. bounded (trigonometric_set n ` {- pi..pi})
 4. f absolutely_integrable_on {- pi..pi}
[PROOF STEP]
show "trigonometric_set n \<in> borel_measurable (lebesgue_on {-pi..pi})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trigonometric_set n \<in> borel_measurable (lebesgue_on {- pi..pi})
[PROOF STEP]
using square_integrable_def square_integrable_trigonometric_set
[PROOF STATE]
proof (prove)
using this:
?f square_integrable ?S \<equiv> ?S \<in> sets lebesgue \<and> ?f \<in> borel_measurable (lebesgue_on ?S) \<and> integrable (lebesgue_on ?S) (\<lambda>x. (?f x)\<^sup>2)
trigonometric_set ?i square_integrable {- pi..pi}

goal (1 subgoal):
 1. trigonometric_set n \<in> borel_measurable (lebesgue_on {- pi..pi})
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
trigonometric_set n \<in> borel_measurable (lebesgue_on {- pi..pi})

goal (3 subgoals):
 1. {- pi..pi} \<in> sets lebesgue
 2. bounded (trigonometric_set n ` {- pi..pi})
 3. f absolutely_integrable_on {- pi..pi}
[PROOF STEP]
show "bounded (trigonometric_set n ` {-pi..pi})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bounded (trigonometric_set n ` {- pi..pi})
[PROOF STEP]
unfolding bounded_iff
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>a. \<forall>x\<in>trigonometric_set n ` {- pi..pi}. norm x \<le> a
[PROOF STEP]
using pi_gt3 sqrt_pi_ge1
[PROOF STATE]
proof (prove)
using this:
3 < pi
1 \<le> sqrt pi

goal (1 subgoal):
 1. \<exists>a. \<forall>x\<in>trigonometric_set n ` {- pi..pi}. norm x \<le> a
[PROOF STEP]
by (rule_tac x=1 in exI)
      (auto simp: trigonometric_set_def dist_real_def
        intro: order_trans [OF abs_sin_le_one] order_trans [OF abs_cos_le_one])
[PROOF STATE]
proof (state)
this:
bounded (trigonometric_set n ` {- pi..pi})

goal (2 subgoals):
 1. {- pi..pi} \<in> sets lebesgue
 2. f absolutely_integrable_on {- pi..pi}
[PROOF STEP]
qed (auto simp: assms)


[STATEMENT]
lemma unit_vec_of_right_length_is_state [simp]:
  assumes "i < 2^n"
  shows "unit_vec (2^n) i \<in> {v| n v::complex vec. dim_vec v = 2^n \<and> \<parallel>v\<parallel> = 1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unit_vec (2 ^ n) i \<in> {uu_. \<exists>n v. uu_ = v \<and> dim_vec v = 2 ^ n \<and> \<parallel>v\<parallel> = 1}
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. unit_vec (2 ^ n) i \<in> {uu_. \<exists>n v. uu_ = v \<and> dim_vec v = 2 ^ n \<and> \<parallel>v\<parallel> = 1}
[PROOF STEP]
have "dim_vec (unit_vec (2^n) i) = 2^n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec (unit_vec (2 ^ n) i) = 2 ^ n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
dim_vec (unit_vec (2 ^ n) i) = 2 ^ n

goal (1 subgoal):
 1. unit_vec (2 ^ n) i \<in> {uu_. \<exists>n v. uu_ = v \<and> dim_vec v = 2 ^ n \<and> \<parallel>v\<parallel> = 1}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
dim_vec (unit_vec (2 ^ n) i) = 2 ^ n

goal (1 subgoal):
 1. unit_vec (2 ^ n) i \<in> {uu_. \<exists>n v. uu_ = v \<and> dim_vec v = 2 ^ n \<and> \<parallel>v\<parallel> = 1}
[PROOF STEP]
have "\<parallel>unit_vec (2^n) i\<parallel> = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>unit_vec (2 ^ n) i\<parallel> = 1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
i < 2 ^ n

goal (1 subgoal):
 1. \<parallel>unit_vec (2 ^ n) i\<parallel> = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<parallel>unit_vec (2 ^ n) i\<parallel> = 1

goal (1 subgoal):
 1. unit_vec (2 ^ n) i \<in> {uu_. \<exists>n v. uu_ = v \<and> dim_vec v = 2 ^ n \<and> \<parallel>v\<parallel> = 1}
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
dim_vec (unit_vec (2 ^ n) i) = 2 ^ n
\<parallel>unit_vec (2 ^ n) i\<parallel> = 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
dim_vec (unit_vec (2 ^ n) i) = 2 ^ n
\<parallel>unit_vec (2 ^ n) i\<parallel> = 1

goal (1 subgoal):
 1. unit_vec (2 ^ n) i \<in> {uu_. \<exists>n v. uu_ = v \<and> dim_vec v = 2 ^ n \<and> \<parallel>v\<parallel> = 1}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
unit_vec (2 ^ n) i \<in> {uu_. \<exists>n v. uu_ = v \<and> dim_vec v = 2 ^ n \<and> \<parallel>v\<parallel> = 1}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma column_Gram_Schmidt_column_k:
  fixes A::"'a::{real_inner}^'n::{mod_type}^'m::{mod_type}"
  shows "column k (Gram_Schmidt_column_k A (to_nat k)) =
  (column k A) - (\<Sum>x\<in>{column i A|i. i < k}. (x \<bullet> (column k A) / (x \<bullet> x)) *\<^sub>R x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. column k (Gram_Schmidt_column_k A (mod_type_class.to_nat k)) = column k A - (\<Sum>x\<in>{column i A |i. i < k}. (x \<bullet> column k A / (x \<bullet> x)) *\<^sub>R x)
[PROOF STEP]
unfolding Gram_Schmidt_column_k_def column_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i. (\<chi>a b. (if b = mod_type_class.from_nat (mod_type_class.to_nat k) then (\<chi>i. A $ i $ b) - proj_onto (\<chi>i. A $ i $ b) {\<chi>ia. A $ ia $ i |i. i < b} else \<chi>i. A $ i $ b) $ a) $ i $ k) = (\<chi>i. A $ i $ k) - (\<Sum>x\<in>{\<chi>ia. A $ ia $ i |i. i < k}. (x \<bullet> (\<chi>i. A $ i $ k) / (x \<bullet> x)) *\<^sub>R x)
[PROOF STEP]
unfolding from_nat_to_nat_id
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i. (\<chi>a b. (if b = k then (\<chi>i. A $ i $ b) - proj_onto (\<chi>i. A $ i $ b) {\<chi>ia. A $ ia $ i |i. i < b} else \<chi>i. A $ i $ b) $ a) $ i $ k) = (\<chi>i. A $ i $ k) - (\<Sum>x\<in>{\<chi>ia. A $ ia $ i |i. i < k}. (x \<bullet> (\<chi>i. A $ i $ k) / (x \<bullet> x)) *\<^sub>R x)
[PROOF STEP]
unfolding proj_onto_def proj_def[abs_def]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i. (\<chi>a b. (if b = k then (\<chi>i. A $ i $ b) - (\<Sum>u\<in>{\<chi>ia. A $ ia $ i |i. i < b}. ((\<chi>i. A $ i $ b) \<bullet> u / (u \<bullet> u)) *\<^sub>R u) else \<chi>i. A $ i $ b) $ a) $ i $ k) = (\<chi>i. A $ i $ k) - (\<Sum>x\<in>{\<chi>ia. A $ ia $ i |i. i < k}. (x \<bullet> (\<chi>i. A $ i $ k) / (x \<bullet> x)) *\<^sub>R x)
[PROOF STEP]
unfolding proj_onto_sum_rw
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i. (\<chi>a b. (if b = k then (\<chi>i. A $ i $ b) - (\<Sum>u\<in>{\<chi>ia. A $ ia $ i |i. i < b}. ((\<chi>i. A $ i $ b) \<bullet> u / (u \<bullet> u)) *\<^sub>R u) else \<chi>i. A $ i $ b) $ a) $ i $ k) = (\<chi>i. A $ i $ k) - (\<Sum>x\<in>{\<chi>ia. A $ ia $ i |i. i < k}. ((\<chi>i. A $ i $ k) \<bullet> x / (x \<bullet> x)) *\<^sub>R x)
[PROOF STEP]
by vector


[STATEMENT]
lemma binary_expression_gteq0:
  assumes "\<And>n. a n \<in> {0,1 :: nat}"
  shows "0 \<le> (\<Sum>n. real (a (n + k)) * (1 / 2) ^ Suc (n + k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> (\<Sum>n. real (a (n + k)) * (1 / 2) ^ Suc (n + k))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 0 \<le> (\<Sum>n. real (a (n + k)) * (1 / 2) ^ Suc (n + k))
[PROOF STEP]
have "(\<Sum>n. 0) \<le> (\<Sum>n. real (a (n + k)) * (1 / 2) ^ Suc (n + k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>n. 0) \<le> (\<Sum>n. real (a (n + k)) * (1 / 2) ^ Suc (n + k))
[PROOF STEP]
using binary_expression_summable[of a] summable_iff_shift[of "\<lambda>n. real (a n) * (1 / 2) ^ Suc n" k] suminf_le[of "\<lambda>n. 0" "\<lambda>n. real (a (n + k)) * (1 / 2) ^ Suc (n + k)"] assms
[PROOF STATE]
proof (prove)
using this:
(\<And>n. a n \<in> {0, 1}) \<Longrightarrow> summable (\<lambda>n. real (a n) * (1 / 2) ^ Suc n)
summable (\<lambda>n. real (a (n + k)) * (1 / 2) ^ Suc (n + k)) = summable (\<lambda>n. real (a n) * (1 / 2) ^ Suc n)
\<lbrakk>\<And>n. 0 \<le> real (a (n + k)) * (1 / 2) ^ Suc (n + k); summable (\<lambda>n. 0); summable (\<lambda>n. real (a (n + k)) * (1 / 2) ^ Suc (n + k))\<rbrakk> \<Longrightarrow> (\<Sum>n. 0) \<le> (\<Sum>n. real (a (n + k)) * (1 / 2) ^ Suc (n + k))
a ?n \<in> {0, 1}

goal (1 subgoal):
 1. (\<Sum>n. 0) \<le> (\<Sum>n. real (a (n + k)) * (1 / 2) ^ Suc (n + k))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>n. 0) \<le> (\<Sum>n. real (a (n + k)) * (1 / 2) ^ Suc (n + k))

goal (1 subgoal):
 1. 0 \<le> (\<Sum>n. real (a (n + k)) * (1 / 2) ^ Suc (n + k))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>n. 0) \<le> (\<Sum>n. real (a (n + k)) * (1 / 2) ^ Suc (n + k))

goal (1 subgoal):
 1. 0 \<le> (\<Sum>n. real (a (n + k)) * (1 / 2) ^ Suc (n + k))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 \<le> (\<Sum>n. real (a (n + k)) * (1 / 2) ^ Suc (n + k))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma coeff_Bernstein_sum:
  fixes b::"nat \<Rightarrow> real" and p::nat and c d::real
  defines "P \<equiv> (\<Sum>j = 0..p. (smult (b j) (Bernstein_Poly j p c d)))"
  assumes "i \<le> p" and "c \<noteq> d"
  shows "coeff ((reciprocal_poly p (P \<circ>\<^sub>p [:c, 1:]
      \<circ>\<^sub>p [:0, d-c:])) \<circ>\<^sub>p [:1, 1:]) (p - i) = (p choose i) * (b i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff (reciprocal_poly p (P \<circ>\<^sub>p [:c, 1:] \<circ>\<^sub>p [:0, d - c:]) \<circ>\<^sub>p [:1, 1:]) (p - i) = real (p choose i) * b i
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. coeff (reciprocal_poly p (P \<circ>\<^sub>p [:c, 1:] \<circ>\<^sub>p [:0, d - c:]) \<circ>\<^sub>p [:1, 1:]) (p - i) = real (p choose i) * b i
[PROOF STEP]
have h: "P \<circ>\<^sub>p [:c, 1:] \<circ>\<^sub>p [:0, d-c:]
      = (\<Sum>j = 0..p. (smult (b j) (Bernstein_Poly_01 j p)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P \<circ>\<^sub>p [:c, 1:] \<circ>\<^sub>p [:0, d - c:] = (\<Sum>j = 0..p. smult (b j) (Bernstein_Poly_01 j p))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
P \<equiv> \<Sum>j = 0..p. smult (b j) (Bernstein_Poly j p c d)
i \<le> p
c \<noteq> d

goal (1 subgoal):
 1. P \<circ>\<^sub>p [:c, 1:] \<circ>\<^sub>p [:0, d - c:] = (\<Sum>j = 0..p. smult (b j) (Bernstein_Poly_01 j p))
[PROOF STEP]
by (auto simp: P_def pcompose_sum pcompose_smult
          pcompose_add Bernstein_Poly_rescale_01)
[PROOF STATE]
proof (state)
this:
P \<circ>\<^sub>p [:c, 1:] \<circ>\<^sub>p [:0, d - c:] = (\<Sum>j = 0..p. smult (b j) (Bernstein_Poly_01 j p))

goal (1 subgoal):
 1. coeff (reciprocal_poly p (P \<circ>\<^sub>p [:c, 1:] \<circ>\<^sub>p [:0, d - c:]) \<circ>\<^sub>p [:1, 1:]) (p - i) = real (p choose i) * b i
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
P \<circ>\<^sub>p [:c, 1:] \<circ>\<^sub>p [:0, d - c:] = (\<Sum>j = 0..p. smult (b j) (Bernstein_Poly_01 j p))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
P \<circ>\<^sub>p [:c, 1:] \<circ>\<^sub>p [:0, d - c:] = (\<Sum>j = 0..p. smult (b j) (Bernstein_Poly_01 j p))

goal (1 subgoal):
 1. coeff (reciprocal_poly p (P \<circ>\<^sub>p [:c, 1:] \<circ>\<^sub>p [:0, d - c:]) \<circ>\<^sub>p [:1, 1:]) (p - i) = real (p choose i) * b i
[PROOF STEP]
using coeff_Bernstein_sum_01 assms
[PROOF STATE]
proof (prove)
using this:
P \<circ>\<^sub>p [:c, 1:] \<circ>\<^sub>p [:0, d - c:] = (\<Sum>j = 0..p. smult (b j) (Bernstein_Poly_01 j p))
?i \<le> ?p \<Longrightarrow> coeff (reciprocal_poly ?p (\<Sum>x = 0..?p. smult (?b x) (Bernstein_Poly_01 x ?p)) \<circ>\<^sub>p [:1, 1:]) (?p - ?i) = real (?p choose ?i) * ?b ?i
P \<equiv> \<Sum>j = 0..p. smult (b j) (Bernstein_Poly j p c d)
i \<le> p
c \<noteq> d

goal (1 subgoal):
 1. coeff (reciprocal_poly p (P \<circ>\<^sub>p [:c, 1:] \<circ>\<^sub>p [:0, d - c:]) \<circ>\<^sub>p [:1, 1:]) (p - i) = real (p choose i) * b i
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
coeff (reciprocal_poly p (P \<circ>\<^sub>p [:c, 1:] \<circ>\<^sub>p [:0, d - c:]) \<circ>\<^sub>p [:1, 1:]) (p - i) = real (p choose i) * b i

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma homeomorphic_spheres_gen:
    fixes a :: "'a::euclidean_space" and b :: "'b::euclidean_space"
  assumes "0 < r" "0 < s" "DIM('a::euclidean_space) = DIM('b::euclidean_space)"
  shows "(sphere a r homeomorphic sphere b s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sphere a r homeomorphic sphere b s
[PROOF STEP]
using assms homeomorphic_trans [OF homeomorphic_spheres homeomorphic_spheres']
[PROOF STATE]
proof (prove)
using this:
0 < r
0 < s
DIM('a) = DIM('b)
\<lbrakk>0 < ?d2; 0 < ?\<delta>1; 0 < ?\<delta>1; DIM(?'a1) = DIM(?'b1)\<rbrakk> \<Longrightarrow> sphere ?a2 ?d2 homeomorphic sphere ?b1 ?\<delta>1

goal (1 subgoal):
 1. sphere a r homeomorphic sphere b s
[PROOF STEP]
by auto


[STATEMENT]
lemma icard_inj_on_le: "\<lbrakk> inj_on f A; f ` A \<subseteq> B \<rbrakk> \<Longrightarrow> icard A \<le> icard B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>inj_on f A; f ` A \<subseteq> B\<rbrakk> \<Longrightarrow> icard A \<le> icard B
[PROOF STEP]
apply (case_tac "finite B")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>inj_on f A; f ` A \<subseteq> B; finite B\<rbrakk> \<Longrightarrow> icard A \<le> icard B
 2. \<lbrakk>inj_on f A; f ` A \<subseteq> B; infinite B\<rbrakk> \<Longrightarrow> icard A \<le> icard B
[PROOF STEP]
apply (metis icard_image icard_mono)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>inj_on f A; f ` A \<subseteq> B; infinite B\<rbrakk> \<Longrightarrow> icard A \<le> icard B
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma Suc_unat_mask_div:
  "Suc (unat (mask sz div word_size :: machine_word)) = 2 ^ (min sz word_bits - word_size_bits)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc (unat (mask sz div word_size)) = 2 ^ (min sz word_bits - word_size_bits)
[PROOF STEP]
by (simp add: word_size_word_size_bits unat_drop_bit_eq unat_mask_eq drop_bit_mask_eq Suc_mask_eq_exp
    flip: drop_bit_eq_div word_bits_conv)


[STATEMENT]
lemma winding_number_homotopic_paths_null_eq:
  assumes "path p" and \<zeta>: "\<zeta> \<notin> path_image p"
  shows "winding_number p \<zeta> = 0 \<longleftrightarrow> (\<exists>a. homotopic_paths (-{\<zeta>}) p (\<lambda>t. a))"
    (is "?lhs = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (winding_number p \<zeta> = 0) = (\<exists>a. homotopic_paths (- {\<zeta>}) p (\<lambda>t. a))
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. winding_number p \<zeta> = 0 \<Longrightarrow> \<exists>a. homotopic_paths (- {\<zeta>}) p (\<lambda>t. a)
 2. \<exists>a. homotopic_paths (- {\<zeta>}) p (\<lambda>t. a) \<Longrightarrow> winding_number p \<zeta> = 0
[PROOF STEP]
assume ?lhs
[PROOF STATE]
proof (state)
this:
winding_number p \<zeta> = 0

goal (2 subgoals):
 1. winding_number p \<zeta> = 0 \<Longrightarrow> \<exists>a. homotopic_paths (- {\<zeta>}) p (\<lambda>t. a)
 2. \<exists>a. homotopic_paths (- {\<zeta>}) p (\<lambda>t. a) \<Longrightarrow> winding_number p \<zeta> = 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
winding_number p \<zeta> = 0
[PROOF STEP]
show ?rhs
[PROOF STATE]
proof (prove)
using this:
winding_number p \<zeta> = 0

goal (1 subgoal):
 1. \<exists>a. homotopic_paths (- {\<zeta>}) p (\<lambda>t. a)
[PROOF STEP]
by (auto simp: winding_number_homotopic_paths_null_explicit_eq [OF assms] linepath_refl)
[PROOF STATE]
proof (state)
this:
\<exists>a. homotopic_paths (- {\<zeta>}) p (\<lambda>t. a)

goal (1 subgoal):
 1. \<exists>a. homotopic_paths (- {\<zeta>}) p (\<lambda>t. a) \<Longrightarrow> winding_number p \<zeta> = 0
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>a. homotopic_paths (- {\<zeta>}) p (\<lambda>t. a) \<Longrightarrow> winding_number p \<zeta> = 0
[PROOF STEP]
assume ?rhs
[PROOF STATE]
proof (state)
this:
\<exists>a. homotopic_paths (- {\<zeta>}) p (\<lambda>t. a)

goal (1 subgoal):
 1. \<exists>a. homotopic_paths (- {\<zeta>}) p (\<lambda>t. a) \<Longrightarrow> winding_number p \<zeta> = 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>a. homotopic_paths (- {\<zeta>}) p (\<lambda>t. a)
[PROOF STEP]
show ?lhs
[PROOF STATE]
proof (prove)
using this:
\<exists>a. homotopic_paths (- {\<zeta>}) p (\<lambda>t. a)

goal (1 subgoal):
 1. winding_number p \<zeta> = 0
[PROOF STEP]
by (metis \<zeta> homotopic_paths_imp_pathfinish pathfinish_def pathfinish_in_path_image winding_number_homotopic_paths winding_number_zero_const)
[PROOF STATE]
proof (state)
this:
winding_number p \<zeta> = 0

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma eventually_nat_real:
  assumes "eventually P (at_top :: real filter)"
  shows   "eventually (\<lambda>x. P (real x)) (at_top :: nat filter)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in sequentially. P (real x)
[PROOF STEP]
using assms filterlim_real_sequentially
[PROOF STATE]
proof (prove)
using this:
eventually P at_top
filterlim real at_top sequentially

goal (1 subgoal):
 1. \<forall>\<^sub>F x in sequentially. P (real x)
[PROOF STEP]
unfolding filterlim_def le_filter_def eventually_filtermap
[PROOF STATE]
proof (prove)
using this:
eventually P at_top
\<forall>P. eventually P at_top \<longrightarrow> (\<forall>\<^sub>F x in sequentially. P (real x))

goal (1 subgoal):
 1. \<forall>\<^sub>F x in sequentially. P (real x)
[PROOF STEP]
by auto


[STATEMENT]
lemma prod_mset_prime_factorization_int:
  fixes n :: int
  assumes "n > 0"
  shows   "prod_mset (prime_factorization n) = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Prod>\<^sub># (prime_factorization n) = n
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < n

goal (1 subgoal):
 1. \<Prod>\<^sub># (prime_factorization n) = n
[PROOF STEP]
by (simp add: prod_mset_prime_factorization)


[STATEMENT]
lemma log_est: "log 2 (real n + 1) \<le> n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. log 2 (real n + 1) \<le> real n
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. log 2 (real n + 1) \<le> real n
[PROOF STEP]
have "1 + real n = real (n + 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 + real n = real (n + 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 + real n = real (n + 1)

goal (1 subgoal):
 1. log 2 (real n + 1) \<le> real n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 + real n = real (n + 1)

goal (1 subgoal):
 1. log 2 (real n + 1) \<le> real n
[PROOF STEP]
have "... \<le> real (2 ^ n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (n + 1) \<le> real (2 ^ n)
[PROOF STEP]
by (intro of_nat_mono suc_n_le_2_pow_n)
[PROOF STATE]
proof (state)
this:
real (n + 1) \<le> real (2 ^ n)

goal (1 subgoal):
 1. log 2 (real n + 1) \<le> real n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real (n + 1) \<le> real (2 ^ n)

goal (1 subgoal):
 1. log 2 (real n + 1) \<le> real n
[PROOF STEP]
have "... = 2 powr (real n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (2 ^ n) = 2 powr real n
[PROOF STEP]
by (simp add:powr_realpow)
[PROOF STATE]
proof (state)
this:
real (2 ^ n) = 2 powr real n

goal (1 subgoal):
 1. log 2 (real n + 1) \<le> real n
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
1 + real n \<le> 2 powr real n
[PROOF STEP]
have "1 + real n \<le> 2 powr (real n)"
[PROOF STATE]
proof (prove)
using this:
1 + real n \<le> 2 powr real n

goal (1 subgoal):
 1. 1 + real n \<le> 2 powr real n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 + real n \<le> 2 powr real n

goal (1 subgoal):
 1. log 2 (real n + 1) \<le> real n
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
1 + real n \<le> 2 powr real n

goal (1 subgoal):
 1. log 2 (real n + 1) \<le> real n
[PROOF STEP]
by (simp add: Transcendental.log_le_iff)
[PROOF STATE]
proof (state)
this:
log 2 (real n + 1) \<le> real n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma compact_fip_Heine_Borel:
  fixes \<F> :: "'a::heine_borel set set"
  assumes clof: "\<And>T. T \<in> \<F> \<Longrightarrow> compact T"
      and none: "\<And>\<F>'. \<lbrakk>finite \<F>'; \<F>' \<subseteq> \<F>\<rbrakk> \<Longrightarrow> \<Inter>\<F>' \<noteq> {}"
    shows "\<Inter>\<F> \<noteq> {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Inter> \<F> \<noteq> {}
[PROOF STEP]
by (metis InterI all_not_in_conv clof closed_fip_Heine_Borel compact_eq_bounded_closed none)


[STATEMENT]
theorem residue_primroot_bij_betw_primroots:
  assumes "m > 1" and "residue_primroot m g"
  shows   "bij_betw (\<lambda>i. g ^ i mod m) (totatives (totient m))
                                      {g\<in>totatives m. residue_primroot m g}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij_betw (\<lambda>i. g ^ i mod m) (totatives (totient m)) {g \<in> totatives m. residue_primroot m g}
[PROOF STEP]
proof (cases "m = 2")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. m = 2 \<Longrightarrow> bij_betw (\<lambda>i. g ^ i mod m) (totatives (totient m)) {g \<in> totatives m. residue_primroot m g}
 2. m \<noteq> 2 \<Longrightarrow> bij_betw (\<lambda>i. g ^ i mod m) (totatives (totient m)) {g \<in> totatives m. residue_primroot m g}
[PROOF STEP]
case [simp]: True
[PROOF STATE]
proof (state)
this:
m = 2

goal (2 subgoals):
 1. m = 2 \<Longrightarrow> bij_betw (\<lambda>i. g ^ i mod m) (totatives (totient m)) {g \<in> totatives m. residue_primroot m g}
 2. m \<noteq> 2 \<Longrightarrow> bij_betw (\<lambda>i. g ^ i mod m) (totatives (totient m)) {g \<in> totatives m. residue_primroot m g}
[PROOF STEP]
have [simp]: "totatives 2 = {1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. totatives 2 = {1}
[PROOF STEP]
by (auto simp: totatives_def elim!: oddE)
[PROOF STATE]
proof (state)
this:
totatives 2 = {1}

goal (2 subgoals):
 1. m = 2 \<Longrightarrow> bij_betw (\<lambda>i. g ^ i mod m) (totatives (totient m)) {g \<in> totatives m. residue_primroot m g}
 2. m \<noteq> 2 \<Longrightarrow> bij_betw (\<lambda>i. g ^ i mod m) (totatives (totient m)) {g \<in> totatives m. residue_primroot m g}
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
1 < m
residue_primroot m g
[PROOF STEP]
have "odd g"
[PROOF STATE]
proof (prove)
using this:
1 < m
residue_primroot m g

goal (1 subgoal):
 1. odd g
[PROOF STEP]
by (auto simp: residue_primroot_def)
[PROOF STATE]
proof (state)
this:
odd g

goal (2 subgoals):
 1. m = 2 \<Longrightarrow> bij_betw (\<lambda>i. g ^ i mod m) (totatives (totient m)) {g \<in> totatives m. residue_primroot m g}
 2. m \<noteq> 2 \<Longrightarrow> bij_betw (\<lambda>i. g ^ i mod m) (totatives (totient m)) {g \<in> totatives m. residue_primroot m g}
[PROOF STEP]
hence pow_eq: "(\<lambda>i. g ^ i mod m) = (\<lambda>_. 1)"
[PROOF STATE]
proof (prove)
using this:
odd g

goal (1 subgoal):
 1. (\<lambda>i. g ^ i mod m) = (\<lambda>_. 1)
[PROOF STEP]
by (auto simp: fun_eq_iff mod_2_eq_odd)
[PROOF STATE]
proof (state)
this:
(\<lambda>i. g ^ i mod m) = (\<lambda>_. 1)

goal (2 subgoals):
 1. m = 2 \<Longrightarrow> bij_betw (\<lambda>i. g ^ i mod m) (totatives (totient m)) {g \<in> totatives m. residue_primroot m g}
 2. m \<noteq> 2 \<Longrightarrow> bij_betw (\<lambda>i. g ^ i mod m) (totatives (totient m)) {g \<in> totatives m. residue_primroot m g}
[PROOF STEP]
have "{g \<in> totatives m. residue_primroot m g} = {1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {g \<in> totatives m. residue_primroot m g} = {1}
[PROOF STEP]
by (auto simp: residue_primroot_def)
[PROOF STATE]
proof (state)
this:
{g \<in> totatives m. residue_primroot m g} = {1}

goal (2 subgoals):
 1. m = 2 \<Longrightarrow> bij_betw (\<lambda>i. g ^ i mod m) (totatives (totient m)) {g \<in> totatives m. residue_primroot m g}
 2. m \<noteq> 2 \<Longrightarrow> bij_betw (\<lambda>i. g ^ i mod m) (totatives (totient m)) {g \<in> totatives m. residue_primroot m g}
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
{g \<in> totatives m. residue_primroot m g} = {1}

goal (1 subgoal):
 1. bij_betw (\<lambda>i. g ^ i mod m) (totatives (totient m)) {g \<in> totatives m. residue_primroot m g}
[PROOF STEP]
using pow_eq
[PROOF STATE]
proof (prove)
using this:
{g \<in> totatives m. residue_primroot m g} = {1}
(\<lambda>i. g ^ i mod m) = (\<lambda>_. 1)

goal (1 subgoal):
 1. bij_betw (\<lambda>i. g ^ i mod m) (totatives (totient m)) {g \<in> totatives m. residue_primroot m g}
[PROOF STEP]
by (auto simp: bij_betw_def)
[PROOF STATE]
proof (state)
this:
bij_betw (\<lambda>i. g ^ i mod m) (totatives (totient m)) {g \<in> totatives m. residue_primroot m g}

goal (1 subgoal):
 1. m \<noteq> 2 \<Longrightarrow> bij_betw (\<lambda>i. g ^ i mod m) (totatives (totient m)) {g \<in> totatives m. residue_primroot m g}
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. m \<noteq> 2 \<Longrightarrow> bij_betw (\<lambda>i. g ^ i mod m) (totatives (totient m)) {g \<in> totatives m. residue_primroot m g}
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
m \<noteq> 2

goal (1 subgoal):
 1. m \<noteq> 2 \<Longrightarrow> bij_betw (\<lambda>i. g ^ i mod m) (totatives (totient m)) {g \<in> totatives m. residue_primroot m g}
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
m \<noteq> 2

goal (1 subgoal):
 1. bij_betw (\<lambda>i. g ^ i mod m) (totatives (totient m)) {g \<in> totatives m. residue_primroot m g}
[PROOF STEP]
unfolding bij_betw_def
[PROOF STATE]
proof (prove)
using this:
m \<noteq> 2

goal (1 subgoal):
 1. inj_on (\<lambda>i. g ^ i mod m) (totatives (totient m)) \<and> (\<lambda>i. g ^ i mod m) ` totatives (totient m) = {g \<in> totatives m. residue_primroot m g}
[PROOF STEP]
proof safe
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. m \<noteq> 2 \<Longrightarrow> inj_on (\<lambda>i. g ^ i mod m) (totatives (totient m))
 2. \<And>x i. \<lbrakk>m \<noteq> 2; i \<in> totatives (totient m)\<rbrakk> \<Longrightarrow> g ^ i mod m \<in> totatives m
 3. \<And>x i. \<lbrakk>m \<noteq> 2; i \<in> totatives (totient m)\<rbrakk> \<Longrightarrow> residue_primroot m (g ^ i mod m)
 4. \<And>x. \<lbrakk>m \<noteq> 2; x \<in> totatives m; residue_primroot m x\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>i. g ^ i mod m) ` totatives (totient m)
[PROOF STEP]
from assms False
[PROOF STATE]
proof (chain)
picking this:
1 < m
residue_primroot m g
m \<noteq> 2
[PROOF STEP]
have "m > 2"
[PROOF STATE]
proof (prove)
using this:
1 < m
residue_primroot m g
m \<noteq> 2

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

goal (4 subgoals):
 1. m \<noteq> 2 \<Longrightarrow> inj_on (\<lambda>i. g ^ i mod m) (totatives (totient m))
 2. \<And>x i. \<lbrakk>m \<noteq> 2; i \<in> totatives (totient m)\<rbrakk> \<Longrightarrow> g ^ i mod m \<in> totatives m
 3. \<And>x i. \<lbrakk>m \<noteq> 2; i \<in> totatives (totient m)\<rbrakk> \<Longrightarrow> residue_primroot m (g ^ i mod m)
 4. \<And>x. \<lbrakk>m \<noteq> 2; x \<in> totatives m; residue_primroot m x\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>i. g ^ i mod m) ` totatives (totient m)
[PROOF STEP]
from assms \<open>m > 2\<close>
[PROOF STATE]
proof (chain)
picking this:
1 < m
residue_primroot m g
2 < m
[PROOF STEP]
have "totient m > 1"
[PROOF STATE]
proof (prove)
using this:
1 < m
residue_primroot m g
2 < m

goal (1 subgoal):
 1. 1 < totient m
[PROOF STEP]
by (intro totient_gt_1) auto
[PROOF STATE]
proof (state)
this:
1 < totient m

goal (4 subgoals):
 1. m \<noteq> 2 \<Longrightarrow> inj_on (\<lambda>i. g ^ i mod m) (totatives (totient m))
 2. \<And>x i. \<lbrakk>m \<noteq> 2; i \<in> totatives (totient m)\<rbrakk> \<Longrightarrow> g ^ i mod m \<in> totatives m
 3. \<And>x i. \<lbrakk>m \<noteq> 2; i \<in> totatives (totient m)\<rbrakk> \<Longrightarrow> residue_primroot m (g ^ i mod m)
 4. \<And>x. \<lbrakk>m \<noteq> 2; x \<in> totatives m; residue_primroot m x\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>i. g ^ i mod m) ` totatives (totient m)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
1 < m
residue_primroot m g
[PROOF STEP]
have [simp]: "ord m g = totient m"
[PROOF STATE]
proof (prove)
using this:
1 < m
residue_primroot m g

goal (1 subgoal):
 1. ord m g = totient m
[PROOF STEP]
by (simp add: residue_primroot_def)
[PROOF STATE]
proof (state)
this:
ord m g = totient m

goal (4 subgoals):
 1. m \<noteq> 2 \<Longrightarrow> inj_on (\<lambda>i. g ^ i mod m) (totatives (totient m))
 2. \<And>x i. \<lbrakk>m \<noteq> 2; i \<in> totatives (totient m)\<rbrakk> \<Longrightarrow> g ^ i mod m \<in> totatives m
 3. \<And>x i. \<lbrakk>m \<noteq> 2; i \<in> totatives (totient m)\<rbrakk> \<Longrightarrow> residue_primroot m (g ^ i mod m)
 4. \<And>x. \<lbrakk>m \<noteq> 2; x \<in> totatives m; residue_primroot m x\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>i. g ^ i mod m) ` totatives (totient m)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
1 < m
residue_primroot m g
[PROOF STEP]
have "coprime m g"
[PROOF STATE]
proof (prove)
using this:
1 < m
residue_primroot m g

goal (1 subgoal):
 1. coprime m g
[PROOF STEP]
by (simp add: residue_primroot_def)
[PROOF STATE]
proof (state)
this:
coprime m g

goal (4 subgoals):
 1. m \<noteq> 2 \<Longrightarrow> inj_on (\<lambda>i. g ^ i mod m) (totatives (totient m))
 2. \<And>x i. \<lbrakk>m \<noteq> 2; i \<in> totatives (totient m)\<rbrakk> \<Longrightarrow> g ^ i mod m \<in> totatives m
 3. \<And>x i. \<lbrakk>m \<noteq> 2; i \<in> totatives (totient m)\<rbrakk> \<Longrightarrow> residue_primroot m (g ^ i mod m)
 4. \<And>x. \<lbrakk>m \<noteq> 2; x \<in> totatives m; residue_primroot m x\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>i. g ^ i mod m) ` totatives (totient m)
[PROOF STEP]
hence "inj_on (\<lambda>i. g ^ i mod m) {..<ord m g}"
[PROOF STATE]
proof (prove)
using this:
coprime m g

goal (1 subgoal):
 1. inj_on (\<lambda>i. g ^ i mod m) {..<ord m g}
[PROOF STEP]
by (intro inj_power_mod)
[PROOF STATE]
proof (state)
this:
inj_on (\<lambda>i. g ^ i mod m) {..<ord m g}

goal (4 subgoals):
 1. m \<noteq> 2 \<Longrightarrow> inj_on (\<lambda>i. g ^ i mod m) (totatives (totient m))
 2. \<And>x i. \<lbrakk>m \<noteq> 2; i \<in> totatives (totient m)\<rbrakk> \<Longrightarrow> g ^ i mod m \<in> totatives m
 3. \<And>x i. \<lbrakk>m \<noteq> 2; i \<in> totatives (totient m)\<rbrakk> \<Longrightarrow> residue_primroot m (g ^ i mod m)
 4. \<And>x. \<lbrakk>m \<noteq> 2; x \<in> totatives m; residue_primroot m x\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>i. g ^ i mod m) ` totatives (totient m)
[PROOF STEP]
thus "inj_on (\<lambda>i. g ^ i mod m) (totatives (totient m))"
[PROOF STATE]
proof (prove)
using this:
inj_on (\<lambda>i. g ^ i mod m) {..<ord m g}

goal (1 subgoal):
 1. inj_on (\<lambda>i. g ^ i mod m) (totatives (totient m))
[PROOF STEP]
by (rule inj_on_subset)
         (use assms \<open>totient m > 1\<close> in \<open>auto simp: totatives_less residue_primroot_def\<close>)
[PROOF STATE]
proof (state)
this:
inj_on (\<lambda>i. g ^ i mod m) (totatives (totient m))

goal (3 subgoals):
 1. \<And>x i. \<lbrakk>m \<noteq> 2; i \<in> totatives (totient m)\<rbrakk> \<Longrightarrow> g ^ i mod m \<in> totatives m
 2. \<And>x i. \<lbrakk>m \<noteq> 2; i \<in> totatives (totient m)\<rbrakk> \<Longrightarrow> residue_primroot m (g ^ i mod m)
 3. \<And>x. \<lbrakk>m \<noteq> 2; x \<in> totatives m; residue_primroot m x\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>i. g ^ i mod m) ` totatives (totient m)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
inj_on (\<lambda>i. g ^ i mod m) (totatives (totient m))

goal (3 subgoals):
 1. \<And>x i. \<lbrakk>m \<noteq> 2; i \<in> totatives (totient m)\<rbrakk> \<Longrightarrow> g ^ i mod m \<in> totatives m
 2. \<And>x i. \<lbrakk>m \<noteq> 2; i \<in> totatives (totient m)\<rbrakk> \<Longrightarrow> residue_primroot m (g ^ i mod m)
 3. \<And>x. \<lbrakk>m \<noteq> 2; x \<in> totatives m; residue_primroot m x\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>i. g ^ i mod m) ` totatives (totient m)
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>x i. \<lbrakk>m \<noteq> 2; i \<in> totatives (totient m)\<rbrakk> \<Longrightarrow> g ^ i mod m \<in> totatives m
 2. \<And>x i. \<lbrakk>m \<noteq> 2; i \<in> totatives (totient m)\<rbrakk> \<Longrightarrow> residue_primroot m (g ^ i mod m)
 3. \<And>x. \<lbrakk>m \<noteq> 2; x \<in> totatives m; residue_primroot m x\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>i. g ^ i mod m) ` totatives (totient m)
[PROOF STEP]
assume i: "i \<in> totatives (totient m)"
[PROOF STATE]
proof (state)
this:
i \<in> totatives (totient m)

goal (3 subgoals):
 1. \<And>x i. \<lbrakk>m \<noteq> 2; i \<in> totatives (totient m)\<rbrakk> \<Longrightarrow> g ^ i mod m \<in> totatives m
 2. \<And>x i. \<lbrakk>m \<noteq> 2; i \<in> totatives (totient m)\<rbrakk> \<Longrightarrow> residue_primroot m (g ^ i mod m)
 3. \<And>x. \<lbrakk>m \<noteq> 2; x \<in> totatives m; residue_primroot m x\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>i. g ^ i mod m) ` totatives (totient m)
[PROOF STEP]
from \<open>coprime m g\<close> and \<open>m > 2\<close>
[PROOF STATE]
proof (chain)
picking this:
coprime m g
2 < m
[PROOF STEP]
show "g ^ i mod m \<in> totatives m"
[PROOF STATE]
proof (prove)
using this:
coprime m g
2 < m

goal (1 subgoal):
 1. g ^ i mod m \<in> totatives m
[PROOF STEP]
by (intro power_in_totatives) auto
[PROOF STATE]
proof (state)
this:
g ^ i mod m \<in> totatives m

goal (2 subgoals):
 1. \<And>x i. \<lbrakk>m \<noteq> 2; i \<in> totatives (totient m)\<rbrakk> \<Longrightarrow> residue_primroot m (g ^ i mod m)
 2. \<And>x. \<lbrakk>m \<noteq> 2; x \<in> totatives m; residue_primroot m x\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>i. g ^ i mod m) ` totatives (totient m)
[PROOF STEP]
show "residue_primroot m (g ^ i mod m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. residue_primroot m (g ^ i mod m)
[PROOF STEP]
using i \<open>m > 2\<close> \<open>coprime m g\<close>
[PROOF STATE]
proof (prove)
using this:
i \<in> totatives (totient m)
2 < m
coprime m g

goal (1 subgoal):
 1. residue_primroot m (g ^ i mod m)
[PROOF STEP]
by (auto simp: residue_primroot_def coprime_commute ord_power totatives_def)
[PROOF STATE]
proof (state)
this:
residue_primroot m (g ^ i mod m)

goal (1 subgoal):
 1. \<And>x. \<lbrakk>m \<noteq> 2; x \<in> totatives m; residue_primroot m x\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>i. g ^ i mod m) ` totatives (totient m)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?i2 \<in> totatives (totient m) \<Longrightarrow> residue_primroot m (g ^ ?i2 mod m)

goal (1 subgoal):
 1. \<And>x. \<lbrakk>m \<noteq> 2; x \<in> totatives m; residue_primroot m x\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>i. g ^ i mod m) ` totatives (totient m)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
?i2 \<in> totatives (totient m) \<Longrightarrow> residue_primroot m (g ^ ?i2 mod m)

goal (1 subgoal):
 1. \<And>x. \<lbrakk>m \<noteq> 2; x \<in> totatives m; residue_primroot m x\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>i. g ^ i mod m) ` totatives (totient m)
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>m \<noteq> 2; x \<in> totatives m; residue_primroot m x\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>i. g ^ i mod m) ` totatives (totient m)
[PROOF STEP]
assume x: "x \<in> totatives m" "residue_primroot m x"
[PROOF STATE]
proof (state)
this:
x \<in> totatives m
residue_primroot m x

goal (1 subgoal):
 1. \<And>x. \<lbrakk>m \<noteq> 2; x \<in> totatives m; residue_primroot m x\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>i. g ^ i mod m) ` totatives (totient m)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> totatives m
residue_primroot m x
[PROOF STEP]
obtain i where i: "i < totient m" "x = (g ^ i mod m)"
[PROOF STATE]
proof (prove)
using this:
x \<in> totatives m
residue_primroot m x

goal (1 subgoal):
 1. (\<And>i. \<lbrakk>i < totient m; x = g ^ i mod m\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms residue_primroot_is_generator[of m g]
[PROOF STATE]
proof (prove)
using this:
x \<in> totatives m
residue_primroot m x
1 < m
residue_primroot m g
\<lbrakk>1 < m; residue_primroot m g\<rbrakk> \<Longrightarrow> bij_betw (\<lambda>i. g ^ i mod m) {..<totient m} (totatives m)

goal (1 subgoal):
 1. (\<And>i. \<lbrakk>i < totient m; x = g ^ i mod m\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: bij_betw_def)
[PROOF STATE]
proof (state)
this:
i < totient m
x = g ^ i mod m

goal (1 subgoal):
 1. \<And>x. \<lbrakk>m \<noteq> 2; x \<in> totatives m; residue_primroot m x\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>i. g ^ i mod m) ` totatives (totient m)
[PROOF STEP]
from i x \<open>m > 2\<close>
[PROOF STATE]
proof (chain)
picking this:
i < totient m
x = g ^ i mod m
x \<in> totatives m
residue_primroot m x
2 < m
[PROOF STEP]
have "i > 0"
[PROOF STATE]
proof (prove)
using this:
i < totient m
x = g ^ i mod m
x \<in> totatives m
residue_primroot m x
2 < m

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

goal (1 subgoal):
 1. \<And>x. \<lbrakk>m \<noteq> 2; x \<in> totatives m; residue_primroot m x\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>i. g ^ i mod m) ` totatives (totient m)
[PROOF STEP]
have "totient m div gcd i (totient m) = totient m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. totient m div gcd i (totient m) = totient m
[PROOF STEP]
using x i \<open>coprime m g\<close>
[PROOF STATE]
proof (prove)
using this:
x \<in> totatives m
residue_primroot m x
i < totient m
x = g ^ i mod m
coprime m g

goal (1 subgoal):
 1. totient m div gcd i (totient m) = totient m
[PROOF STEP]
by (auto simp add: residue_primroot_def ord_power)
[PROOF STATE]
proof (state)
this:
totient m div gcd i (totient m) = totient m

goal (1 subgoal):
 1. \<And>x. \<lbrakk>m \<noteq> 2; x \<in> totatives m; residue_primroot m x\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>i. g ^ i mod m) ` totatives (totient m)
[PROOF STEP]
hence "coprime i (totient m)"
[PROOF STATE]
proof (prove)
using this:
totient m div gcd i (totient m) = totient m

goal (1 subgoal):
 1. coprime i (totient m)
[PROOF STEP]
unfolding coprime_iff_gcd_eq_1
[PROOF STATE]
proof (prove)
using this:
totient m div gcd i (totient m) = totient m

goal (1 subgoal):
 1. gcd i (totient m) = 1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
totient m div gcd i (totient m) = totient m
1 < m
residue_primroot m g

goal (1 subgoal):
 1. gcd i (totient m) = 1
[PROOF STEP]
by (subst (asm) dvd_div_eq_mult) auto
[PROOF STATE]
proof (state)
this:
coprime i (totient m)

goal (1 subgoal):
 1. \<And>x. \<lbrakk>m \<noteq> 2; x \<in> totatives m; residue_primroot m x\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>i. g ^ i mod m) ` totatives (totient m)
[PROOF STEP]
with i \<open>i > 0\<close>
[PROOF STATE]
proof (chain)
picking this:
i < totient m
x = g ^ i mod m
0 < i
coprime i (totient m)
[PROOF STEP]
have "i \<in> totatives (totient m)"
[PROOF STATE]
proof (prove)
using this:
i < totient m
x = g ^ i mod m
0 < i
coprime i (totient m)

goal (1 subgoal):
 1. i \<in> totatives (totient m)
[PROOF STEP]
by (auto simp: totatives_def)
[PROOF STATE]
proof (state)
this:
i \<in> totatives (totient m)

goal (1 subgoal):
 1. \<And>x. \<lbrakk>m \<noteq> 2; x \<in> totatives m; residue_primroot m x\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>i. g ^ i mod m) ` totatives (totient m)
[PROOF STEP]
thus "x \<in> (\<lambda>i. g ^ i mod m) ` totatives (totient m)"
[PROOF STATE]
proof (prove)
using this:
i \<in> totatives (totient m)

goal (1 subgoal):
 1. x \<in> (\<lambda>i. g ^ i mod m) ` totatives (totient m)
[PROOF STEP]
using i
[PROOF STATE]
proof (prove)
using this:
i \<in> totatives (totient m)
i < totient m
x = g ^ i mod m

goal (1 subgoal):
 1. x \<in> (\<lambda>i. g ^ i mod m) ` totatives (totient m)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> (\<lambda>i. g ^ i mod m) ` totatives (totient m)

goal:
No subgoals!
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>?x2 \<in> totatives m; residue_primroot m ?x2\<rbrakk> \<Longrightarrow> ?x2 \<in> (\<lambda>i. g ^ i mod m) ` totatives (totient m)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
bij_betw (\<lambda>i. g ^ i mod m) (totatives (totient m)) {g \<in> totatives m. residue_primroot m g}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem sublist_imp_len_filter_le:
  fixes P l l'
  assumes "subseq l' l"
  shows "length (filter P l') \<le> length (filter P l)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (filter P l') \<le> length (filter P l)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
subseq l' l

goal (1 subgoal):
 1. length (filter P l') \<le> length (filter P l)
[PROOF STEP]
by (simp add: sublist_length)

\<comment> \<open>TODO showcase (non-trivial proof translation/ obscurity).\<close>


[STATEMENT]
lemma sum_moebius_mu_divisors':
  "(\<Sum>d | d dvd n. moebius_mu d) = (if n = 1 then 1 else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (if n = 1 then 1::'a else (0::'a))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (if n = 1 then 1::'a else (0::'a))
[PROOF STEP]
have "n = 0 \<or> n = 1 \<or> n > 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n = 0 \<or> n = 1 \<or> 1 < n
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
n = 0 \<or> n = 1 \<or> 1 < n

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (if n = 1 then 1::'a else (0::'a))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
n = 0 \<or> n = 1 \<or> 1 < n

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (if n = 1 then 1::'a else (0::'a))
[PROOF STEP]
using sum_moebius_mu_divisors[of n]
[PROOF STATE]
proof (prove)
using this:
n = 0 \<or> n = 1 \<or> 1 < n
1 < n \<Longrightarrow> (\<Sum>d | d dvd n. moebius_mu d) = (0::?'a)

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (if n = 1 then 1::'a else (0::'a))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd n. moebius_mu d) = (if n = 1 then 1::'a else (0::'a))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem vec_mat_Tensor_length:
 "length(vec_mat_Tensor xs ys) = length ys"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (vec_mat_Tensor xs ys) = length ys
[PROOF STEP]
by(induction ys)(auto)


[STATEMENT]
theorem deleteMin_correct:
  assumes I: "invar q"
    and NE: "q \<noteq> Nil"
  shows "invar (deleteMin q)"
    and "queue_to_multiset (deleteMin q) = queue_to_multiset q - {#findMin q#}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invar (deleteMin q) &&& queue_to_multiset (deleteMin q) = queue_to_multiset q - {#findMin q#}
[PROOF STEP]
apply (rule deleteMin_invar[OF I NE])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. queue_to_multiset (deleteMin q) = queue_to_multiset q - {#findMin q#}
[PROOF STEP]
using deleteMin_mset[of q] I NE
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>queue_invar q; queue_to_multiset q \<noteq> {#}\<rbrakk> \<Longrightarrow> queue_to_multiset (deleteMin q) = queue_to_multiset q - {#findMin q#}
invar q
q \<noteq> []

goal (1 subgoal):
 1. queue_to_multiset (deleteMin q) = queue_to_multiset q - {#findMin q#}
[PROOF STEP]
unfolding invar_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>queue_invar q; queue_to_multiset q \<noteq> {#}\<rbrakk> \<Longrightarrow> queue_to_multiset (deleteMin q) = queue_to_multiset q - {#findMin q#}
queue_invar q \<and> rank_skew_invar q
q \<noteq> []

goal (1 subgoal):
 1. queue_to_multiset (deleteMin q) = queue_to_multiset q - {#findMin q#}
[PROOF STEP]
apply (auto simp add: empty_correct)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma Proj_sup: \<open>orthogonal_spaces S T \<Longrightarrow> Proj (sup S T) = Proj S + Proj T\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. orthogonal_spaces S T \<Longrightarrow> Proj (S \<squnion> T) = Proj S + Proj T
[PROOF STEP]
unfolding orthogonal_spaces_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>space_as_set S. \<forall>y\<in>space_as_set T. is_orthogonal x y \<Longrightarrow> Proj (S \<squnion> T) = Proj S + Proj T
[PROOF STEP]
apply transfer
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>S T. \<lbrakk>closed_csubspace S; closed_csubspace T; \<forall>x\<in>S. \<forall>y\<in>T. is_orthogonal x y\<rbrakk> \<Longrightarrow> projection (S +\<^sub>M T) = (\<lambda>x. projection S x + projection T x)
[PROOF STEP]
by (simp add: projection_plus)


[STATEMENT]
lemma Suc_Suc_div:  "\<lbrakk>0 < s; s mod 2 = Suc 0; Suc (Suc s) \<le> 2 * n\<rbrakk>
           \<Longrightarrow> (Suc (Suc (s div 2))) \<le> n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < s; s mod 2 = Suc 0; Suc (Suc s) \<le> 2 * n\<rbrakk> \<Longrightarrow> Suc (Suc (s div 2)) \<le> n
[PROOF STEP]
by(arith)


[STATEMENT]
lemma ln_fact_conv_sum_upto: "ln (fact n) = sum_upto ln n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ln (fact n) = sum_upto (\<lambda>x. ln (real x)) (real n)
[PROOF STEP]
by (induction n) (auto simp: sum_upto_plus1 add.commute[of 1] ln_mult)


[STATEMENT]
lemma even_of_intvl_intvl:
  fixes S :: "nat set"
  assumes "S = {m..n} \<inter> {i. even i}"
  shows "\<exists>m' n'. S = (\<lambda>i. i * 2) ` {m'..n'}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>m' n'. S = (\<lambda>i. i * 2) ` {m'..n'}
[PROOF STEP]
apply (rule exI[where x="Suc m div 2"], rule exI[where x="n div 2"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S = (\<lambda>i. i * 2) ` {Suc m div 2..n div 2}
[PROOF STEP]
apply (fastforce simp add: assms mult.commute)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma square_powr_half [simp]:
  fixes x::real shows "x\<^sup>2 powr (1/2) = \<bar>x\<bar>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x\<^sup>2 powr (1 / 2) = \<bar>x\<bar>
[PROOF STEP]
by (simp add: powr_half_sqrt)


[STATEMENT]
lemma norm2_le_norm1_int: "\<parallel>f :: int poly\<parallel>\<^sup>2 \<le> (norm1 f)^2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>f\<parallel>\<^sup>2 \<le> (norm1 f)\<^sup>2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<parallel>f\<parallel>\<^sup>2 \<le> (norm1 f)\<^sup>2
[PROOF STEP]
define F where "F = (!) (coeffs f)"
[PROOF STATE]
proof (state)
this:
F = (!) (coeffs f)

goal (1 subgoal):
 1. \<parallel>f\<parallel>\<^sup>2 \<le> (norm1 f)\<^sup>2
[PROOF STEP]
define n where "n = length (coeffs f)"
[PROOF STATE]
proof (state)
this:
n = length (coeffs f)

goal (1 subgoal):
 1. \<parallel>f\<parallel>\<^sup>2 \<le> (norm1 f)\<^sup>2
[PROOF STEP]
have 1: "\<parallel>f\<parallel>\<^sup>2 = (\<Sum>i = 0..<n. F i * F i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>f\<parallel>\<^sup>2 = (\<Sum>i = 0..<n. F i * F i)
[PROOF STEP]
unfolding norm1_def sq_norm_poly_def sum_list_sum_nth F_def n_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum ((!) (map sq_norm (coeffs f))) {0..<length (map sq_norm (coeffs f))} = (\<Sum>i = 0..<length (coeffs f). coeffs f ! i * coeffs f ! i)
[PROOF STEP]
by (subst sum.cong, auto simp: power2_eq_square)
[PROOF STATE]
proof (state)
this:
\<parallel>f\<parallel>\<^sup>2 = (\<Sum>i = 0..<n. F i * F i)

goal (1 subgoal):
 1. \<parallel>f\<parallel>\<^sup>2 \<le> (norm1 f)\<^sup>2
[PROOF STEP]
have 2: "norm1 f = (\<Sum>i = 0..<n. \<bar>F i\<bar>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm1 f = (\<Sum>i = 0..<n. \<bar>F i\<bar>)
[PROOF STEP]
unfolding norm1_def sq_norm_poly_def sum_list_sum_nth F_def n_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum ((!) (map abs (coeffs f))) {0..<length (map abs (coeffs f))} = (\<Sum>i = 0..<length (coeffs f). \<bar>coeffs f ! i\<bar>)
[PROOF STEP]
by (subst sum.cong, auto)
[PROOF STATE]
proof (state)
this:
norm1 f = (\<Sum>i = 0..<n. \<bar>F i\<bar>)

goal (1 subgoal):
 1. \<parallel>f\<parallel>\<^sup>2 \<le> (norm1 f)\<^sup>2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>f\<parallel>\<^sup>2 \<le> (norm1 f)\<^sup>2
[PROOF STEP]
unfolding 1 2
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<n. F i * F i) \<le> (\<Sum>i = 0..<n. \<bar>F i\<bar>)\<^sup>2
[PROOF STEP]
by (rule norm2_norm1_main_inequality)
[PROOF STATE]
proof (state)
this:
\<parallel>f\<parallel>\<^sup>2 \<le> (norm1 f)\<^sup>2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma replicate_spec: "\<lbrakk>\<forall>i < n. xs ! i = x; n=length xs\<rbrakk>
  \<Longrightarrow> replicate (length xs) x = xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>i<n. xs ! i = x; n = length xs\<rbrakk> \<Longrightarrow> replicate (length xs) x = xs
[PROOF STEP]
apply hypsubst_thin
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i<length xs. xs ! i = x \<Longrightarrow> replicate (length xs) x = xs
[PROOF STEP]
apply (induct xs)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<forall>i<length []. [] ! i = x \<Longrightarrow> replicate (length []) x = []
 2. \<And>a xs. \<lbrakk>\<forall>i<length xs. xs ! i = x \<Longrightarrow> replicate (length xs) x = xs; \<forall>i<length (a # xs). (a # xs) ! i = x\<rbrakk> \<Longrightarrow> replicate (length (a # xs)) x = a # xs
[PROOF STEP]
apply  simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a xs. \<lbrakk>\<forall>i<length xs. xs ! i = x \<Longrightarrow> replicate (length xs) x = xs; \<forall>i<length (a # xs). (a # xs) ! i = x\<rbrakk> \<Longrightarrow> replicate (length (a # xs)) x = a # xs
[PROOF STEP]
apply force
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma assoc_as_fmset_eq:
  assumes "wfactors G as a"
    and "wfactors G bs b"
    and "a \<in> carrier G"
    and "b \<in> carrier G"
    and "set as \<subseteq> carrier G"
    and "set bs \<subseteq> carrier G"
  shows "a \<sim> b \<longleftrightarrow> (fmset G as = fmset G bs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<sim> b = (fmset G as = fmset G bs)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a \<sim> b = (fmset G as = fmset G bs)
[PROOF STEP]
have "a \<sim> b \<longleftrightarrow> (a divides b \<and> b divides a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<sim> b = (a divides b \<and> b divides a)
[PROOF STEP]
by (simp add:associated_def)
[PROOF STATE]
proof (state)
this:
a \<sim> b = (a divides b \<and> b divides a)

goal (1 subgoal):
 1. a \<sim> b = (fmset G as = fmset G bs)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
a \<sim> b = (a divides b \<and> b divides a)

goal (1 subgoal):
 1. a \<sim> b = (fmset G as = fmset G bs)
[PROOF STEP]
have "... \<longleftrightarrow>
    (fmset G as \<subseteq># fmset G bs \<and> fmset G bs \<subseteq># fmset G as)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a divides b \<and> b divides a) = (fmset G as \<subseteq># fmset G bs \<and> fmset G bs \<subseteq># fmset G as)
[PROOF STEP]
using divides_as_fmsubset assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>wfactors G ?as ?a; wfactors G ?bs ?b; ?a \<in> carrier G; ?b \<in> carrier G; set ?as \<subseteq> carrier G; set ?bs \<subseteq> carrier G\<rbrakk> \<Longrightarrow> ?a divides ?b = (fmset G ?as \<subseteq># fmset G ?bs)
wfactors G as a
wfactors G bs b
a \<in> carrier G
b \<in> carrier G
set as \<subseteq> carrier G
set bs \<subseteq> carrier G

goal (1 subgoal):
 1. (a divides b \<and> b divides a) = (fmset G as \<subseteq># fmset G bs \<and> fmset G bs \<subseteq># fmset G as)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(a divides b \<and> b divides a) = (fmset G as \<subseteq># fmset G bs \<and> fmset G bs \<subseteq># fmset G as)

goal (1 subgoal):
 1. a \<sim> b = (fmset G as = fmset G bs)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(a divides b \<and> b divides a) = (fmset G as \<subseteq># fmset G bs \<and> fmset G bs \<subseteq># fmset G as)

goal (1 subgoal):
 1. a \<sim> b = (fmset G as = fmset G bs)
[PROOF STEP]
have "... \<longleftrightarrow> (fmset G as = fmset G bs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (fmset G as \<subseteq># fmset G bs \<and> fmset G bs \<subseteq># fmset G as) = (fmset G as = fmset G bs)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(fmset G as \<subseteq># fmset G bs \<and> fmset G bs \<subseteq># fmset G as) = (fmset G as = fmset G bs)

goal (1 subgoal):
 1. a \<sim> b = (fmset G as = fmset G bs)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
a \<sim> b = (fmset G as = fmset G bs)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
a \<sim> b = (fmset G as = fmset G bs)

goal (1 subgoal):
 1. a \<sim> b = (fmset G as = fmset G bs)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a \<sim> b = (fmset G as = fmset G bs)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Chebyshev_sum_upper_nat:
  fixes a b :: "nat \<Rightarrow> nat"
  shows "(\<And>i j. \<lbrakk> i\<le>j; j<n \<rbrakk> \<Longrightarrow> a i \<le> a j) \<Longrightarrow>
         (\<And>i j. \<lbrakk> i\<le>j; j<n \<rbrakk> \<Longrightarrow> b i \<ge> b j) \<Longrightarrow>
    n * (\<Sum>i=0..<n. a i * b i) \<le> (\<Sum>i=0..<n. a i) * (\<Sum>i=0..<n. b i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<And>i j. \<lbrakk>i \<le> j; j < n\<rbrakk> \<Longrightarrow> a i \<le> a j; \<And>i j. \<lbrakk>i \<le> j; j < n\<rbrakk> \<Longrightarrow> b j \<le> b i\<rbrakk> \<Longrightarrow> n * (\<Sum>i = 0..<n. a i * b i) \<le> sum a {0..<n} * sum b {0..<n}
[PROOF STEP]
using Chebyshev_sum_upper[where 'a=real, of n a b]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>i j. \<lbrakk>i \<le> j; j < n\<rbrakk> \<Longrightarrow> real (a i) \<le> real (a j); \<And>i j. \<lbrakk>i \<le> j; j < n\<rbrakk> \<Longrightarrow> real (b j) \<le> real (b i)\<rbrakk> \<Longrightarrow> real n * (\<Sum>k = 0..<n. real (a k) * real (b k)) \<le> (\<Sum>k = 0..<n. real (a k)) * (\<Sum>k = 0..<n. real (b k))

goal (1 subgoal):
 1. \<lbrakk>\<And>i j. \<lbrakk>i \<le> j; j < n\<rbrakk> \<Longrightarrow> a i \<le> a j; \<And>i j. \<lbrakk>i \<le> j; j < n\<rbrakk> \<Longrightarrow> b j \<le> b i\<rbrakk> \<Longrightarrow> n * (\<Sum>i = 0..<n. a i * b i) \<le> sum a {0..<n} * sum b {0..<n}
[PROOF STEP]
by (simp del: of_nat_mult of_nat_sum  add: of_nat_mult[symmetric] of_nat_sum[symmetric])


[STATEMENT]
lemma singleton_le_zero[simp]: "(singleton_matrix j i x <= 0) = (x <= (0::'a::{order,zero}))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (singleton_matrix j i x \<le> 0) = (x \<le> (0::'a))
[PROOF STEP]
apply (auto)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. singleton_matrix j i x \<le> 0 \<Longrightarrow> x \<le> (0::'a)
 2. x \<le> (0::'a) \<Longrightarrow> singleton_matrix j i x \<le> 0
[PROOF STEP]
apply (simp add: le_matrix_def)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<forall>ja ia. (if j = ja \<and> i = ia then x else (0::'a)) \<le> (0::'a) \<Longrightarrow> x \<le> (0::'a)
 2. x \<le> (0::'a) \<Longrightarrow> singleton_matrix j i x \<le> 0
[PROOF STEP]
apply (drule_tac j=j and i=i in spec2)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. (if j = j \<and> i = i then x else (0::'a)) \<le> (0::'a) \<Longrightarrow> x \<le> (0::'a)
 2. x \<le> (0::'a) \<Longrightarrow> singleton_matrix j i x \<le> 0
[PROOF STEP]
apply (simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<le> (0::'a) \<Longrightarrow> singleton_matrix j i x \<le> 0
[PROOF STEP]
apply (simp add: le_matrix_def)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma append_rows_mult_right:
  assumes A: "(A::'a::comm_semiring_1 mat) \<in> carrier_mat a n" and B: "B \<in> carrier_mat b n"
    and Q: "Q\<in> carrier_mat n n"
  shows "(A @\<^sub>r B) * Q = (A * Q) @\<^sub>r (B*Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (A @\<^sub>r B) * Q = A * Q @\<^sub>r B * Q
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (A @\<^sub>r B) * Q = A * Q @\<^sub>r B * Q
[PROOF STEP]
have "transpose_mat ((A @\<^sub>r B) * Q) = Q\<^sup>T * (A @\<^sub>r B)\<^sup>T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((A @\<^sub>r B) * Q)\<^sup>T = Q\<^sup>T * (A @\<^sub>r B)\<^sup>T
[PROOF STEP]
by (rule transpose_mult, insert A B Q, auto)
[PROOF STATE]
proof (state)
this:
((A @\<^sub>r B) * Q)\<^sup>T = Q\<^sup>T * (A @\<^sub>r B)\<^sup>T

goal (1 subgoal):
 1. (A @\<^sub>r B) * Q = A * Q @\<^sub>r B * Q
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
((A @\<^sub>r B) * Q)\<^sup>T = Q\<^sup>T * (A @\<^sub>r B)\<^sup>T

goal (1 subgoal):
 1. (A @\<^sub>r B) * Q = A * Q @\<^sub>r B * Q
[PROOF STEP]
have "... = Q\<^sup>T * (A\<^sup>T @\<^sub>c B\<^sup>T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Q\<^sup>T * (A @\<^sub>r B)\<^sup>T = Q\<^sup>T * (A\<^sup>T @\<^sub>c B\<^sup>T)
[PROOF STEP]
using transpose_mat_append_rows assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?A \<in> carrier_mat ?a ?n; ?B \<in> carrier_mat ?b ?n\<rbrakk> \<Longrightarrow> (?A @\<^sub>r ?B)\<^sup>T = ?A\<^sup>T @\<^sub>c ?B\<^sup>T
A \<in> carrier_mat a n
B \<in> carrier_mat b n
Q \<in> carrier_mat n n

goal (1 subgoal):
 1. Q\<^sup>T * (A @\<^sub>r B)\<^sup>T = Q\<^sup>T * (A\<^sup>T @\<^sub>c B\<^sup>T)
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
Q\<^sup>T * (A @\<^sub>r B)\<^sup>T = Q\<^sup>T * (A\<^sup>T @\<^sub>c B\<^sup>T)

goal (1 subgoal):
 1. (A @\<^sub>r B) * Q = A * Q @\<^sub>r B * Q
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Q\<^sup>T * (A @\<^sub>r B)\<^sup>T = Q\<^sup>T * (A\<^sup>T @\<^sub>c B\<^sup>T)

goal (1 subgoal):
 1. (A @\<^sub>r B) * Q = A * Q @\<^sub>r B * Q
[PROOF STEP]
have "... = Q\<^sup>T * A\<^sup>T @\<^sub>c Q\<^sup>T * B\<^sup>T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Q\<^sup>T * (A\<^sup>T @\<^sub>c B\<^sup>T) = Q\<^sup>T * A\<^sup>T @\<^sub>c Q\<^sup>T * B\<^sup>T
[PROOF STEP]
using append_cols_mult_left assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?A \<in> carrier_mat ?n ?a; ?B \<in> carrier_mat ?n ?b; ?P \<in> carrier_mat ?n ?n\<rbrakk> \<Longrightarrow> ?P * (?A @\<^sub>c ?B) = ?P * ?A @\<^sub>c ?P * ?B
A \<in> carrier_mat a n
B \<in> carrier_mat b n
Q \<in> carrier_mat n n

goal (1 subgoal):
 1. Q\<^sup>T * (A\<^sup>T @\<^sub>c B\<^sup>T) = Q\<^sup>T * A\<^sup>T @\<^sub>c Q\<^sup>T * B\<^sup>T
[PROOF STEP]
by (metis transpose_carrier_mat)
[PROOF STATE]
proof (state)
this:
Q\<^sup>T * (A\<^sup>T @\<^sub>c B\<^sup>T) = Q\<^sup>T * A\<^sup>T @\<^sub>c Q\<^sup>T * B\<^sup>T

goal (1 subgoal):
 1. (A @\<^sub>r B) * Q = A * Q @\<^sub>r B * Q
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Q\<^sup>T * (A\<^sup>T @\<^sub>c B\<^sup>T) = Q\<^sup>T * A\<^sup>T @\<^sub>c Q\<^sup>T * B\<^sup>T

goal (1 subgoal):
 1. (A @\<^sub>r B) * Q = A * Q @\<^sub>r B * Q
[PROOF STEP]
have "transpose_mat ... = (A * Q) @\<^sub>r (B*Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Q\<^sup>T * A\<^sup>T @\<^sub>c Q\<^sup>T * B\<^sup>T)\<^sup>T = A * Q @\<^sub>r B * Q
[PROOF STEP]
by (smt A B Matrix.transpose_mult Matrix.transpose_transpose append_cols_def append_rows_def Q
        carrier_mat_triv index_mult_mat(2) index_transpose_mat(2) transpose_four_block_mat
        zero_carrier_mat zero_transpose_mat)
[PROOF STATE]
proof (state)
this:
(Q\<^sup>T * A\<^sup>T @\<^sub>c Q\<^sup>T * B\<^sup>T)\<^sup>T = A * Q @\<^sub>r B * Q

goal (1 subgoal):
 1. (A @\<^sub>r B) * Q = A * Q @\<^sub>r B * Q
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
((A @\<^sub>r B) * Q)\<^sup>T\<^sup>T = A * Q @\<^sub>r B * Q
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
((A @\<^sub>r B) * Q)\<^sup>T\<^sup>T = A * Q @\<^sub>r B * Q

goal (1 subgoal):
 1. (A @\<^sub>r B) * Q = A * Q @\<^sub>r B * Q
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(A @\<^sub>r B) * Q = A * Q @\<^sub>r B * Q

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma poly_monom: "poly (monom a n) x = a * x ^ n"
  for a x :: "'a::comm_semiring_1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly (monom a n) x = a * x ^ n
[PROOF STEP]
by (cases "a = 0", simp_all) (induct n, simp_all add: mult.left_commute poly_eq_fold_coeffs)


[STATEMENT]
lemma orthogonal_commute: "orthogonal x y \<longleftrightarrow> orthogonal y x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. orthogonal x y = orthogonal y x
[PROOF STEP]
by (simp add: orthogonal_def inner_commute)


[STATEMENT]
lemma row_rank_eq_col_rank_rref:
  fixes A::"'a::{field}^'m::{mod_type}^'n::{mod_type}"
assumes r: "reduced_row_echelon_form A"
shows "row_rank A = col_rank A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. row_rank A = col_rank A
[PROOF STEP]
unfolding rref_row_rank[OF r] rref_col_rank[OF r]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {column (LEAST n. A $ i $ n \<noteq> (0::'a)) A |i. row i A \<noteq> 0} = card {column (LEAST n. A $ i $ n \<noteq> (0::'a)) A |i. row i A \<noteq> 0}
[PROOF STEP]
..


[STATEMENT]
lemma echelon_form_upt_row_condition2_explicit:
  assumes "echelon_form_upt_row A k"
  and "ia < j" and "to_nat j < k" and "\<not> is_zero_row ia A" and "\<not> is_zero_row j A"
  shows "(LEAST n. A $ ia $ n \<noteq> 0) < (LEAST n. A $ j $ n \<noteq> 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (LEAST n. A $ ia $ n \<noteq> (0::'a)) < (LEAST n. A $ j $ n \<noteq> (0::'a))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
echelon_form_upt_row A k
ia < j
mod_type_class.to_nat j < k
\<not> is_zero_row ia A
\<not> is_zero_row j A

goal (1 subgoal):
 1. (LEAST n. A $ ia $ n \<noteq> (0::'a)) < (LEAST n. A $ j $ n \<noteq> (0::'a))
[PROOF STEP]
unfolding echelon_form_upt_row_def
[PROOF STATE]
proof (prove)
using this:
(\<forall>i. mod_type_class.to_nat i < k \<and> is_zero_row i A \<longrightarrow> \<not> (\<exists>j>i. mod_type_class.to_nat j < k \<and> \<not> is_zero_row j A)) \<and> (\<forall>i j. i < j \<and> mod_type_class.to_nat j < k \<and> \<not> is_zero_row i A \<and> \<not> is_zero_row j A \<longrightarrow> (LEAST n. A $ i $ n \<noteq> (0::'a)) < (LEAST n. A $ j $ n \<noteq> (0::'a)))
ia < j
mod_type_class.to_nat j < k
\<not> is_zero_row ia A
\<not> is_zero_row j A

goal (1 subgoal):
 1. (LEAST n. A $ ia $ n \<noteq> (0::'a)) < (LEAST n. A $ j $ n \<noteq> (0::'a))
[PROOF STEP]
by auto


[STATEMENT]
lemma sin_30: "sin (pi / 6) = 1 / 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin (pi / 6) = 1 / 2
[PROOF STEP]
by (simp add: sin_cos_eq cos_60)


[STATEMENT]
lemma "((x::int) - y) ^ 2 = x ^ 2 + y ^ 2 - 2 * x * y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x - y)\<^sup>2 = x\<^sup>2 + y\<^sup>2 - 2 * x * y
[PROOF STEP]
by ring


[STATEMENT]
theorem derangement_enum_distinct: "distinct xs \<Longrightarrow> distinct (derangement_enum xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct xs \<Longrightarrow> distinct (derangement_enum xs)
[PROOF STEP]
using derangement_enum_aux_distinct
[PROOF STATE]
proof (prove)
using this:
distinct ?ys \<Longrightarrow> distinct (derangement_enum_aux ?xs ?ys)

goal (1 subgoal):
 1. distinct xs \<Longrightarrow> distinct (derangement_enum xs)
[PROOF STEP]
by auto


[STATEMENT]
lemma Icc_plus_Icc:
  "{a .. b} + {c .. d} = {a + c .. b + d}"
  if "a \<le> b" "c \<le> d"
  for a b c d::"'a::linordered_ab_group_add"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {a..b} + {c..d} = {a + c..b + d}
[PROOF STEP]
using ex_sum_in_interval[OF that]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>a + c \<le> ?x; ?x \<le> b + d\<rbrakk> \<Longrightarrow> \<exists>xa\<ge>a. xa \<le> b \<and> (\<exists>xb\<ge>c. xb \<le> d \<and> ?x = xa + xb)

goal (1 subgoal):
 1. {a..b} + {c..d} = {a + c..b + d}
[PROOF STEP]
by (auto intro: add_mono simp: atLeastAtMost_iff Bex_def set_plus_def)


[STATEMENT]
theorem meet_commute: "x \<sqinter> y = y \<sqinter> x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<sqinter> y = y \<sqinter> x
[PROOF STEP]
proof (rule meetI)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. y \<sqinter> x \<sqsubseteq> x
 2. y \<sqinter> x \<sqsubseteq> y
 3. \<And>z. \<lbrakk>z \<sqsubseteq> x; z \<sqsubseteq> y\<rbrakk> \<Longrightarrow> z \<sqsubseteq> y \<sqinter> x
[PROOF STEP]
show "y \<sqinter> x \<sqsubseteq> x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y \<sqinter> x \<sqsubseteq> x
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
y \<sqinter> x \<sqsubseteq> x

goal (2 subgoals):
 1. y \<sqinter> x \<sqsubseteq> y
 2. \<And>z. \<lbrakk>z \<sqsubseteq> x; z \<sqsubseteq> y\<rbrakk> \<Longrightarrow> z \<sqsubseteq> y \<sqinter> x
[PROOF STEP]
show "y \<sqinter> x \<sqsubseteq> y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y \<sqinter> x \<sqsubseteq> y
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
y \<sqinter> x \<sqsubseteq> y

goal (1 subgoal):
 1. \<And>z. \<lbrakk>z \<sqsubseteq> x; z \<sqsubseteq> y\<rbrakk> \<Longrightarrow> z \<sqsubseteq> y \<sqinter> x
[PROOF STEP]
fix z
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>z. \<lbrakk>z \<sqsubseteq> x; z \<sqsubseteq> y\<rbrakk> \<Longrightarrow> z \<sqsubseteq> y \<sqinter> x
[PROOF STEP]
assume "z \<sqsubseteq> y" and "z \<sqsubseteq> x"
[PROOF STATE]
proof (state)
this:
z \<sqsubseteq> y
z \<sqsubseteq> x

goal (1 subgoal):
 1. \<And>z. \<lbrakk>z \<sqsubseteq> x; z \<sqsubseteq> y\<rbrakk> \<Longrightarrow> z \<sqsubseteq> y \<sqinter> x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
z \<sqsubseteq> y
z \<sqsubseteq> x
[PROOF STEP]
show "z \<sqsubseteq> y \<sqinter> x"
[PROOF STATE]
proof (prove)
using this:
z \<sqsubseteq> y
z \<sqsubseteq> x

goal (1 subgoal):
 1. z \<sqsubseteq> y \<sqinter> x
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
z \<sqsubseteq> y \<sqinter> x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in poly_mod) inverse_mod_coprime_exp:
  assumes m: "m = p^n" and p: "prime p"
  and n: "n \<noteq> 0" and cop: "coprime x p"
  shows "M (inverse_mod x m * x) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M (inverse_mod x m * x) = 1
[PROOF STEP]
unfolding M_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inverse_mod x m * x mod m = 1
[PROOF STEP]
unfolding m
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inverse_mod x (p ^ n) * x mod p ^ n = 1
[PROOF STEP]
using inverse_mod_pow[OF cop _ n] p
[PROOF STATE]
proof (prove)
using this:
1 < p \<Longrightarrow> inverse_mod x (p ^ n) * x mod p ^ n = 1
prime p

goal (1 subgoal):
 1. inverse_mod x (p ^ n) * x mod p ^ n = 1
[PROOF STEP]
by (auto simp: prime_int_iff)


[STATEMENT]
lemma sin_kpi [simp]:
  fixes k::int
  shows "sin (k * pi) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin (real_of_int k * pi) = 0
[PROOF STEP]
by (simp add: sin_zero_iff_int2)


[STATEMENT]
lemma homeomorphic_path_connectedness:
  "S homeomorphic T \<Longrightarrow> path_connected S \<longleftrightarrow> path_connected T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S homeomorphic T \<Longrightarrow> path_connected S = path_connected T
[PROOF STEP]
unfolding homeomorphic_def homeomorphism_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>f g. (\<forall>x\<in>S. g (f x) = x) \<and> f ` S = T \<and> continuous_on S f \<and> (\<forall>y\<in>T. f (g y) = y) \<and> g ` T = S \<and> continuous_on T g \<Longrightarrow> path_connected S = path_connected T
[PROOF STEP]
by (metis path_connected_continuous_image)


[STATEMENT]
lemma ex_kleene_qfp:
  assumes comp: "omega_complete A (\<sqsubseteq>)"
  shows "\<exists>p. extreme_bound A (\<sqsubseteq>) Fn p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Ex (extreme_bound A (\<sqsubseteq>) {f^n \<bottom> |. n})
[PROOF STEP]
using fn_monotone
[PROOF STATE]
proof (prove)
using this:
monotone (\<le>) (\<sqsubseteq>) (\<lambda>n. f^n \<bottom>)

goal (1 subgoal):
 1. Ex (extreme_bound A (\<sqsubseteq>) {f^n \<bottom> |. n})
[PROOF STEP]
apply (intro comp[unfolded omega_complete_def, THEN completeD, OF FnA])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. monotone (\<le>) (\<sqsubseteq>) (\<lambda>n. f^n \<bottom>) \<Longrightarrow> {f^n \<bottom> |. n} \<in> {range f |f. monotone (\<le>) (\<sqsubseteq>) f}
[PROOF STEP]
by fast