[STATEMENT]
lemma "bool_fun_threshold_2_3
          (vec 4 (\<lambda>i. if i = 0 \<or> i = 1 then True else False)) = True"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bool_fun_threshold_2_3 (vec 4 (\<lambda>i. if i = 0 \<or> i = 1 then True else False)) = True
[PROOF STEP]
unfolding bool_fun_threshold_2_3_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if 2 \<le> count_true (vec 4 (\<lambda>i. if i = 0 \<or> i = 1 then True else False)) then True else False) = True
[PROOF STEP]
unfolding count_true_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if 2 \<le> (\<Sum>i = 0..<dim_vec (vec 4 (\<lambda>i. if i = 0 \<or> i = 1 then True else False)). if vec 4 (\<lambda>i. if i = 0 \<or> i = 1 then True else False) $ i then 1 else 0) then True else False) = True
[PROOF STEP]
unfolding dim_vec
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if 2 \<le> (\<Sum>i = 0..<4. if vec 4 (\<lambda>i. if i = 0 \<or> i = 1 then True else False) $ i then 1 else 0) then True else False) = True
[PROOF STEP]
unfolding sum.eq_fold
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if 2 \<le> Finite_Set.fold ((+) \<circ> (\<lambda>i. if vec 4 (\<lambda>i. if i = 0 \<or> i = 1 then True else False) $ i then 1 else 0)) 0 {0..<4} then True else False) = True
[PROOF STEP]
using index_vec [of _ 4]
[PROOF STATE]
proof (prove)
using this:
?i < 4 \<Longrightarrow> vec 4 ?f $ ?i = ?f ?i

goal (1 subgoal):
 1. (if 2 \<le> Finite_Set.fold ((+) \<circ> (\<lambda>i. if vec 4 (\<lambda>i. if i = 0 \<or> i = 1 then True else False) $ i then 1 else 0)) 0 {0..<4} then True else False) = True
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 \<le> Finite_Set.fold ((+) \<circ> (\<lambda>i. if vec 4 (\<lambda>i. i = 0 \<or> i = Suc 0) $ i then 1 else 0)) 0 {0..<4}
[PROOF STEP]
unfolding set_list_four
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 \<le> Finite_Set.fold ((+) \<circ> (\<lambda>i. if vec 4 (\<lambda>i. i = 0 \<or> i = Suc 0) $ i then 1 else 0)) 0 (set [0, 1, 2, 3])
[PROOF STEP]
unfolding comp_fun_commute_on.fold_set_fold_remdups [OF comp_fun_commute_lambda, simplified]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 \<le> fold ((+) \<circ> (\<lambda>i. if vec 4 (\<lambda>i. i = 0 \<or> i = Suc 0) $ i then 1 else 0)) (remdups [0, 1, 2, 3]) 0
[PROOF STEP]
by simp


[STATEMENT]
lemma card_bijections_range_permutation_eq_1:
  assumes "finite A" "finite B"
  assumes "card A = card B"
  shows "card ({f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // range_permutation A B) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // range_permutation A B) = 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // range_permutation A B) = 1
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
finite A
finite B
card A = card B
[PROOF STEP]
have "{f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // range_permutation A B =
    {f \<in> A \<rightarrow>\<^sub>E B. f ` A = B} // range_permutation A B"
[PROOF STATE]
proof (prove)
using this:
finite A
finite B
card A = card B

goal (1 subgoal):
 1. {f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // range_permutation A B = {f \<in> A \<rightarrow>\<^sub>E B. f ` A = B} // range_permutation A B
[PROOF STEP]
by (metis (no_types, lifting) PiE_cong bij_betw_implies_surj_on_and_card_eq)
[PROOF STATE]
proof (state)
this:
{f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // range_permutation A B = {f \<in> A \<rightarrow>\<^sub>E B. f ` A = B} // range_permutation A B

goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // range_permutation A B) = 1
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
{f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // range_permutation A B = {f \<in> A \<rightarrow>\<^sub>E B. f ` A = B} // range_permutation A B
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
{f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // range_permutation A B = {f \<in> A \<rightarrow>\<^sub>E B. f ` A = B} // range_permutation A B

goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // range_permutation A B) = 1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
{f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // range_permutation A B = {f \<in> A \<rightarrow>\<^sub>E B. f ` A = B} // range_permutation A B
finite A
finite B
card A = card B

goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // range_permutation A B) = 1
[PROOF STEP]
by (simp add: card_surjective_functions_range_permutation)
[PROOF STATE]
proof (state)
this:
card ({f \<in> A \<rightarrow>\<^sub>E B. bij_betw f A B} // range_permutation A B) = 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma card_triangle_triples_rotate: "card (triangle_triples X Y Z) = card (triangle_triples Y Z X)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (triangle_triples X Y Z) = card (triangle_triples Y Z X)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card (triangle_triples X Y Z) = card (triangle_triples Y Z X)
[PROOF STEP]
have "triangle_triples Y Z X = (\<lambda>(x,y,z). (y,z,x)) ` triangle_triples X Y Z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. triangle_triples Y Z X = (\<lambda>(x, y, z). (y, z, x)) ` triangle_triples X Y Z
[PROOF STEP]
by (auto simp: triangle_triples_def case_prod_unfold image_iff insert_commute triangle_in_graph_def)
[PROOF STATE]
proof (state)
this:
triangle_triples Y Z X = (\<lambda>(x, y, z). (y, z, x)) ` triangle_triples X Y Z

goal (1 subgoal):
 1. card (triangle_triples X Y Z) = card (triangle_triples Y Z X)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
triangle_triples Y Z X = (\<lambda>(x, y, z). (y, z, x)) ` triangle_triples X Y Z

goal (1 subgoal):
 1. card (triangle_triples X Y Z) = card (triangle_triples Y Z X)
[PROOF STEP]
have "inj_on (\<lambda>(x, y, z). (y, z, x)) (triangle_triples X Y Z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on (\<lambda>(x, y, z). (y, z, x)) (triangle_triples X Y Z)
[PROOF STEP]
by (auto simp: inj_on_def)
[PROOF STATE]
proof (state)
this:
inj_on (\<lambda>(x, y, z). (y, z, x)) (triangle_triples X Y Z)

goal (1 subgoal):
 1. card (triangle_triples X Y Z) = card (triangle_triples Y Z X)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
triangle_triples Y Z X = (\<lambda>(x, y, z). (y, z, x)) ` triangle_triples X Y Z
inj_on (\<lambda>(x, y, z). (y, z, x)) (triangle_triples X Y Z)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
triangle_triples Y Z X = (\<lambda>(x, y, z). (y, z, x)) ` triangle_triples X Y Z
inj_on (\<lambda>(x, y, z). (y, z, x)) (triangle_triples X Y Z)

goal (1 subgoal):
 1. card (triangle_triples X Y Z) = card (triangle_triples Y Z X)
[PROOF STEP]
by (simp add: card_image)
[PROOF STATE]
proof (state)
this:
card (triangle_triples X Y Z) = card (triangle_triples Y Z X)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma  trace_add:
  assumes "square_mat A"
  and "square_mat B"
  and "dim_row A = dim_row B"
  shows "Complex_Matrix.trace (A + B) = Complex_Matrix.trace A + Complex_Matrix.trace B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex_Matrix.trace (A + B) = Complex_Matrix.trace A + Complex_Matrix.trace B
[PROOF STEP]
using  assms
[PROOF STATE]
proof (prove)
using this:
square_mat A
square_mat B
dim_row A = dim_row B

goal (1 subgoal):
 1. Complex_Matrix.trace (A + B) = Complex_Matrix.trace A + Complex_Matrix.trace B
[PROOF STEP]
by (simp add: Complex_Matrix.trace_def sum.distrib)


[STATEMENT]
lemma le_powr_half_mult:
  fixes x y z:: real
  assumes "x ^ 2 \<le> y * z" and "0 \<le> y" and "0 \<le> z"
  shows "x \<le> y powr(1/2) * z powr (1/2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<le> y powr (1 / 2) * z powr (1 / 2)
[PROOF STEP]
using assms power2_eq_square
[PROOF STATE]
proof (prove)
using this:
x\<^sup>2 \<le> y * z
0 \<le> y
0 \<le> z
?a\<^sup>2 = ?a * ?a

goal (1 subgoal):
 1. x \<le> y powr (1 / 2) * z powr (1 / 2)
[PROOF STEP]
by (metis dual_order.trans linorder_linear powr_ge_pzero powr_half_sqrt powr_mult real_le_rsqrt
    real_sqrt_le_0_iff)


[STATEMENT]
lemma inner_prod_with_itself_Re:
  "Re (\<langle>u|u\<rangle>) \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> Re \<langle>u|u\<rangle>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 0 \<le> Re \<langle>u|u\<rangle>
[PROOF STEP]
have "Re (\<langle>u|u\<rangle>) = (\<Sum>i<dim_vec u. Re (cnj(u $ i) * (u $ i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Re \<langle>u|u\<rangle> = (\<Sum>i<dim_vec u. Re (cnj (u $ i) * u $ i))
[PROOF STEP]
by (simp add: inner_prod_def lessThan_atLeast0)
[PROOF STATE]
proof (state)
this:
Re \<langle>u|u\<rangle> = (\<Sum>i<dim_vec u. Re (cnj (u $ i) * u $ i))

goal (1 subgoal):
 1. 0 \<le> Re \<langle>u|u\<rangle>
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
Re \<langle>u|u\<rangle> = (\<Sum>i<dim_vec u. Re (cnj (u $ i) * u $ i))

goal (1 subgoal):
 1. 0 \<le> Re \<langle>u|u\<rangle>
[PROOF STEP]
have "\<dots> = (\<Sum>i<dim_vec u. (Re (u $ i))\<^sup>2 + (Im (u $ i))\<^sup>2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<dim_vec u. Re (cnj (u $ i) * u $ i)) = (\<Sum>i<dim_vec u. (Re (u $ i))\<^sup>2 + (Im (u $ i))\<^sup>2)
[PROOF STEP]
using complex_mult_cnj
[PROOF STATE]
proof (prove)
using this:
?z * cnj ?z = complex_of_real ((Re ?z)\<^sup>2 + (Im ?z)\<^sup>2)

goal (1 subgoal):
 1. (\<Sum>i<dim_vec u. Re (cnj (u $ i) * u $ i)) = (\<Sum>i<dim_vec u. (Re (u $ i))\<^sup>2 + (Im (u $ i))\<^sup>2)
[PROOF STEP]
by (metis (no_types, lifting) Re_complex_of_real semiring_normalization_rules(7))
[PROOF STATE]
proof (state)
this:
(\<Sum>i<dim_vec u. Re (cnj (u $ i) * u $ i)) = (\<Sum>i<dim_vec u. (Re (u $ i))\<^sup>2 + (Im (u $ i))\<^sup>2)

goal (1 subgoal):
 1. 0 \<le> Re \<langle>u|u\<rangle>
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
Re \<langle>u|u\<rangle> = (\<Sum>i<dim_vec u. Re (cnj (u $ i) * u $ i))
(\<Sum>i<dim_vec u. Re (cnj (u $ i) * u $ i)) = (\<Sum>i<dim_vec u. (Re (u $ i))\<^sup>2 + (Im (u $ i))\<^sup>2)
[PROOF STEP]
show "Re (\<langle>u|u\<rangle>) \<ge> 0"
[PROOF STATE]
proof (prove)
using this:
Re \<langle>u|u\<rangle> = (\<Sum>i<dim_vec u. Re (cnj (u $ i) * u $ i))
(\<Sum>i<dim_vec u. Re (cnj (u $ i) * u $ i)) = (\<Sum>i<dim_vec u. (Re (u $ i))\<^sup>2 + (Im (u $ i))\<^sup>2)

goal (1 subgoal):
 1. 0 \<le> Re \<langle>u|u\<rangle>
[PROOF STEP]
by (simp add: sum_nonneg)
[PROOF STATE]
proof (state)
this:
0 \<le> Re \<langle>u|u\<rangle>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma det_interchange_rows:
shows "det (interchange_rows A i j) = of_int (if i = j then 1 else -1) * det A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (interchange_rows A i j) = of_int (if i = j then 1 else - 1) * det A
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. det (interchange_rows A i j) = of_int (if i = j then 1 else - 1) * det A
[PROOF STEP]
have "(interchange_rows A i j) = (\<chi> a. A $ (Transposition.transpose i j) a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. interchange_rows A i j = (\<chi>a. A $ Transposition.transpose i j a)
[PROOF STEP]
unfolding interchange_rows_def Transposition.transpose_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>ia ja. if ia = i then A $ j $ ja else if ia = j then A $ i $ ja else A $ ia $ ja) = (\<chi>a. A $ (if a = i then j else if a = j then i else a))
[PROOF STEP]
by vector
[PROOF STATE]
proof (state)
this:
interchange_rows A i j = (\<chi>a. A $ Transposition.transpose i j a)

goal (1 subgoal):
 1. det (interchange_rows A i j) = of_int (if i = j then 1 else - 1) * det A
[PROOF STEP]
hence "det(interchange_rows A i j) = det(\<chi> a. A$(Transposition.transpose i j) a)"
[PROOF STATE]
proof (prove)
using this:
interchange_rows A i j = (\<chi>a. A $ Transposition.transpose i j a)

goal (1 subgoal):
 1. det (interchange_rows A i j) = det (\<chi>a. A $ Transposition.transpose i j a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
det (interchange_rows A i j) = det (\<chi>a. A $ Transposition.transpose i j a)

goal (1 subgoal):
 1. det (interchange_rows A i j) = of_int (if i = j then 1 else - 1) * det A
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
det (interchange_rows A i j) = det (\<chi>a. A $ Transposition.transpose i j a)

goal (1 subgoal):
 1. det (interchange_rows A i j) = of_int (if i = j then 1 else - 1) * det A
[PROOF STEP]
have "... = of_int (sign (Transposition.transpose i j)) * det A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (\<chi>a. A $ Transposition.transpose i j a) = of_int (sign (Transposition.transpose i j)) * det A
[PROOF STEP]
by (rule det_permute_rows[of "Transposition.transpose i j" A], simp add: permutes_swap_id)
[PROOF STATE]
proof (state)
this:
det (\<chi>a. A $ Transposition.transpose i j a) = of_int (sign (Transposition.transpose i j)) * det A

goal (1 subgoal):
 1. det (interchange_rows A i j) = of_int (if i = j then 1 else - 1) * det A
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
det (interchange_rows A i j) = of_int (sign (Transposition.transpose i j)) * det A
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
det (interchange_rows A i j) = of_int (sign (Transposition.transpose i j)) * det A

goal (1 subgoal):
 1. det (interchange_rows A i j) = of_int (if i = j then 1 else - 1) * det A
[PROOF STEP]
unfolding sign_swap_id
[PROOF STATE]
proof (prove)
using this:
det (interchange_rows A i j) = of_int (if i = j then 1 else - 1) * det A

goal (1 subgoal):
 1. det (interchange_rows A i j) = of_int (if i = j then 1 else - 1) * det A
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
det (interchange_rows A i j) = of_int (if i = j then 1 else - 1) * det A

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma unity_root_eq_1_iff:
  fixes k n :: nat
  assumes "k > 0"
  shows "unity_root k n = 1 \<longleftrightarrow> k dvd n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (unity_root k (int n) = 1) = (k dvd n)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (unity_root k (int n) = 1) = (k dvd n)
[PROOF STEP]
have "unity_root k n = exp ((2*pi*n/k) * \<i>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unity_root k (int n) = exp (complex_of_real (2 * pi * real n / real k) * \<i>)
[PROOF STEP]
by (simp add: unity_root_conv_exp)
[PROOF STATE]
proof (state)
this:
unity_root k (int n) = exp (complex_of_real (2 * pi * real n / real k) * \<i>)

goal (1 subgoal):
 1. (unity_root k (int n) = 1) = (k dvd n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
unity_root k (int n) = exp (complex_of_real (2 * pi * real n / real k) * \<i>)

goal (1 subgoal):
 1. (unity_root k (int n) = 1) = (k dvd n)
[PROOF STEP]
have "exp ((2*pi*n/k)* \<i>) = 1 \<longleftrightarrow> k dvd n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (exp (complex_of_real (2 * pi * real n / real k) * \<i>) = 1) = (k dvd n)
[PROOF STEP]
using complex_root_unity_eq_1[of k n] assms
[PROOF STATE]
proof (prove)
using this:
1 \<le> k \<Longrightarrow> (exp (2 * complex_of_real pi * \<i> * of_nat n / of_nat k) = 1) = (k dvd n)
0 < k

goal (1 subgoal):
 1. (exp (complex_of_real (2 * pi * real n / real k) * \<i>) = 1) = (k dvd n)
[PROOF STEP]
by (auto simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
(exp (complex_of_real (2 * pi * real n / real k) * \<i>) = 1) = (k dvd n)

goal (1 subgoal):
 1. (unity_root k (int n) = 1) = (k dvd n)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(unity_root k (int n) = 1) = (k dvd n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(unity_root k (int n) = 1) = (k dvd n)

goal (1 subgoal):
 1. (unity_root k (int n) = 1) = (k dvd n)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(unity_root k (int n) = 1) = (k dvd n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma dest_segment:
  fixes x b::real
  assumes "(x, b) \<in> closed_segment (x0, y0) (x1, y1)"
  assumes "x0 \<noteq> x1"
  shows "b = (y1 - y0) * (x - x0) / (x1 - x0) + y0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b = (y1 - y0) * (x - x0) / (x1 - x0) + y0
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. b = (y1 - y0) * (x - x0) / (x1 - x0) + y0
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
(x, b) \<in> closed_segment (x0, y0) (x1, y1)
x0 \<noteq> x1
[PROOF STEP]
obtain u where u: "x = x0 *\<^sub>R (1 - u) + u * x1" "b = y0 *\<^sub>R (1 - u) + u * y1" "0 \<le> u" "u \<le> 1"
[PROOF STATE]
proof (prove)
using this:
(x, b) \<in> closed_segment (x0, y0) (x1, y1)
x0 \<noteq> x1

goal (1 subgoal):
 1. (\<And>u. \<lbrakk>x = x0 *\<^sub>R (1 - u) + u * x1; b = y0 *\<^sub>R (1 - u) + u * y1; 0 \<le> u; u \<le> 1\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: closed_segment_def algebra_simps)
[PROOF STATE]
proof (state)
this:
x = x0 *\<^sub>R (1 - u) + u * x1
b = y0 *\<^sub>R (1 - u) + u * y1
0 \<le> u
u \<le> 1

goal (1 subgoal):
 1. b = (y1 - y0) * (x - x0) / (x1 - x0) + y0
[PROOF STEP]
show "b = (y1 - y0) * (x - x0) / (x1 - x0) + y0 "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b = (y1 - y0) * (x - x0) / (x1 - x0) + y0
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
(x, b) \<in> closed_segment (x0, y0) (x1, y1)
x0 \<noteq> x1

goal (1 subgoal):
 1. b = (y1 - y0) * (x - x0) / (x1 - x0) + y0
[PROOF STEP]
by (auto simp: closed_segment_def field_simps u)
[PROOF STATE]
proof (state)
this:
b = (y1 - y0) * (x - x0) / (x1 - x0) + y0

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma setdist_eq_0_compact_closed:
  assumes S: "compact S" and T: "closed T"
    shows "setdist S T = 0 \<longleftrightarrow> S = {} \<or> T = {} \<or> S \<inter> T \<noteq> {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (setdist S T = 0) = (S = {} \<or> T = {} \<or> S \<inter> T \<noteq> {})
[PROOF STEP]
proof (cases "S = {} \<or> T = {}")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. S = {} \<or> T = {} \<Longrightarrow> (setdist S T = 0) = (S = {} \<or> T = {} \<or> S \<inter> T \<noteq> {})
 2. \<not> (S = {} \<or> T = {}) \<Longrightarrow> (setdist S T = 0) = (S = {} \<or> T = {} \<or> S \<inter> T \<noteq> {})
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
S = {} \<or> T = {}

goal (2 subgoals):
 1. S = {} \<or> T = {} \<Longrightarrow> (setdist S T = 0) = (S = {} \<or> T = {} \<or> S \<inter> T \<noteq> {})
 2. \<not> (S = {} \<or> T = {}) \<Longrightarrow> (setdist S T = 0) = (S = {} \<or> T = {} \<or> S \<inter> T \<noteq> {})
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
S = {} \<or> T = {}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
S = {} \<or> T = {}

goal (1 subgoal):
 1. (setdist S T = 0) = (S = {} \<or> T = {} \<or> S \<inter> T \<noteq> {})
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
(setdist S T = 0) = (S = {} \<or> T = {} \<or> S \<inter> T \<noteq> {})

goal (1 subgoal):
 1. \<not> (S = {} \<or> T = {}) \<Longrightarrow> (setdist S T = 0) = (S = {} \<or> T = {} \<or> S \<inter> T \<noteq> {})
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> (S = {} \<or> T = {}) \<Longrightarrow> (setdist S T = 0) = (S = {} \<or> T = {} \<or> S \<inter> T \<noteq> {})
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> (S = {} \<or> T = {})

goal (1 subgoal):
 1. \<not> (S = {} \<or> T = {}) \<Longrightarrow> (setdist S T = 0) = (S = {} \<or> T = {} \<or> S \<inter> T \<noteq> {})
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> (S = {} \<or> T = {})
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> (S = {} \<or> T = {})

goal (1 subgoal):
 1. (setdist S T = 0) = (S = {} \<or> T = {} \<or> S \<inter> T \<noteq> {})
[PROOF STEP]
by (metis S T disjoint_iff_not_equal in_closed_iff_infdist_zero setdist_attains_inf setdist_eq_0I setdist_sym)
[PROOF STATE]
proof (state)
this:
(setdist S T = 0) = (S = {} \<or> T = {} \<or> S \<inter> T \<noteq> {})

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sin_times_sin: "sin w * sin z = (cos (w - z) - cos (w + z)) / 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin w * sin z = (cos (w - z) - cos (w + z)) / (2::'a)
[PROOF STEP]
by (simp add: cos_diff cos_add)


[STATEMENT]
lemma frechet_derivative_pair:
  "frechet_derivative (\<lambda>x. (f x, g x)) (at x) = (\<lambda>v. (frechet_derivative f (at x) v, frechet_derivative g (at x) v))"
  if "f differentiable (at x)" "g differentiable (at x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. frechet_derivative (\<lambda>x. (f x, g x)) (at x) = (\<lambda>v. (frechet_derivative f (at x) v, frechet_derivative g (at x) v))
[PROOF STEP]
apply (rule frechet_derivative_at')
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. (f x, g x)) has_derivative (\<lambda>v. (frechet_derivative f (at x) v, frechet_derivative g (at x) v))) (at x)
[PROOF STEP]
apply (rule derivative_eq_intros)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. (f has_derivative ?f'3) (at x)
 2. (g has_derivative ?g'3) (at x)
 3. (\<lambda>h. (?f'3 h, ?g'3 h)) = (\<lambda>v. (frechet_derivative f (at x) v, frechet_derivative g (at x) v))
[PROOF STEP]
apply (rule frechet_derivative_worksI)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. f differentiable at x
 2. (g has_derivative ?g'3) (at x)
 3. (\<lambda>h. (frechet_derivative f (at x) h, ?g'3 h)) = (\<lambda>v. (frechet_derivative f (at x) v, frechet_derivative g (at x) v))
[PROOF STEP]
apply fact
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. (g has_derivative ?g'3) (at x)
 2. (\<lambda>h. (frechet_derivative f (at x) h, ?g'3 h)) = (\<lambda>v. (frechet_derivative f (at x) v, frechet_derivative g (at x) v))
[PROOF STEP]
apply (rule frechet_derivative_worksI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. g differentiable at x
 2. (\<lambda>h. (frechet_derivative f (at x) h, frechet_derivative g (at x) h)) = (\<lambda>v. (frechet_derivative f (at x) v, frechet_derivative g (at x) v))
[PROOF STEP]
apply fact
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>h. (frechet_derivative f (at x) h, frechet_derivative g (at x) h)) = (\<lambda>v. (frechet_derivative f (at x) v, frechet_derivative g (at x) v))
[PROOF STEP]
..


[STATEMENT]
lemma kernel_code[code]:
  \<comment> \<open>Computes the kernel of an operator \<^term>\<open>A\<close>.
      This is implemented using the existing functions
      for transforming a matrix into row echelon form (\<^term>\<open>gauss_jordan_single\<close>)
      and for computing a basis of the kernel of such a matrix
      (\<^term>\<open>find_base_vectors\<close>)\<close>
  "kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))"
  for A::"('a::onb_enum,'b::onb_enum) cblinfun"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
define dA dB Am Ag base
    where "dA = length (canonical_basis :: 'a list)"
      and "dB = length (canonical_basis :: 'b list)"
      and "Am = mat_of_cblinfun A"
      and "Ag = gauss_jordan_single Am"
      and "base = find_base_vectors Ag"
[PROOF STATE]
proof (state)
this:
dA = length canonical_basis
dB = length canonical_basis
Am = mat_of_cblinfun A
Ag = gauss_jordan_single Am
base = find_base_vectors Ag

goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
interpret complex_vec_space dA
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
.
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
have Am_carrier: "Am \<in> carrier_mat dB dA"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Am \<in> carrier_mat dB dA
[PROOF STEP]
unfolding Am_def mat_of_cblinfun_def dA_def dB_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat (length canonical_basis) (length canonical_basis) (\<lambda>(i, j). crepresentation (set canonical_basis) (A *\<^sub>V canonical_basis ! j) (canonical_basis ! i)) \<in> carrier_mat (length canonical_basis) (length canonical_basis)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Am \<in> carrier_mat dB dA

goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
have row_echelon: "row_echelon_form Ag"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. row_echelon_form Ag
[PROOF STEP]
unfolding Ag_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. row_echelon_form (gauss_jordan_single Am)
[PROOF STEP]
using Am_carrier refl
[PROOF STATE]
proof (prove)
using this:
Am \<in> carrier_mat dB dA
?t = ?t

goal (1 subgoal):
 1. row_echelon_form (gauss_jordan_single Am)
[PROOF STEP]
by (rule gauss_jordan_single)
[PROOF STATE]
proof (state)
this:
row_echelon_form Ag

goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
have Ag_carrier: "Ag \<in> carrier_mat dB dA"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Ag \<in> carrier_mat dB dA
[PROOF STEP]
unfolding Ag_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gauss_jordan_single Am \<in> carrier_mat dB dA
[PROOF STEP]
using Am_carrier refl
[PROOF STATE]
proof (prove)
using this:
Am \<in> carrier_mat dB dA
?t = ?t

goal (1 subgoal):
 1. gauss_jordan_single Am \<in> carrier_mat dB dA
[PROOF STEP]
by (rule gauss_jordan_single(2))
[PROOF STATE]
proof (state)
this:
Ag \<in> carrier_mat dB dA

goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
have base_carrier: "set base \<subseteq> carrier_vec dA"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set base \<subseteq> carrier_vec dA
[PROOF STEP]
unfolding base_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (find_base_vectors Ag) \<subseteq> carrier_vec dA
[PROOF STEP]
using find_base_vectors(1)[OF row_echelon Ag_carrier]
[PROOF STATE]
proof (prove)
using this:
set (find_base_vectors Ag) \<subseteq> mat_kernel Ag

goal (1 subgoal):
 1. set (find_base_vectors Ag) \<subseteq> carrier_vec dA
[PROOF STEP]
using Ag_carrier mat_kernel_def
[PROOF STATE]
proof (prove)
using this:
set (find_base_vectors Ag) \<subseteq> mat_kernel Ag
Ag \<in> carrier_mat dB dA
mat_kernel ?A = {v \<in> carrier_vec (dim_col ?A). ?A *\<^sub>v v = 0\<^sub>v (dim_row ?A)}

goal (1 subgoal):
 1. set (find_base_vectors Ag) \<subseteq> carrier_vec dA
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
set base \<subseteq> carrier_vec dA

goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
interpret k: kernel dB dA Ag
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix_Kernel.kernel dB dA Ag
[PROOF STEP]
apply standard
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Ag \<in> carrier_mat dB dA
[PROOF STEP]
using Ag_carrier
[PROOF STATE]
proof (prove)
using this:
Ag \<in> carrier_mat dB dA

goal (1 subgoal):
 1. Ag \<in> carrier_mat dB dA
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
have basis_base: "kernel.basis dA Ag (set base)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k.basis (set base)
[PROOF STEP]
using row_echelon Ag_carrier
[PROOF STATE]
proof (prove)
using this:
row_echelon_form Ag
Ag \<in> carrier_mat dB dA

goal (1 subgoal):
 1. k.basis (set base)
[PROOF STEP]
unfolding base_def
[PROOF STATE]
proof (prove)
using this:
row_echelon_form Ag
Ag \<in> carrier_mat dB dA

goal (1 subgoal):
 1. k.basis (set (find_base_vectors Ag))
[PROOF STEP]
by (rule find_base_vectors(3))
[PROOF STATE]
proof (state)
this:
k.basis (set base)

goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
have "space_as_set (SPAN base)
       = space_as_set (ccspan (basis_enum_of_vec ` set base :: 'a set))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. space_as_set (SPAN base) = space_as_set (ccspan (basis_enum_of_vec ` set base))
[PROOF STEP]
unfolding SPAN_def dA_def[symmetric] Let_def filter_set
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. space_as_set (ccspan (basis_enum_of_vec ` set (filter (\<lambda>v. dim_vec v = dA) base))) = space_as_set (ccspan (basis_enum_of_vec ` set base))
[PROOF STEP]
apply (subst filter_True)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<forall>x\<in>set base. dim_vec x = dA
 2. space_as_set (ccspan (basis_enum_of_vec ` set base)) = space_as_set (ccspan (basis_enum_of_vec ` set base))
[PROOF STEP]
using base_carrier
[PROOF STATE]
proof (prove)
using this:
set base \<subseteq> carrier_vec dA

goal (2 subgoals):
 1. \<forall>x\<in>set base. dim_vec x = dA
 2. space_as_set (ccspan (basis_enum_of_vec ` set base)) = space_as_set (ccspan (basis_enum_of_vec ` set base))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
space_as_set (SPAN base) = space_as_set (ccspan (basis_enum_of_vec ` set base))

goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
space_as_set (SPAN base) = space_as_set (ccspan (basis_enum_of_vec ` set base))

goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
have "\<dots> = cspan (basis_enum_of_vec ` set base)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. space_as_set (ccspan (basis_enum_of_vec ` set base)) = cspan (basis_enum_of_vec ` set base)
[PROOF STEP]
apply transfer
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>base. closure (cspan (basis_enum_of_vec ` set base)) = cspan (basis_enum_of_vec ` set base)
[PROOF STEP]
apply (subst closure_finite_cspan)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>base. finite (basis_enum_of_vec ` set base)
 2. \<And>base. cspan (basis_enum_of_vec ` set base) = cspan (basis_enum_of_vec ` set base)
[PROOF STEP]
by simp_all
[PROOF STATE]
proof (state)
this:
space_as_set (ccspan (basis_enum_of_vec ` set base)) = cspan (basis_enum_of_vec ` set base)

goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
space_as_set (ccspan (basis_enum_of_vec ` set base)) = cspan (basis_enum_of_vec ` set base)

goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
have "\<dots> = basis_enum_of_vec ` span (set base)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cspan (basis_enum_of_vec ` set base) = basis_enum_of_vec ` local.span (set base)
[PROOF STEP]
apply (subst basis_enum_of_vec_span)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. length canonical_basis = dA
 2. set base \<subseteq> carrier_vec dA
 3. cspan (basis_enum_of_vec ` set base) = cspan (basis_enum_of_vec ` set base)
[PROOF STEP]
using base_carrier dA_def
[PROOF STATE]
proof (prove)
using this:
set base \<subseteq> carrier_vec dA
dA = length canonical_basis

goal (3 subgoals):
 1. length canonical_basis = dA
 2. set base \<subseteq> carrier_vec dA
 3. cspan (basis_enum_of_vec ` set base) = cspan (basis_enum_of_vec ` set base)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
cspan (basis_enum_of_vec ` set base) = basis_enum_of_vec ` local.span (set base)

goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
cspan (basis_enum_of_vec ` set base) = basis_enum_of_vec ` local.span (set base)

goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
have "\<dots> = basis_enum_of_vec ` mat_kernel Ag"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. basis_enum_of_vec ` local.span (set base) = basis_enum_of_vec ` mat_kernel Ag
[PROOF STEP]
using basis_base k.Ker.basis_def k.span_same
[PROOF STATE]
proof (prove)
using this:
k.basis (set base)
k.basis ?A = (k.lin_indpt ?A \<and> k.span ?A = mat_kernel Ag \<and> ?A \<subseteq> mat_kernel Ag)
?S \<subseteq> mat_kernel Ag \<Longrightarrow> k.span ?S = local.span ?S

goal (1 subgoal):
 1. basis_enum_of_vec ` local.span (set base) = basis_enum_of_vec ` mat_kernel Ag
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
basis_enum_of_vec ` local.span (set base) = basis_enum_of_vec ` mat_kernel Ag

goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
basis_enum_of_vec ` local.span (set base) = basis_enum_of_vec ` mat_kernel Ag

goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
have "\<dots> = basis_enum_of_vec ` {v \<in> carrier_vec dA. Ag *\<^sub>v v = 0\<^sub>v dB}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. basis_enum_of_vec ` mat_kernel Ag = basis_enum_of_vec ` {v \<in> carrier_vec dA. Ag *\<^sub>v v = 0\<^sub>v dB}
[PROOF STEP]
apply (rule arg_cong[where f="\<lambda>x. basis_enum_of_vec ` x"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_kernel Ag = {v \<in> carrier_vec dA. Ag *\<^sub>v v = 0\<^sub>v dB}
[PROOF STEP]
unfolding mat_kernel_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {v \<in> carrier_vec (dim_col Ag). Ag *\<^sub>v v = 0\<^sub>v (dim_row Ag)} = {v \<in> carrier_vec dA. Ag *\<^sub>v v = 0\<^sub>v dB}
[PROOF STEP]
using Ag_carrier
[PROOF STATE]
proof (prove)
using this:
Ag \<in> carrier_mat dB dA

goal (1 subgoal):
 1. {v \<in> carrier_vec (dim_col Ag). Ag *\<^sub>v v = 0\<^sub>v (dim_row Ag)} = {v \<in> carrier_vec dA. Ag *\<^sub>v v = 0\<^sub>v dB}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
basis_enum_of_vec ` mat_kernel Ag = basis_enum_of_vec ` {v \<in> carrier_vec dA. Ag *\<^sub>v v = 0\<^sub>v dB}

goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
basis_enum_of_vec ` mat_kernel Ag = basis_enum_of_vec ` {v \<in> carrier_vec dA. Ag *\<^sub>v v = 0\<^sub>v dB}

goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
have "\<dots> = basis_enum_of_vec ` {v \<in> carrier_vec dA. Am *\<^sub>v v = 0\<^sub>v dB}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. basis_enum_of_vec ` {v \<in> carrier_vec dA. Ag *\<^sub>v v = 0\<^sub>v dB} = basis_enum_of_vec ` {v \<in> carrier_vec dA. Am *\<^sub>v v = 0\<^sub>v dB}
[PROOF STEP]
using gauss_jordan_single(1)[OF Am_carrier Ag_def[symmetric]]
[PROOF STATE]
proof (prove)
using this:
?x \<in> carrier_vec dA \<Longrightarrow> (Am *\<^sub>v ?x = 0\<^sub>v dB) = (Ag *\<^sub>v ?x = 0\<^sub>v dB)

goal (1 subgoal):
 1. basis_enum_of_vec ` {v \<in> carrier_vec dA. Ag *\<^sub>v v = 0\<^sub>v dB} = basis_enum_of_vec ` {v \<in> carrier_vec dA. Am *\<^sub>v v = 0\<^sub>v dB}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
basis_enum_of_vec ` {v \<in> carrier_vec dA. Ag *\<^sub>v v = 0\<^sub>v dB} = basis_enum_of_vec ` {v \<in> carrier_vec dA. Am *\<^sub>v v = 0\<^sub>v dB}

goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
basis_enum_of_vec ` {v \<in> carrier_vec dA. Ag *\<^sub>v v = 0\<^sub>v dB} = basis_enum_of_vec ` {v \<in> carrier_vec dA. Am *\<^sub>v v = 0\<^sub>v dB}

goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
have "\<dots> = {w. A *\<^sub>V w = 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. basis_enum_of_vec ` {v \<in> carrier_vec dA. Am *\<^sub>v v = 0\<^sub>v dB} = {w. A *\<^sub>V w = (0::'b)}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. basis_enum_of_vec ` {v \<in> carrier_vec dA. Am *\<^sub>v v = 0\<^sub>v dB} = {w. A *\<^sub>V w = (0::'b)}
[PROOF STEP]
have "basis_enum_of_vec ` {v \<in> carrier_vec dA. Am *\<^sub>v v = 0\<^sub>v dB}
        = basis_enum_of_vec ` {v \<in> carrier_vec dA. A *\<^sub>V basis_enum_of_vec v = 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. basis_enum_of_vec ` {v \<in> carrier_vec dA. Am *\<^sub>v v = 0\<^sub>v dB} = basis_enum_of_vec ` {v \<in> carrier_vec dA. A *\<^sub>V basis_enum_of_vec v = (0::'b)}
[PROOF STEP]
apply (rule arg_cong[where f="\<lambda>t. basis_enum_of_vec ` t"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {v \<in> carrier_vec dA. Am *\<^sub>v v = 0\<^sub>v dB} = {v \<in> carrier_vec dA. A *\<^sub>V basis_enum_of_vec v = (0::'b)}
[PROOF STEP]
apply (rule Collect_cong)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>v. (v \<in> carrier_vec dA \<and> Am *\<^sub>v v = 0\<^sub>v dB) = (v \<in> carrier_vec dA \<and> A *\<^sub>V basis_enum_of_vec v = (0::'b))
[PROOF STEP]
apply (simp add: Am_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>v. (v \<in> carrier_vec dA \<and> mat_of_cblinfun A *\<^sub>v v = 0\<^sub>v dB) = (v \<in> carrier_vec dA \<and> A *\<^sub>V basis_enum_of_vec v = (0::'b))
[PROOF STEP]
by (metis Am_carrier Am_def carrier_matD(2) carrier_vecD dB_def mat_carrier
          mat_of_cblinfun_def mat_of_cblinfun_cblinfun_apply vec_of_basis_enum_inverse
          basis_enum_of_vec_inverse vec_of_basis_enum_zero)
[PROOF STATE]
proof (state)
this:
basis_enum_of_vec ` {v \<in> carrier_vec dA. Am *\<^sub>v v = 0\<^sub>v dB} = basis_enum_of_vec ` {v \<in> carrier_vec dA. A *\<^sub>V basis_enum_of_vec v = (0::'b)}

goal (1 subgoal):
 1. basis_enum_of_vec ` {v \<in> carrier_vec dA. Am *\<^sub>v v = 0\<^sub>v dB} = {w. A *\<^sub>V w = (0::'b)}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
basis_enum_of_vec ` {v \<in> carrier_vec dA. Am *\<^sub>v v = 0\<^sub>v dB} = basis_enum_of_vec ` {v \<in> carrier_vec dA. A *\<^sub>V basis_enum_of_vec v = (0::'b)}

goal (1 subgoal):
 1. basis_enum_of_vec ` {v \<in> carrier_vec dA. Am *\<^sub>v v = 0\<^sub>v dB} = {w. A *\<^sub>V w = (0::'b)}
[PROOF STEP]
have "\<dots> = {w \<in> basis_enum_of_vec ` carrier_vec dA. A *\<^sub>V w = 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. basis_enum_of_vec ` {v \<in> carrier_vec dA. A *\<^sub>V basis_enum_of_vec v = (0::'b)} = {w \<in> basis_enum_of_vec ` carrier_vec dA. A *\<^sub>V w = (0::'b)}
[PROOF STEP]
apply (subst Compr_image_eq[symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x \<in> basis_enum_of_vec ` carrier_vec dA. A *\<^sub>V x = (0::'b)} = {w \<in> basis_enum_of_vec ` carrier_vec dA. A *\<^sub>V w = (0::'b)}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
basis_enum_of_vec ` {v \<in> carrier_vec dA. A *\<^sub>V basis_enum_of_vec v = (0::'b)} = {w \<in> basis_enum_of_vec ` carrier_vec dA. A *\<^sub>V w = (0::'b)}

goal (1 subgoal):
 1. basis_enum_of_vec ` {v \<in> carrier_vec dA. Am *\<^sub>v v = 0\<^sub>v dB} = {w. A *\<^sub>V w = (0::'b)}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
basis_enum_of_vec ` {v \<in> carrier_vec dA. A *\<^sub>V basis_enum_of_vec v = (0::'b)} = {w \<in> basis_enum_of_vec ` carrier_vec dA. A *\<^sub>V w = (0::'b)}

goal (1 subgoal):
 1. basis_enum_of_vec ` {v \<in> carrier_vec dA. Am *\<^sub>v v = 0\<^sub>v dB} = {w. A *\<^sub>V w = (0::'b)}
[PROOF STEP]
have "\<dots> = {w. A *\<^sub>V w = 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {w \<in> basis_enum_of_vec ` carrier_vec dA. A *\<^sub>V w = (0::'b)} = {w. A *\<^sub>V w = (0::'b)}
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. A *\<^sub>V x = (0::'b) \<Longrightarrow> x \<in> basis_enum_of_vec ` carrier_vec dA
[PROOF STEP]
by (metis (no_types, lifting) Am_carrier Am_def carrier_matD(2) carrier_vec_dim_vec dim_vec_of_basis_enum' image_iff mat_carrier mat_of_cblinfun_def vec_of_basis_enum_inverse)
[PROOF STATE]
proof (state)
this:
{w \<in> basis_enum_of_vec ` carrier_vec dA. A *\<^sub>V w = (0::'b)} = {w. A *\<^sub>V w = (0::'b)}

goal (1 subgoal):
 1. basis_enum_of_vec ` {v \<in> carrier_vec dA. Am *\<^sub>v v = 0\<^sub>v dB} = {w. A *\<^sub>V w = (0::'b)}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
basis_enum_of_vec ` {v \<in> carrier_vec dA. Am *\<^sub>v v = 0\<^sub>v dB} = {w. A *\<^sub>V w = (0::'b)}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
basis_enum_of_vec ` {v \<in> carrier_vec dA. Am *\<^sub>v v = 0\<^sub>v dB} = {w. A *\<^sub>V w = (0::'b)}

goal (1 subgoal):
 1. basis_enum_of_vec ` {v \<in> carrier_vec dA. Am *\<^sub>v v = 0\<^sub>v dB} = {w. A *\<^sub>V w = (0::'b)}
[PROOF STEP]
by -
[PROOF STATE]
proof (state)
this:
basis_enum_of_vec ` {v \<in> carrier_vec dA. Am *\<^sub>v v = 0\<^sub>v dB} = {w. A *\<^sub>V w = (0::'b)}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
basis_enum_of_vec ` {v \<in> carrier_vec dA. Am *\<^sub>v v = 0\<^sub>v dB} = {w. A *\<^sub>V w = (0::'b)}

goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
basis_enum_of_vec ` {v \<in> carrier_vec dA. Am *\<^sub>v v = 0\<^sub>v dB} = {w. A *\<^sub>V w = (0::'b)}

goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
have "\<dots> = space_as_set (kernel A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {w. A *\<^sub>V w = (0::'b)} = space_as_set (kernel A)
[PROOF STEP]
apply transfer
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>A. bounded_clinear A \<Longrightarrow> {w. A w = (0::'b)} = A -` {0::'b}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{w. A *\<^sub>V w = (0::'b)} = space_as_set (kernel A)

goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
space_as_set (SPAN base) = space_as_set (kernel A)
[PROOF STEP]
have "SPAN base = kernel A"
[PROOF STATE]
proof (prove)
using this:
space_as_set (SPAN base) = space_as_set (kernel A)

goal (1 subgoal):
 1. SPAN base = kernel A
[PROOF STEP]
by (simp add: space_as_set_inject)
[PROOF STATE]
proof (state)
this:
SPAN base = kernel A

goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
SPAN base = kernel A
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
SPAN base = kernel A

goal (1 subgoal):
 1. kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))
[PROOF STEP]
by (simp add: base_def Ag_def Am_def)
[PROOF STATE]
proof (state)
this:
kernel A = SPAN (find_base_vectors (gauss_jordan_single (mat_of_cblinfun A)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma L2_set_eq_0_iff: "finite A \<Longrightarrow> L2_set f A = 0 \<longleftrightarrow> (\<forall>x\<in>A. f x = 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite A \<Longrightarrow> (L2_set f A = 0) = (\<forall>x\<in>A. f x = 0)
[PROOF STEP]
unfolding L2_set_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite A \<Longrightarrow> (sqrt (\<Sum>i\<in>A. (f i)\<^sup>2) = 0) = (\<forall>x\<in>A. f x = 0)
[PROOF STEP]
by (simp add: sum_nonneg sum_nonneg_eq_0_iff)


[STATEMENT]
lemma Inf_ccsubspace_code[code]:
  \<comment> \<open>Infimum (intersection) of a set of subspaces.
      Implemented by the orthogonal complement of the supremum.\<close>
  "Inf (Set_Monad l :: 'a::onb_enum ccsubspace set)
  = - Sup (Set_Monad (map uminus l))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Sqinter> Set_Monad l = - \<Squnion> Set_Monad (map uminus l)
[PROOF STEP]
unfolding Set_Monad_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Sqinter> set l = - \<Squnion> set (map uminus l)
[PROOF STEP]
apply (induction l)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<Sqinter> set [] = - \<Squnion> set (map uminus [])
 2. \<And>a l. \<Sqinter> set l = - \<Squnion> set (map uminus l) \<Longrightarrow> \<Sqinter> set (a # l) = - \<Squnion> set (map uminus (a # l))
[PROOF STEP]
by auto


[STATEMENT]
lemma sum_swap: "(\<Sum>i=0..<(x::nat). \<Sum>j=0..<(y::nat). f i j) =
                 (\<Sum>j=0..<(y::nat). \<Sum>i=0..<(x::nat). f i j ) "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<x. sum (f i) {0..<y}) = (\<Sum>j = 0..<y. \<Sum>i = 0..<x. f i j)
[PROOF STEP]
using Groups_Big.comm_monoid_add_class.sum.swap
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i\<in>?A. sum (?g i) ?B) = (\<Sum>j\<in>?B. \<Sum>i\<in>?A. ?g i j)

goal (1 subgoal):
 1. (\<Sum>i = 0..<x. sum (f i) {0..<y}) = (\<Sum>j = 0..<y. \<Sum>i = 0..<x. f i j)
[PROOF STEP]
by fast


[STATEMENT]
lemma main_real:
  assumes "b < a"
  shows "valid_countings a b = (a - b) / (a + b) * all_countings a b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (valid_countings a b) = (real a - real b) / (real a + real b) * real (all_countings a b)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
b < a

goal (1 subgoal):
 1. real (valid_countings a b) = (real a - real b) / (real a + real b) * real (all_countings a b)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. b < a \<Longrightarrow> real (valid_countings a b) = (real a - real b) / (real a + real b) * real (all_countings a b)
[PROOF STEP]
from main_nat[of a b] \<open>b < a\<close>
[PROOF STATE]
proof (chain)
picking this:
(a + b) * valid_countings a b = (a - b) * all_countings a b
b < a
[PROOF STEP]
have
    "(real a + real b) * real (valid_countings a b) = (real a - real b) * real (all_countings a b)"
[PROOF STATE]
proof (prove)
using this:
(a + b) * valid_countings a b = (a - b) * all_countings a b
b < a

goal (1 subgoal):
 1. (real a + real b) * real (valid_countings a b) = (real a - real b) * real (all_countings a b)
[PROOF STEP]
by (simp only: of_nat_add[symmetric] of_nat_mult[symmetric]) auto
[PROOF STATE]
proof (state)
this:
(real a + real b) * real (valid_countings a b) = (real a - real b) * real (all_countings a b)

goal (1 subgoal):
 1. b < a \<Longrightarrow> real (valid_countings a b) = (real a - real b) / (real a + real b) * real (all_countings a b)
[PROOF STEP]
from this \<open>b < a\<close>
[PROOF STATE]
proof (chain)
picking this:
(real a + real b) * real (valid_countings a b) = (real a - real b) * real (all_countings a b)
b < a
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(real a + real b) * real (valid_countings a b) = (real a - real b) * real (all_countings a b)
b < a

goal (1 subgoal):
 1. real (valid_countings a b) = (real a - real b) / (real a + real b) * real (all_countings a b)
[PROOF STEP]
by (subst mult_left_cancel[of "real a + real b", symmetric]) auto
[PROOF STATE]
proof (state)
this:
real (valid_countings a b) = (real a - real b) / (real a + real b) * real (all_countings a b)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma finite_k_words: "finite (k_words k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {w. length w = k \<and> set w \<subseteq> L}
[PROOF STEP]
proof (induct k)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. finite {w. length w = 0 \<and> set w \<subseteq> L}
 2. \<And>k. finite {w. length w = k \<and> set w \<subseteq> L} \<Longrightarrow> finite {w. length w = Suc k \<and> set w \<subseteq> L}
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. finite {w. length w = 0 \<and> set w \<subseteq> L}
 2. \<And>k. finite {w. length w = k \<and> set w \<subseteq> L} \<Longrightarrow> finite {w. length w = Suc k \<and> set w \<subseteq> L}
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {w. length w = 0 \<and> set w \<subseteq> L}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
finite {w. length w = 0 \<and> set w \<subseteq> L}

goal (1 subgoal):
 1. \<And>k. finite {w. length w = k \<and> set w \<subseteq> L} \<Longrightarrow> finite {w. length w = Suc k \<and> set w \<subseteq> L}
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
finite {w. length w = n \<and> set w \<subseteq> L}

goal (1 subgoal):
 1. \<And>k. finite {w. length w = k \<and> set w \<subseteq> L} \<Longrightarrow> finite {w. length w = Suc k \<and> set w \<subseteq> L}
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
finite {w. length w = n \<and> set w \<subseteq> L}

goal (1 subgoal):
 1. finite {w. length w = Suc n \<and> set w \<subseteq> L}
[PROOF STEP]
using bij_k_words bij_betw_finite fin_L
[PROOF STATE]
proof (prove)
using this:
finite {w. length w = n \<and> set w \<subseteq> L}
bij_betw (\<lambda>wi. fst wi # snd wi) (L \<times> {w. length w = ?k \<and> set w \<subseteq> L}) {w. length w = Suc ?k \<and> set w \<subseteq> L}
bij_betw ?f ?A ?B \<Longrightarrow> finite ?A = finite ?B
finite L

goal (1 subgoal):
 1. finite {w. length w = Suc n \<and> set w \<subseteq> L}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
finite {w. length w = Suc n \<and> set w \<subseteq> L}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma tanh_real_altdef: "tanh (x::real) = (1 - exp (- 2 * x)) / (1 + exp (- 2 * x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tanh x = (1 - exp (- 2 * x)) / (1 + exp (- 2 * x))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. tanh x = (1 - exp (- 2 * x)) / (1 + exp (- 2 * x))
[PROOF STEP]
have [simp]: "exp (2 * x) = exp x * exp x" "exp (x * 2) = exp x * exp x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. exp (2 * x) = exp x * exp x &&& exp (x * 2) = exp x * exp x
[PROOF STEP]
by (subst exp_add [symmetric]; simp)+
[PROOF STATE]
proof (state)
this:
exp (2 * x) = exp x * exp x
exp (x * 2) = exp x * exp x

goal (1 subgoal):
 1. tanh x = (1 - exp (- 2 * x)) / (1 + exp (- 2 * x))
[PROOF STEP]
have "tanh x = (2 * exp (-x) * sinh x) / (2 * exp (-x) * cosh x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tanh x = 2 * exp (- x) * sinh x / (2 * exp (- x) * cosh x)
[PROOF STEP]
by (simp add: tanh_def)
[PROOF STATE]
proof (state)
this:
tanh x = 2 * exp (- x) * sinh x / (2 * exp (- x) * cosh x)

goal (1 subgoal):
 1. tanh x = (1 - exp (- 2 * x)) / (1 + exp (- 2 * x))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
tanh x = 2 * exp (- x) * sinh x / (2 * exp (- x) * cosh x)

goal (1 subgoal):
 1. tanh x = (1 - exp (- 2 * x)) / (1 + exp (- 2 * x))
[PROOF STEP]
have "2 * exp (-x) * sinh x = 1 - exp (-2*x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * exp (- x) * sinh x = 1 - exp (- 2 * x)
[PROOF STEP]
by (simp add: exp_minus field_simps sinh_def)
[PROOF STATE]
proof (state)
this:
2 * exp (- x) * sinh x = 1 - exp (- 2 * x)

goal (1 subgoal):
 1. tanh x = (1 - exp (- 2 * x)) / (1 + exp (- 2 * x))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 * exp (- x) * sinh x = 1 - exp (- 2 * x)

goal (1 subgoal):
 1. tanh x = (1 - exp (- 2 * x)) / (1 + exp (- 2 * x))
[PROOF STEP]
have "2 * exp (-x) * cosh x = 1 + exp (-2*x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * exp (- x) * cosh x = 1 + exp (- 2 * x)
[PROOF STEP]
by (simp add: exp_minus field_simps cosh_def)
[PROOF STATE]
proof (state)
this:
2 * exp (- x) * cosh x = 1 + exp (- 2 * x)

goal (1 subgoal):
 1. tanh x = (1 - exp (- 2 * x)) / (1 + exp (- 2 * x))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
tanh x = (1 - exp (- 2 * x)) / (1 + exp (- 2 * x))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
tanh x = (1 - exp (- 2 * x)) / (1 + exp (- 2 * x))

goal (1 subgoal):
 1. tanh x = (1 - exp (- 2 * x)) / (1 + exp (- 2 * x))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
tanh x = (1 - exp (- 2 * x)) / (1 + exp (- 2 * x))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Rats_solution_QE_converse:
  assumes "a \<in> \<rat>" "b \<in> \<rat>"
  and "a*x^2 + b*x + c = 0"
  and "x \<in> \<rat>"
  shows "sqrt (discrim a b c) \<in> \<rat>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sqrt (discrim a b c) \<in> \<rat>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. sqrt (discrim a b c) \<in> \<rat>
[PROOF STEP]
from assms(3)
[PROOF STATE]
proof (chain)
picking this:
a * x\<^sup>2 + b * x + c = 0
[PROOF STEP]
have "discrim a b c = (2*a*x+b)^2"
[PROOF STATE]
proof (prove)
using this:
a * x\<^sup>2 + b * x + c = 0

goal (1 subgoal):
 1. discrim a b c = (2 * a * x + b)\<^sup>2
[PROOF STEP]
unfolding discrim_def
[PROOF STATE]
proof (prove)
using this:
a * x\<^sup>2 + b * x + c = 0

goal (1 subgoal):
 1. b\<^sup>2 - 4 * a * c = (2 * a * x + b)\<^sup>2
[PROOF STEP]
by algebra
[PROOF STATE]
proof (state)
this:
discrim a b c = (2 * a * x + b)\<^sup>2

goal (1 subgoal):
 1. sqrt (discrim a b c) \<in> \<rat>
[PROOF STEP]
hence "sqrt (discrim a b c) = \<bar>2*a*x+b\<bar>"
[PROOF STATE]
proof (prove)
using this:
discrim a b c = (2 * a * x + b)\<^sup>2

goal (1 subgoal):
 1. sqrt (discrim a b c) = \<bar>2 * a * x + b\<bar>
[PROOF STEP]
by (simp)
[PROOF STATE]
proof (state)
this:
sqrt (discrim a b c) = \<bar>2 * a * x + b\<bar>

goal (1 subgoal):
 1. sqrt (discrim a b c) \<in> \<rat>
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
sqrt (discrim a b c) = \<bar>2 * a * x + b\<bar>

goal (1 subgoal):
 1. sqrt (discrim a b c) \<in> \<rat>
[PROOF STEP]
using \<open>a \<in> \<rat>\<close> \<open>b \<in> \<rat>\<close> \<open>x \<in> \<rat>\<close>
[PROOF STATE]
proof (prove)
using this:
sqrt (discrim a b c) = \<bar>2 * a * x + b\<bar>
a \<in> \<rat>
b \<in> \<rat>
x \<in> \<rat>

goal (1 subgoal):
 1. sqrt (discrim a b c) \<in> \<rat>
[PROOF STEP]
by (simp)
[PROOF STATE]
proof (state)
this:
sqrt (discrim a b c) \<in> \<rat>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem catalan_Suc':
  "catalan (Suc n) = (catalan n * (2*(2*n+1))) div (n+2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. catalan (Suc n) = catalan n * (2 * (2 * n + 1)) div (n + 2)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. catalan (Suc n) = catalan n * (2 * (2 * n + 1)) div (n + 2)
[PROOF STEP]
from catalan_Suc_aux[of n]
[PROOF STATE]
proof (chain)
picking this:
(n + 2) * catalan (Suc n) = 2 * (2 * n + 1) * catalan n
[PROOF STEP]
have "catalan n * (2*(2*n+1)) = catalan (Suc n) * (n+2)"
[PROOF STATE]
proof (prove)
using this:
(n + 2) * catalan (Suc n) = 2 * (2 * n + 1) * catalan n

goal (1 subgoal):
 1. catalan n * (2 * (2 * n + 1)) = catalan (Suc n) * (n + 2)
[PROOF STEP]
by (simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
catalan n * (2 * (2 * n + 1)) = catalan (Suc n) * (n + 2)

goal (1 subgoal):
 1. catalan (Suc n) = catalan n * (2 * (2 * n + 1)) div (n + 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
catalan n * (2 * (2 * n + 1)) = catalan (Suc n) * (n + 2)

goal (1 subgoal):
 1. catalan (Suc n) = catalan n * (2 * (2 * n + 1)) div (n + 2)
[PROOF STEP]
have "\<dots> div (n+2) = catalan (Suc n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. catalan (Suc n) * (n + 2) div (n + 2) = catalan (Suc n)
[PROOF STEP]
by (simp del: mult_Suc mult_Suc_right)
[PROOF STATE]
proof (state)
this:
catalan (Suc n) * (n + 2) div (n + 2) = catalan (Suc n)

goal (1 subgoal):
 1. catalan (Suc n) = catalan n * (2 * (2 * n + 1)) div (n + 2)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
catalan n * (2 * (2 * n + 1)) div (n + 2) = catalan (Suc n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
catalan n * (2 * (2 * n + 1)) div (n + 2) = catalan (Suc n)

goal (1 subgoal):
 1. catalan (Suc n) = catalan n * (2 * (2 * n + 1)) div (n + 2)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
catalan (Suc n) = catalan n * (2 * (2 * n + 1)) div (n + 2)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma cos_multiple: "cos (n * x) = 2 * cos x * cos ((n - 1) * x) - cos ((n - 2) * x)"
  for x :: "'a :: {banach,real_normed_field}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos (n * x) = (2::'a) * cos x * cos ((n - (1::'a)) * x) - cos ((n - (2::'a)) * x)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. cos (n * x) = (2::'a) * cos x * cos ((n - (1::'a)) * x) - cos ((n - (2::'a)) * x)
[PROOF STEP]
have "cos ((n - 1) * x + x) + cos ((n - 1) * x - x) = 2 * cos ((n - 1) * x) * cos x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos ((n - (1::'a)) * x + x) + cos ((n - (1::'a)) * x - x) = (2::'a) * cos ((n - (1::'a)) * x) * cos x
[PROOF STEP]
by (simp add: cos_add cos_diff)
[PROOF STATE]
proof (state)
this:
cos ((n - (1::'a)) * x + x) + cos ((n - (1::'a)) * x - x) = (2::'a) * cos ((n - (1::'a)) * x) * cos x

goal (1 subgoal):
 1. cos (n * x) = (2::'a) * cos x * cos ((n - (1::'a)) * x) - cos ((n - (2::'a)) * x)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
cos ((n - (1::'a)) * x + x) + cos ((n - (1::'a)) * x - x) = (2::'a) * cos ((n - (1::'a)) * x) * cos x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
cos ((n - (1::'a)) * x + x) + cos ((n - (1::'a)) * x - x) = (2::'a) * cos ((n - (1::'a)) * x) * cos x

goal (1 subgoal):
 1. cos (n * x) = (2::'a) * cos x * cos ((n - (1::'a)) * x) - cos ((n - (2::'a)) * x)
[PROOF STEP]
by (simp add: left_diff_distrib' eq_diff_eq)
[PROOF STATE]
proof (state)
this:
cos (n * x) = (2::'a) * cos x * cos ((n - (1::'a)) * x) - cos ((n - (2::'a)) * x)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma matrix_sum_trace_le:
  fixes f :: "nat \<Rightarrow> complex mat" and g :: "nat \<Rightarrow> complex mat"
  assumes "(\<And>k. k < n \<Longrightarrow> f k \<in> carrier_mat d d)"
    "(\<And>k. k < n \<Longrightarrow> g k \<in> carrier_mat d d)"
    "(\<And>k. k < n \<Longrightarrow> trace (f k) \<le> trace (g k))"
  shows "trace (matrix_sum d f n) \<le> trace (matrix_sum d g n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (matrix_sum d f n) \<le> trace (matrix_sum d g n)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. trace (matrix_sum d f n) \<le> trace (matrix_sum d g n)
[PROOF STEP]
have "sum (\<lambda>k. trace (f k)) {0..<n} \<le>  sum (\<lambda>k. trace (g k)) {0..<n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k = 0..<n. trace (f k)) \<le> (\<Sum>k = 0..<n. trace (g k))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
?k < n \<Longrightarrow> f ?k \<in> carrier_mat d d
?k < n \<Longrightarrow> g ?k \<in> carrier_mat d d
?k < n \<Longrightarrow> trace (f ?k) \<le> trace (g ?k)

goal (1 subgoal):
 1. (\<Sum>k = 0..<n. trace (f k)) \<le> (\<Sum>k = 0..<n. trace (g k))
[PROOF STEP]
by (meson atLeastLessThan_iff sum_mono)
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 0..<n. trace (f k)) \<le> (\<Sum>k = 0..<n. trace (g k))

goal (1 subgoal):
 1. trace (matrix_sum d f n) \<le> trace (matrix_sum d g n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>k = 0..<n. trace (f k)) \<le> (\<Sum>k = 0..<n. trace (g k))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>k = 0..<n. trace (f k)) \<le> (\<Sum>k = 0..<n. trace (g k))

goal (1 subgoal):
 1. trace (matrix_sum d f n) \<le> trace (matrix_sum d g n)
[PROOF STEP]
using trace_matrix_sum_linear assms
[PROOF STATE]
proof (prove)
using this:
(\<Sum>k = 0..<n. trace (f k)) \<le> (\<Sum>k = 0..<n. trace (g k))
(\<And>k. k < ?n \<Longrightarrow> ?f k \<in> carrier_mat ?d ?d) \<Longrightarrow> trace (matrix_sum ?d ?f ?n) = (\<Sum>k = 0..<?n. trace (?f k))
?k < n \<Longrightarrow> f ?k \<in> carrier_mat d d
?k < n \<Longrightarrow> g ?k \<in> carrier_mat d d
?k < n \<Longrightarrow> trace (f ?k) \<le> trace (g ?k)

goal (1 subgoal):
 1. trace (matrix_sum d f n) \<le> trace (matrix_sum d g n)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (matrix_sum d f n) \<le> trace (matrix_sum d g n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem of_nat_catalan_Suc':
  "of_nat (catalan (Suc n)) =
     (of_nat (2*(2*n+1)) / of_nat (n+2) * of_nat (catalan n) :: 'a :: field_char_0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_nat (catalan (Suc n)) = of_nat (2 * (2 * n + 1)) / of_nat (n + 2) * of_nat (catalan n)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. of_nat (catalan (Suc n)) = of_nat (2 * (2 * n + 1)) / of_nat (n + 2) * of_nat (catalan n)
[PROOF STEP]
have "(of_nat (2*(2*n+1)) / of_nat (n+2) * of_nat (catalan n) :: 'a) =
          of_nat (2*(2*n + 1) * catalan n) / of_nat (n+2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_nat (2 * (2 * n + 1)) / of_nat (n + 2) * of_nat (catalan n) = of_nat (2 * (2 * n + 1) * catalan n) / of_nat (n + 2)
[PROOF STEP]
by (simp add: divide_simps mult_ac del: mult_Suc mult_Suc_right)
[PROOF STATE]
proof (state)
this:
of_nat (2 * (2 * n + 1)) / of_nat (n + 2) * of_nat (catalan n) = of_nat (2 * (2 * n + 1) * catalan n) / of_nat (n + 2)

goal (1 subgoal):
 1. of_nat (catalan (Suc n)) = of_nat (2 * (2 * n + 1)) / of_nat (n + 2) * of_nat (catalan n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
of_nat (2 * (2 * n + 1)) / of_nat (n + 2) * of_nat (catalan n) = of_nat (2 * (2 * n + 1) * catalan n) / of_nat (n + 2)

goal (1 subgoal):
 1. of_nat (catalan (Suc n)) = of_nat (2 * (2 * n + 1)) / of_nat (n + 2) * of_nat (catalan n)
[PROOF STEP]
note catalan_Suc_aux[of n, symmetric]
[PROOF STATE]
proof (state)
this:
2 * (2 * n + 1) * catalan n = (n + 2) * catalan (Suc n)

goal (1 subgoal):
 1. of_nat (catalan (Suc n)) = of_nat (2 * (2 * n + 1)) / of_nat (n + 2) * of_nat (catalan n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 * (2 * n + 1) * catalan n = (n + 2) * catalan (Suc n)

goal (1 subgoal):
 1. of_nat (catalan (Suc n)) = of_nat (2 * (2 * n + 1)) / of_nat (n + 2) * of_nat (catalan n)
[PROOF STEP]
have "of_nat ((n + 2) * catalan (Suc n)) / of_nat (n + 2) = (of_nat (catalan (Suc n)) :: 'a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_nat ((n + 2) * catalan (Suc n)) / of_nat (n + 2) = of_nat (catalan (Suc n))
[PROOF STEP]
by (simp del: of_nat_Suc mult_Suc_right mult_Suc)
[PROOF STATE]
proof (state)
this:
of_nat ((n + 2) * catalan (Suc n)) / of_nat (n + 2) = of_nat (catalan (Suc n))

goal (1 subgoal):
 1. of_nat (catalan (Suc n)) = of_nat (2 * (2 * n + 1)) / of_nat (n + 2) * of_nat (catalan n)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
of_nat (2 * (2 * n + 1)) / of_nat (n + 2) * of_nat (catalan n) = of_nat (catalan (Suc n))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
of_nat (2 * (2 * n + 1)) / of_nat (n + 2) * of_nat (catalan n) = of_nat (catalan (Suc n))

goal (1 subgoal):
 1. of_nat (catalan (Suc n)) = of_nat (2 * (2 * n + 1)) / of_nat (n + 2) * of_nat (catalan n)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
of_nat (catalan (Suc n)) = of_nat (2 * (2 * n + 1)) / of_nat (n + 2) * of_nat (catalan n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem pi_series: "pi / 4 = (\<Sum>k. (-1)^k * 1 / real (k * 2 + 1))"
  (is "_ = ?SUM")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pi / 4 = (\<Sum>k. (- 1) ^ k * 1 / real (k * 2 + 1))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. pi / 4 = (\<Sum>k. (- 1) ^ k * 1 / real (k * 2 + 1))
[PROOF STEP]
have "pi / 4 = arctan 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pi / 4 = arctan 1
[PROOF STEP]
using arctan_one
[PROOF STATE]
proof (prove)
using this:
arctan 1 = pi / 4

goal (1 subgoal):
 1. pi / 4 = arctan 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
pi / 4 = arctan 1

goal (1 subgoal):
 1. pi / 4 = (\<Sum>k. (- 1) ^ k * 1 / real (k * 2 + 1))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
pi / 4 = arctan 1

goal (1 subgoal):
 1. pi / 4 = (\<Sum>k. (- 1) ^ k * 1 / real (k * 2 + 1))
[PROOF STEP]
have "\<dots> = ?SUM"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. arctan 1 = (\<Sum>k. (- 1) ^ k * 1 / real (k * 2 + 1))
[PROOF STEP]
using arctan_series[of 1]
[PROOF STATE]
proof (prove)
using this:
\<bar>1\<bar> \<le> 1 \<Longrightarrow> arctan 1 = (\<Sum>k. (- 1) ^ k * (1 / real (k * 2 + 1) * 1 ^ (k * 2 + 1)))

goal (1 subgoal):
 1. arctan 1 = (\<Sum>k. (- 1) ^ k * 1 / real (k * 2 + 1))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
arctan 1 = (\<Sum>k. (- 1) ^ k * 1 / real (k * 2 + 1))

goal (1 subgoal):
 1. pi / 4 = (\<Sum>k. (- 1) ^ k * 1 / real (k * 2 + 1))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
pi / 4 = (\<Sum>k. (- 1) ^ k * 1 / real (k * 2 + 1))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
pi / 4 = (\<Sum>k. (- 1) ^ k * 1 / real (k * 2 + 1))

goal (1 subgoal):
 1. pi / 4 = (\<Sum>k. (- 1) ^ k * 1 / real (k * 2 + 1))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
pi / 4 = (\<Sum>k. (- 1) ^ k * 1 / real (k * 2 + 1))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma card_cartesian_product_6: "card (A \<times> A \<times> A \<times> A \<times> A \<times> A) = (card A) ^ 6"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (A \<times> A \<times> A \<times> A \<times> A \<times> A) = card A ^ 6
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card (A \<times> A \<times> A \<times> A \<times> A \<times> A) = card A ^ 6
[PROOF STEP]
have "card (A \<times> A \<times> A \<times> A \<times> A \<times> A) =
    card A * card A * card A * card A * card A * card A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (A \<times> A \<times> A \<times> A \<times> A \<times> A) = card A * card A * card A * card A * card A * card A
[PROOF STEP]
using card_cartesian_product mult.commute
[PROOF STATE]
proof (prove)
using this:
card (?A \<times> ?B) = card ?A * card ?B
?a * ?b = ?b * ?a

goal (1 subgoal):
 1. card (A \<times> A \<times> A \<times> A \<times> A \<times> A) = card A * card A * card A * card A * card A * card A
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
card (A \<times> A \<times> A \<times> A \<times> A \<times> A) = card A * card A * card A * card A * card A * card A

goal (1 subgoal):
 1. card (A \<times> A \<times> A \<times> A \<times> A \<times> A) = card A ^ 6
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
card (A \<times> A \<times> A \<times> A \<times> A \<times> A) = card A * card A * card A * card A * card A * card A
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
card (A \<times> A \<times> A \<times> A \<times> A \<times> A) = card A * card A * card A * card A * card A * card A

goal (1 subgoal):
 1. card (A \<times> A \<times> A \<times> A \<times> A \<times> A) = card A ^ 6
[PROOF STEP]
by algebra
[PROOF STATE]
proof (state)
this:
card (A \<times> A \<times> A \<times> A \<times> A \<times> A) = card A ^ 6

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Euclid_GCD: "VARS a b
 {0<A & 0<B}
 a := A; b := B;
 WHILE  a \<noteq> b
 INV {0<a & 0<b & gcd A B = gcd a b}
 DO IF a<b THEN b := b-a ELSE a := a-b FI OD
 {a = gcd A B}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {0 < A \<and> 0 < B}
a := A; b := B; WHILE a \<noteq> b INV {0 < a \<and> 0 < b \<and> Arith2.gcd A B = Arith2.gcd a b}  VAR {0}
DO IF a < b THEN b := b - a  ELSE a := a - b FI OD
{a = Arith2.gcd A B}
[PROOF STEP]
apply vcg
  \<comment> \<open>Now prove the verification conditions\<close>
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>a b. 0 < A \<and> 0 < B \<Longrightarrow> 0 < A \<and> 0 < B \<and> Arith2.gcd A B = Arith2.gcd A B
 2. \<And>a b. (0 < a \<and> 0 < b \<and> Arith2.gcd A B = Arith2.gcd a b) \<and> a \<noteq> b \<Longrightarrow> (a < b \<longrightarrow> 0 < a \<and> 0 < b - a \<and> Arith2.gcd A B = Arith2.gcd a (b - a)) \<and> (\<not> a < b \<longrightarrow> 0 < a - b \<and> 0 < b \<and> Arith2.gcd A B = Arith2.gcd (a - b) b)
 3. \<And>a b. (0 < a \<and> 0 < b \<and> Arith2.gcd A B = Arith2.gcd a b) \<and> \<not> a \<noteq> b \<Longrightarrow> a = Arith2.gcd A B
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>a b. \<lbrakk>0 < a; Arith2.gcd A B = Arith2.gcd a b; a < b\<rbrakk> \<Longrightarrow> Arith2.gcd a b = Arith2.gcd a (b - a)
 2. \<And>a b. \<lbrakk>0 < b; Arith2.gcd A B = Arith2.gcd a b; a \<noteq> b; \<not> a < b\<rbrakk> \<Longrightarrow> Arith2.gcd a b = Arith2.gcd (a - b) b
 3. \<And>a. \<lbrakk>0 < a; Arith2.gcd A B = Arith2.gcd a a\<rbrakk> \<Longrightarrow> a = Arith2.gcd a a
[PROOF STEP]
apply(simp add: gcd_diff_r less_imp_le)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>a b. \<lbrakk>0 < b; Arith2.gcd A B = Arith2.gcd a b; a \<noteq> b; \<not> a < b\<rbrakk> \<Longrightarrow> Arith2.gcd a b = Arith2.gcd (a - b) b
 2. \<And>a. \<lbrakk>0 < a; Arith2.gcd A B = Arith2.gcd a a\<rbrakk> \<Longrightarrow> a = Arith2.gcd a a
[PROOF STEP]
apply(simp add: linorder_not_less gcd_diff_l)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a. \<lbrakk>0 < a; Arith2.gcd A B = Arith2.gcd a a\<rbrakk> \<Longrightarrow> a = Arith2.gcd a a
[PROOF STEP]
apply(erule gcd_nnn)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma col_space_eq_row_space_transpose:
  fixes A::"'a::{field}^'n^'m"
  shows "col_space A = row_space (transpose A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. col_space A = row_space (Finite_Cartesian_Product.transpose A)
[PROOF STEP]
unfolding col_space_def row_space_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec.span (columns A) = vec.span (rows (Finite_Cartesian_Product.transpose A))
[PROOF STEP]
unfolding rows_transpose[of A]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec.span (columns A) = vec.span (columns A)
[PROOF STEP]
..


[STATEMENT]
lemma Cauchy_product:
  fixes a b :: "nat \<Rightarrow> 'a::{real_normed_algebra,banach}"
  assumes "summable (\<lambda>k. norm (a k))"
    and "summable (\<lambda>k. norm (b k))"
  shows "(\<Sum>k. a k) * (\<Sum>k. b k) = (\<Sum>k. \<Sum>i\<le>k. a i * b (k - i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k. a k) * (\<Sum>k. b k) = (\<Sum>k. \<Sum>i\<le>k. a i * b (k - i))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
summable (\<lambda>k. norm (a k))
summable (\<lambda>k. norm (b k))

goal (1 subgoal):
 1. (\<Sum>k. a k) * (\<Sum>k. b k) = (\<Sum>k. \<Sum>i\<le>k. a i * b (k - i))
[PROOF STEP]
by (rule Cauchy_product_sums [THEN sums_unique])


[STATEMENT]
lemma odd_div2_plus_1_eq: "(n::nat) mod 2 \<noteq> 0 \<Longrightarrow> (n div 2) + 1 = (n+1) div 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n mod 2 \<noteq> 0 \<Longrightarrow> n div 2 + 1 = (n + 1) div 2
[PROOF STEP]
proof (induct n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 mod 2 \<noteq> 0 \<Longrightarrow> 0 div 2 + 1 = (0 + 1) div 2
 2. \<And>n. \<lbrakk>n mod 2 \<noteq> 0 \<Longrightarrow> n div 2 + 1 = (n + 1) div 2; Suc n mod 2 \<noteq> 0\<rbrakk> \<Longrightarrow> Suc n div 2 + 1 = (Suc n + 1) div 2
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
0 mod 2 \<noteq> 0

goal (2 subgoals):
 1. 0 mod 2 \<noteq> 0 \<Longrightarrow> 0 div 2 + 1 = (0 + 1) div 2
 2. \<And>n. \<lbrakk>n mod 2 \<noteq> 0 \<Longrightarrow> n div 2 + 1 = (n + 1) div 2; Suc n mod 2 \<noteq> 0\<rbrakk> \<Longrightarrow> Suc n div 2 + 1 = (Suc n + 1) div 2
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 mod 2 \<noteq> 0
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
0 mod 2 \<noteq> 0

goal (1 subgoal):
 1. 0 div 2 + 1 = (0 + 1) div 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 div 2 + 1 = (0 + 1) div 2

goal (1 subgoal):
 1. \<And>n. \<lbrakk>n mod 2 \<noteq> 0 \<Longrightarrow> n div 2 + 1 = (n + 1) div 2; Suc n mod 2 \<noteq> 0\<rbrakk> \<Longrightarrow> Suc n div 2 + 1 = (Suc n + 1) div 2
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>n mod 2 \<noteq> 0 \<Longrightarrow> n div 2 + 1 = (n + 1) div 2; Suc n mod 2 \<noteq> 0\<rbrakk> \<Longrightarrow> Suc n div 2 + 1 = (Suc n + 1) div 2
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
n mod 2 \<noteq> 0 \<Longrightarrow> n div 2 + 1 = (n + 1) div 2
Suc n mod 2 \<noteq> 0

goal (1 subgoal):
 1. \<And>n. \<lbrakk>n mod 2 \<noteq> 0 \<Longrightarrow> n div 2 + 1 = (n + 1) div 2; Suc n mod 2 \<noteq> 0\<rbrakk> \<Longrightarrow> Suc n div 2 + 1 = (Suc n + 1) div 2
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n mod 2 \<noteq> 0 \<Longrightarrow> n div 2 + 1 = (n + 1) div 2
Suc n mod 2 \<noteq> 0
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
n mod 2 \<noteq> 0 \<Longrightarrow> n div 2 + 1 = (n + 1) div 2
Suc n mod 2 \<noteq> 0

goal (1 subgoal):
 1. Suc n div 2 + 1 = (Suc n + 1) div 2
[PROOF STEP]
by arith
[PROOF STATE]
proof (state)
this:
Suc n div 2 + 1 = (Suc n + 1) div 2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma tanh_altdef:
  "tanh x = (exp x - exp (-x)) / (exp x + exp (-x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tanh x = (exp x - exp (- x)) / (exp x + exp (- x))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. tanh x = (exp x - exp (- x)) / (exp x + exp (- x))
[PROOF STEP]
have "tanh x = (2 *\<^sub>R sinh x) / (2 *\<^sub>R cosh x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tanh x = 2 *\<^sub>R sinh x / 2 *\<^sub>R cosh x
[PROOF STEP]
by (simp add: tanh_def scaleR_conv_of_real)
[PROOF STATE]
proof (state)
this:
tanh x = 2 *\<^sub>R sinh x / 2 *\<^sub>R cosh x

goal (1 subgoal):
 1. tanh x = (exp x - exp (- x)) / (exp x + exp (- x))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
tanh x = 2 *\<^sub>R sinh x / 2 *\<^sub>R cosh x

goal (1 subgoal):
 1. tanh x = (exp x - exp (- x)) / (exp x + exp (- x))
[PROOF STEP]
have "2 *\<^sub>R sinh x = exp x - exp (-x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 *\<^sub>R sinh x = exp x - exp (- x)
[PROOF STEP]
by (simp add: sinh_def)
[PROOF STATE]
proof (state)
this:
2 *\<^sub>R sinh x = exp x - exp (- x)

goal (1 subgoal):
 1. tanh x = (exp x - exp (- x)) / (exp x + exp (- x))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 *\<^sub>R sinh x = exp x - exp (- x)

goal (1 subgoal):
 1. tanh x = (exp x - exp (- x)) / (exp x + exp (- x))
[PROOF STEP]
have "2 *\<^sub>R cosh x = exp x + exp (-x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 *\<^sub>R cosh x = exp x + exp (- x)
[PROOF STEP]
by (simp add: cosh_def)
[PROOF STATE]
proof (state)
this:
2 *\<^sub>R cosh x = exp x + exp (- x)

goal (1 subgoal):
 1. tanh x = (exp x - exp (- x)) / (exp x + exp (- x))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
tanh x = (exp x - exp (- x)) / (exp x + exp (- x))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
tanh x = (exp x - exp (- x)) / (exp x + exp (- x))

goal (1 subgoal):
 1. tanh x = (exp x - exp (- x)) / (exp x + exp (- x))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
tanh x = (exp x - exp (- x)) / (exp x + exp (- x))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem of_nat_catalan_closed_form:
  "of_nat (catalan n) = (of_nat ((2*n) choose n) / of_nat (Suc n) :: 'a :: field_char_0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_nat (catalan n) = of_nat (2 * n choose n) / of_nat (Suc n)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. of_nat (catalan n) = of_nat (2 * n choose n) / of_nat (Suc n)
[PROOF STEP]
have "of_nat (catalan n * Suc n) = of_nat ((2*n) choose n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_nat (catalan n * Suc n) = of_nat (2 * n choose n)
[PROOF STEP]
by (subst catalan_closed_form_aux) (rule refl)
[PROOF STATE]
proof (state)
this:
of_nat (catalan n * Suc n) = of_nat (2 * n choose n)

goal (1 subgoal):
 1. of_nat (catalan n) = of_nat (2 * n choose n) / of_nat (Suc n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
of_nat (catalan n * Suc n) = of_nat (2 * n choose n)

goal (1 subgoal):
 1. of_nat (catalan n) = of_nat (2 * n choose n) / of_nat (Suc n)
[PROOF STEP]
have "of_nat (catalan n * Suc n) = of_nat (catalan n) * of_nat (Suc n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_nat (catalan n * Suc n) = of_nat (catalan n) * of_nat (Suc n)
[PROOF STEP]
by (simp only: of_nat_mult)
[PROOF STATE]
proof (state)
this:
of_nat (catalan n * Suc n) = of_nat (catalan n) * of_nat (Suc n)

goal (1 subgoal):
 1. of_nat (catalan n) = of_nat (2 * n choose n) / of_nat (Suc n)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
of_nat (catalan n) * of_nat (Suc n) = of_nat (2 * n choose n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
of_nat (catalan n) * of_nat (Suc n) = of_nat (2 * n choose n)

goal (1 subgoal):
 1. of_nat (catalan n) = of_nat (2 * n choose n) / of_nat (Suc n)
[PROOF STEP]
by (simp add: divide_simps del: of_nat_Suc)
[PROOF STATE]
proof (state)
this:
of_nat (catalan n) = of_nat (2 * n choose n) / of_nat (Suc n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma inverse_matrix_code[code_unfold]:
fixes A::"'a::{field}^'n::{mod_type}^'n::{mod_type}"
shows "inverse_matrix A = (let GJ = Gauss_Jordan_PA A;
                                rank_A = (if A = 0 then 0 else to_nat (GREATEST a. row a (snd GJ) \<noteq> 0) + 1) in
                                if nrows A = rank_A then Some (fst(GJ)) else None)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inverse_matrix A = (let GJ = Gauss_Jordan_PA A; rank_A = if A = 0 then 0 else mod_type_class.to_nat (GREATEST a. row a (snd GJ) \<noteq> 0) + 1 in if nrows A = rank_A then Some (fst GJ) else None)
[PROOF STEP]
unfolding inverse_matrix
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if invertible A then Some (P_Gauss_Jordan A) else None) = (let GJ = Gauss_Jordan_PA A; rank_A = if A = 0 then 0 else mod_type_class.to_nat (GREATEST a. row a (snd GJ) \<noteq> 0) + 1 in if nrows A = rank_A then Some (fst GJ) else None)
[PROOF STEP]
unfolding invertible_eq_full_rank
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if rank A = nrows A then Some (P_Gauss_Jordan A) else None) = (let GJ = Gauss_Jordan_PA A; rank_A = if A = 0 then 0 else mod_type_class.to_nat (GREATEST a. row a (snd GJ) \<noteq> 0) + 1 in if nrows A = rank_A then Some (fst GJ) else None)
[PROOF STEP]
unfolding rank_Gauss_Jordan_code
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if (if A = 0 then 0 else let A' = Gauss_Jordan A in mod_type_class.to_nat (GREATEST a. row a A' \<noteq> 0) + 1) = nrows A then Some (P_Gauss_Jordan A) else None) = (let GJ = Gauss_Jordan_PA A; rank_A = if A = 0 then 0 else mod_type_class.to_nat (GREATEST a. row a (snd GJ) \<noteq> 0) + 1 in if nrows A = rank_A then Some (fst GJ) else None)
[PROOF STEP]
unfolding P_Gauss_Jordan_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if (if A = 0 then 0 else let A' = Gauss_Jordan A in mod_type_class.to_nat (GREATEST a. row a A' \<noteq> 0) + 1) = nrows A then Some (fst (Gauss_Jordan_PA A)) else None) = (let GJ = Gauss_Jordan_PA A; rank_A = if A = 0 then 0 else mod_type_class.to_nat (GREATEST a. row a (snd GJ) \<noteq> 0) + 1 in if nrows A = rank_A then Some (fst GJ) else None)
[PROOF STEP]
unfolding Let_def Gauss_Jordan_PA_eq
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if (if A = 0 then 0 else mod_type_class.to_nat (GREATEST a. row a (Gauss_Jordan A) \<noteq> 0) + 1) = nrows A then Some (fst (Gauss_Jordan_PA A)) else None) = (if nrows A = (if A = 0 then 0 else mod_type_class.to_nat (GREATEST a. row a (Gauss_Jordan A) \<noteq> 0) + 1) then Some (fst (Gauss_Jordan_PA A)) else None)
[PROOF STEP]
by presburger


[STATEMENT]
lemma C_msort_log: "length xs = 2^k \<Longrightarrow> C_msort xs \<le> length xs * log 2 (length xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length xs = 2 ^ k \<Longrightarrow> real (C_msort xs) \<le> real (length xs) * log 2 (real (length xs))
[PROOF STEP]
using C_msort_le[of xs k]
[PROOF STATE]
proof (prove)
using this:
length xs = 2 ^ k \<Longrightarrow> C_msort xs \<le> k * 2 ^ k

goal (1 subgoal):
 1. length xs = 2 ^ k \<Longrightarrow> real (C_msort xs) \<le> real (length xs) * log 2 (real (length xs))
[PROOF STEP]
apply (simp add: log_nat_power algebra_simps)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>length xs = 2 ^ k; C_msort xs \<le> k * 2 ^ k\<rbrakk> \<Longrightarrow> real (C_msort xs) \<le> real k * 2 ^ k
[PROOF STEP]
by (metis (mono_tags) numeral_power_eq_of_nat_cancel_iff of_nat_le_iff of_nat_mult)


[STATEMENT]
lemma card_ordered_pairs:
  fixes M :: "('a ::linorder) set"
  assumes "finite M"
  shows "2 * card {(x,y) \<in> M \<times> M. x < y} = card M * (card M - 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} = card M * (card M - 1)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 2 * card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} = card M * (card M - 1)
[PROOF STEP]
have a: "finite (M \<times> M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (M \<times> M)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite M

goal (1 subgoal):
 1. finite (M \<times> M)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
finite (M \<times> M)

goal (1 subgoal):
 1. 2 * card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} = card M * (card M - 1)
[PROOF STEP]
have inj_swap: "inj (\<lambda>x. (snd x, fst x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj (\<lambda>x. (snd x, fst x))
[PROOF STEP]
by (rule inj_onI, simp add: prod_eq_iff)
[PROOF STATE]
proof (state)
this:
inj (\<lambda>x. (snd x, fst x))

goal (1 subgoal):
 1. 2 * card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} = card M * (card M - 1)
[PROOF STEP]
have "2 * card {(x,y) \<in> M \<times> M. x < y} =
    card {(x,y) \<in> M \<times> M. x < y} + card ((\<lambda>x. (snd x, fst x))`{(x,y) \<in> M \<times> M. x < y})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} = card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} + card ((\<lambda>x. (snd x, fst x)) ` {(x, y). (x, y) \<in> M \<times> M \<and> x < y})
[PROOF STEP]
by (simp add: card_image[OF inj_on_subset[OF inj_swap]])
[PROOF STATE]
proof (state)
this:
2 * card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} = card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} + card ((\<lambda>x. (snd x, fst x)) ` {(x, y). (x, y) \<in> M \<times> M \<and> x < y})

goal (1 subgoal):
 1. 2 * card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} = card M * (card M - 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 * card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} = card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} + card ((\<lambda>x. (snd x, fst x)) ` {(x, y). (x, y) \<in> M \<times> M \<and> x < y})

goal (1 subgoal):
 1. 2 * card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} = card M * (card M - 1)
[PROOF STEP]
have "... = card {(x,y) \<in> M \<times> M. x < y} + card {(x,y) \<in> M \<times> M. y < x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} + card ((\<lambda>x. (snd x, fst x)) ` {(x, y). (x, y) \<in> M \<times> M \<and> x < y}) = card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} + card {(x, y). (x, y) \<in> M \<times> M \<and> y < x}
[PROOF STEP]
by (auto intro: arg_cong[where f="card"] simp add:set_eq_iff image_iff)
[PROOF STATE]
proof (state)
this:
card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} + card ((\<lambda>x. (snd x, fst x)) ` {(x, y). (x, y) \<in> M \<times> M \<and> x < y}) = card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} + card {(x, y). (x, y) \<in> M \<times> M \<and> y < x}

goal (1 subgoal):
 1. 2 * card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} = card M * (card M - 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} + card ((\<lambda>x. (snd x, fst x)) ` {(x, y). (x, y) \<in> M \<times> M \<and> x < y}) = card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} + card {(x, y). (x, y) \<in> M \<times> M \<and> y < x}

goal (1 subgoal):
 1. 2 * card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} = card M * (card M - 1)
[PROOF STEP]
have "... = card ({(x,y) \<in> M \<times> M. x < y} \<union> {(x,y) \<in> M \<times> M. y < x})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} + card {(x, y). (x, y) \<in> M \<times> M \<and> y < x} = card ({(x, y). (x, y) \<in> M \<times> M \<and> x < y} \<union> {(x, y). (x, y) \<in> M \<times> M \<and> y < x})
[PROOF STEP]
by (intro card_Un_disjoint[symmetric] a finite_subset[where B="M \<times> M"] subsetI) auto
[PROOF STATE]
proof (state)
this:
card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} + card {(x, y). (x, y) \<in> M \<times> M \<and> y < x} = card ({(x, y). (x, y) \<in> M \<times> M \<and> x < y} \<union> {(x, y). (x, y) \<in> M \<times> M \<and> y < x})

goal (1 subgoal):
 1. 2 * card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} = card M * (card M - 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} + card {(x, y). (x, y) \<in> M \<times> M \<and> y < x} = card ({(x, y). (x, y) \<in> M \<times> M \<and> x < y} \<union> {(x, y). (x, y) \<in> M \<times> M \<and> y < x})

goal (1 subgoal):
 1. 2 * card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} = card M * (card M - 1)
[PROOF STEP]
have "... = card ((M \<times> M) - {(x,y) \<in> M \<times> M. x = y})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card ({(x, y). (x, y) \<in> M \<times> M \<and> x < y} \<union> {(x, y). (x, y) \<in> M \<times> M \<and> y < x}) = card (M \<times> M - {(x, y). (x, y) \<in> M \<times> M \<and> x = y})
[PROOF STEP]
by (auto intro: arg_cong[where f="card"] simp add:set_eq_iff)
[PROOF STATE]
proof (state)
this:
card ({(x, y). (x, y) \<in> M \<times> M \<and> x < y} \<union> {(x, y). (x, y) \<in> M \<times> M \<and> y < x}) = card (M \<times> M - {(x, y). (x, y) \<in> M \<times> M \<and> x = y})

goal (1 subgoal):
 1. 2 * card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} = card M * (card M - 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card ({(x, y). (x, y) \<in> M \<times> M \<and> x < y} \<union> {(x, y). (x, y) \<in> M \<times> M \<and> y < x}) = card (M \<times> M - {(x, y). (x, y) \<in> M \<times> M \<and> x = y})

goal (1 subgoal):
 1. 2 * card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} = card M * (card M - 1)
[PROOF STEP]
have "... = card (M \<times> M) - card {(x,y) \<in> M \<times> M. x = y}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (M \<times> M - {(x, y). (x, y) \<in> M \<times> M \<and> x = y}) = card (M \<times> M) - card {(x, y). (x, y) \<in> M \<times> M \<and> x = y}
[PROOF STEP]
by (intro card_Diff_subset a finite_subset[where B="M \<times> M"] subsetI) auto
[PROOF STATE]
proof (state)
this:
card (M \<times> M - {(x, y). (x, y) \<in> M \<times> M \<and> x = y}) = card (M \<times> M) - card {(x, y). (x, y) \<in> M \<times> M \<and> x = y}

goal (1 subgoal):
 1. 2 * card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} = card M * (card M - 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card (M \<times> M - {(x, y). (x, y) \<in> M \<times> M \<and> x = y}) = card (M \<times> M) - card {(x, y). (x, y) \<in> M \<times> M \<and> x = y}

goal (1 subgoal):
 1. 2 * card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} = card M * (card M - 1)
[PROOF STEP]
have "... = card M ^ 2 - card ((\<lambda>x. (x,x)) ` M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (M \<times> M) - card {(x, y). (x, y) \<in> M \<times> M \<and> x = y} = (card M)\<^sup>2 - card ((\<lambda>x. (x, x)) ` M)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite M

goal (1 subgoal):
 1. card (M \<times> M) - card {(x, y). (x, y) \<in> M \<times> M \<and> x = y} = (card M)\<^sup>2 - card ((\<lambda>x. (x, x)) ` M)
[PROOF STEP]
by (intro arg_cong2[where f="(-)"] arg_cong[where f="card"])
      (auto simp:power2_eq_square set_eq_iff image_iff)
[PROOF STATE]
proof (state)
this:
card (M \<times> M) - card {(x, y). (x, y) \<in> M \<times> M \<and> x = y} = (card M)\<^sup>2 - card ((\<lambda>x. (x, x)) ` M)

goal (1 subgoal):
 1. 2 * card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} = card M * (card M - 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card (M \<times> M) - card {(x, y). (x, y) \<in> M \<times> M \<and> x = y} = (card M)\<^sup>2 - card ((\<lambda>x. (x, x)) ` M)

goal (1 subgoal):
 1. 2 * card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} = card M * (card M - 1)
[PROOF STEP]
have "... = card M ^ 2 - card M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (card M)\<^sup>2 - card ((\<lambda>x. (x, x)) ` M) = (card M)\<^sup>2 - card M
[PROOF STEP]
by (intro arg_cong2[where f="(-)"] card_image inj_onI, auto)
[PROOF STATE]
proof (state)
this:
(card M)\<^sup>2 - card ((\<lambda>x. (x, x)) ` M) = (card M)\<^sup>2 - card M

goal (1 subgoal):
 1. 2 * card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} = card M * (card M - 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(card M)\<^sup>2 - card ((\<lambda>x. (x, x)) ` M) = (card M)\<^sup>2 - card M

goal (1 subgoal):
 1. 2 * card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} = card M * (card M - 1)
[PROOF STEP]
have "... = card M * (card M - 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (card M)\<^sup>2 - card M = card M * (card M - 1)
[PROOF STEP]
by (cases "card M \<ge> 0", auto simp:power2_eq_square algebra_simps)
[PROOF STATE]
proof (state)
this:
(card M)\<^sup>2 - card M = card M * (card M - 1)

goal (1 subgoal):
 1. 2 * card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} = card M * (card M - 1)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
2 * card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} = card M * (card M - 1)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
2 * card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} = card M * (card M - 1)

goal (1 subgoal):
 1. 2 * card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} = card M * (card M - 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 * card {(x, y). (x, y) \<in> M \<times> M \<and> x < y} = card M * (card M - 1)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma det_map_matrix:
  fixes A :: "int^'n::mod_type^'n::mod_type"
  shows "det (map_matrix rat_of_int A) = rat_of_int (det A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (map_matrix rat_of_int A) = rat_of_int (det A)
[PROOF STEP]
unfolding map_matrix_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (\<chi>i j. rat_of_int (A $ i $ j)) = rat_of_int (det A)
[PROOF STEP]
unfolding Determinants.det_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>p | p permutes UNIV. rat_of_int (sign p) * (\<Prod>i\<in>UNIV. (\<chi>i j. rat_of_int (A $ i $ j)) $ i $ p i)) = rat_of_int (\<Sum>p | p permutes UNIV. of_int (sign p) * (\<Prod>i\<in>UNIV. A $ i $ p i))
[PROOF STEP]
by auto


[STATEMENT]
lemma real_of_nat_div_aux: "real x / real d = real (x div d) + real (x mod d) / real d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real x / real d = real (x div d) + real (x mod d) / real d
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. real x / real d = real (x div d) + real (x mod d) / real d
[PROOF STEP]
have "x = (x div d) * d + x mod d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x = x div d * d + x mod d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x = x div d * d + x mod d

goal (1 subgoal):
 1. real x / real d = real (x div d) + real (x mod d) / real d
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x = x div d * d + x mod d
[PROOF STEP]
have "real x = real (x div d) * real d + real(x mod d)"
[PROOF STATE]
proof (prove)
using this:
x = x div d * d + x mod d

goal (1 subgoal):
 1. real x = real (x div d) * real d + real (x mod d)
[PROOF STEP]
by (metis of_nat_add of_nat_mult)
[PROOF STATE]
proof (state)
this:
real x = real (x div d) * real d + real (x mod d)

goal (1 subgoal):
 1. real x / real d = real (x div d) + real (x mod d) / real d
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
real x = real (x div d) * real d + real (x mod d)
[PROOF STEP]
have "real x / real d = \<dots> / real d"
[PROOF STATE]
proof (prove)
using this:
real x = real (x div d) * real d + real (x mod d)

goal (1 subgoal):
 1. real x / real d = (real (x div d) * real d + real (x mod d)) / real d
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
real x / real d = (real (x div d) * real d + real (x mod d)) / real d

goal (1 subgoal):
 1. real x / real d = real (x div d) + real (x mod d) / real d
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
real x / real d = (real (x div d) * real d + real (x mod d)) / real d
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
real x / real d = (real (x div d) * real d + real (x mod d)) / real d

goal (1 subgoal):
 1. real x / real d = real (x div d) + real (x mod d) / real d
[PROOF STEP]
by (auto simp add: add_divide_distrib algebra_simps)
[PROOF STATE]
proof (state)
this:
real x / real d = real (x div d) + real (x mod d) / real d

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Schwartz_inequality_strong:
  assumes "f square_integrable S" "g square_integrable S"
  shows "l2product S (\<lambda>x. \<bar>f x\<bar>) (\<lambda>x. \<bar>g x\<bar>) \<le> l2norm S f * l2norm S g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. l2product S (\<lambda>x. \<bar>f x\<bar>) (\<lambda>x. \<bar>g x\<bar>) \<le> l2norm S f * l2norm S g
[PROOF STEP]
using Holder_inequality_lnorm [of 2 2 f "lebesgue_on S" g] assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 < 2; 0 < 2; 1 / 2 + 1 / 2 = 1; f \<in> borel_measurable (lebesgue_on S); g \<in> borel_measurable (lebesgue_on S); integrable (lebesgue_on S) (\<lambda>x. \<bar>f x\<bar> powr 2); integrable (lebesgue_on S) (\<lambda>x. \<bar>g x\<bar> powr 2)\<rbrakk> \<Longrightarrow> LINT x|lebesgue_on S. \<bar>f x * g x\<bar> \<le> lnorm (lebesgue_on S) 2 f * lnorm (lebesgue_on S) 2 g
\<lbrakk>0 < 2; 0 < 2; 1 / 2 + 1 / 2 = 1; f \<in> borel_measurable (lebesgue_on S); g \<in> borel_measurable (lebesgue_on S); integrable (lebesgue_on S) (\<lambda>x. \<bar>f x\<bar> powr 2); integrable (lebesgue_on S) (\<lambda>x. \<bar>g x\<bar> powr 2)\<rbrakk> \<Longrightarrow> \<bar>LINT x|lebesgue_on S. f x * g x\<bar> \<le> lnorm (lebesgue_on S) 2 f * lnorm (lebesgue_on S) 2 g
f square_integrable S
g square_integrable S

goal (1 subgoal):
 1. l2product S (\<lambda>x. \<bar>f x\<bar>) (\<lambda>x. \<bar>g x\<bar>) \<le> l2norm S f * l2norm S g
[PROOF STEP]
by (simp add: square_integrable_def l2product_def abs_mult flip: l2norm_lnorm)


[STATEMENT]
lemma cos_times_sin: "cos w * sin z = (sin (w + z) - sin (w - z)) / 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos w * sin z = (sin (w + z) - sin (w - z)) / (2::'a)
[PROOF STEP]
by (simp add: sin_diff sin_add)


[STATEMENT]
theorem descartes_sign:
  fixes p::"real poly"
  assumes "p\<noteq>0"
  shows " changes (coeffs p) \<ge> proots_count p {x. 0 < x} \<and>
          even (changes (coeffs p) - proots_count p {x. 0< x})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int (proots_count p {x. 0 < x}) \<le> changes (coeffs p) \<and> even (changes (coeffs p) - int (proots_count p {x. 0 < x}))
[PROOF STEP]
using budan_fourier_gt[OF \<open>p\<noteq>0\<close>,of 0]
[PROOF STATE]
proof (prove)
using this:
int (proots_count p {x. 0 < x}) \<le> changes_gt_der 0 p \<and> even (changes_gt_der 0 p - int (proots_count p {x. 0 < x}))

goal (1 subgoal):
 1. int (proots_count p {x. 0 < x}) \<le> changes (coeffs p) \<and> even (changes (coeffs p) - int (proots_count p {x. 0 < x}))
[PROOF STEP]
unfolding changes_gt_der_def
[PROOF STATE]
proof (prove)
using this:
int (proots_count p {x. 0 < x}) \<le> changes_poly_at (pders p) 0 \<and> even (changes_poly_at (pders p) 0 - int (proots_count p {x. 0 < x}))

goal (1 subgoal):
 1. int (proots_count p {x. 0 < x}) \<le> changes (coeffs p) \<and> even (changes (coeffs p) - int (proots_count p {x. 0 < x}))
[PROOF STEP]
by (simp add:changes_poly_at_pders_0)


[STATEMENT]
lemma "filterlim (\<lambda>x::real. x^2 / (sqrt (x^2 + 12) - sqrt (12))) (nhds (12 / sqrt 3)) (at 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. x\<^sup>2 / (sqrt (x\<^sup>2 + 12) - sqrt 12)) \<midarrow>0\<rightarrow> 12 / sqrt 3
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>x. x\<^sup>2 / (sqrt (x\<^sup>2 + 12) - sqrt 12)) \<midarrow>0\<rightarrow> 12 / sqrt 3
[PROOF STEP]
note [simp] = powr_half_sqrt sqrt_def
[PROOF STATE]
proof (state)
this:
0 \<le> ?x \<Longrightarrow> ?x powr (1 / 2) = sqrt ?x
sqrt = root 2

goal (1 subgoal):
 1. (\<lambda>x. x\<^sup>2 / (sqrt (x\<^sup>2 + 12) - sqrt 12)) \<midarrow>0\<rightarrow> 12 / sqrt 3
[PROOF STEP]
have "sqrt (12 :: real) = sqrt (4 * 3)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sqrt 12 = sqrt (4 * 3)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sqrt 12 = sqrt (4 * 3)

goal (1 subgoal):
 1. (\<lambda>x. x\<^sup>2 / (sqrt (x\<^sup>2 + 12) - sqrt 12)) \<midarrow>0\<rightarrow> 12 / sqrt 3
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sqrt 12 = sqrt (4 * 3)

goal (1 subgoal):
 1. (\<lambda>x. x\<^sup>2 / (sqrt (x\<^sup>2 + 12) - sqrt 12)) \<midarrow>0\<rightarrow> 12 / sqrt 3
[PROOF STEP]
have "\<dots> = 2 * sqrt 3"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sqrt (4 * 3) = 2 * sqrt 3
[PROOF STEP]
by (subst real_sqrt_mult) simp
[PROOF STATE]
proof (state)
this:
sqrt (4 * 3) = 2 * sqrt 3

goal (1 subgoal):
 1. (\<lambda>x. x\<^sup>2 / (sqrt (x\<^sup>2 + 12) - sqrt 12)) \<midarrow>0\<rightarrow> 12 / sqrt 3
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sqrt 12 = 2 * sqrt 3
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
sqrt 12 = 2 * sqrt 3

goal (1 subgoal):
 1. (\<lambda>x. x\<^sup>2 / (sqrt (x\<^sup>2 + 12) - sqrt 12)) \<midarrow>0\<rightarrow> 12 / sqrt 3
[PROOF STEP]
by real_asymp
[PROOF STATE]
proof (state)
this:
(\<lambda>x. x\<^sup>2 / (sqrt (x\<^sup>2 + 12) - sqrt 12)) \<midarrow>0\<rightarrow> 12 / sqrt 3

goal:
No subgoals!
[PROOF STEP]
qed