[STATEMENT]
theorem Cayley_Hamilton:
  fixes A :: "'a::comm_ring_1 ^^ 'n"
  shows "poly_mat (charpoly A) A = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
text %visible \<open>\hrulefill ~~ Part 1 ~~ \hrulefill\<close>
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
define n where "n = CARD('n) - 1"
[PROOF STATE]
proof (state)
this:
n = CARD('n) - 1

goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n = CARD('n) - 1
[PROOF STEP]
have d_charpoly: "n + 1 = degree (charpoly A)" and
      d_adj: "n = max_degree (adjugate (\<^bold>X - \<^bold>C A))"
[PROOF STATE]
proof (prove)
using this:
n = CARD('n) - 1

goal (1 subgoal):
 1. n + 1 = degree (charpoly A) &&& n = max_degree (adjugate (\<^bold>X - \<^bold>C A))
[PROOF STEP]
by %invisible (simp_all add: degree_charpoly n_def max_degree_adjugate monom_0 diag_1[symmetric])
[PROOF STATE]
proof (state)
this:
n + 1 = degree (charpoly A)
n = max_degree (adjugate (\<^bold>X - \<^bold>C A))

goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
define B where "B i = map_sq_matrix (\<lambda>p. coeff p i) (adjugate (\<^bold>X - \<^bold>C A))" for i
[PROOF STATE]
proof (state)
this:
B ?i = map_sq_matrix (\<lambda>p. coeff p ?i) (adjugate (\<^bold>X - \<^bold>C A))

goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
have A_eq_B: "adjugate (\<^bold>X - \<^bold>C A) = (\<Sum>i\<le>n. X^i *\<^sub>S \<^bold>C (B i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. adjugate (\<^bold>X - \<^bold>C A) = (\<Sum>i\<le>n. X ^ i *\<^sub>S \<^bold>C (B i))
[PROOF STEP]
by %invisible (simp add: map_sq_matrix_smult sum_map_sq_matrix B_def d_adj
                        degree_le_max_degree poly_as_sum_of_monoms' cong: map_sq_matrix_cong)
[PROOF STATE]
proof (state)
this:
adjugate (\<^bold>X - \<^bold>C A) = (\<Sum>i\<le>n. X ^ i *\<^sub>S \<^bold>C (B i))

goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
text %visible \<open>\hrulefill ~~ Part 2 ~~ \hrulefill\<close>
[PROOF STATE]
proof (state)
this:
adjugate (\<^bold>X - \<^bold>C A) = (\<Sum>i\<le>n. X ^ i *\<^sub>S \<^bold>C (B i))

goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
have "charpoly A *\<^sub>S 1 = X *\<^sub>S adjugate (\<^bold>X - \<^bold>C A) - \<^bold>C A * adjugate (\<^bold>X - \<^bold>C A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. charpoly A *\<^sub>S 1 = X *\<^sub>S adjugate (\<^bold>X - \<^bold>C A) - \<^bold>C A * adjugate (\<^bold>X - \<^bold>C A)
[PROOF STEP]
by %invisible (simp add: smult_one charpoly_def mult_adjugate_det[symmetric] field_simps diag_mult)
[PROOF STATE]
proof (state)
this:
charpoly A *\<^sub>S 1 = X *\<^sub>S adjugate (\<^bold>X - \<^bold>C A) - \<^bold>C A * adjugate (\<^bold>X - \<^bold>C A)

goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
charpoly A *\<^sub>S 1 = X *\<^sub>S adjugate (\<^bold>X - \<^bold>C A) - \<^bold>C A * adjugate (\<^bold>X - \<^bold>C A)

goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
have "\<dots> = (\<Sum>i\<le>n. X^(i + 1) *\<^sub>S \<^bold>C (B i)) - (\<Sum>i\<le>n. X^i *\<^sub>S \<^bold>C (A * B i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. X *\<^sub>S adjugate (\<^bold>X - \<^bold>C A) - \<^bold>C A * adjugate (\<^bold>X - \<^bold>C A) = (\<Sum>i\<le>n. X ^ (i + 1) *\<^sub>S \<^bold>C (B i)) - (\<Sum>i\<le>n. X ^ i *\<^sub>S \<^bold>C (A * B i))
[PROOF STEP]
unfolding %invisible A_eq_B
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. X *\<^sub>S (\<Sum>i\<le>n. X ^ i *\<^sub>S \<^bold>C (B i)) - \<^bold>C A * (\<Sum>i\<le>n. X ^ i *\<^sub>S \<^bold>C (B i)) = (\<Sum>i\<le>n. X ^ (i + 1) *\<^sub>S \<^bold>C (B i)) - (\<Sum>i\<le>n. X ^ i *\<^sub>S \<^bold>C (A * B i))
[PROOF STEP]
by %invisible (simp add: sum_distrib_left smult_mult2[symmetric]
      map_sq_matrix_mult[symmetric] C_linear smult_sum[symmetric] smult_smult)
[PROOF STATE]
proof (state)
this:
X *\<^sub>S adjugate (\<^bold>X - \<^bold>C A) - \<^bold>C A * adjugate (\<^bold>X - \<^bold>C A) = (\<Sum>i\<le>n. X ^ (i + 1) *\<^sub>S \<^bold>C (B i)) - (\<Sum>i\<le>n. X ^ i *\<^sub>S \<^bold>C (A * B i))

goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
X *\<^sub>S adjugate (\<^bold>X - \<^bold>C A) - \<^bold>C A * adjugate (\<^bold>X - \<^bold>C A) = (\<Sum>i\<le>n. X ^ (i + 1) *\<^sub>S \<^bold>C (B i)) - (\<Sum>i\<le>n. X ^ i *\<^sub>S \<^bold>C (A * B i))

goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
have "(\<Sum>i\<le>n. X^(i + 1) *\<^sub>S \<^bold>C (B i)) =
      (\<Sum>i<n. X^(i + 1) *\<^sub>S \<^bold>C (B i)) + X^(n + 1) *\<^sub>S \<^bold>C (B n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<le>n. X ^ (i + 1) *\<^sub>S \<^bold>C (B i)) = (\<Sum>i<n. X ^ (i + 1) *\<^sub>S \<^bold>C (B i)) + X ^ (n + 1) *\<^sub>S \<^bold>C (B n)
[PROOF STEP]
by %invisible (simp add: lessThan_Suc_atMost[symmetric])
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>n. X ^ (i + 1) *\<^sub>S \<^bold>C (B i)) = (\<Sum>i<n. X ^ (i + 1) *\<^sub>S \<^bold>C (B i)) + X ^ (n + 1) *\<^sub>S \<^bold>C (B n)

goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>n. X ^ (i + 1) *\<^sub>S \<^bold>C (B i)) = (\<Sum>i<n. X ^ (i + 1) *\<^sub>S \<^bold>C (B i)) + X ^ (n + 1) *\<^sub>S \<^bold>C (B n)

goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
have "(\<Sum>i\<le>n. X^i *\<^sub>S \<^bold>C (A * B i)) =
      (\<Sum>i<n. X^(i + 1) *\<^sub>S \<^bold>C (A * B (i + 1))) + \<^bold>C (A * B 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<le>n. X ^ i *\<^sub>S \<^bold>C (A * B i)) = (\<Sum>i<n. X ^ (i + 1) *\<^sub>S \<^bold>C (A * B (i + 1))) + \<^bold>C (A * B 0)
[PROOF STEP]
unfolding %invisible lessThan_Suc_atMost[symmetric] lessThan_Suc_eq_insert_0
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>insert 0 (Suc ` {..<n}). X ^ i *\<^sub>S \<^bold>C (A * B i)) = (\<Sum>i<n. X ^ (i + 1) *\<^sub>S \<^bold>C (A * B (i + 1))) + \<^bold>C (A * B 0)
[PROOF STEP]
by %invisible (simp add: zero_notin_Suc_image monom_0 sum.reindex one_poly_def[symmetric] diag_mult)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>n. X ^ i *\<^sub>S \<^bold>C (A * B i)) = (\<Sum>i<n. X ^ (i + 1) *\<^sub>S \<^bold>C (A * B (i + 1))) + \<^bold>C (A * B 0)

goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
charpoly A *\<^sub>S 1 = (\<Sum>i<n. X ^ (i + 1) *\<^sub>S \<^bold>C (B i)) + X ^ (n + 1) *\<^sub>S \<^bold>C (B n) - ((\<Sum>i<n. X ^ (i + 1) *\<^sub>S \<^bold>C (A * B (i + 1))) + \<^bold>C (A * B 0))
[PROOF STEP]
have diag_charpoly:
    "charpoly A *\<^sub>S 1 = X^(n + 1) *\<^sub>S \<^bold>C (B n) +
      (\<Sum>i<n. X^(i + 1) *\<^sub>S \<^bold>C (B i - A * B (i + 1))) - \<^bold>C (A * B 0)"
[PROOF STATE]
proof (prove)
using this:
charpoly A *\<^sub>S 1 = (\<Sum>i<n. X ^ (i + 1) *\<^sub>S \<^bold>C (B i)) + X ^ (n + 1) *\<^sub>S \<^bold>C (B n) - ((\<Sum>i<n. X ^ (i + 1) *\<^sub>S \<^bold>C (A * B (i + 1))) + \<^bold>C (A * B 0))

goal (1 subgoal):
 1. charpoly A *\<^sub>S 1 = X ^ (n + 1) *\<^sub>S \<^bold>C (B n) + (\<Sum>i<n. X ^ (i + 1) *\<^sub>S \<^bold>C (B i - A * B (i + 1))) - \<^bold>C (A * B 0)
[PROOF STEP]
by %invisible (simp add: map_sq_matrix_diff C_linear sum_subtractf smult_diff)
[PROOF STATE]
proof (state)
this:
charpoly A *\<^sub>S 1 = X ^ (n + 1) *\<^sub>S \<^bold>C (B n) + (\<Sum>i<n. X ^ (i + 1) *\<^sub>S \<^bold>C (B i - A * B (i + 1))) - \<^bold>C (A * B 0)

goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
text %visible \<open>\hrulefill ~~ Part 3 ~~ \hrulefill\<close>
[PROOF STATE]
proof (state)
this:
charpoly A *\<^sub>S 1 = X ^ (n + 1) *\<^sub>S \<^bold>C (B n) + (\<Sum>i<n. X ^ (i + 1) *\<^sub>S \<^bold>C (B i - A * B (i + 1))) - \<^bold>C (A * B 0)

goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
let ?p = "\<lambda>i. coeff (charpoly A) i *\<^sub>S A^i"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
let ?AB = "\<lambda>i. A^(i + 1) * B i"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
have "(\<Sum>i\<le>n+1. ?p i) = ?p 0 + (\<Sum>i<n. ?p (i + 1)) + ?p (n + 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<le>n + 1. coeff (charpoly A) i *\<^sub>S A ^ i) = coeff (charpoly A) 0 *\<^sub>S A ^ 0 + (\<Sum>i<n. coeff (charpoly A) (i + 1) *\<^sub>S A ^ (i + 1)) + coeff (charpoly A) (n + 1) *\<^sub>S A ^ (n + 1)
[PROOF STEP]
unfolding %invisible sum.atMost_Suc_shift Suc_eq_plus1[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff (charpoly A) 0 *\<^sub>S A ^ 0 + (\<Sum>i\<le>n. coeff (charpoly A) (Suc i) *\<^sub>S A ^ Suc i) = coeff (charpoly A) 0 *\<^sub>S A ^ 0 + (\<Sum>i<n. coeff (charpoly A) (Suc i) *\<^sub>S A ^ Suc i) + coeff (charpoly A) (Suc n) *\<^sub>S A ^ Suc n
[PROOF STEP]
by %invisible (simp add: lessThan_Suc_atMost[symmetric])
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>n + 1. coeff (charpoly A) i *\<^sub>S A ^ i) = coeff (charpoly A) 0 *\<^sub>S A ^ 0 + (\<Sum>i<n. coeff (charpoly A) (i + 1) *\<^sub>S A ^ (i + 1)) + coeff (charpoly A) (n + 1) *\<^sub>S A ^ (n + 1)

goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>n + 1. coeff (charpoly A) i *\<^sub>S A ^ i) = coeff (charpoly A) 0 *\<^sub>S A ^ 0 + (\<Sum>i<n. coeff (charpoly A) (i + 1) *\<^sub>S A ^ (i + 1)) + coeff (charpoly A) (n + 1) *\<^sub>S A ^ (n + 1)

goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
have "?p 0 = - ?AB 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff (charpoly A) 0 *\<^sub>S A ^ 0 = - (A ^ (0 + 1) * B 0)
[PROOF STEP]
by %invisible (simp add: coeff_smult_1 diag_charpoly map_sq_matrix)
[PROOF STATE]
proof (state)
this:
coeff (charpoly A) 0 *\<^sub>S A ^ 0 = - (A ^ (0 + 1) * B 0)

goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
coeff (charpoly A) 0 *\<^sub>S A ^ 0 = - (A ^ (0 + 1) * B 0)

goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
have "(\<Sum>i<n. ?p (i + 1)) = (\<Sum>i=0..<n. ?AB i - ?AB (i + 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<n. coeff (charpoly A) (i + 1) *\<^sub>S A ^ (i + 1)) = (\<Sum>i = 0..<n. A ^ (i + 1) * B i - A ^ (i + 1 + 1) * B (i + 1))
[PROOF STEP]
by %invisible (rule sum.cong)
         (auto simp: coeff_smult_1 coeff_pow_X diag_charpoly map_sq_matrix sum_subtractf
                     if_distrib[where f="\<lambda>x. x a" for a] if_distrib[where f="\<lambda>x. a * x" for a]
                     field_simps sum.If_cases power_Suc2
               simp del: power_Suc)
[PROOF STATE]
proof (state)
this:
(\<Sum>i<n. coeff (charpoly A) (i + 1) *\<^sub>S A ^ (i + 1)) = (\<Sum>i = 0..<n. A ^ (i + 1) * B i - A ^ (i + 1 + 1) * B (i + 1))

goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i<n. coeff (charpoly A) (i + 1) *\<^sub>S A ^ (i + 1)) = (\<Sum>i = 0..<n. A ^ (i + 1) * B i - A ^ (i + 1 + 1) * B (i + 1))

goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
have "\<dots> = ?AB 0 - ?AB n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<n. A ^ (i + 1) * B i - A ^ (i + 1 + 1) * B (i + 1)) = A ^ (0 + 1) * B 0 - A ^ (n + 1) * B n
[PROOF STEP]
unfolding %invisible Suc_eq_plus1[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<n. A ^ Suc i * B i - A ^ Suc (Suc i) * B (Suc i)) = A ^ Suc 0 * B 0 - A ^ Suc n * B n
[PROOF STEP]
by %invisible (subst sum_telescope_Ico) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<n. A ^ (i + 1) * B i - A ^ (i + 1 + 1) * B (i + 1)) = A ^ (0 + 1) * B 0 - A ^ (n + 1) * B n

goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<n. A ^ (i + 1) * B i - A ^ (i + 1 + 1) * B (i + 1)) = A ^ (0 + 1) * B 0 - A ^ (n + 1) * B n

goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
have "?AB n = ?p (n + 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A ^ (n + 1) * B n = coeff (charpoly A) (n + 1) *\<^sub>S A ^ (n + 1)
[PROOF STEP]
unfolding %invisible coeff_smult_1 diag_charpoly
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A ^ (n + 1) * B n = A ^ (n + 1) * map_sq_matrix (\<lambda>p. coeff p (n + 1)) (X ^ (n + 1) *\<^sub>S \<^bold>C (B n) + (\<Sum>i<n. X ^ (i + 1) *\<^sub>S \<^bold>C (B i - A * B (i + 1))) - \<^bold>C (A * B 0))
[PROOF STEP]
by %invisible (simp add: mult_diag map_sq_matrix coeff_pow_X)
[PROOF STATE]
proof (state)
this:
A ^ (n + 1) * B n = coeff (charpoly A) (n + 1) *\<^sub>S A ^ (n + 1)

goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
A ^ (n + 1) * B n = coeff (charpoly A) (n + 1) *\<^sub>S A ^ (n + 1)

goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
have "coeff (charpoly A) (n + 1) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff (charpoly A) (n + 1) = (1::'a)
[PROOF STEP]
by %invisible (simp add: coeff_charpoly d_charpoly[simplified])
[PROOF STATE]
proof (state)
this:
coeff (charpoly A) (n + 1) = (1::'a)

goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>i\<le>n + 1. coeff (charpoly A) i *\<^sub>S A ^ i) = - (A ^ (0 + 1) * B 0) + (A ^ (0 + 1) * B 0 - (1::'a) *\<^sub>S A ^ (n + 1)) + (1::'a) *\<^sub>S A ^ (n + 1)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i\<le>n + 1. coeff (charpoly A) i *\<^sub>S A ^ i) = - (A ^ (0 + 1) * B 0) + (A ^ (0 + 1) * B 0 - (1::'a) *\<^sub>S A ^ (n + 1)) + (1::'a) *\<^sub>S A ^ (n + 1)

goal (1 subgoal):
 1. poly_mat (charpoly A) A = 0
[PROOF STEP]
by %invisible (simp add: poly_mat_def d_charpoly[simplified] diag_0_eq mult_diag)
[PROOF STATE]
proof (state)
this:
poly_mat (charpoly A) A = 0

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma inv_stereographic_on_sphere:
  assumes "X = Re (2*z / (1 + z*cnj z))" and "Y = Im (2*z / (1 + z*cnj z))" and "Z = ((cmod z)\<^sup>2 - 1) / (1 + (cmod z)\<^sup>2)"
  shows "X*X + Y*Y + Z*Z = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. X * X + Y * Y + Z * Z = 1
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. X * X + Y * Y + Z * Z = 1
[PROOF STEP]
have "1 + (cmod z)\<^sup>2 \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 + (cmod z)\<^sup>2 \<noteq> 0
[PROOF STEP]
by (smt power2_less_0)
[PROOF STATE]
proof (state)
this:
1 + (cmod z)\<^sup>2 \<noteq> 0

goal (1 subgoal):
 1. X * X + Y * Y + Z * Z = 1
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
1 + (cmod z)\<^sup>2 \<noteq> 0

goal (1 subgoal):
 1. X * X + Y * Y + Z * Z = 1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
1 + (cmod z)\<^sup>2 \<noteq> 0
X = Re (2 * z / (1 + z * cnj z))
Y = Im (2 * z / (1 + z * cnj z))
Z = ((cmod z)\<^sup>2 - 1) / (1 + (cmod z)\<^sup>2)

goal (1 subgoal):
 1. X * X + Y * Y + Z * Z = 1
[PROOF STEP]
by (simp add: Re_stereographic Im_stereographic)
       (cases z, simp add: power2_eq_square real_sqrt_mult[symmetric] add_divide_distrib[symmetric], simp add: complex_norm power2_eq_square field_simps)
[PROOF STATE]
proof (state)
this:
X * X + Y * Y + Z * Z = 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma card_bind:
  assumes "finite S"
  assumes "\<forall>X \<in> S. finite (f X)"
  assumes "disjoint_family_on f S"
  shows "card (S \<bind> f) = (\<Sum>x\<in>S. card (f x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (S \<bind> f) = (\<Sum>x\<in>S. card (f x))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card (S \<bind> f) = (\<Sum>x\<in>S. card (f x))
[PROOF STEP]
have "card (S \<bind> f) = card (\<Union>(f ` S))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (S \<bind> f) = card (\<Union> (f ` S))
[PROOF STEP]
by (simp add: bind_UNION)
[PROOF STATE]
proof (state)
this:
card (S \<bind> f) = card (\<Union> (f ` S))

goal (1 subgoal):
 1. card (S \<bind> f) = (\<Sum>x\<in>S. card (f x))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card (S \<bind> f) = card (\<Union> (f ` S))

goal (1 subgoal):
 1. card (S \<bind> f) = (\<Sum>x\<in>S. card (f x))
[PROOF STEP]
have "card (\<Union>(f ` S)) = (\<Sum>x\<in>S. card (f x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (\<Union> (f ` S)) = (\<Sum>x\<in>S. card (f x))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite S
\<forall>X\<in>S. finite (f X)
disjoint_family_on f S

goal (1 subgoal):
 1. card (\<Union> (f ` S)) = (\<Sum>x\<in>S. card (f x))
[PROOF STEP]
unfolding disjoint_family_on_def
[PROOF STATE]
proof (prove)
using this:
finite S
\<forall>X\<in>S. finite (f X)
\<forall>m\<in>S. \<forall>n\<in>S. m \<noteq> n \<longrightarrow> f m \<inter> f n = {}

goal (1 subgoal):
 1. card (\<Union> (f ` S)) = (\<Sum>x\<in>S. card (f x))
[PROOF STEP]
by (simp add: card_UN_disjoint)
[PROOF STATE]
proof (state)
this:
card (\<Union> (f ` S)) = (\<Sum>x\<in>S. card (f x))

goal (1 subgoal):
 1. card (S \<bind> f) = (\<Sum>x\<in>S. card (f x))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
card (S \<bind> f) = (\<Sum>x\<in>S. card (f x))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
card (S \<bind> f) = (\<Sum>x\<in>S. card (f x))

goal (1 subgoal):
 1. card (S \<bind> f) = (\<Sum>x\<in>S. card (f x))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
card (S \<bind> f) = (\<Sum>x\<in>S. card (f x))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma cscalar_prod_adjoint:
  fixes M:: "complex mat"
  assumes "M \<in> carrier_mat nB nA"
    and "dim_vec v = nA"
    and "dim_vec u = nB"
  shows "v \<bullet>c ((mat_adjoint M) *\<^sub>v u) = (M *\<^sub>v v) \<bullet>c u"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v \<bullet>c (mat_adjoint M *\<^sub>v u) = (M *\<^sub>v v) \<bullet>c u
[PROOF STEP]
unfolding mat_adjoint_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v \<bullet>c (mat_of_rows (dim_row M) (map conjugate (cols M)) *\<^sub>v u) = (M *\<^sub>v v) \<bullet>c u
[PROOF STEP]
using assms(1) assms(2,3)[symmetric]
[PROOF STATE]
proof (prove)
using this:
M \<in> carrier_mat nB nA
nA = dim_vec v
nB = dim_vec u

goal (1 subgoal):
 1. v \<bullet>c (mat_of_rows (dim_row M) (map conjugate (cols M)) *\<^sub>v u) = (M *\<^sub>v v) \<bullet>c u
[PROOF STEP]
apply (simp add: scalar_prod_def sum_distrib_left field_simps)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>M \<in> carrier_mat (dim_vec u) (dim_vec v); nA = dim_vec v; nB = dim_vec u\<rbrakk> \<Longrightarrow> (\<Sum>i = 0..<dim_vec v. \<Sum>n = 0..<dim_vec u. v $ i * (cnj (u $ n) * M $$ (n, i))) = (\<Sum>i = 0..<dim_vec u. \<Sum>n = 0..<dim_vec v. v $ n * (cnj (u $ i) * M $$ (i, n)))
[PROOF STEP]
by (intro sum.swap)


[STATEMENT]
lemma map_list_snoc: "\<And>xs.
  length fs < length xs \<Longrightarrow>
  map_list (fs @ [f]) xs =
  map_list fs xs @  [f (xs ! (length fs))]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>xs. length fs < length xs \<Longrightarrow> map_list (fs @ [f]) xs = map_list fs xs @ [f (xs ! length fs)]
[PROOF STEP]
apply (induct fs)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>xs. length [] < length xs \<Longrightarrow> map_list ([] @ [f]) xs = map_list [] xs @ [f (xs ! length [])]
 2. \<And>a fs xs. \<lbrakk>\<And>xs. length fs < length xs \<Longrightarrow> map_list (fs @ [f]) xs = map_list fs xs @ [f (xs ! length fs)]; length (a # fs) < length xs\<rbrakk> \<Longrightarrow> map_list ((a # fs) @ [f]) xs = map_list (a # fs) xs @ [f (xs ! length (a # fs))]
[PROOF STEP]
apply (simp add: hd_conv_nth)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a fs xs. \<lbrakk>\<And>xs. length fs < length xs \<Longrightarrow> map_list (fs @ [f]) xs = map_list fs xs @ [f (xs ! length fs)]; length (a # fs) < length xs\<rbrakk> \<Longrightarrow> map_list ((a # fs) @ [f]) xs = map_list (a # fs) xs @ [f (xs ! length (a # fs))]
[PROOF STEP]
apply (simp add: nth_tl_eq_nth_Suc2)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
theorem ptolemy_trigonometric:
  fixes \<omega>\<^sub>1 \<omega>\<^sub>2 \<omega>\<^sub>3 :: real
  shows "sin (\<omega>\<^sub>1 + \<omega>\<^sub>2) * sin (\<omega>\<^sub>2 + \<omega>\<^sub>3) = sin \<omega>\<^sub>1 * sin \<omega>\<^sub>3 + sin \<omega>\<^sub>2 * sin (\<omega>\<^sub>1 + \<omega>\<^sub>2 + \<omega>\<^sub>3)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin (\<omega>\<^sub>1 + \<omega>\<^sub>2) * sin (\<omega>\<^sub>2 + \<omega>\<^sub>3) = sin \<omega>\<^sub>1 * sin \<omega>\<^sub>3 + sin \<omega>\<^sub>2 * sin (\<omega>\<^sub>1 + \<omega>\<^sub>2 + \<omega>\<^sub>3)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. sin (\<omega>\<^sub>1 + \<omega>\<^sub>2) * sin (\<omega>\<^sub>2 + \<omega>\<^sub>3) = sin \<omega>\<^sub>1 * sin \<omega>\<^sub>3 + sin \<omega>\<^sub>2 * sin (\<omega>\<^sub>1 + \<omega>\<^sub>2 + \<omega>\<^sub>3)
[PROOF STEP]
have "sin (\<omega>\<^sub>1 + \<omega>\<^sub>2) * sin (\<omega>\<^sub>2 + \<omega>\<^sub>3) = ((sin \<omega>\<^sub>2)\<^sup>2 + (cos \<omega>\<^sub>2)\<^sup>2) * sin \<omega>\<^sub>1 * sin \<omega>\<^sub>3 + sin \<omega>\<^sub>2 * sin (\<omega>\<^sub>1 + \<omega>\<^sub>2 + \<omega>\<^sub>3)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin (\<omega>\<^sub>1 + \<omega>\<^sub>2) * sin (\<omega>\<^sub>2 + \<omega>\<^sub>3) = ((sin \<omega>\<^sub>2)\<^sup>2 + (cos \<omega>\<^sub>2)\<^sup>2) * sin \<omega>\<^sub>1 * sin \<omega>\<^sub>3 + sin \<omega>\<^sub>2 * sin (\<omega>\<^sub>1 + \<omega>\<^sub>2 + \<omega>\<^sub>3)
[PROOF STEP]
by (simp only: sin_add cos_add) algebra
[PROOF STATE]
proof (state)
this:
sin (\<omega>\<^sub>1 + \<omega>\<^sub>2) * sin (\<omega>\<^sub>2 + \<omega>\<^sub>3) = ((sin \<omega>\<^sub>2)\<^sup>2 + (cos \<omega>\<^sub>2)\<^sup>2) * sin \<omega>\<^sub>1 * sin \<omega>\<^sub>3 + sin \<omega>\<^sub>2 * sin (\<omega>\<^sub>1 + \<omega>\<^sub>2 + \<omega>\<^sub>3)

goal (1 subgoal):
 1. sin (\<omega>\<^sub>1 + \<omega>\<^sub>2) * sin (\<omega>\<^sub>2 + \<omega>\<^sub>3) = sin \<omega>\<^sub>1 * sin \<omega>\<^sub>3 + sin \<omega>\<^sub>2 * sin (\<omega>\<^sub>1 + \<omega>\<^sub>2 + \<omega>\<^sub>3)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sin (\<omega>\<^sub>1 + \<omega>\<^sub>2) * sin (\<omega>\<^sub>2 + \<omega>\<^sub>3) = ((sin \<omega>\<^sub>2)\<^sup>2 + (cos \<omega>\<^sub>2)\<^sup>2) * sin \<omega>\<^sub>1 * sin \<omega>\<^sub>3 + sin \<omega>\<^sub>2 * sin (\<omega>\<^sub>1 + \<omega>\<^sub>2 + \<omega>\<^sub>3)

goal (1 subgoal):
 1. sin (\<omega>\<^sub>1 + \<omega>\<^sub>2) * sin (\<omega>\<^sub>2 + \<omega>\<^sub>3) = sin \<omega>\<^sub>1 * sin \<omega>\<^sub>3 + sin \<omega>\<^sub>2 * sin (\<omega>\<^sub>1 + \<omega>\<^sub>2 + \<omega>\<^sub>3)
[PROOF STEP]
have "\<dots> = sin \<omega>\<^sub>1 * sin \<omega>\<^sub>3 + sin \<omega>\<^sub>2 * sin (\<omega>\<^sub>1 + \<omega>\<^sub>2 + \<omega>\<^sub>3)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((sin \<omega>\<^sub>2)\<^sup>2 + (cos \<omega>\<^sub>2)\<^sup>2) * sin \<omega>\<^sub>1 * sin \<omega>\<^sub>3 + sin \<omega>\<^sub>2 * sin (\<omega>\<^sub>1 + \<omega>\<^sub>2 + \<omega>\<^sub>3) = sin \<omega>\<^sub>1 * sin \<omega>\<^sub>3 + sin \<omega>\<^sub>2 * sin (\<omega>\<^sub>1 + \<omega>\<^sub>2 + \<omega>\<^sub>3)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
((sin \<omega>\<^sub>2)\<^sup>2 + (cos \<omega>\<^sub>2)\<^sup>2) * sin \<omega>\<^sub>1 * sin \<omega>\<^sub>3 + sin \<omega>\<^sub>2 * sin (\<omega>\<^sub>1 + \<omega>\<^sub>2 + \<omega>\<^sub>3) = sin \<omega>\<^sub>1 * sin \<omega>\<^sub>3 + sin \<omega>\<^sub>2 * sin (\<omega>\<^sub>1 + \<omega>\<^sub>2 + \<omega>\<^sub>3)

goal (1 subgoal):
 1. sin (\<omega>\<^sub>1 + \<omega>\<^sub>2) * sin (\<omega>\<^sub>2 + \<omega>\<^sub>3) = sin \<omega>\<^sub>1 * sin \<omega>\<^sub>3 + sin \<omega>\<^sub>2 * sin (\<omega>\<^sub>1 + \<omega>\<^sub>2 + \<omega>\<^sub>3)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sin (\<omega>\<^sub>1 + \<omega>\<^sub>2) * sin (\<omega>\<^sub>2 + \<omega>\<^sub>3) = sin \<omega>\<^sub>1 * sin \<omega>\<^sub>3 + sin \<omega>\<^sub>2 * sin (\<omega>\<^sub>1 + \<omega>\<^sub>2 + \<omega>\<^sub>3)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
sin (\<omega>\<^sub>1 + \<omega>\<^sub>2) * sin (\<omega>\<^sub>2 + \<omega>\<^sub>3) = sin \<omega>\<^sub>1 * sin \<omega>\<^sub>3 + sin \<omega>\<^sub>2 * sin (\<omega>\<^sub>1 + \<omega>\<^sub>2 + \<omega>\<^sub>3)

goal (1 subgoal):
 1. sin (\<omega>\<^sub>1 + \<omega>\<^sub>2) * sin (\<omega>\<^sub>2 + \<omega>\<^sub>3) = sin \<omega>\<^sub>1 * sin \<omega>\<^sub>3 + sin \<omega>\<^sub>2 * sin (\<omega>\<^sub>1 + \<omega>\<^sub>2 + \<omega>\<^sub>3)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
sin (\<omega>\<^sub>1 + \<omega>\<^sub>2) * sin (\<omega>\<^sub>2 + \<omega>\<^sub>3) = sin \<omega>\<^sub>1 * sin \<omega>\<^sub>3 + sin \<omega>\<^sub>2 * sin (\<omega>\<^sub>1 + \<omega>\<^sub>2 + \<omega>\<^sub>3)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma dim_zero_eq:
  assumes dim_A: "dim A = 0"
  shows "A = {} \<or> A = {0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A = {} \<or> A = {0::'b}
[PROOF STEP]
using dim_A local.card_ge_dim_independent local.independent_empty
[PROOF STATE]
proof (prove)
using this:
local.dim A = 0
\<lbrakk>?B \<subseteq> ?V; local.independent ?B; local.dim ?V \<le> card ?B\<rbrakk> \<Longrightarrow> ?V \<subseteq> local.span ?B
local.independent {}

goal (1 subgoal):
 1. A = {} \<or> A = {0::'b}
[PROOF STEP]
by force


[STATEMENT]
lemma card_Un_conv: "
  \<lbrakk> finite A; finite B \<rbrakk> \<Longrightarrow>
  card (A \<union> B) = card A + card B - card (A \<inter> B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite A; finite B\<rbrakk> \<Longrightarrow> card (A \<union> B) = card A + card B - card (A \<inter> B)
[PROOF STEP]
by (simp only: card_Un_Int diff_add_inverse2)


[STATEMENT]
lemma type_based: "\<exists>f :: 'a::finite \<Rightarrow> nat. injective f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>f. injective f
[PROOF STEP]
unfolding injective_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>f. \<forall>x y. f x = f y \<longrightarrow> x = y
[PROOF STEP]
using finite_imp_inj_to_nat_seg[of "UNIV::'a set", unfolded inj_on_def]
[PROOF STATE]
proof (prove)
using this:
finite UNIV \<Longrightarrow> \<exists>f n. range f = {i. i < n} \<and> (\<forall>x\<in>UNIV. \<forall>y\<in>UNIV. f x = f y \<longrightarrow> x = y)

goal (1 subgoal):
 1. \<exists>f. \<forall>x y. f x = f y \<longrightarrow> x = y
[PROOF STEP]
by auto


[STATEMENT]
lemma nth_prime_partition':
  assumes "x \<ge> 2"
  shows   "\<exists>k. x \<in> {real (nth_prime k)..<real (nth_prime (Suc k))}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>k. x \<in> {real (nth_prime k)..<real (nth_prime (Suc k))}
[PROOF STEP]
by (rule strict_mono_sequence_partition)
     (auto simp: strict_mono_Suc_iff assms
           intro!: filterlim_real_sequentially filterlim_compose[OF _ nth_prime_at_top])


[STATEMENT]
lemma transpose_add: "A \<in> carrier_mat nr nc \<Longrightarrow> B \<in> carrier_mat nr nc
  \<Longrightarrow> transpose_mat (A + B) = transpose_mat A + transpose_mat B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A \<in> carrier_mat nr nc; B \<in> carrier_mat nr nc\<rbrakk> \<Longrightarrow> transpose_mat (A + B) = transpose_mat A + transpose_mat B
[PROOF STEP]
by (intro eq_matI, auto)


[STATEMENT]
lemma lfp_loop:
  assumes "finite (UNIV :: 'b set)" and "mono (\<tau> :: ('b set \<Rightarrow> 'b set))"
  shows "\<exists> n . lfp \<tau>  = (\<tau> ^^ n) {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>n. lfp \<tau> = (\<tau> ^^ n) {}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>n. lfp \<tau> = (\<tau> ^^ n) {}
[PROOF STEP]
have "\<exists>i. (\<tau> ^^ i) {} = (\<tau> ^^ (i + (1))) {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>i. (\<tau> ^^ i) {} = (\<tau> ^^ (i + 1)) {}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite UNIV
mono \<tau>

goal (1 subgoal):
 1. \<exists>i. (\<tau> ^^ i) {} = (\<tau> ^^ (i + 1)) {}
[PROOF STEP]
by (rule finite_fixp)
[PROOF STATE]
proof (state)
this:
\<exists>i. (\<tau> ^^ i) {} = (\<tau> ^^ (i + 1)) {}

goal (1 subgoal):
 1. \<exists>n. lfp \<tau> = (\<tau> ^^ n) {}
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
\<exists>i. (\<tau> ^^ i) {} = (\<tau> ^^ (i + 1)) {}
[PROOF STEP]
obtain i where " (\<tau> ^^ i) {} = (\<tau> ^^ (i + (1))) {}"
[PROOF STATE]
proof (prove)
using this:
\<exists>i. (\<tau> ^^ i) {} = (\<tau> ^^ (i + 1)) {}

goal (1 subgoal):
 1. (\<And>i. (\<tau> ^^ i) {} = (\<tau> ^^ (i + 1)) {} \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (erule exE)
[PROOF STATE]
proof (state)
this:
(\<tau> ^^ i) {} = (\<tau> ^^ (i + 1)) {}

goal (1 subgoal):
 1. \<exists>n. lfp \<tau> = (\<tau> ^^ n) {}
[PROOF STEP]
hence "(\<tau> ^^ i) {} = (\<tau> ^^ Suc i) {}"
[PROOF STATE]
proof (prove)
using this:
(\<tau> ^^ i) {} = (\<tau> ^^ (i + 1)) {}

goal (1 subgoal):
 1. (\<tau> ^^ i) {} = (\<tau> ^^ Suc i) {}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<tau> ^^ i) {} = (\<tau> ^^ Suc i) {}

goal (1 subgoal):
 1. \<exists>n. lfp \<tau> = (\<tau> ^^ n) {}
[PROOF STEP]
hence "(\<tau> ^^ Suc i) {} = (\<tau> ^^ i) {}"
[PROOF STATE]
proof (prove)
using this:
(\<tau> ^^ i) {} = (\<tau> ^^ Suc i) {}

goal (1 subgoal):
 1. (\<tau> ^^ Suc i) {} = (\<tau> ^^ i) {}
[PROOF STEP]
by (rule sym)
[PROOF STATE]
proof (state)
this:
(\<tau> ^^ Suc i) {} = (\<tau> ^^ i) {}

goal (1 subgoal):
 1. \<exists>n. lfp \<tau> = (\<tau> ^^ n) {}
[PROOF STEP]
hence "lfp \<tau> = (\<tau> ^^ i) {}"
[PROOF STATE]
proof (prove)
using this:
(\<tau> ^^ Suc i) {} = (\<tau> ^^ i) {}

goal (1 subgoal):
 1. lfp \<tau> = (\<tau> ^^ i) {}
[PROOF STEP]
by (simp add: assms(2) lfp_Kleene_iter)
[PROOF STATE]
proof (state)
this:
lfp \<tau> = (\<tau> ^^ i) {}

goal (1 subgoal):
 1. \<exists>n. lfp \<tau> = (\<tau> ^^ n) {}
[PROOF STEP]
thus "\<exists> n . lfp \<tau>  = (\<tau> ^^ n) {}"
[PROOF STATE]
proof (prove)
using this:
lfp \<tau> = (\<tau> ^^ i) {}

goal (1 subgoal):
 1. \<exists>n. lfp \<tau> = (\<tau> ^^ n) {}
[PROOF STEP]
by (rule exI)
[PROOF STATE]
proof (state)
this:
\<exists>n. lfp \<tau> = (\<tau> ^^ n) {}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma kronecker_distr_right:
  assumes "dim_row B = dim_row C" "dim_col B = dim_col C"
  shows "kronecker_product (B+C) A = kronecker_product B A + kronecker_product C A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. kronecker_product (B + C) A = kronecker_product B A + kronecker_product C A
[PROOF STEP]
unfolding kronecker_product_def Let_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat (dim_row (B + C) * dim_row A) (dim_col (B + C) * dim_col A) (\<lambda>(i, j). (B + C) $$ (i div dim_row A, j div dim_col A) * A $$ (i mod dim_row A, j mod dim_col A)) = mat (dim_row B * dim_row A) (dim_col B * dim_col A) (\<lambda>(i, j). B $$ (i div dim_row A, j div dim_col A) * A $$ (i mod dim_row A, j mod dim_col A)) + mat (dim_row C * dim_row A) (dim_col C * dim_col A) (\<lambda>(i, j). C $$ (i div dim_row A, j div dim_col A) * A $$ (i mod dim_row A, j mod dim_col A))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
dim_row B = dim_row C
dim_col B = dim_col C

goal (1 subgoal):
 1. mat (dim_row (B + C) * dim_row A) (dim_col (B + C) * dim_col A) (\<lambda>(i, j). (B + C) $$ (i div dim_row A, j div dim_col A) * A $$ (i mod dim_row A, j mod dim_col A)) = mat (dim_row B * dim_row A) (dim_col B * dim_col A) (\<lambda>(i, j). B $$ (i div dim_row A, j div dim_col A) * A $$ (i mod dim_row A, j mod dim_col A)) + mat (dim_row C * dim_row A) (dim_col C * dim_col A) (\<lambda>(i, j). C $$ (i div dim_row A, j div dim_col A) * A $$ (i mod dim_row A, j mod dim_col A))
[PROOF STEP]
by (auto simp add: mat_eq_iff less_mult_imp_div_less distrib_right)


[STATEMENT]
lemma sum_divisors_coprime_mult:
  assumes "coprime a (b :: nat)"
  shows   "(\<Sum>d | d dvd a * b. f d) = (\<Sum>r | r dvd a. \<Sum>s | s dvd b. f (r * s))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>d | d dvd a * b. f d) = (\<Sum>r | r dvd a. \<Sum>s | s dvd b. f (r * s))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>d | d dvd a * b. f d) = (\<Sum>r | r dvd a. \<Sum>s | s dvd b. f (r * s))
[PROOF STEP]
have "(\<Sum>r | r dvd a. \<Sum>s | s dvd b. f (r * s)) =
          (\<Sum>z\<in>{r. r dvd a} \<times> {s. s dvd b}. f (fst z * snd z))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>r | r dvd a. \<Sum>s | s dvd b. f (r * s)) = (\<Sum>z\<in>{r. r dvd a} \<times> {s. s dvd b}. f (fst z * snd z))
[PROOF STEP]
by (subst sum.cartesian_product) (simp add: case_prod_unfold)
[PROOF STATE]
proof (state)
this:
(\<Sum>r | r dvd a. \<Sum>s | s dvd b. f (r * s)) = (\<Sum>z\<in>{r. r dvd a} \<times> {s. s dvd b}. f (fst z * snd z))

goal (1 subgoal):
 1. (\<Sum>d | d dvd a * b. f d) = (\<Sum>r | r dvd a. \<Sum>s | s dvd b. f (r * s))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>r | r dvd a. \<Sum>s | s dvd b. f (r * s)) = (\<Sum>z\<in>{r. r dvd a} \<times> {s. s dvd b}. f (fst z * snd z))

goal (1 subgoal):
 1. (\<Sum>d | d dvd a * b. f d) = (\<Sum>r | r dvd a. \<Sum>s | s dvd b. f (r * s))
[PROOF STEP]
have "\<dots> = (\<Sum>d | d dvd a * b. f d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>z\<in>{r. r dvd a} \<times> {s. s dvd b}. f (fst z * snd z)) = (\<Sum>d | d dvd a * b. f d)
[PROOF STEP]
by (intro sum.reindex_bij_betw bij_betw_prod_divisors_coprime assms)
[PROOF STATE]
proof (state)
this:
(\<Sum>z\<in>{r. r dvd a} \<times> {s. s dvd b}. f (fst z * snd z)) = (\<Sum>d | d dvd a * b. f d)

goal (1 subgoal):
 1. (\<Sum>d | d dvd a * b. f d) = (\<Sum>r | r dvd a. \<Sum>s | s dvd b. f (r * s))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>r | r dvd a. \<Sum>s | s dvd b. f (r * s)) = (\<Sum>d | d dvd a * b. f d)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>r | r dvd a. \<Sum>s | s dvd b. f (r * s)) = (\<Sum>d | d dvd a * b. f d)

goal (1 subgoal):
 1. (\<Sum>d | d dvd a * b. f d) = (\<Sum>r | r dvd a. \<Sum>s | s dvd b. f (r * s))
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd a * b. f d) = (\<Sum>r | r dvd a. \<Sum>s | s dvd b. f (r * s))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sym_mod_diff_eq: "(a symmod c - b symmod c) symmod c = (a - b) symmod c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a symmod c - b symmod c) symmod c = (a - b) symmod c
[PROOF STEP]
unfolding sym_mod_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_mod.inv_M c ((poly_mod.inv_M c (a mod c) - poly_mod.inv_M c (b mod c)) mod c) = poly_mod.inv_M c ((a - b) mod c)
[PROOF STEP]
by (metis mod_diff_cong mod_mod_trivial poly_mod.M_def poly_mod.M_inv_M_id)


[STATEMENT]
lemma of_nat_prime_sum_upto: "of_nat (prime_sum_upto f x) = prime_sum_upto (\<lambda>p. of_nat (f p)) x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_nat (prime_sum_upto f x) = prime_sum_upto (\<lambda>p. of_nat (f p)) x
[PROOF STEP]
by (simp add: prime_sum_upto_def)


[STATEMENT]
lemma mat_conj_smult:
  assumes "A\<in> carrier_mat n n"
  and "U\<in> carrier_mat n n"
  and "B \<in> carrier_mat n n"
  and "A = U * B * (Complex_Matrix.adjoint U)"
shows "x  \<cdot>\<^sub>m A = U * (x  \<cdot>\<^sub>m B) * (Complex_Matrix.adjoint U)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<cdot>\<^sub>m A = U * (x \<cdot>\<^sub>m B) * Complex_Matrix.adjoint U
[PROOF STEP]
using assms mult_smult_distrib
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n n
U \<in> carrier_mat n n
B \<in> carrier_mat n n
A = U * B * Complex_Matrix.adjoint U
\<lbrakk>?A \<in> carrier_mat ?nr ?n; ?B \<in> carrier_mat ?n ?nc\<rbrakk> \<Longrightarrow> ?A * (?k \<cdot>\<^sub>m ?B) = ?k \<cdot>\<^sub>m (?A * ?B)

goal (1 subgoal):
 1. x \<cdot>\<^sub>m A = U * (x \<cdot>\<^sub>m B) * Complex_Matrix.adjoint U
[PROOF STEP]
by (smt (z3) adjoint_dim' mult_carrier_mat mult_smult_assoc_mat)


[STATEMENT]
lemma finite_exponents:
  "finite {i. 2 ^ i \<le> (n::nat)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {i. 2 ^ i \<le> n}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. finite {i. 2 ^ i \<le> n}
[PROOF STEP]
have "{i::nat. 2 ^ i \<le> n} \<subseteq> {0..n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {i. 2 ^ i \<le> n} \<subseteq> {0..n}
[PROOF STEP]
using dual_order.trans
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?b \<le> ?a; ?c \<le> ?b\<rbrakk> \<Longrightarrow> ?c \<le> ?a

goal (1 subgoal):
 1. {i. 2 ^ i \<le> n} \<subseteq> {0..n}
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
{i. 2 ^ i \<le> n} \<subseteq> {0..n}

goal (1 subgoal):
 1. finite {i. 2 ^ i \<le> n}
[PROOF STEP]
from finite_subset[OF this]
[PROOF STATE]
proof (chain)
picking this:
finite {0..n} \<Longrightarrow> finite {i. 2 ^ i \<le> n}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
finite {0..n} \<Longrightarrow> finite {i. 2 ^ i \<le> n}

goal (1 subgoal):
 1. finite {i. 2 ^ i \<le> n}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
finite {i. 2 ^ i \<le> n}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma suminf_indicator:
  assumes "disjoint_family A"
  shows "(\<Sum>n. indicator (A n) x :: ennreal) = indicator (\<Union>i. A i) x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>n. indicator (A n) x) = indicator (\<Union> (range A)) x
[PROOF STEP]
proof cases
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ?P \<Longrightarrow> (\<Sum>n. indicator (A n) x) = indicator (\<Union> (range A)) x
 2. \<not> ?P \<Longrightarrow> (\<Sum>n. indicator (A n) x) = indicator (\<Union> (range A)) x
[PROOF STEP]
assume *: "x \<in> (\<Union>i. A i)"
[PROOF STATE]
proof (state)
this:
x \<in> \<Union> (range A)

goal (2 subgoals):
 1. ?P \<Longrightarrow> (\<Sum>n. indicator (A n) x) = indicator (\<Union> (range A)) x
 2. \<not> ?P \<Longrightarrow> (\<Sum>n. indicator (A n) x) = indicator (\<Union> (range A)) x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> \<Union> (range A)
[PROOF STEP]
obtain i where "x \<in> A i"
[PROOF STATE]
proof (prove)
using this:
x \<in> \<Union> (range A)

goal (1 subgoal):
 1. (\<And>i. x \<in> A i \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> A i

goal (2 subgoals):
 1. ?P \<Longrightarrow> (\<Sum>n. indicator (A n) x) = indicator (\<Union> (range A)) x
 2. \<not> ?P \<Longrightarrow> (\<Sum>n. indicator (A n) x) = indicator (\<Union> (range A)) x
[PROOF STEP]
from suminf_cmult_indicator[OF assms(1), OF \<open>x \<in> A i\<close>, of "\<lambda>k. 1"]
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>n. 1 * indicator (A n) x) = 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>n. 1 * indicator (A n) x) = 1

goal (1 subgoal):
 1. (\<Sum>n. indicator (A n) x) = indicator (\<Union> (range A)) x
[PROOF STEP]
using *
[PROOF STATE]
proof (prove)
using this:
(\<Sum>n. 1 * indicator (A n) x) = 1
x \<in> \<Union> (range A)

goal (1 subgoal):
 1. (\<Sum>n. indicator (A n) x) = indicator (\<Union> (range A)) x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>n. indicator (A n) x) = indicator (\<Union> (range A)) x

goal (1 subgoal):
 1. x \<notin> \<Union> (range A) \<Longrightarrow> (\<Sum>n. indicator (A n) x) = indicator (\<Union> (range A)) x
[PROOF STEP]
qed simp


[STATEMENT]
lemma cos_30: "cos (pi / 6) = sqrt 3/2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos (pi / 6) = sqrt 3 / 2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. cos (pi / 6) = sqrt 3 / 2
[PROOF STEP]
let ?c = "cos (pi / 6)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. cos (pi / 6) = sqrt 3 / 2
[PROOF STEP]
let ?s = "sin (pi / 6)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. cos (pi / 6) = sqrt 3 / 2
[PROOF STEP]
have pos_c: "0 < ?c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < cos (pi / 6)
[PROOF STEP]
by (rule cos_gt_zero) simp_all
[PROOF STATE]
proof (state)
this:
0 < cos (pi / 6)

goal (1 subgoal):
 1. cos (pi / 6) = sqrt 3 / 2
[PROOF STEP]
have "0 = cos (pi / 6 + pi / 6 + pi / 6)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 = cos (pi / 6 + pi / 6 + pi / 6)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 = cos (pi / 6 + pi / 6 + pi / 6)

goal (1 subgoal):
 1. cos (pi / 6) = sqrt 3 / 2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
0 = cos (pi / 6 + pi / 6 + pi / 6)

goal (1 subgoal):
 1. cos (pi / 6) = sqrt 3 / 2
[PROOF STEP]
have "\<dots> = (?c * ?c - ?s * ?s) * ?c - (?s * ?c + ?c * ?s) * ?s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos (pi / 6 + pi / 6 + pi / 6) = (cos (pi / 6) * cos (pi / 6) - sin (pi / 6) * sin (pi / 6)) * cos (pi / 6) - (sin (pi / 6) * cos (pi / 6) + cos (pi / 6) * sin (pi / 6)) * sin (pi / 6)
[PROOF STEP]
by (simp only: cos_add sin_add)
[PROOF STATE]
proof (state)
this:
cos (pi / 6 + pi / 6 + pi / 6) = (cos (pi / 6) * cos (pi / 6) - sin (pi / 6) * sin (pi / 6)) * cos (pi / 6) - (sin (pi / 6) * cos (pi / 6) + cos (pi / 6) * sin (pi / 6)) * sin (pi / 6)

goal (1 subgoal):
 1. cos (pi / 6) = sqrt 3 / 2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
cos (pi / 6 + pi / 6 + pi / 6) = (cos (pi / 6) * cos (pi / 6) - sin (pi / 6) * sin (pi / 6)) * cos (pi / 6) - (sin (pi / 6) * cos (pi / 6) + cos (pi / 6) * sin (pi / 6)) * sin (pi / 6)

goal (1 subgoal):
 1. cos (pi / 6) = sqrt 3 / 2
[PROOF STEP]
have "\<dots> = ?c * (?c\<^sup>2 - 3 * ?s\<^sup>2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cos (pi / 6) * cos (pi / 6) - sin (pi / 6) * sin (pi / 6)) * cos (pi / 6) - (sin (pi / 6) * cos (pi / 6) + cos (pi / 6) * sin (pi / 6)) * sin (pi / 6) = cos (pi / 6) * ((cos (pi / 6))\<^sup>2 - 3 * (sin (pi / 6))\<^sup>2)
[PROOF STEP]
by (simp add: algebra_simps power2_eq_square)
[PROOF STATE]
proof (state)
this:
(cos (pi / 6) * cos (pi / 6) - sin (pi / 6) * sin (pi / 6)) * cos (pi / 6) - (sin (pi / 6) * cos (pi / 6) + cos (pi / 6) * sin (pi / 6)) * sin (pi / 6) = cos (pi / 6) * ((cos (pi / 6))\<^sup>2 - 3 * (sin (pi / 6))\<^sup>2)

goal (1 subgoal):
 1. cos (pi / 6) = sqrt 3 / 2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
0 = cos (pi / 6) * ((cos (pi / 6))\<^sup>2 - 3 * (sin (pi / 6))\<^sup>2)
[PROOF STEP]
have "?c\<^sup>2 = (sqrt 3/2)\<^sup>2"
[PROOF STATE]
proof (prove)
using this:
0 = cos (pi / 6) * ((cos (pi / 6))\<^sup>2 - 3 * (sin (pi / 6))\<^sup>2)

goal (1 subgoal):
 1. (cos (pi / 6))\<^sup>2 = (sqrt 3 / 2)\<^sup>2
[PROOF STEP]
using pos_c
[PROOF STATE]
proof (prove)
using this:
0 = cos (pi / 6) * ((cos (pi / 6))\<^sup>2 - 3 * (sin (pi / 6))\<^sup>2)
0 < cos (pi / 6)

goal (1 subgoal):
 1. (cos (pi / 6))\<^sup>2 = (sqrt 3 / 2)\<^sup>2
[PROOF STEP]
by (simp add: sin_squared_eq power_divide)
[PROOF STATE]
proof (state)
this:
(cos (pi / 6))\<^sup>2 = (sqrt 3 / 2)\<^sup>2

goal (1 subgoal):
 1. cos (pi / 6) = sqrt 3 / 2
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(cos (pi / 6))\<^sup>2 = (sqrt 3 / 2)\<^sup>2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(cos (pi / 6))\<^sup>2 = (sqrt 3 / 2)\<^sup>2

goal (1 subgoal):
 1. cos (pi / 6) = sqrt 3 / 2
[PROOF STEP]
using pos_c [THEN order_less_imp_le]
[PROOF STATE]
proof (prove)
using this:
(cos (pi / 6))\<^sup>2 = (sqrt 3 / 2)\<^sup>2
0 \<le> cos (pi / 6)

goal (1 subgoal):
 1. cos (pi / 6) = sqrt 3 / 2
[PROOF STEP]
by (rule power2_eq_imp_eq) simp
[PROOF STATE]
proof (state)
this:
cos (pi / 6) = sqrt 3 / 2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sum_choose_diagonal:
  assumes "m \<le> n"
  shows "(\<Sum>k\<le>m. (n - k) choose (m - k)) = Suc n choose m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k\<le>m. n - k choose (m - k)) = Suc n choose m
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>k\<le>m. n - k choose (m - k)) = Suc n choose m
[PROOF STEP]
have "(\<Sum>k\<le>m. (n-k) choose (m - k)) = (\<Sum>k\<le>m. (n - m + k) choose k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k\<le>m. n - k choose (m - k)) = (\<Sum>k\<le>m. n - m + k choose k)
[PROOF STEP]
using sum.atLeastAtMost_rev [of "\<lambda>k. (n - k) choose (m - k)" 0 m] assms
[PROOF STATE]
proof (prove)
using this:
(\<Sum>k = 0..m. n - k choose (m - k)) = (\<Sum>i = 0..m. n - (m + 0 - i) choose (m - (m + 0 - i)))
m \<le> n

goal (1 subgoal):
 1. (\<Sum>k\<le>m. n - k choose (m - k)) = (\<Sum>k\<le>m. n - m + k choose k)
[PROOF STEP]
by (simp add: atMost_atLeast0)
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<le>m. n - k choose (m - k)) = (\<Sum>k\<le>m. n - m + k choose k)

goal (1 subgoal):
 1. (\<Sum>k\<le>m. n - k choose (m - k)) = Suc n choose m
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<le>m. n - k choose (m - k)) = (\<Sum>k\<le>m. n - m + k choose k)

goal (1 subgoal):
 1. (\<Sum>k\<le>m. n - k choose (m - k)) = Suc n choose m
[PROOF STEP]
have "\<dots> = Suc (n - m + m) choose m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k\<le>m. n - m + k choose k) = Suc (n - m + m) choose m
[PROOF STEP]
by (rule sum_choose_lower)
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<le>m. n - m + k choose k) = Suc (n - m + m) choose m

goal (1 subgoal):
 1. (\<Sum>k\<le>m. n - k choose (m - k)) = Suc n choose m
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<le>m. n - m + k choose k) = Suc (n - m + m) choose m

goal (1 subgoal):
 1. (\<Sum>k\<le>m. n - k choose (m - k)) = Suc n choose m
[PROOF STEP]
have "\<dots> = Suc n choose m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc (n - m + m) choose m = Suc n choose m
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
m \<le> n

goal (1 subgoal):
 1. Suc (n - m + m) choose m = Suc n choose m
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Suc (n - m + m) choose m = Suc n choose m

goal (1 subgoal):
 1. (\<Sum>k\<le>m. n - k choose (m - k)) = Suc n choose m
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>k\<le>m. n - k choose (m - k)) = Suc n choose m
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>k\<le>m. n - k choose (m - k)) = Suc n choose m

goal (1 subgoal):
 1. (\<Sum>k\<le>m. n - k choose (m - k)) = Suc n choose m
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<le>m. n - k choose (m - k)) = Suc n choose m

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma emeasure_interval_measure_Ioc_eq:
  "(\<And>x y. x \<le> y \<Longrightarrow> F x \<le> F y) \<Longrightarrow> (\<And>a. continuous (at_right a) F) \<Longrightarrow>
    emeasure (interval_measure F) {a <.. b} = (if a \<le> b then F b - F a else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<And>x y. x \<le> y \<Longrightarrow> F x \<le> F y; \<And>a. continuous (at_right a) F\<rbrakk> \<Longrightarrow> emeasure (interval_measure F) {a<..b} = ennreal (if a \<le> b then F b - F a else 0)
[PROOF STEP]
using emeasure_interval_measure_Ioc[of a b F]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>a \<le> b; \<And>x y. x \<le> y \<Longrightarrow> F x \<le> F y; \<And>a. continuous (at_right a) F\<rbrakk> \<Longrightarrow> emeasure (interval_measure F) {a<..b} = ennreal (F b - F a)

goal (1 subgoal):
 1. \<lbrakk>\<And>x y. x \<le> y \<Longrightarrow> F x \<le> F y; \<And>a. continuous (at_right a) F\<rbrakk> \<Longrightarrow> emeasure (interval_measure F) {a<..b} = ennreal (if a \<le> b then F b - F a else 0)
[PROOF STEP]
by auto


[STATEMENT]
lemma cot_altdef: "cot x = inverse (tan x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cot x = inverse (tan x)
[PROOF STEP]
by (simp add: cot_def tan_def)


[STATEMENT]
lemma iso_homology_group_prod_deformation:
  assumes "homotopic_with (\<lambda>x. True) X X id f" and "f ` (topspace X) \<subseteq> S"
  shows "homology_group p (subtopology X S)
      \<cong> DirProd (homology_group p X) (relative_homology_group(p + 1) X S)"
    (is "?G \<cong> DirProd ?H ?R")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. homology_group p (subtopology X S) \<cong> homology_group p X \<times>\<times> relative_homology_group (p + 1) X S
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. homology_group p (subtopology X S) \<cong> homology_group p X \<times>\<times> relative_homology_group (p + 1) X S
[PROOF STEP]
obtain H K where HK:
    "(\<lambda>(x, y). x \<otimes>\<^bsub>?G\<^esub> y)
     \<in> Group.iso (subgroup_generated (?G) H \<times>\<times> subgroup_generated (?G) K) (?G)"
    "hom_boundary (p + 1) X S \<in> Group.iso (?R) (subgroup_generated (?G) H)"
    "hom_induced p (subtopology X S) {} X {} id \<in> Group.iso (subgroup_generated (?G) K) (?H)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>H K. \<lbrakk>(\<lambda>(x, y). x \<otimes>\<^bsub>homology_group p (subtopology X S)\<^esub> y) \<in> Group.iso (subgroup_generated (homology_group p (subtopology X S)) H \<times>\<times> subgroup_generated (homology_group p (subtopology X S)) K) (homology_group p (subtopology X S)); hom_boundary (p + 1) X S \<in> Group.iso (relative_homology_group (p + 1) X S) (subgroup_generated (homology_group p (subtopology X S)) H); hom_induced p (subtopology X S) {} X {} id \<in> Group.iso (subgroup_generated (homology_group p (subtopology X S)) K) (homology_group p X)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (blast intro: group_isomorphisms_homology_group_prod_deformation [OF assms])
[PROOF STATE]
proof (state)
this:
(\<lambda>(x, y). x \<otimes>\<^bsub>homology_group p (subtopology X S)\<^esub> y) \<in> Group.iso (subgroup_generated (homology_group p (subtopology X S)) H \<times>\<times> subgroup_generated (homology_group p (subtopology X S)) K) (homology_group p (subtopology X S))
hom_boundary (p + 1) X S \<in> Group.iso (relative_homology_group (p + 1) X S) (subgroup_generated (homology_group p (subtopology X S)) H)
hom_induced p (subtopology X S) {} X {} id \<in> Group.iso (subgroup_generated (homology_group p (subtopology X S)) K) (homology_group p X)

goal (1 subgoal):
 1. homology_group p (subtopology X S) \<cong> homology_group p X \<times>\<times> relative_homology_group (p + 1) X S
[PROOF STEP]
have "?G \<cong> DirProd (subgroup_generated (?G) H) (subgroup_generated (?G) K)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. homology_group p (subtopology X S) \<cong> subgroup_generated (homology_group p (subtopology X S)) H \<times>\<times> subgroup_generated (homology_group p (subtopology X S)) K
[PROOF STEP]
by (meson DirProd_group HK(1) group.group_subgroup_generated group.iso_sym group_relative_homology_group is_isoI)
[PROOF STATE]
proof (state)
this:
homology_group p (subtopology X S) \<cong> subgroup_generated (homology_group p (subtopology X S)) H \<times>\<times> subgroup_generated (homology_group p (subtopology X S)) K

goal (1 subgoal):
 1. homology_group p (subtopology X S) \<cong> homology_group p X \<times>\<times> relative_homology_group (p + 1) X S
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
homology_group p (subtopology X S) \<cong> subgroup_generated (homology_group p (subtopology X S)) H \<times>\<times> subgroup_generated (homology_group p (subtopology X S)) K

goal (1 subgoal):
 1. homology_group p (subtopology X S) \<cong> homology_group p X \<times>\<times> relative_homology_group (p + 1) X S
[PROOF STEP]
have "\<dots> \<cong> DirProd ?R ?H"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. subgroup_generated (homology_group p (subtopology X S)) H \<times>\<times> subgroup_generated (homology_group p (subtopology X S)) K \<cong> relative_homology_group (p + 1) X S \<times>\<times> homology_group p X
[PROOF STEP]
by (meson HK group.DirProd_iso_trans group.group_subgroup_generated group.iso_sym group_relative_homology_group is_isoI)
[PROOF STATE]
proof (state)
this:
subgroup_generated (homology_group p (subtopology X S)) H \<times>\<times> subgroup_generated (homology_group p (subtopology X S)) K \<cong> relative_homology_group (p + 1) X S \<times>\<times> homology_group p X

goal (1 subgoal):
 1. homology_group p (subtopology X S) \<cong> homology_group p X \<times>\<times> relative_homology_group (p + 1) X S
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
subgroup_generated (homology_group p (subtopology X S)) H \<times>\<times> subgroup_generated (homology_group p (subtopology X S)) K \<cong> relative_homology_group (p + 1) X S \<times>\<times> homology_group p X

goal (1 subgoal):
 1. homology_group p (subtopology X S) \<cong> homology_group p X \<times>\<times> relative_homology_group (p + 1) X S
[PROOF STEP]
have "\<dots>  \<cong> DirProd ?H ?R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. relative_homology_group (p + 1) X S \<times>\<times> homology_group p X \<cong> homology_group p X \<times>\<times> relative_homology_group (p + 1) X S
[PROOF STEP]
by (simp add: DirProd_commute_iso)
[PROOF STATE]
proof (state)
this:
relative_homology_group (p + 1) X S \<times>\<times> homology_group p X \<cong> homology_group p X \<times>\<times> relative_homology_group (p + 1) X S

goal (1 subgoal):
 1. homology_group p (subtopology X S) \<cong> homology_group p X \<times>\<times> relative_homology_group (p + 1) X S
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
homology_group p (subtopology X S) \<cong> homology_group p X \<times>\<times> relative_homology_group (p + 1) X S
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
homology_group p (subtopology X S) \<cong> homology_group p X \<times>\<times> relative_homology_group (p + 1) X S

goal (1 subgoal):
 1. homology_group p (subtopology X S) \<cong> homology_group p X \<times>\<times> relative_homology_group (p + 1) X S
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
homology_group p (subtopology X S) \<cong> homology_group p X \<times>\<times> relative_homology_group (p + 1) X S

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma complex_quadratic_equation_monic_distinct_roots:
  fixes b c :: complex
  assumes "b\<^sup>2 - 4*c \<noteq> 0"
  shows "\<exists> k\<^sub>1 k\<^sub>2. k\<^sub>1 \<noteq> k\<^sub>2 \<and> k\<^sub>1\<^sup>2 + b*k\<^sub>1 + c = 0 \<and> k\<^sub>2\<^sup>2 + b*k\<^sub>2 + c = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>k\<^sub>1 k\<^sub>2. k\<^sub>1 \<noteq> k\<^sub>2 \<and> k\<^sub>1\<^sup>2 + b * k\<^sub>1 + c = 0 \<and> k\<^sub>2\<^sup>2 + b * k\<^sub>2 + c = 0
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>k\<^sub>1 k\<^sub>2. k\<^sub>1 \<noteq> k\<^sub>2 \<and> k\<^sub>1\<^sup>2 + b * k\<^sub>1 + c = 0 \<and> k\<^sub>2\<^sup>2 + b * k\<^sub>2 + c = 0
[PROOF STEP]
let ?\<xi>1 = "(-b + ccsqrt(b\<^sup>2 - 4*c)) / 2"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>k\<^sub>1 k\<^sub>2. k\<^sub>1 \<noteq> k\<^sub>2 \<and> k\<^sub>1\<^sup>2 + b * k\<^sub>1 + c = 0 \<and> k\<^sub>2\<^sup>2 + b * k\<^sub>2 + c = 0
[PROOF STEP]
let ?\<xi>2 = "(-b - ccsqrt(b\<^sup>2 - 4*c)) / 2"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>k\<^sub>1 k\<^sub>2. k\<^sub>1 \<noteq> k\<^sub>2 \<and> k\<^sub>1\<^sup>2 + b * k\<^sub>1 + c = 0 \<and> k\<^sub>2\<^sup>2 + b * k\<^sub>2 + c = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>k\<^sub>1 k\<^sub>2. k\<^sub>1 \<noteq> k\<^sub>2 \<and> k\<^sub>1\<^sup>2 + b * k\<^sub>1 + c = 0 \<and> k\<^sub>2\<^sup>2 + b * k\<^sub>2 + c = 0
[PROOF STEP]
apply (rule_tac x="?\<xi>1" in exI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>k\<^sub>2. (- b + ccsqrt (b\<^sup>2 - 4 * c)) / 2 \<noteq> k\<^sub>2 \<and> ((- b + ccsqrt (b\<^sup>2 - 4 * c)) / 2)\<^sup>2 + b * ((- b + ccsqrt (b\<^sup>2 - 4 * c)) / 2) + c = 0 \<and> k\<^sub>2\<^sup>2 + b * k\<^sub>2 + c = 0
[PROOF STEP]
apply (rule_tac x="?\<xi>2" in exI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (- b + ccsqrt (b\<^sup>2 - 4 * c)) / 2 \<noteq> (- b - ccsqrt (b\<^sup>2 - 4 * c)) / 2 \<and> ((- b + ccsqrt (b\<^sup>2 - 4 * c)) / 2)\<^sup>2 + b * ((- b + ccsqrt (b\<^sup>2 - 4 * c)) / 2) + c = 0 \<and> ((- b - ccsqrt (b\<^sup>2 - 4 * c)) / 2)\<^sup>2 + b * ((- b - ccsqrt (b\<^sup>2 - 4 * c)) / 2) + c = 0
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
b\<^sup>2 - 4 * c \<noteq> 0

goal (1 subgoal):
 1. (- b + ccsqrt (b\<^sup>2 - 4 * c)) / 2 \<noteq> (- b - ccsqrt (b\<^sup>2 - 4 * c)) / 2 \<and> ((- b + ccsqrt (b\<^sup>2 - 4 * c)) / 2)\<^sup>2 + b * ((- b + ccsqrt (b\<^sup>2 - 4 * c)) / 2) + c = 0 \<and> ((- b - ccsqrt (b\<^sup>2 - 4 * c)) / 2)\<^sup>2 + b * ((- b - ccsqrt (b\<^sup>2 - 4 * c)) / 2) + c = 0
[PROOF STEP]
using complex_quadratic_equation_monic_roots[of ?\<xi>1 b c]
[PROOF STATE]
proof (prove)
using this:
b\<^sup>2 - 4 * c \<noteq> 0
(- b + ccsqrt (b\<^sup>2 - 4 * c)) / 2 = (- b + ccsqrt (b\<^sup>2 - 4 * c)) / 2 \<or> (- b + ccsqrt (b\<^sup>2 - 4 * c)) / 2 = (- b - ccsqrt (b\<^sup>2 - 4 * c)) / 2 \<Longrightarrow> ((- b + ccsqrt (b\<^sup>2 - 4 * c)) / 2)\<^sup>2 + b * ((- b + ccsqrt (b\<^sup>2 - 4 * c)) / 2) + c = 0

goal (1 subgoal):
 1. (- b + ccsqrt (b\<^sup>2 - 4 * c)) / 2 \<noteq> (- b - ccsqrt (b\<^sup>2 - 4 * c)) / 2 \<and> ((- b + ccsqrt (b\<^sup>2 - 4 * c)) / 2)\<^sup>2 + b * ((- b + ccsqrt (b\<^sup>2 - 4 * c)) / 2) + c = 0 \<and> ((- b - ccsqrt (b\<^sup>2 - 4 * c)) / 2)\<^sup>2 + b * ((- b - ccsqrt (b\<^sup>2 - 4 * c)) / 2) + c = 0
[PROOF STEP]
using complex_quadratic_equation_monic_roots[of ?\<xi>2 b c]
[PROOF STATE]
proof (prove)
using this:
b\<^sup>2 - 4 * c \<noteq> 0
(- b + ccsqrt (b\<^sup>2 - 4 * c)) / 2 = (- b + ccsqrt (b\<^sup>2 - 4 * c)) / 2 \<or> (- b + ccsqrt (b\<^sup>2 - 4 * c)) / 2 = (- b - ccsqrt (b\<^sup>2 - 4 * c)) / 2 \<Longrightarrow> ((- b + ccsqrt (b\<^sup>2 - 4 * c)) / 2)\<^sup>2 + b * ((- b + ccsqrt (b\<^sup>2 - 4 * c)) / 2) + c = 0
(- b - ccsqrt (b\<^sup>2 - 4 * c)) / 2 = (- b + ccsqrt (b\<^sup>2 - 4 * c)) / 2 \<or> (- b - ccsqrt (b\<^sup>2 - 4 * c)) / 2 = (- b - ccsqrt (b\<^sup>2 - 4 * c)) / 2 \<Longrightarrow> ((- b - ccsqrt (b\<^sup>2 - 4 * c)) / 2)\<^sup>2 + b * ((- b - ccsqrt (b\<^sup>2 - 4 * c)) / 2) + c = 0

goal (1 subgoal):
 1. (- b + ccsqrt (b\<^sup>2 - 4 * c)) / 2 \<noteq> (- b - ccsqrt (b\<^sup>2 - 4 * c)) / 2 \<and> ((- b + ccsqrt (b\<^sup>2 - 4 * c)) / 2)\<^sup>2 + b * ((- b + ccsqrt (b\<^sup>2 - 4 * c)) / 2) + c = 0 \<and> ((- b - ccsqrt (b\<^sup>2 - 4 * c)) / 2)\<^sup>2 + b * ((- b - ccsqrt (b\<^sup>2 - 4 * c)) / 2) + c = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<exists>k\<^sub>1 k\<^sub>2. k\<^sub>1 \<noteq> k\<^sub>2 \<and> k\<^sub>1\<^sup>2 + b * k\<^sub>1 + c = 0 \<and> k\<^sub>2\<^sup>2 + b * k\<^sub>2 + c = 0

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mono_cInf:
  fixes f :: "'a::conditionally_complete_lattice \<Rightarrow> 'b::conditionally_complete_lattice"
  assumes "mono f" "A \<noteq> {}" "bdd_below A"
  shows "f(Inf A) \<le> Inf (f`A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f (\<Sqinter> A) \<le> \<Sqinter> (f ` A)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
mono f
A \<noteq> {}
bdd_below A

goal (1 subgoal):
 1. f (\<Sqinter> A) \<le> \<Sqinter> (f ` A)
[PROOF STEP]
by (simp add: cINF_greatest cInf_lower monoD)


[STATEMENT]
lemma \<pi>_nonneg [intro]: "\<pi> x \<ge> 0"
  and \<theta>_nonneg [intro]: "\<theta> x \<ge> 0"
  and primes_M_nonneg [intro]: "\<MM> x \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> \<pi> x &&& 0 \<le> \<theta> x &&& 0 \<le> \<MM> x
[PROOF STEP]
unfolding primes_pi_def primes_theta_def primes_M_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> prime_sum_upto (\<lambda>p. 1) x &&& 0 \<le> prime_sum_upto (\<lambda>p. ln (real p)) x &&& 0 \<le> prime_sum_upto (\<lambda>p. ln (real p) / real p) x
[PROOF STEP]
by (rule prime_sum_upto_nonneg; simp)+


[STATEMENT]
lemma "0.5 \<le> x \<and> x \<le> 4.5 \<Longrightarrow> \<bar> arctan x - 0.91 \<bar> < 0.455"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 5 / 10 \<le> x \<and> x \<le> 45 / 10 \<Longrightarrow> \<bar>arctan x - 91 / 10\<^sup>2\<bar> < 455 / 10 ^ 3
[PROOF STEP]
by (approximation 10)


[STATEMENT]
lemma matrix_index:
  assumes wf1: "mat (row_length m1) n m1"
      and wf2: "mat n nc m2"
        and i: "i < (row_length m1)"
        and j: "j < nc"
 shows  "matrix_mult  m1 m2 ! j ! i
                 = scalar_product  (row m1 i) (col m2 j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (m1 \<circ> m2) ! j ! i = scalar_product (row m1 i) (col m2 j)
[PROOF STEP]
using wf1 wf2 i j ma scalar_product_def
[PROOF STATE]
proof (prove)
using this:
mat (row_length m1) n m1
mat n nc m2
i < row_length m1
j < nc
\<lbrakk>mat ?nr ?n ?m1.0; mat ?n ?nc ?m2.0; ?i < ?nr; ?j < ?nc\<rbrakk> \<Longrightarrow> mat_multI zer (+) (*) ?nr ?m1.0 ?m2.0 ! ?j ! ?i = scalar_prodI zer (+) (*) (row ?m1.0 ?i) (col ?m2.0 ?j)
scalar_product ?v ?w = scalar_prodI zer (+) (*) ?v ?w

goal (1 subgoal):
 1. (m1 \<circ> m2) ! j ! i = scalar_product (row m1 i) (col m2 j)
[PROOF STEP]
by auto


[STATEMENT]
theorem Bex_def': "(\<exists>x\<in>S. P x) \<longleftrightarrow> (\<exists>x. x \<in> S \<and> P x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<exists>x\<in>S. P x) = (\<exists>x. x \<in> S \<and> P x)
[PROOF STEP]
by auto


[STATEMENT]
lemma power2_norm_eq_cinner:
  shows "(complex_of_real (norm x))\<^sup>2 = (cinner x x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (complex_of_real (norm x))\<^sup>2 = cinner x x
[PROOF STEP]
by (smt (verit, del_insts) Im_complex_of_real Re_complex_of_real cinner_gt_zero_iff cinner_zero_right cmod_def complex_eq_0 complex_eq_iff less_complex_def local.norm_eq_sqrt_cinner of_real_power real_sqrt_abs real_sqrt_pow2_iff zero_complex.sel(1))


[STATEMENT]
lemma face_of_halfspace_ge:
  fixes a :: "'n::euclidean_space"
  shows "F face_of {x. a \<bullet> x \<ge> b} \<longleftrightarrow>
         F = {} \<or> F = {x. a \<bullet> x = b} \<or> F = {x. a \<bullet> x \<ge> b}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (F face_of {x. b \<le> a \<bullet> x}) = (F = {} \<or> F = {x. a \<bullet> x = b} \<or> F = {x. b \<le> a \<bullet> x})
[PROOF STEP]
using face_of_halfspace_le [of F "-a" "-b"]
[PROOF STATE]
proof (prove)
using this:
(F face_of {x. - a \<bullet> x \<le> - b}) = (F = {} \<or> F = {x. - a \<bullet> x = - b} \<or> F = {x. - a \<bullet> x \<le> - b})

goal (1 subgoal):
 1. (F face_of {x. b \<le> a \<bullet> x}) = (F = {} \<or> F = {x. a \<bullet> x = b} \<or> F = {x. b \<le> a \<bullet> x})
[PROOF STEP]
by simp


[STATEMENT]
lemma hol_pal_lem0:
  assumes "d \<bullet> a \<le> k" "k \<le> d \<bullet> b"
  obtains c where
     "c \<in> closed_segment a b" "d \<bullet> c = k"
     "\<And>z. z \<in> closed_segment a c \<Longrightarrow> d \<bullet> z \<le> k"
     "\<And>z. z \<in> closed_segment c b \<Longrightarrow> k \<le> d \<bullet> z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>c. \<lbrakk>c \<in> closed_segment a b; d \<bullet> c = k; \<And>z. z \<in> closed_segment a c \<Longrightarrow> d \<bullet> z \<le> k; \<And>z. z \<in> closed_segment c b \<Longrightarrow> k \<le> d \<bullet> z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>c. \<lbrakk>c \<in> closed_segment a b; d \<bullet> c = k; \<And>z. z \<in> closed_segment a c \<Longrightarrow> d \<bullet> z \<le> k; \<And>z. z \<in> closed_segment c b \<Longrightarrow> k \<le> d \<bullet> z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
obtain c where cin: "c \<in> closed_segment a b" and keq: "k = d \<bullet> c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>c. \<lbrakk>c \<in> closed_segment a b; k = d \<bullet> c\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using connected_ivt_hyperplane [of "closed_segment a b" a b d k]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>connected (closed_segment a b); a \<in> closed_segment a b; b \<in> closed_segment a b; d \<bullet> a \<le> k; k \<le> d \<bullet> b\<rbrakk> \<Longrightarrow> \<exists>z\<in>closed_segment a b. d \<bullet> z = k

goal (1 subgoal):
 1. (\<And>c. \<lbrakk>c \<in> closed_segment a b; k = d \<bullet> c\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: assms)
[PROOF STATE]
proof (state)
this:
c \<in> closed_segment a b
k = d \<bullet> c

goal (1 subgoal):
 1. (\<And>c. \<lbrakk>c \<in> closed_segment a b; d \<bullet> c = k; \<And>z. z \<in> closed_segment a c \<Longrightarrow> d \<bullet> z \<le> k; \<And>z. z \<in> closed_segment c b \<Longrightarrow> k \<le> d \<bullet> z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "closed_segment a c \<subseteq> {z. d \<bullet> z \<le> k}"  "closed_segment c b \<subseteq> {z. k \<le> d \<bullet> z}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. closed_segment a c \<subseteq> {z. d \<bullet> z \<le> k} &&& closed_segment c b \<subseteq> {z. k \<le> d \<bullet> z}
[PROOF STEP]
unfolding segment_convex_hull
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. convex hull {a, c} \<subseteq> {z. d \<bullet> z \<le> k} &&& convex hull {c, b} \<subseteq> {z. k \<le> d \<bullet> z}
[PROOF STEP]
using assms keq
[PROOF STATE]
proof (prove)
using this:
d \<bullet> a \<le> k
k \<le> d \<bullet> b
k = d \<bullet> c

goal (1 subgoal):
 1. convex hull {a, c} \<subseteq> {z. d \<bullet> z \<le> k} &&& convex hull {c, b} \<subseteq> {z. k \<le> d \<bullet> z}
[PROOF STEP]
by (auto simp: convex_halfspace_le convex_halfspace_ge hull_minimal)
[PROOF STATE]
proof (state)
this:
closed_segment a c \<subseteq> {z. d \<bullet> z \<le> k}
closed_segment c b \<subseteq> {z. k \<le> d \<bullet> z}

goal (1 subgoal):
 1. (\<And>c. \<lbrakk>c \<in> closed_segment a b; d \<bullet> c = k; \<And>z. z \<in> closed_segment a c \<Longrightarrow> d \<bullet> z \<le> k; \<And>z. z \<in> closed_segment c b \<Longrightarrow> k \<le> d \<bullet> z\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
closed_segment a c \<subseteq> {z. d \<bullet> z \<le> k}
closed_segment c b \<subseteq> {z. k \<le> d \<bullet> z}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
closed_segment a c \<subseteq> {z. d \<bullet> z \<le> k}
closed_segment c b \<subseteq> {z. k \<le> d \<bullet> z}

goal (1 subgoal):
 1. thesis
[PROOF STEP]
using cin that
[PROOF STATE]
proof (prove)
using this:
closed_segment a c \<subseteq> {z. d \<bullet> z \<le> k}
closed_segment c b \<subseteq> {z. k \<le> d \<bullet> z}
c \<in> closed_segment a b
\<lbrakk>?c \<in> closed_segment a b; d \<bullet> ?c = k; \<And>z. z \<in> closed_segment a ?c \<Longrightarrow> d \<bullet> z \<le> k; \<And>z. z \<in> closed_segment ?c b \<Longrightarrow> k \<le> d \<bullet> z\<rbrakk> \<Longrightarrow> thesis

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma powr_at_bot_neg:
  assumes "(a::real) > 0" "a < 1"
  shows   "filterlim (\<lambda>x. a powr x) at_top at_bot"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. filterlim ((powr) a) at_top at_bot
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. filterlim ((powr) a) at_top at_bot
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
0 < a
a < 1
[PROOF STEP]
have "LIM x at_bot. ln (inverse a) * -x :> at_top"
[PROOF STATE]
proof (prove)
using this:
0 < a
a < 1

goal (1 subgoal):
 1. LIM x at_bot. ln (inverse a) * - x :> at_top
[PROOF STEP]
by (intro filterlim_tendsto_pos_mult_at_top[OF tendsto_const] filterlim_uminus_at_top_at_bot)
       (simp_all add: ln_inverse)
[PROOF STATE]
proof (state)
this:
LIM x at_bot. ln (inverse a) * - x :> at_top

goal (1 subgoal):
 1. filterlim ((powr) a) at_top at_bot
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
0 < a
a < 1
LIM x at_bot. ln (inverse a) * - x :> at_top
[PROOF STEP]
have "LIM x at_bot. x * ln a :> at_top"
[PROOF STATE]
proof (prove)
using this:
0 < a
a < 1
LIM x at_bot. ln (inverse a) * - x :> at_top

goal (1 subgoal):
 1. LIM x at_bot. x * ln a :> at_top
[PROOF STEP]
by (subst (asm) ln_inverse) (simp_all add: mult.commute)
[PROOF STATE]
proof (state)
this:
LIM x at_bot. x * ln a :> at_top

goal (1 subgoal):
 1. filterlim ((powr) a) at_top at_bot
[PROOF STEP]
hence "LIM x at_bot. exp (x * ln a) :> at_top"
[PROOF STATE]
proof (prove)
using this:
LIM x at_bot. x * ln a :> at_top

goal (1 subgoal):
 1. LIM x at_bot. exp (x * ln a) :> at_top
[PROOF STEP]
by (intro filterlim_compose[OF exp_at_top]) simp
[PROOF STATE]
proof (state)
this:
LIM x at_bot. exp (x * ln a) :> at_top

goal (1 subgoal):
 1. filterlim ((powr) a) at_top at_bot
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
LIM x at_bot. exp (x * ln a) :> at_top

goal (1 subgoal):
 1. filterlim ((powr) a) at_top at_bot
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
LIM x at_bot. exp (x * ln a) :> at_top
0 < a
a < 1

goal (1 subgoal):
 1. filterlim ((powr) a) at_top at_bot
[PROOF STEP]
unfolding powr_def
[PROOF STATE]
proof (prove)
using this:
LIM x at_bot. exp (x * ln a) :> at_top
0 < a
a < 1

goal (1 subgoal):
 1. LIM x at_bot. if a = 0 then 0 else exp (x * ln a) :> at_top
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
filterlim ((powr) a) at_top at_bot

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma arctan_inverse_neg: "x < 0 \<Longrightarrow> arctan x = -pi / 2 - arctan (inverse x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < 0 \<Longrightarrow> arctan x = - pi / 2 - arctan (inverse x)
[PROOF STEP]
using arctan_inverse[of x]
[PROOF STATE]
proof (prove)
using this:
x \<noteq> 0 \<Longrightarrow> arctan (1 / x) = sgn x * pi / 2 - arctan x

goal (1 subgoal):
 1. x < 0 \<Longrightarrow> arctan x = - pi / 2 - arctan (inverse x)
[PROOF STEP]
by (simp add: field_simps)


[STATEMENT]
lemma matrix_mult_distrib_right:
  "((A::('a::{comm_monoid_add,semiring},'m,'n::len) matrix) + B) *\<^sub>M C = A *\<^sub>M C + B *\<^sub>M C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (A + B) *\<^sub>M C = A *\<^sub>M C + B *\<^sub>M C
[PROOF STEP]
by (cases A, cases B, cases C, simp add: distrib_right sum.distrib)


[STATEMENT]
lemma ln3_gt_1: "ln 3 > (1::real)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 < ln 3
[PROOF STEP]
by (simp add: less_trans [OF ln_272_gt_1])


[STATEMENT]
lemma reciprocal_diff:
  fixes P Q :: "'a::comm_ring poly"
  assumes "degree P \<le> p" and "degree Q \<le> p"
  shows "reciprocal_poly p (P - Q) = reciprocal_poly p P - reciprocal_poly p Q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reciprocal_poly p (P - Q) = reciprocal_poly p P - reciprocal_poly p Q
[PROOF STEP]
by (metis (no_types, lifting) ab_group_add_class.ab_diff_conv_add_uminus assms
      add_diff_cancel degree_add_le degree_minus diff_add_cancel reciprocal_add)


[STATEMENT]
lemma ceiling_log2_div2: assumes "n \<ge> 2"
shows "ceiling(log 2 (real n)) = ceiling(log 2 ((n-1) div 2 + 1)) + 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lceil>log 2 (real n)\<rceil> = \<lceil>log 2 (real ((n - 1) div 2 + 1))\<rceil> + 1
[PROOF STEP]
proof cases
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ?P \<Longrightarrow> \<lceil>log 2 (real n)\<rceil> = \<lceil>log 2 (real ((n - 1) div 2 + 1))\<rceil> + 1
 2. \<not> ?P \<Longrightarrow> \<lceil>log 2 (real n)\<rceil> = \<lceil>log 2 (real ((n - 1) div 2 + 1))\<rceil> + 1
[PROOF STEP]
assume "n=2"
[PROOF STATE]
proof (state)
this:
n = 2

goal (2 subgoals):
 1. ?P \<Longrightarrow> \<lceil>log 2 (real n)\<rceil> = \<lceil>log 2 (real ((n - 1) div 2 + 1))\<rceil> + 1
 2. \<not> ?P \<Longrightarrow> \<lceil>log 2 (real n)\<rceil> = \<lceil>log 2 (real ((n - 1) div 2 + 1))\<rceil> + 1
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
n = 2

goal (1 subgoal):
 1. \<lceil>log 2 (real n)\<rceil> = \<lceil>log 2 (real ((n - 1) div 2 + 1))\<rceil> + 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<lceil>log 2 (real n)\<rceil> = \<lceil>log 2 (real ((n - 1) div 2 + 1))\<rceil> + 1

goal (1 subgoal):
 1. n \<noteq> 2 \<Longrightarrow> \<lceil>log 2 (real n)\<rceil> = \<lceil>log 2 (real ((n - 1) div 2 + 1))\<rceil> + 1
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n \<noteq> 2 \<Longrightarrow> \<lceil>log 2 (real n)\<rceil> = \<lceil>log 2 (real ((n - 1) div 2 + 1))\<rceil> + 1
[PROOF STEP]
let ?m = "(n-1) div 2 + 1"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n \<noteq> 2 \<Longrightarrow> \<lceil>log 2 (real n)\<rceil> = \<lceil>log 2 (real ((n - 1) div 2 + 1))\<rceil> + 1
[PROOF STEP]
assume "n\<noteq>2"
[PROOF STATE]
proof (state)
this:
n \<noteq> 2

goal (1 subgoal):
 1. n \<noteq> 2 \<Longrightarrow> \<lceil>log 2 (real n)\<rceil> = \<lceil>log 2 (real ((n - 1) div 2 + 1))\<rceil> + 1
[PROOF STEP]
hence "2 \<le> ?m"
[PROOF STATE]
proof (prove)
using this:
n \<noteq> 2

goal (1 subgoal):
 1. 2 \<le> (n - 1) div 2 + 1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
n \<noteq> 2
2 \<le> n

goal (1 subgoal):
 1. 2 \<le> (n - 1) div 2 + 1
[PROOF STEP]
by arith
[PROOF STATE]
proof (state)
this:
2 \<le> (n - 1) div 2 + 1

goal (1 subgoal):
 1. n \<noteq> 2 \<Longrightarrow> \<lceil>log 2 (real n)\<rceil> = \<lceil>log 2 (real ((n - 1) div 2 + 1))\<rceil> + 1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
2 \<le> (n - 1) div 2 + 1
[PROOF STEP]
obtain i where i: "2 ^ i < ?m" "?m \<le> 2 ^ (i + 1)"
[PROOF STATE]
proof (prove)
using this:
2 \<le> (n - 1) div 2 + 1

goal (1 subgoal):
 1. (\<And>i. \<lbrakk>2 ^ i < (n - 1) div 2 + 1; (n - 1) div 2 + 1 \<le> 2 ^ (i + 1)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using ex_power_ivl2[of 2 ?m]
[PROOF STATE]
proof (prove)
using this:
2 \<le> (n - 1) div 2 + 1
\<lbrakk>2 \<le> 2; 2 \<le> (n - 1) div 2 + 1\<rbrakk> \<Longrightarrow> \<exists>na. 2 ^ na < (n - 1) div 2 + 1 \<and> (n - 1) div 2 + 1 \<le> 2 ^ (na + 1)

goal (1 subgoal):
 1. (\<And>i. \<lbrakk>2 ^ i < (n - 1) div 2 + 1; (n - 1) div 2 + 1 \<le> 2 ^ (i + 1)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
2 ^ i < (n - 1) div 2 + 1
(n - 1) div 2 + 1 \<le> 2 ^ (i + 1)

goal (1 subgoal):
 1. n \<noteq> 2 \<Longrightarrow> \<lceil>log 2 (real n)\<rceil> = \<lceil>log 2 (real ((n - 1) div 2 + 1))\<rceil> + 1
[PROOF STEP]
have "n \<le> 2*?m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n \<le> 2 * ((n - 1) div 2 + 1)
[PROOF STEP]
by arith
[PROOF STATE]
proof (state)
this:
n \<le> 2 * ((n - 1) div 2 + 1)

goal (1 subgoal):
 1. n \<noteq> 2 \<Longrightarrow> \<lceil>log 2 (real n)\<rceil> = \<lceil>log 2 (real ((n - 1) div 2 + 1))\<rceil> + 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
n \<le> 2 * ((n - 1) div 2 + 1)

goal (1 subgoal):
 1. n \<noteq> 2 \<Longrightarrow> \<lceil>log 2 (real n)\<rceil> = \<lceil>log 2 (real ((n - 1) div 2 + 1))\<rceil> + 1
[PROOF STEP]
have "2*?m \<le> 2 ^ ((i+1)+1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * ((n - 1) div 2 + 1) \<le> 2 ^ (i + 1 + 1)
[PROOF STEP]
using i(2)
[PROOF STATE]
proof (prove)
using this:
(n - 1) div 2 + 1 \<le> 2 ^ (i + 1)

goal (1 subgoal):
 1. 2 * ((n - 1) div 2 + 1) \<le> 2 ^ (i + 1 + 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 * ((n - 1) div 2 + 1) \<le> 2 ^ (i + 1 + 1)

goal (1 subgoal):
 1. n \<noteq> 2 \<Longrightarrow> \<lceil>log 2 (real n)\<rceil> = \<lceil>log 2 (real ((n - 1) div 2 + 1))\<rceil> + 1
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
n \<le> 2 ^ (i + 1 + 1)
[PROOF STEP]
have *: "n \<le> \<dots>"
[PROOF STATE]
proof (prove)
using this:
n \<le> 2 ^ (i + 1 + 1)

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

goal (1 subgoal):
 1. n \<noteq> 2 \<Longrightarrow> \<lceil>log 2 (real n)\<rceil> = \<lceil>log 2 (real ((n - 1) div 2 + 1))\<rceil> + 1
[PROOF STEP]
have "2^(i+1) < n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 ^ (i + 1) < n
[PROOF STEP]
using i(1)
[PROOF STATE]
proof (prove)
using this:
2 ^ i < (n - 1) div 2 + 1

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

goal (1 subgoal):
 1. n \<noteq> 2 \<Longrightarrow> \<lceil>log 2 (real n)\<rceil> = \<lceil>log 2 (real ((n - 1) div 2 + 1))\<rceil> + 1
[PROOF STEP]
from ceiling_log_nat_eq_if[OF this *] ceiling_log_nat_eq_if[OF i]
[PROOF STATE]
proof (chain)
picking this:
2 \<le> 2 \<Longrightarrow> \<lceil>log (real 2) (real n)\<rceil> = int (i + 1) + 1
2 \<le> 2 \<Longrightarrow> \<lceil>log (real 2) (real ((n - 1) div 2 + 1))\<rceil> = int i + 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
2 \<le> 2 \<Longrightarrow> \<lceil>log (real 2) (real n)\<rceil> = int (i + 1) + 1
2 \<le> 2 \<Longrightarrow> \<lceil>log (real 2) (real ((n - 1) div 2 + 1))\<rceil> = int i + 1

goal (1 subgoal):
 1. \<lceil>log 2 (real n)\<rceil> = \<lceil>log 2 (real ((n - 1) div 2 + 1))\<rceil> + 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<lceil>log 2 (real n)\<rceil> = \<lceil>log 2 (real ((n - 1) div 2 + 1))\<rceil> + 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma adjoint_matrix: "adjoint(\<lambda>x. (A::real^'n^'m) *v x) = (\<lambda>x. transpose A *v x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. adjoint ((*v) A) = (*v) (Finite_Cartesian_Product.transpose A)
[PROOF STEP]
apply (rule adjoint_unique)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x y. (A *v x) \<bullet> y = x \<bullet> (Finite_Cartesian_Product.transpose A *v y)
[PROOF STEP]
apply (simp add: transpose_def inner_vec_def matrix_vector_mult_def
    sum_distrib_right sum_distrib_left)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x y. (\<Sum>i\<in>UNIV. \<Sum>n\<in>UNIV. A $ i $ n * x $ n * y $ i) = (\<Sum>i\<in>UNIV. \<Sum>n\<in>UNIV. x $ i * (A $ n $ i * y $ n))
[PROOF STEP]
apply (subst sum.swap)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x y. (\<Sum>j\<in>UNIV. \<Sum>i\<in>UNIV. A $ i $ j * x $ j * y $ i) = (\<Sum>i\<in>UNIV. \<Sum>n\<in>UNIV. x $ i * (A $ n $ i * y $ n))
[PROOF STEP]
apply (simp add:  ac_simps)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma sum_atLeastAtMost_of_int_nat_transfer:
  "(\<Sum>k=int a..int b. f (of_int k)) = (\<Sum>k=a..b. f (of_nat k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k = int a..int b. f (of_int k)) = (\<Sum>k = a..b. f (of_nat k))
[PROOF STEP]
by (intro sum.reindex_bij_witness[of _ int nat]) auto


[STATEMENT]
lemma padic_set_res_closed:
  assumes "f \<in> padic_set p"
  shows "(f m) \<in> (carrier (residue_ring (p^m)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f m \<in> carrier (residue_ring (p ^ m))
[PROOF STEP]
using assms padic_set_def
[PROOF STATE]
proof (prove)
using this:
f \<in> padic_set p
padic_set ?p = {f. (\<forall>m. f m \<in> carrier (residue_ring (?p ^ m))) \<and> (\<forall>n m. m < n \<longrightarrow> residue (?p ^ m) (f n) = f m)}

goal (1 subgoal):
 1. f m \<in> carrier (residue_ring (p ^ m))
[PROOF STEP]
by auto


[STATEMENT]
lemma jordan_matrix_pow: "(jordan_matrix n_as) ^\<^sub>m r =
  diag_block_mat (map (\<lambda> (n,a). (jordan_block n a) ^\<^sub>m r) n_as)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. jordan_matrix n_as ^\<^sub>m r = diag_block_mat (map (\<lambda>(n, a). jordan_block n a ^\<^sub>m r) n_as)
[PROOF STEP]
unfolding jordan_matrix_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diag_block_mat (map (\<lambda>(x, y). jordan_block x y) n_as) ^\<^sub>m r = diag_block_mat (map (\<lambda>(n, a). jordan_block n a ^\<^sub>m r) n_as)
[PROOF STEP]
by (subst diag_block_pow_mat, force, rule arg_cong[of _ _ diag_block_mat], auto)