[STATEMENT]
lemma sum_mat_add: assumes A: "(A :: 'a :: comm_monoid_add mat) \<in> carrier_mat nr nc" and B: "B \<in> carrier_mat nr nc"
  shows "sum_mat (A + B) = sum_mat A + sum_mat B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_mat (A + B) = sum_mat A + sum_mat B
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. sum_mat (A + B) = sum_mat A + sum_mat B
[PROOF STEP]
from A B
[PROOF STATE]
proof (chain)
picking this:
A \<in> carrier_mat nr nc
B \<in> carrier_mat nr nc
[PROOF STEP]
have id: "dim_row A = nr" "dim_row B = nr" "dim_col A = nc" "dim_col B = nc"
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat nr nc
B \<in> carrier_mat nr nc

goal (1 subgoal):
 1. (dim_row A = nr &&& dim_row B = nr) &&& dim_col A = nc &&& dim_col B = nc
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
dim_row A = nr
dim_row B = nr
dim_col A = nc
dim_col B = nc

goal (1 subgoal):
 1. sum_mat (A + B) = sum_mat A + sum_mat B
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_mat (A + B) = sum_mat A + sum_mat B
[PROOF STEP]
unfolding sum_mat_def id
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum (($$) (A + B)) ({0..<dim_row (A + B)} \<times> {0..<dim_col (A + B)}) = sum (($$) A) ({0..<nr} \<times> {0..<nc}) + sum (($$) B) ({0..<nr} \<times> {0..<nc})
[PROOF STEP]
by (subst sum.distrib[symmetric], rule sum.cong, insert A B, auto)
[PROOF STATE]
proof (state)
this:
sum_mat (A + B) = sum_mat A + sum_mat B

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma proots_count_union_disjoint:
  assumes "A \<inter> B = {}" "p\<noteq>0"
  shows "proots_count p (A \<union> B) = proots_count p A + proots_count p B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proots_count p (A \<union> B) = proots_count p A + proots_count p B
[PROOF STEP]
unfolding proots_count_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>r\<in>proots_within p (A \<union> B). order r p) = (\<Sum>r\<in>proots_within p A. order r p) + (\<Sum>r\<in>proots_within p B. order r p)
[PROOF STEP]
apply (subst proots_within_union[symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>r\<in>proots_within p A \<union> proots_within p B. order r p) = (\<Sum>r\<in>proots_within p A. order r p) + (\<Sum>r\<in>proots_within p B. order r p)
[PROOF STEP]
apply (subst sum.union_disjoint)
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. finite (proots_within p A)
 2. finite (proots_within p B)
 3. proots_within p A \<inter> proots_within p B = {}
 4. (\<Sum>r\<in>proots_within p A. order r p) + (\<Sum>r\<in>proots_within p B. order r p) = (\<Sum>r\<in>proots_within p A. order r p) + (\<Sum>r\<in>proots_within p B. order r p)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
A \<inter> B = {}
p \<noteq> 0

goal (4 subgoals):
 1. finite (proots_within p A)
 2. finite (proots_within p B)
 3. proots_within p A \<inter> proots_within p B = {}
 4. (\<Sum>r\<in>proots_within p A. order r p) + (\<Sum>r\<in>proots_within p B. order r p) = (\<Sum>r\<in>proots_within p A. order r p) + (\<Sum>r\<in>proots_within p B. order r p)
[PROOF STEP]
by auto


[STATEMENT]
lemma iT_Mult_icard: "0 < k \<Longrightarrow> icard (I \<otimes> k) = icard I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < k \<Longrightarrow> icard (I \<otimes> k) = icard I
[PROOF STEP]
apply (unfold iT_Mult_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < k \<Longrightarrow> icard ((\<lambda>n. n * k) ` I) = icard I
[PROOF STEP]
apply (rule icard_image)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < k \<Longrightarrow> inj_on (\<lambda>n. n * k) I
[PROOF STEP]
apply (rule inj_imp_inj_on)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < k \<Longrightarrow> inj (\<lambda>n. n * k)
[PROOF STEP]
apply (simp add: mult_right_inj)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma two_cong_0_iff: "[2 = 0] (mod p) \<longleftrightarrow> p = 1 \<or> p = 2" for p :: nat
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [2 = 0] (mod p) = (p = 1 \<or> p = 2)
[PROOF STEP]
unfolding cong_altdef_nat[of 0 2 p, simplified]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (p dvd 2) = (p = 1 \<or> p = 2)
[PROOF STEP]
using dvd_refl prime_nat_iff two_is_prime_nat
[PROOF STATE]
proof (prove)
using this:
?a dvd ?a
prime ?n = (1 < ?n \<and> (\<forall>m. m dvd ?n \<longrightarrow> m = 1 \<or> m = ?n))
prime 2

goal (1 subgoal):
 1. (p dvd 2) = (p = 1 \<or> p = 2)
[PROOF STEP]
by blast


[STATEMENT]
lemma left_null_space_orthogonal_complement_col_space:
  fixes A::"'a^'cols::{finite, wellorder}^'rows::{finite, wellorder}"
  shows "left_null_space A = ROWS.v.orthogonal_complement (col_space (\<chi> i j. cnj (A $ i $ j)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. left_null_space A = ROWS.v.orthogonal_complement (col_space (\<chi>i j. cnj_class.cnj (A $ i $ j)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. left_null_space A = ROWS.v.orthogonal_complement (col_space (\<chi>i j. cnj_class.cnj (A $ i $ j)))
[PROOF STEP]
interpret m: matrix inner_rows inner_cols
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Generalizations2.matrix inner_rows inner_cols
[PROOF STEP]
by unfold_locales
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. left_null_space A = ROWS.v.orthogonal_complement (col_space (\<chi>i j. cnj_class.cnj (A $ i $ j)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. left_null_space A = ROWS.v.orthogonal_complement (col_space (\<chi>i j. cnj_class.cnj (A $ i $ j)))
[PROOF STEP]
using m.null_space_orthogonal_complement_row_space[of "transpose A"]
[PROOF STATE]
proof (prove)
using this:
null_space (Finite_Cartesian_Product.transpose A) = ROWS.v.orthogonal_complement (row_space (\<chi>i j. cnj_class.cnj (Finite_Cartesian_Product.transpose A $ i $ j)))

goal (1 subgoal):
 1. left_null_space A = ROWS.v.orthogonal_complement (col_space (\<chi>i j. cnj_class.cnj (A $ i $ j)))
[PROOF STEP]
unfolding left_null_space_eq_null_space_transpose
[PROOF STATE]
proof (prove)
using this:
null_space (Finite_Cartesian_Product.transpose A) = ROWS.v.orthogonal_complement (row_space (\<chi>i j. cnj_class.cnj (Finite_Cartesian_Product.transpose A $ i $ j)))

goal (1 subgoal):
 1. null_space (Finite_Cartesian_Product.transpose A) = ROWS.v.orthogonal_complement (col_space (\<chi>i j. cnj_class.cnj (A $ i $ j)))
[PROOF STEP]
unfolding col_space_eq_row_space_transpose
[PROOF STATE]
proof (prove)
using this:
null_space (Finite_Cartesian_Product.transpose A) = ROWS.v.orthogonal_complement (row_space (\<chi>i j. cnj_class.cnj (Finite_Cartesian_Product.transpose A $ i $ j)))

goal (1 subgoal):
 1. null_space (Finite_Cartesian_Product.transpose A) = ROWS.v.orthogonal_complement (row_space (Finite_Cartesian_Product.transpose (\<chi>i j. cnj_class.cnj (A $ i $ j))))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
left_null_space A = ROWS.v.orthogonal_complement (col_space (\<chi>i j. cnj_class.cnj (A $ i $ j)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma dist_riemann_sphere_ge_0 [simp]:
  shows "dist_riemann_sphere' M1 M2 \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> dist_riemann_sphere' M1 M2
[PROOF STEP]
apply transfer
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>M1 M2. \<lbrakk>M1 \<in> unit_sphere; M2 \<in> unit_sphere\<rbrakk> \<Longrightarrow> 0 \<le> dist_riemann_sphere_r3 M1 M2
[PROOF STEP]
using norm_ge_zero
[PROOF STATE]
proof (prove)
using this:
0 \<le> norm ?x

goal (1 subgoal):
 1. \<And>M1 M2. \<lbrakk>M1 \<in> unit_sphere; M2 \<in> unit_sphere\<rbrakk> \<Longrightarrow> 0 \<le> dist_riemann_sphere_r3 M1 M2
[PROOF STEP]
by (simp add: split_def Let_def)


[STATEMENT]
theorem injections_equiv:
  assumes "finite Y" and "distinct X"
  shows  "set (injections_alg X Y) = injections (set X) Y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (injections_alg X Y) = injections (set X) Y
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. set (injections_alg X Y) = injections (set X) Y
[PROOF STEP]
let ?P="\<lambda> l. distinct l \<longrightarrow> (set (injections_alg l Y)=injections (set l) Y)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. set (injections_alg X Y) = injections (set X) Y
[PROOF STEP]
have "?P []"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct [] \<longrightarrow> set (injections_alg [] Y) = injections (set []) Y
[PROOF STEP]
using injectionsFromEmptyAreEmpty list.set(1) lm099
[PROOF STATE]
proof (prove)
using this:
set (injections_alg [] ?Z) = {{}}
set [] = {}
injections {} ?Y = {{}}

goal (1 subgoal):
 1. distinct [] \<longrightarrow> set (injections_alg [] Y) = injections (set []) Y
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
distinct [] \<longrightarrow> set (injections_alg [] Y) = injections (set []) Y

goal (1 subgoal):
 1. set (injections_alg X Y) = injections (set X) Y
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
distinct [] \<longrightarrow> set (injections_alg [] Y) = injections (set []) Y

goal (1 subgoal):
 1. set (injections_alg X Y) = injections (set X) Y
[PROOF STEP]
have "\<forall>x xs. ?P xs \<longrightarrow> ?P (x#xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x xs. (distinct xs \<longrightarrow> set (injections_alg xs Y) = injections (set xs) Y) \<longrightarrow> distinct (x # xs) \<longrightarrow> set (injections_alg (x # xs) Y) = injections (set (x # xs)) Y
[PROOF STEP]
using assms(1) lm101
[PROOF STATE]
proof (prove)
using this:
finite Y
\<lbrakk>?x \<notin> set ?xs; set (injections_alg ?xs ?Y) = injections (set ?xs) ?Y; finite ?Y\<rbrakk> \<Longrightarrow> set (injections_alg (?x # ?xs) ?Y) = injections ({?x} \<union> set ?xs) ?Y

goal (1 subgoal):
 1. \<forall>x xs. (distinct xs \<longrightarrow> set (injections_alg xs Y) = injections (set xs) Y) \<longrightarrow> distinct (x # xs) \<longrightarrow> set (injections_alg (x # xs) Y) = injections (set (x # xs)) Y
[PROOF STEP]
by (metis distinct.simps(2) insert_is_Un list.simps(15))
[PROOF STATE]
proof (state)
this:
\<forall>x xs. (distinct xs \<longrightarrow> set (injections_alg xs Y) = injections (set xs) Y) \<longrightarrow> distinct (x # xs) \<longrightarrow> set (injections_alg (x # xs) Y) = injections (set (x # xs)) Y

goal (1 subgoal):
 1. set (injections_alg X Y) = injections (set X) Y
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
distinct [] \<longrightarrow> set (injections_alg [] Y) = injections (set []) Y
\<forall>x xs. (distinct xs \<longrightarrow> set (injections_alg xs Y) = injections (set xs) Y) \<longrightarrow> distinct (x # xs) \<longrightarrow> set (injections_alg (x # xs) Y) = injections (set (x # xs)) Y
[PROOF STEP]
have "?P X"
[PROOF STATE]
proof (prove)
using this:
distinct [] \<longrightarrow> set (injections_alg [] Y) = injections (set []) Y
\<forall>x xs. (distinct xs \<longrightarrow> set (injections_alg xs Y) = injections (set xs) Y) \<longrightarrow> distinct (x # xs) \<longrightarrow> set (injections_alg (x # xs) Y) = injections (set (x # xs)) Y

goal (1 subgoal):
 1. distinct X \<longrightarrow> set (injections_alg X Y) = injections (set X) Y
[PROOF STEP]
by (rule structInduct)
[PROOF STATE]
proof (state)
this:
distinct X \<longrightarrow> set (injections_alg X Y) = injections (set X) Y

goal (1 subgoal):
 1. set (injections_alg X Y) = injections (set X) Y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
distinct X \<longrightarrow> set (injections_alg X Y) = injections (set X) Y
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
distinct X \<longrightarrow> set (injections_alg X Y) = injections (set X) Y

goal (1 subgoal):
 1. set (injections_alg X Y) = injections (set X) Y
[PROOF STEP]
using assms(2)
[PROOF STATE]
proof (prove)
using this:
distinct X \<longrightarrow> set (injections_alg X Y) = injections (set X) Y
distinct X

goal (1 subgoal):
 1. set (injections_alg X Y) = injections (set X) Y
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
set (injections_alg X Y) = injections (set X) Y

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma cos_squared_le_one:
  fixes x:: real
  shows "(cos x)\<^sup>2 \<le> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cos x)\<^sup>2 \<le> 1
[PROOF STEP]
using abs_cos_le_one abs_square_le_1
[PROOF STATE]
proof (prove)
using this:
\<bar>cos ?x\<bar> \<le> 1
(?x\<^sup>2 \<le> (1::?'a)) = (\<bar>?x\<bar> \<le> (1::?'a))

goal (1 subgoal):
 1. (cos x)\<^sup>2 \<le> 1
[PROOF STEP]
by blast


[STATEMENT]
lemma subgroup_Inter:
  assumes "\<forall>I\<in>S. subgroup I"
  shows "subgroup (\<Inter>S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. subgroup (\<Inter> S)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<forall>I\<in>S. subgroup I

goal (1 subgoal):
 1. subgroup (\<Inter> S)
[PROOF STEP]
unfolding subgroup_def
[PROOF STATE]
proof (prove)
using this:
\<forall>I\<in>S. (0::'a) \<in> I \<and> (\<forall>a\<in>I. \<forall>b\<in>I. a + b \<in> I) \<and> (\<forall>a\<in>I. - a \<in> I)

goal (1 subgoal):
 1. (0::'a) \<in> \<Inter> S \<and> (\<forall>a\<in>\<Inter> S. \<forall>b\<in>\<Inter> S. a + b \<in> \<Inter> S) \<and> (\<forall>a\<in>\<Inter> S. - a \<in> \<Inter> S)
[PROOF STEP]
by auto


[STATEMENT]
lemma weighted_nesting_sum:
  fixes g :: "nat \<Rightarrow> 'a::comm_ring_1"
  shows "(\<Sum>k<n. (1 + of_nat k) * (g (Suc k) - g k)) = of_nat n * g n - (\<Sum>i<n. g i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k<n. ((1::'a) + of_nat k) * (g (Suc k) - g k)) = of_nat n * g n - sum g {..<n}
[PROOF STEP]
by (induction n) (auto simp: algebra_simps)


[STATEMENT]
theorem gs1: "\<lbrakk> Pref P\<^sub>a P\<^sub>b; n = length P\<^sub>a \<rbrakk> \<Longrightarrow>
 \<exists>A. Gale_Shapley1 P\<^sub>a P\<^sub>b = Some(A) \<and> Pref.matching P\<^sub>a A {<n} \<and>
   Pref.stable P\<^sub>a P\<^sub>b A {<n} \<and> Pref.opti\<^sub>a P\<^sub>a P\<^sub>b A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Pref P\<^sub>a P\<^sub>b; n = length P\<^sub>a\<rbrakk> \<Longrightarrow> \<exists>A. Gale_Shapley1 P\<^sub>a P\<^sub>b = Some A \<and> Pref.matching P\<^sub>a A {<n} \<and> Pref.stable P\<^sub>a P\<^sub>b A {<n} \<and> Pref.opti\<^sub>a P\<^sub>a P\<^sub>b A
[PROOF STEP]
unfolding Gale_Shapley1_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Pref P\<^sub>a P\<^sub>b; n = length P\<^sub>a\<rbrakk> \<Longrightarrow> \<exists>A. (if Pref P\<^sub>a P\<^sub>b then Some (fst (gs1 (length P\<^sub>a) P\<^sub>a (map ranking P\<^sub>b))) else None) = Some A \<and> Pref.matching P\<^sub>a A {<n} \<and> Pref.stable P\<^sub>a P\<^sub>b A {<n} \<and> Pref.opti\<^sub>a P\<^sub>a P\<^sub>b A
[PROOF STEP]
using Pref.gs1
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>Pref ?P\<^sub>a ?P\<^sub>b; ?R\<^sub>b = map ranking ?P\<^sub>b\<rbrakk> \<Longrightarrow> gs1 (length ?P\<^sub>a) ?P\<^sub>a ?R\<^sub>b = (?A, ?BMaia) \<longrightarrow> Pref.matching ?P\<^sub>a ?A {<length ?P\<^sub>a} \<and> Pref.stable ?P\<^sub>a ?P\<^sub>b ?A {<length ?P\<^sub>a} \<and> Pref.opti\<^sub>a ?P\<^sub>a ?P\<^sub>b ?A

goal (1 subgoal):
 1. \<lbrakk>Pref P\<^sub>a P\<^sub>b; n = length P\<^sub>a\<rbrakk> \<Longrightarrow> \<exists>A. (if Pref P\<^sub>a P\<^sub>b then Some (fst (gs1 (length P\<^sub>a) P\<^sub>a (map ranking P\<^sub>b))) else None) = Some A \<and> Pref.matching P\<^sub>a A {<n} \<and> Pref.stable P\<^sub>a P\<^sub>b A {<n} \<and> Pref.opti\<^sub>a P\<^sub>a P\<^sub>b A
[PROOF STEP]
by (metis fst_conv surj_pair)


[STATEMENT]
lemma hermitian_decomp_decomp':
  fixes A::"complex Matrix.mat"
  assumes "hermitian_decomp A B U"
  shows "real_diag_decomp A B U"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_diag_decomp A B U
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
hermitian_decomp A B U

goal (1 subgoal):
 1. real_diag_decomp A B U
[PROOF STEP]
unfolding hermitian_decomp_def
[PROOF STATE]
proof (prove)
using this:
similar_mat_wit A B U (Complex_Matrix.adjoint U) \<and> diagonal_mat B \<and> diag_mat B = eigvals A \<and> Complex_Matrix.unitary U \<and> (\<forall>i<dim_row B. B $$ (i, i) \<in> \<real>)

goal (1 subgoal):
 1. real_diag_decomp A B U
[PROOF STEP]
by (metis real_diag_decomp_def unitarily_equiv_def unitary_diag_def)


[STATEMENT]
lemma cos_zero_iff_int: "cos x = 0 \<longleftrightarrow> (\<exists>i. odd i \<and> x = of_int i * (pi/2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cos x = 0) = (\<exists>i. odd i \<and> x = real_of_int i * (pi / 2))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (cos x = 0) = (\<exists>i. odd i \<and> x = real_of_int i * (pi / 2))
[PROOF STEP]
have 1: "\<And>n. odd n \<Longrightarrow> \<exists>i. odd i \<and> real n = real_of_int i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. odd n \<Longrightarrow> \<exists>i. odd i \<and> real n = real_of_int i
[PROOF STEP]
by (metis even_of_nat_iff of_int_of_nat_eq)
[PROOF STATE]
proof (state)
this:
odd ?n \<Longrightarrow> \<exists>i. odd i \<and> real ?n = real_of_int i

goal (1 subgoal):
 1. (cos x = 0) = (\<exists>i. odd i \<and> x = real_of_int i * (pi / 2))
[PROOF STEP]
have 2: "\<And>n. odd n \<Longrightarrow> \<exists>i. odd i \<and> - (real n * pi) = real_of_int i * pi"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. odd n \<Longrightarrow> \<exists>i. odd i \<and> - (real n * pi) = real_of_int i * pi
[PROOF STEP]
by (metis even_minus even_of_nat_iff mult.commute mult_minus_right of_int_minus of_int_of_nat_eq)
[PROOF STATE]
proof (state)
this:
odd ?n \<Longrightarrow> \<exists>i. odd i \<and> - (real ?n * pi) = real_of_int i * pi

goal (1 subgoal):
 1. (cos x = 0) = (\<exists>i. odd i \<and> x = real_of_int i * (pi / 2))
[PROOF STEP]
have 3: "\<lbrakk>odd i;  \<forall>n. even n \<or> real_of_int i \<noteq> - (real n)\<rbrakk>
         \<Longrightarrow> \<exists>n. odd n \<and> real_of_int i = real n" for i
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>odd i; \<forall>n. even n \<or> real_of_int i \<noteq> - real n\<rbrakk> \<Longrightarrow> \<exists>n. odd n \<and> real_of_int i = real n
[PROOF STEP]
by (cases i rule: int_cases2) auto
[PROOF STATE]
proof (state)
this:
\<lbrakk>odd ?i; \<forall>n. even n \<or> real_of_int ?i \<noteq> - real n\<rbrakk> \<Longrightarrow> \<exists>n. odd n \<and> real_of_int ?i = real n

goal (1 subgoal):
 1. (cos x = 0) = (\<exists>i. odd i \<and> x = real_of_int i * (pi / 2))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cos x = 0) = (\<exists>i. odd i \<and> x = real_of_int i * (pi / 2))
[PROOF STEP]
by (force simp: cos_zero_iff intro!: 1 2 3)
[PROOF STATE]
proof (state)
this:
(cos x = 0) = (\<exists>i. odd i \<and> x = real_of_int i * (pi / 2))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma effective_elements_matrix_distribution1:
 "matrix_compose_cond A1 A2 B1 B2 i j \<Longrightarrow>
 ((matrix_mult A1  A2)\<otimes>(matrix_mult B1  B2))!j!i
  =  f (scalar_product (row A1 (i div (row_length B1))) (col A2  (j div (length B2))))
       (scalar_product (row B1 (i mod (row_length B1))) (col B2 (j mod (length B2))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_compose_cond A1 A2 B1 B2 i j \<Longrightarrow> (A1 \<circ> A2 \<otimes> B1 \<circ> B2) ! j ! i = scalar_product (row A1 (i div row_length B1)) (col A2 (j div length B2)) * scalar_product (row B1 (i mod row_length B1)) (col B2 (j mod length B2))
[PROOF STEP]
using  elements_matrix_distribution_1 matrix_compose_cond_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>mat (row_length ?A1.0) (length ?A1.0) ?A1.0; mat (row_length ?A2.0) (length ?A2.0) ?A2.0; mat (row_length ?B1.0) (length ?B1.0) ?B1.0; mat (row_length ?B2.0) (length ?B2.0) ?B2.0; length ?A1.0 = row_length ?A2.0; length ?B1.0 = row_length ?B2.0; ?A1.0 \<noteq> [] \<and> ?A2.0 \<noteq> [] \<and> ?B1.0 \<noteq> [] \<and> ?B2.0 \<noteq> []; ?i < row_length ?A1.0 * row_length ?B1.0; ?j < length ?A2.0 * length ?B2.0\<rbrakk> \<Longrightarrow> (?A1.0 \<circ> ?A2.0 \<otimes> ?B1.0 \<circ> ?B2.0) ! ?j ! ?i = scalar_product (row ?A1.0 (?i div row_length ?B1.0)) (col ?A2.0 (?j div length ?B2.0)) * scalar_product (row ?B1.0 (?i mod row_length ?B1.0)) (col ?B2.0 (?j mod length ?B2.0))
matrix_compose_cond ?A1.0 ?A2.0 ?B1.0 ?B2.0 ?i ?j \<equiv> mat (row_length ?A1.0) (length ?A1.0) ?A1.0 \<and> mat (row_length ?A2.0) (length ?A2.0) ?A2.0 \<and> mat (row_length ?B1.0) (length ?B1.0) ?B1.0 \<and> mat (row_length ?B2.0) (length ?B2.0) ?B2.0 \<and> length ?A1.0 = row_length ?A2.0 \<and> length ?B1.0 = row_length ?B2.0 \<and> ?A1.0 \<noteq> [] \<and> ?A2.0 \<noteq> [] \<and> ?B1.0 \<noteq> [] \<and> ?B2.0 \<noteq> [] \<and> ?i < row_length ?A1.0 * row_length ?B1.0 \<and> ?j < length ?A2.0 * length ?B2.0

goal (1 subgoal):
 1. matrix_compose_cond A1 A2 B1 B2 i j \<Longrightarrow> (A1 \<circ> A2 \<otimes> B1 \<circ> B2) ! j ! i = scalar_product (row A1 (i div row_length B1)) (col A2 (j div length B2)) * scalar_product (row B1 (i mod row_length B1)) (col B2 (j mod length B2))
[PROOF STEP]
by auto


[STATEMENT]
lemma sum_equal: "0 < (N::nat) \<Longrightarrow> sum (\<lambda> n. 1/N) {..< N} = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < N \<Longrightarrow> (\<Sum>n<N. 1 / real N) = 1
[PROOF STEP]
unfolding sum_constant
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < N \<Longrightarrow> real (card {..<N}) * (1 / real N) = 1
[PROOF STEP]
by auto


[STATEMENT]
lemma emeasure_lborel_box[simp]:
  assumes [simp]: "\<And>b. b \<in> Basis \<Longrightarrow> l \<bullet> b \<le> u \<bullet> b"
  shows "emeasure lborel (box l u) = (\<Prod>b\<in>Basis. (u - l) \<bullet> b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. emeasure lborel (box l u) = ennreal (prod ((\<bullet>) (u - l)) Basis)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. emeasure lborel (box l u) = ennreal (prod ((\<bullet>) (u - l)) Basis)
[PROOF STEP]
have "(\<lambda>x. \<Prod>b\<in>Basis. indicator {l\<bullet>b <..< u\<bullet>b} (x \<bullet> b) :: ennreal) = indicator (box l u)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. \<Prod>b\<in>Basis. indicator {l \<bullet> b<..<u \<bullet> b} (x \<bullet> b)) = indicator (box l u)
[PROOF STEP]
by (auto simp: fun_eq_iff box_def split: split_indicator)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. \<Prod>b\<in>Basis. indicator {l \<bullet> b<..<u \<bullet> b} (x \<bullet> b)) = indicator (box l u)

goal (1 subgoal):
 1. emeasure lborel (box l u) = ennreal (prod ((\<bullet>) (u - l)) Basis)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>x. \<Prod>b\<in>Basis. indicator {l \<bullet> b<..<u \<bullet> b} (x \<bullet> b)) = indicator (box l u)
[PROOF STEP]
have "emeasure lborel (box l u) = (\<integral>\<^sup>+x. (\<Prod>b\<in>Basis. indicator {l\<bullet>b <..< u\<bullet>b} (x \<bullet> b)) \<partial>lborel)"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. \<Prod>b\<in>Basis. indicator {l \<bullet> b<..<u \<bullet> b} (x \<bullet> b)) = indicator (box l u)

goal (1 subgoal):
 1. emeasure lborel (box l u) = \<integral>\<^sup>+ x. (\<Prod>b\<in>Basis. indicator {l \<bullet> b<..<u \<bullet> b} (x \<bullet> b)) \<partial>lborel
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
emeasure lborel (box l u) = \<integral>\<^sup>+ x. (\<Prod>b\<in>Basis. indicator {l \<bullet> b<..<u \<bullet> b} (x \<bullet> b)) \<partial>lborel

goal (1 subgoal):
 1. emeasure lborel (box l u) = ennreal (prod ((\<bullet>) (u - l)) Basis)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
emeasure lborel (box l u) = \<integral>\<^sup>+ x. (\<Prod>b\<in>Basis. indicator {l \<bullet> b<..<u \<bullet> b} (x \<bullet> b)) \<partial>lborel

goal (1 subgoal):
 1. emeasure lborel (box l u) = ennreal (prod ((\<bullet>) (u - l)) Basis)
[PROOF STEP]
have "\<dots> = (\<Prod>b\<in>Basis. (u - l) \<bullet> b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+ x. (\<Prod>b\<in>Basis. indicator {l \<bullet> b<..<u \<bullet> b} (x \<bullet> b)) \<partial>lborel = ennreal (prod ((\<bullet>) (u - l)) Basis)
[PROOF STEP]
by (subst nn_integral_lborel_prod) (simp_all add: prod_ennreal inner_diff_left)
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. (\<Prod>b\<in>Basis. indicator {l \<bullet> b<..<u \<bullet> b} (x \<bullet> b)) \<partial>lborel = ennreal (prod ((\<bullet>) (u - l)) Basis)

goal (1 subgoal):
 1. emeasure lborel (box l u) = ennreal (prod ((\<bullet>) (u - l)) Basis)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
emeasure lborel (box l u) = ennreal (prod ((\<bullet>) (u - l)) Basis)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
emeasure lborel (box l u) = ennreal (prod ((\<bullet>) (u - l)) Basis)

goal (1 subgoal):
 1. emeasure lborel (box l u) = ennreal (prod ((\<bullet>) (u - l)) Basis)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
emeasure lborel (box l u) = ennreal (prod ((\<bullet>) (u - l)) Basis)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma odd_square_cong_4_int:
  fixes x :: int
  assumes "odd x"
  shows   "[x ^ 2 = 1] (mod 4)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x\<^sup>2 = 1] (mod 4)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. [x\<^sup>2 = 1] (mod 4)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
odd x
[PROOF STEP]
have "odd \<bar>x\<bar>"
[PROOF STATE]
proof (prove)
using this:
odd x

goal (1 subgoal):
 1. odd \<bar>x\<bar>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
odd \<bar>x\<bar>

goal (1 subgoal):
 1. [x\<^sup>2 = 1] (mod 4)
[PROOF STEP]
hence [simp]: "\<bar>x\<bar> mod 2 = 1"
[PROOF STATE]
proof (prove)
using this:
odd \<bar>x\<bar>

goal (1 subgoal):
 1. \<bar>x\<bar> mod 2 = 1
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
\<bar>x\<bar> mod 2 = 1

goal (1 subgoal):
 1. [x\<^sup>2 = 1] (mod 4)
[PROOF STEP]
have "(\<bar>x\<bar> ^ 2) mod 4 = ((\<bar>x\<bar> mod 4) ^ 2) mod 4"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>x\<bar>\<^sup>2 mod 4 = (\<bar>x\<bar> mod 4)\<^sup>2 mod 4
[PROOF STEP]
by (simp add: power_mod)
[PROOF STATE]
proof (state)
this:
\<bar>x\<bar>\<^sup>2 mod 4 = (\<bar>x\<bar> mod 4)\<^sup>2 mod 4

goal (1 subgoal):
 1. [x\<^sup>2 = 1] (mod 4)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<bar>x\<bar>\<^sup>2 mod 4 = (\<bar>x\<bar> mod 4)\<^sup>2 mod 4

goal (1 subgoal):
 1. [x\<^sup>2 = 1] (mod 4)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
odd x
[PROOF STEP]
have "\<bar>x\<bar> mod 4 = 1 \<or> \<bar>x\<bar> mod 4 = 3"
[PROOF STATE]
proof (prove)
using this:
odd x

goal (1 subgoal):
 1. \<bar>x\<bar> mod 4 = 1 \<or> \<bar>x\<bar> mod 4 = 3
[PROOF STEP]
using mod_double_modulus[of 2 "\<bar>x\<bar>"]
[PROOF STATE]
proof (prove)
using this:
odd x
\<lbrakk>0 < 2; 0 \<le> \<bar>x\<bar>\<rbrakk> \<Longrightarrow> \<bar>x\<bar> mod (2 * 2) = \<bar>x\<bar> mod 2 \<or> \<bar>x\<bar> mod (2 * 2) = \<bar>x\<bar> mod 2 + 2

goal (1 subgoal):
 1. \<bar>x\<bar> mod 4 = 1 \<or> \<bar>x\<bar> mod 4 = 3
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<bar>x\<bar> mod 4 = 1 \<or> \<bar>x\<bar> mod 4 = 3

goal (1 subgoal):
 1. [x\<^sup>2 = 1] (mod 4)
[PROOF STEP]
hence "((\<bar>x\<bar> mod 4) ^ 2) mod 4 = 1"
[PROOF STATE]
proof (prove)
using this:
\<bar>x\<bar> mod 4 = 1 \<or> \<bar>x\<bar> mod 4 = 3

goal (1 subgoal):
 1. (\<bar>x\<bar> mod 4)\<^sup>2 mod 4 = 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<bar>x\<bar> mod 4)\<^sup>2 mod 4 = 1

goal (1 subgoal):
 1. [x\<^sup>2 = 1] (mod 4)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<bar>x\<bar>\<^sup>2 mod 4 = 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<bar>x\<bar>\<^sup>2 mod 4 = 1

goal (1 subgoal):
 1. [x\<^sup>2 = 1] (mod 4)
[PROOF STEP]
by (simp add: cong_def)
[PROOF STATE]
proof (state)
this:
[x\<^sup>2 = 1] (mod 4)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in group) finite_subgroup_card_neq_0:
  assumes "subgroup H G" "finite H"
  shows "card H \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card H \<noteq> 0
[PROOF STEP]
using subgroup_nonempty assms
[PROOF STATE]
proof (prove)
using this:
\<not> subgroup {} ?G
subgroup H G
finite H

goal (1 subgoal):
 1. card H \<noteq> 0
[PROOF STEP]
by auto


[STATEMENT]
lemma inner_mult_diag_real:
  fixes B::"complex Matrix.mat"
  assumes "diagonal_mat B"
  and "B \<in> carrier_mat n n"
  and "\<forall>i < n. B$$(i, i) \<in> Reals"
  and "v \<in> carrier_vec n"
shows "inner_prod (B *\<^sub>v v) v \<in> Reals"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex_Matrix.inner_prod (B *\<^sub>v v) v \<in> \<real>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Complex_Matrix.inner_prod (B *\<^sub>v v) v \<in> \<real>
[PROOF STEP]
have  "inner_prod (B *\<^sub>v v) v =
    (\<Sum> i \<in> {0 ..< n}. (conjugate (B $$ (i,i))) * (vec_index v i *
    (conjugate (vec_index v i))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex_Matrix.inner_prod (B *\<^sub>v v) v = (\<Sum>i = 0..<n. conjugate (B $$ (i, i)) * (v $ i * conjugate (v $ i)))
[PROOF STEP]
using inner_mult_diag_expand assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>diagonal_mat ?B; ?B \<in> carrier_mat ?n ?n; ?v \<in> carrier_vec ?n\<rbrakk> \<Longrightarrow> Complex_Matrix.inner_prod (?B *\<^sub>v ?v) ?v = (\<Sum>i = 0..<?n. conjugate (?B $$ (i, i)) * (?v $ i * conjugate (?v $ i)))
diagonal_mat B
B \<in> carrier_mat n n
\<forall>i<n. B $$ (i, i) \<in> \<real>
v \<in> carrier_vec n

goal (1 subgoal):
 1. Complex_Matrix.inner_prod (B *\<^sub>v v) v = (\<Sum>i = 0..<n. conjugate (B $$ (i, i)) * (v $ i * conjugate (v $ i)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Complex_Matrix.inner_prod (B *\<^sub>v v) v = (\<Sum>i = 0..<n. conjugate (B $$ (i, i)) * (v $ i * conjugate (v $ i)))

goal (1 subgoal):
 1. Complex_Matrix.inner_prod (B *\<^sub>v v) v \<in> \<real>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Complex_Matrix.inner_prod (B *\<^sub>v v) v = (\<Sum>i = 0..<n. conjugate (B $$ (i, i)) * (v $ i * conjugate (v $ i)))

goal (1 subgoal):
 1. Complex_Matrix.inner_prod (B *\<^sub>v v) v \<in> \<real>
[PROOF STEP]
have "... \<in> Reals"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<n. conjugate (B $$ (i, i)) * (v $ i * conjugate (v $ i))) \<in> \<real>
[PROOF STEP]
proof (rule real_sum_real)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> conjugate (B $$ (i, i)) * (v $ i * conjugate (v $ i)) \<in> \<real>
[PROOF STEP]
show "\<And>i. i < n \<Longrightarrow>
      conjugate (B $$ (i, i)) *
      ((vec_index v i) * conjugate (vec_index v i)) \<in> \<real>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> conjugate (B $$ (i, i)) * (v $ i * conjugate (v $ i)) \<in> \<real>
[PROOF STEP]
using assms mult_conj_real
[PROOF STATE]
proof (prove)
using this:
diagonal_mat B
B \<in> carrier_mat n n
\<forall>i<n. B $$ (i, i) \<in> \<real>
v \<in> carrier_vec n
?v * conjugate ?v \<in> \<real>

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> conjugate (B $$ (i, i)) * (v $ i * conjugate (v $ i)) \<in> \<real>
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?i < n \<Longrightarrow> conjugate (B $$ (?i, ?i)) * (v $ ?i * conjugate (v $ ?i)) \<in> \<real>

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<n. conjugate (B $$ (i, i)) * (v $ i * conjugate (v $ i))) \<in> \<real>

goal (1 subgoal):
 1. Complex_Matrix.inner_prod (B *\<^sub>v v) v \<in> \<real>
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
Complex_Matrix.inner_prod (B *\<^sub>v v) v \<in> \<real>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Complex_Matrix.inner_prod (B *\<^sub>v v) v \<in> \<real>

goal (1 subgoal):
 1. Complex_Matrix.inner_prod (B *\<^sub>v v) v \<in> \<real>
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
Complex_Matrix.inner_prod (B *\<^sub>v v) v \<in> \<real>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma convex_hull_empty[simp]:
  "convex_hull {} = {}"
  "A \<subseteq> carrier_vec n \<Longrightarrow> convex_hull A = {} \<longleftrightarrow> A = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. convex_hull {} = {} &&& (A \<subseteq> carrier_vec n \<Longrightarrow> (convex_hull A = {}) = (A = {}))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. convex_hull {} = {}
 2. A \<subseteq> carrier_vec n \<Longrightarrow> (convex_hull A = {}) = (A = {})
[PROOF STEP]
show "convex_hull {} = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. convex_hull {} = {}
[PROOF STEP]
unfolding convex_hull_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x. \<exists>Ws c. finite Ws \<and> Ws \<subseteq> {} \<and> convex_lincomb c Ws x} = {}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
convex_hull {} = {}

goal (1 subgoal):
 1. A \<subseteq> carrier_vec n \<Longrightarrow> (convex_hull A = {}) = (A = {})
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
convex_hull {} = {}
[PROOF STEP]
show "A \<subseteq> carrier_vec n \<Longrightarrow> convex_hull A = {} \<longleftrightarrow> A = {}"
[PROOF STATE]
proof (prove)
using this:
convex_hull {} = {}

goal (1 subgoal):
 1. A \<subseteq> carrier_vec n \<Longrightarrow> (convex_hull A = {}) = (A = {})
[PROOF STEP]
using set_in_convex_hull[of A]
[PROOF STATE]
proof (prove)
using this:
convex_hull {} = {}
A \<subseteq> carrier_vec n \<Longrightarrow> A \<subseteq> convex_hull A

goal (1 subgoal):
 1. A \<subseteq> carrier_vec n \<Longrightarrow> (convex_hull A = {}) = (A = {})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A \<subseteq> carrier_vec n \<Longrightarrow> (convex_hull A = {}) = (A = {})

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma integral_normal_moment_abs_odd:
  "integral\<^sup>L lborel (\<lambda>x. normal_density \<mu> \<sigma> x * \<bar>x - \<mu>\<bar>^(2 * k + 1)) = 2 ^ k * \<sigma> ^ (2 * k + 1) * fact k * sqrt (2 / pi)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LBINT x. normal_density \<mu> \<sigma> x * \<bar>x - \<mu>\<bar> ^ (2 * k + 1) = 2 ^ k * \<sigma> ^ (2 * k + 1) * fact k * sqrt (2 / pi)
[PROOF STEP]
using normal_moment_abs_odd
[PROOF STATE]
proof (prove)
using this:
has_bochner_integral lborel (\<lambda>x. normal_density \<mu> \<sigma> x * \<bar>x - \<mu>\<bar> ^ (2 * k + 1)) (2 ^ k * \<sigma> ^ (2 * k + 1) * fact k * sqrt (2 / pi))

goal (1 subgoal):
 1. LBINT x. normal_density \<mu> \<sigma> x * \<bar>x - \<mu>\<bar> ^ (2 * k + 1) = 2 ^ k * \<sigma> ^ (2 * k + 1) * fact k * sqrt (2 / pi)
[PROOF STEP]
by (rule has_bochner_integral_integral_eq)


[STATEMENT]
lemma ccSup_union_distrib: "countable A \<Longrightarrow> countable B \<Longrightarrow> Sup (A \<union> B) = sup (Sup A) (Sup B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>countable A; countable B\<rbrakk> \<Longrightarrow> Sup (A \<union> B) = sup (Sup A) (Sup B)
[PROOF STEP]
by (rule order.antisym) (auto intro: ccSup_least ccSup_upper le_supI1 le_supI2)


[STATEMENT]
lemma closedin_compact_projection:
  fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set"
  assumes "compact S" and clo: "closedin (top_of_set (S \<times> T)) U"
    shows "closedin (top_of_set T) {y. \<exists>x. x \<in> S \<and> (x, y) \<in> U}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. closedin (top_of_set T) {y. \<exists>x. x \<in> S \<and> (x, y) \<in> U}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. closedin (top_of_set T) {y. \<exists>x. x \<in> S \<and> (x, y) \<in> U}
[PROOF STEP]
have "U \<subseteq> S \<times> T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. U \<subseteq> S \<times> T
[PROOF STEP]
by (metis clo closedin_imp_subset)
[PROOF STATE]
proof (state)
this:
U \<subseteq> S \<times> T

goal (1 subgoal):
 1. closedin (top_of_set T) {y. \<exists>x. x \<in> S \<and> (x, y) \<in> U}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
U \<subseteq> S \<times> T
[PROOF STEP]
have "{y. \<exists>x. x \<in> S \<and> (x, y) \<in> U} = snd ` U"
[PROOF STATE]
proof (prove)
using this:
U \<subseteq> S \<times> T

goal (1 subgoal):
 1. {y. \<exists>x. x \<in> S \<and> (x, y) \<in> U} = snd ` U
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
{y. \<exists>x. x \<in> S \<and> (x, y) \<in> U} = snd ` U

goal (1 subgoal):
 1. closedin (top_of_set T) {y. \<exists>x. x \<in> S \<and> (x, y) \<in> U}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
{y. \<exists>x. x \<in> S \<and> (x, y) \<in> U} = snd ` U

goal (1 subgoal):
 1. closedin (top_of_set T) {y. \<exists>x. x \<in> S \<and> (x, y) \<in> U}
[PROOF STEP]
have "closedin (top_of_set T) (snd ` U)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. closedin (top_of_set T) (snd ` U)
[PROOF STEP]
by (rule closed_map_snd [OF assms])
[PROOF STATE]
proof (state)
this:
closedin (top_of_set T) (snd ` U)

goal (1 subgoal):
 1. closedin (top_of_set T) {y. \<exists>x. x \<in> S \<and> (x, y) \<in> U}
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
{y. \<exists>x. x \<in> S \<and> (x, y) \<in> U} = snd ` U
closedin (top_of_set T) (snd ` U)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
{y. \<exists>x. x \<in> S \<and> (x, y) \<in> U} = snd ` U
closedin (top_of_set T) (snd ` U)

goal (1 subgoal):
 1. closedin (top_of_set T) {y. \<exists>x. x \<in> S \<and> (x, y) \<in> U}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
closedin (top_of_set T) {y. \<exists>x. x \<in> S \<and> (x, y) \<in> U}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma gbinomial_trinomial_revision:
  assumes "k \<le> m"
  shows "(a gchoose m) * (of_nat m gchoose k) = (a gchoose k) * (a - of_nat k gchoose (m - k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a gchoose m) * (of_nat m gchoose k) = (a gchoose k) * (a - of_nat k gchoose (m - k))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (a gchoose m) * (of_nat m gchoose k) = (a gchoose k) * (a - of_nat k gchoose (m - k))
[PROOF STEP]
have "(a gchoose m) * (of_nat m gchoose k) = (a gchoose m) * fact m / (fact k * fact (m - k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a gchoose m) * (of_nat m gchoose k) = (a gchoose m) * fact m / (fact k * fact (m - k))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
k \<le> m

goal (1 subgoal):
 1. (a gchoose m) * (of_nat m gchoose k) = (a gchoose m) * fact m / (fact k * fact (m - k))
[PROOF STEP]
by (simp add: binomial_gbinomial [symmetric] binomial_fact)
[PROOF STATE]
proof (state)
this:
(a gchoose m) * (of_nat m gchoose k) = (a gchoose m) * fact m / (fact k * fact (m - k))

goal (1 subgoal):
 1. (a gchoose m) * (of_nat m gchoose k) = (a gchoose k) * (a - of_nat k gchoose (m - k))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(a gchoose m) * (of_nat m gchoose k) = (a gchoose m) * fact m / (fact k * fact (m - k))

goal (1 subgoal):
 1. (a gchoose m) * (of_nat m gchoose k) = (a gchoose k) * (a - of_nat k gchoose (m - k))
[PROOF STEP]
have "\<dots> = (a gchoose k) * (a - of_nat k gchoose (m - k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a gchoose m) * fact m / (fact k * fact (m - k)) = (a gchoose k) * (a - of_nat k gchoose (m - k))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
k \<le> m

goal (1 subgoal):
 1. (a gchoose m) * fact m / (fact k * fact (m - k)) = (a gchoose k) * (a - of_nat k gchoose (m - k))
[PROOF STEP]
by (simp add: gbinomial_pochhammer power_diff pochhammer_product)
[PROOF STATE]
proof (state)
this:
(a gchoose m) * fact m / (fact k * fact (m - k)) = (a gchoose k) * (a - of_nat k gchoose (m - k))

goal (1 subgoal):
 1. (a gchoose m) * (of_nat m gchoose k) = (a gchoose k) * (a - of_nat k gchoose (m - k))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(a gchoose m) * (of_nat m gchoose k) = (a gchoose k) * (a - of_nat k gchoose (m - k))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(a gchoose m) * (of_nat m gchoose k) = (a gchoose k) * (a - of_nat k gchoose (m - k))

goal (1 subgoal):
 1. (a gchoose m) * (of_nat m gchoose k) = (a gchoose k) * (a - of_nat k gchoose (m - k))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(a gchoose m) * (of_nat m gchoose k) = (a gchoose k) * (a - of_nat k gchoose (m - k))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma gbinomial_sum_up_index:
  "(\<Sum>j = 0..n. (of_nat j gchoose k) :: 'a::field_char_0) = (of_nat n + 1) gchoose (k + 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j = 0..n. of_nat j gchoose k) = of_nat n + (1::'a) gchoose (k + 1)
[PROOF STEP]
proof (induct n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (\<Sum>j = 0..0. of_nat j gchoose k) = of_nat 0 + (1::'a) gchoose (k + 1)
 2. \<And>n. (\<Sum>j = 0..n. of_nat j gchoose k) = of_nat n + (1::'a) gchoose (k + 1) \<Longrightarrow> (\<Sum>j = 0..Suc n. of_nat j gchoose k) = of_nat (Suc n) + (1::'a) gchoose (k + 1)
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. (\<Sum>j = 0..0. of_nat j gchoose k) = of_nat 0 + (1::'a) gchoose (k + 1)
 2. \<And>n. (\<Sum>j = 0..n. of_nat j gchoose k) = of_nat n + (1::'a) gchoose (k + 1) \<Longrightarrow> (\<Sum>j = 0..Suc n. of_nat j gchoose k) = of_nat (Suc n) + (1::'a) gchoose (k + 1)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j = 0..0. of_nat j gchoose k) = of_nat 0 + (1::'a) gchoose (k + 1)
[PROOF STEP]
using gbinomial_Suc_Suc[of 0 k]
[PROOF STATE]
proof (prove)
using this:
(0::?'b1) + (1::?'b1) gchoose Suc k = (0::?'b1) gchoose k + ((0::?'b1) gchoose Suc k)

goal (1 subgoal):
 1. (\<Sum>j = 0..0. of_nat j gchoose k) = of_nat 0 + (1::'a) gchoose (k + 1)
[PROOF STEP]
by (cases k) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>j = 0..0. of_nat j gchoose k) = of_nat 0 + (1::'a) gchoose (k + 1)

goal (1 subgoal):
 1. \<And>n. (\<Sum>j = 0..n. of_nat j gchoose k) = of_nat n + (1::'a) gchoose (k + 1) \<Longrightarrow> (\<Sum>j = 0..Suc n. of_nat j gchoose k) = of_nat (Suc n) + (1::'a) gchoose (k + 1)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. (\<Sum>j = 0..n. of_nat j gchoose k) = of_nat n + (1::'a) gchoose (k + 1) \<Longrightarrow> (\<Sum>j = 0..Suc n. of_nat j gchoose k) = of_nat (Suc n) + (1::'a) gchoose (k + 1)
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
(\<Sum>j = 0..n. of_nat j gchoose k) = of_nat n + (1::'a) gchoose (k + 1)

goal (1 subgoal):
 1. \<And>n. (\<Sum>j = 0..n. of_nat j gchoose k) = of_nat n + (1::'a) gchoose (k + 1) \<Longrightarrow> (\<Sum>j = 0..Suc n. of_nat j gchoose k) = of_nat (Suc n) + (1::'a) gchoose (k + 1)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>j = 0..n. of_nat j gchoose k) = of_nat n + (1::'a) gchoose (k + 1)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
(\<Sum>j = 0..n. of_nat j gchoose k) = of_nat n + (1::'a) gchoose (k + 1)

goal (1 subgoal):
 1. (\<Sum>j = 0..Suc n. of_nat j gchoose k) = of_nat (Suc n) + (1::'a) gchoose (k + 1)
[PROOF STEP]
using gbinomial_Suc_Suc[of "of_nat (Suc n) :: 'a" k]
[PROOF STATE]
proof (prove)
using this:
(\<Sum>j = 0..n. of_nat j gchoose k) = of_nat n + (1::'a) gchoose (k + 1)
of_nat (Suc n) + (1::'a) gchoose Suc k = of_nat (Suc n) gchoose k + (of_nat (Suc n) gchoose Suc k)

goal (1 subgoal):
 1. (\<Sum>j = 0..Suc n. of_nat j gchoose k) = of_nat (Suc n) + (1::'a) gchoose (k + 1)
[PROOF STEP]
by (simp add: add_ac)
[PROOF STATE]
proof (state)
this:
(\<Sum>j = 0..Suc n. of_nat j gchoose k) = of_nat (Suc n) + (1::'a) gchoose (k + 1)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma "count_true (vec (5::nat) (\<lambda>i. True)) = 5"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. count_true (vec 5 (\<lambda>i. True)) = 5
[PROOF STEP]
unfolding count_true_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<dim_vec (vec 5 (\<lambda>i. True)). if vec 5 (\<lambda>i. True) $ i then 1 else 0) = 5
[PROOF STEP]
by simp


[STATEMENT]
lemma scaleR_mtx3: "k *\<^sub>R mtx
  ([a\<^sub>1\<^sub>1, a\<^sub>1\<^sub>2, a\<^sub>1\<^sub>3] #
   [a\<^sub>2\<^sub>1, a\<^sub>2\<^sub>2, a\<^sub>2\<^sub>3] #
   [a\<^sub>3\<^sub>1, a\<^sub>3\<^sub>2, a\<^sub>3\<^sub>3] # []) = mtx
  ([k*a\<^sub>1\<^sub>1, k*a\<^sub>1\<^sub>2, k*a\<^sub>1\<^sub>3] #
   [k*a\<^sub>2\<^sub>1, k*a\<^sub>2\<^sub>2, k*a\<^sub>2\<^sub>3] #
   [k*a\<^sub>3\<^sub>1, k*a\<^sub>3\<^sub>2, k*a\<^sub>3\<^sub>3] # [])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k *\<^sub>R mtx [[a\<^sub>1\<^sub>1, a\<^sub>1\<^sub>2, a\<^sub>1\<^sub>3], [a\<^sub>2\<^sub>1, a\<^sub>2\<^sub>2, a\<^sub>2\<^sub>3], [a\<^sub>3\<^sub>1, a\<^sub>3\<^sub>2, a\<^sub>3\<^sub>3]] = mtx [[k * a\<^sub>1\<^sub>1, k * a\<^sub>1\<^sub>2, k * a\<^sub>1\<^sub>3], [k * a\<^sub>2\<^sub>1, k * a\<^sub>2\<^sub>2, k * a\<^sub>2\<^sub>3], [k * a\<^sub>3\<^sub>1, k * a\<^sub>3\<^sub>2, k * a\<^sub>3\<^sub>3]]
[PROOF STEP]
by (simp add: sq_mtx_eq_iff)


[STATEMENT]
lemma isometry_onD:
  assumes "isometry_on X f"
          "x \<in> X" "y \<in> X"
  shows "dist (f x) (f y) = dist x y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dist (f x) (f y) = dist x y
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
isometry_on X f
x \<in> X
y \<in> X

goal (1 subgoal):
 1. dist (f x) (f y) = dist x y
[PROOF STEP]
unfolding isometry_on_def
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>X. \<forall>y\<in>X. dist (f x) (f y) = dist x y
x \<in> X
y \<in> X

goal (1 subgoal):
 1. dist (f x) (f y) = dist x y
[PROOF STEP]
by auto


[STATEMENT]
lemma inner_prod_distrib_right:
  fixes u v w :: "('a::conjugatable_field) vec"
  assumes dimu: "u \<in> carrier_vec n" and dimv:"v \<in> carrier_vec n" and dimw: "w \<in> carrier_vec n"
  shows "inner_prod u (v + w) = inner_prod u v + inner_prod u w" (is "?lhs = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inner_prod u (v + w) = inner_prod u v + inner_prod u w
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. inner_prod u (v + w) = inner_prod u v + inner_prod u w
[PROOF STEP]
have dimvw: "v + w \<in> carrier_vec n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v + w \<in> carrier_vec n
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
u \<in> carrier_vec n
v \<in> carrier_vec n
w \<in> carrier_vec n

goal (1 subgoal):
 1. v + w \<in> carrier_vec n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
v + w \<in> carrier_vec n

goal (1 subgoal):
 1. inner_prod u (v + w) = inner_prod u v + inner_prod u w
[PROOF STEP]
have dimcu: "conjugate u \<in> carrier_vec n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. conjugate u \<in> carrier_vec n
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
u \<in> carrier_vec n
v \<in> carrier_vec n
w \<in> carrier_vec n

goal (1 subgoal):
 1. conjugate u \<in> carrier_vec n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
conjugate u \<in> carrier_vec n

goal (1 subgoal):
 1. inner_prod u (v + w) = inner_prod u v + inner_prod u w
[PROOF STEP]
have "(v + w) \<bullet> (conjugate u) = v \<bullet> conjugate u + w \<bullet> conjugate u"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inner_prod u (v + w) = inner_prod u v + inner_prod u w
[PROOF STEP]
apply (simp add: comm_scalar_prod[OF dimvw dimcu])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. conjugate u \<bullet> (v + w) = inner_prod u v + inner_prod u w
[PROOF STEP]
apply (simp add: scalar_prod_add_distrib[OF dimcu dimv dimw])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. conjugate u \<bullet> v + conjugate u \<bullet> w = inner_prod u v + inner_prod u w
[PROOF STEP]
apply (insert dimv dimw dimcu, simp add: comm_scalar_prod[of _ n])
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
inner_prod u (v + w) = inner_prod u v + inner_prod u w

goal (1 subgoal):
 1. inner_prod u (v + w) = inner_prod u v + inner_prod u w
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
inner_prod u (v + w) = inner_prod u v + inner_prod u w
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
inner_prod u (v + w) = inner_prod u v + inner_prod u w

goal (1 subgoal):
 1. inner_prod u (v + w) = inner_prod u v + inner_prod u w
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
inner_prod u (v + w) = inner_prod u v + inner_prod u w

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma abs_summable_on_diff [intro]:
  assumes "f abs_summable_on A" and "g abs_summable_on A"
  shows   "(\<lambda>x. f x - g x) abs_summable_on A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. f x - g x) abs_summable_on A
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f abs_summable_on A
g abs_summable_on A

goal (1 subgoal):
 1. (\<lambda>x. f x - g x) abs_summable_on A
[PROOF STEP]
unfolding abs_summable_on_def
[PROOF STATE]
proof (prove)
using this:
integrable (count_space A) f
integrable (count_space A) g

goal (1 subgoal):
 1. integrable (count_space A) (\<lambda>x. f x - g x)
[PROOF STEP]
by (rule Bochner_Integration.integrable_diff)


[STATEMENT]
lemma continuous_openin_preimage_gen:
  assumes "continuous_on S f"  "open T"
  shows "openin (top_of_set S) (S \<inter> f -` T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. openin (top_of_set S) (S \<inter> f -` T)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. openin (top_of_set S) (S \<inter> f -` T)
[PROOF STEP]
have *: "(S \<inter> f -` T) = (S \<inter> f -` (T \<inter> f ` S))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S \<inter> f -` T = S \<inter> f -` (T \<inter> f ` S)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
S \<inter> f -` T = S \<inter> f -` (T \<inter> f ` S)

goal (1 subgoal):
 1. openin (top_of_set S) (S \<inter> f -` T)
[PROOF STEP]
have "openin (top_of_set (f ` S)) (T \<inter> f ` S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. openin (top_of_set (f ` S)) (T \<inter> f ` S)
[PROOF STEP]
using openin_open_Int[of T "f ` S", OF assms(2)]
[PROOF STATE]
proof (prove)
using this:
openin (top_of_set (f ` S)) (f ` S \<inter> T)

goal (1 subgoal):
 1. openin (top_of_set (f ` S)) (T \<inter> f ` S)
[PROOF STEP]
unfolding openin_open
[PROOF STATE]
proof (prove)
using this:
\<exists>Ta. open Ta \<and> f ` S \<inter> T = f ` S \<inter> Ta

goal (1 subgoal):
 1. \<exists>Ta. open Ta \<and> T \<inter> f ` S = f ` S \<inter> Ta
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
openin (top_of_set (f ` S)) (T \<inter> f ` S)

goal (1 subgoal):
 1. openin (top_of_set S) (S \<inter> f -` T)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
openin (top_of_set (f ` S)) (T \<inter> f ` S)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
openin (top_of_set (f ` S)) (T \<inter> f ` S)

goal (1 subgoal):
 1. openin (top_of_set S) (S \<inter> f -` T)
[PROOF STEP]
using assms(1)[unfolded continuous_on_open, THEN spec[where x="T \<inter> f ` S"]]
[PROOF STATE]
proof (prove)
using this:
openin (top_of_set (f ` S)) (T \<inter> f ` S)
openin (top_of_set (f ` S)) (T \<inter> f ` S) \<longrightarrow> openin (top_of_set S) (S \<inter> f -` (T \<inter> f ` S))

goal (1 subgoal):
 1. openin (top_of_set S) (S \<inter> f -` T)
[PROOF STEP]
using *
[PROOF STATE]
proof (prove)
using this:
openin (top_of_set (f ` S)) (T \<inter> f ` S)
openin (top_of_set (f ` S)) (T \<inter> f ` S) \<longrightarrow> openin (top_of_set S) (S \<inter> f -` (T \<inter> f ` S))
S \<inter> f -` T = S \<inter> f -` (T \<inter> f ` S)

goal (1 subgoal):
 1. openin (top_of_set S) (S \<inter> f -` T)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
openin (top_of_set S) (S \<inter> f -` T)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma int_less_real_le: "n < m \<longleftrightarrow> real_of_int n + 1 \<le> real_of_int m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (n < m) = (real_of_int n + 1 \<le> real_of_int m)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (n < m) = (real_of_int n + 1 \<le> real_of_int m)
[PROOF STEP]
have "(0::real) \<le> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> 1
[PROOF STEP]
by (metis less_eq_real_def zero_less_one)
[PROOF STATE]
proof (state)
this:
0 \<le> 1

goal (1 subgoal):
 1. (n < m) = (real_of_int n + 1 \<le> real_of_int m)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 \<le> 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
0 \<le> 1

goal (1 subgoal):
 1. (n < m) = (real_of_int n + 1 \<le> real_of_int m)
[PROOF STEP]
by (metis floor_of_int less_floor_iff)
[PROOF STATE]
proof (state)
this:
(n < m) = (real_of_int n + 1 \<le> real_of_int m)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Discrete_sqrt_square_is_square:
  assumes "is_square n"
  shows   "Discrete.sqrt n ^ 2 = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Discrete.sqrt n)\<^sup>2 = n
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
is_square n

goal (1 subgoal):
 1. (Discrete.sqrt n)\<^sup>2 = n
[PROOF STEP]
unfolding is_nth_power_def
[PROOF STATE]
proof (prove)
using this:
\<exists>y. n = y\<^sup>2

goal (1 subgoal):
 1. (Discrete.sqrt n)\<^sup>2 = n
[PROOF STEP]
by force


[STATEMENT]
lemma half_sum:
  "(\<Sum>n. ((1::real) / 2) ^ (Suc (n + k))) = (1/2)^k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>n. (1 / 2) ^ Suc (n + k)) = (1 / 2) ^ k
[PROOF STEP]
using suminf_split_initial_segment[of "\<lambda>n. ((1::real) / 2) ^ (Suc n)" k] half_1_minus_sum[of k] power_half_series sums_unique[of "\<lambda>n. (1 / 2) ^ Suc n" 1] power_half_summable
[PROOF STATE]
proof (prove)
using this:
summable (\<lambda>n. (1 / 2) ^ Suc n) \<Longrightarrow> (\<Sum>n. (1 / 2) ^ Suc n) = (\<Sum>n. (1 / 2) ^ Suc (n + k)) + (\<Sum>i<k. (1 / 2) ^ Suc i)
1 - (\<Sum>i<k. (1 / 2) ^ Suc i) = (1 / 2) ^ k
(\<lambda>n. (1 / 2) ^ Suc n) sums 1
(\<lambda>n. ((1::?'a1) / (2::?'a1)) ^ Suc n) sums (1::?'a1) \<Longrightarrow> (1::?'a1) = (\<Sum>n. ((1::?'a1) / (2::?'a1)) ^ Suc n)
summable (\<lambda>n. (1 / 2) ^ Suc n)

goal (1 subgoal):
 1. (\<Sum>n. (1 / 2) ^ Suc (n + k)) = (1 / 2) ^ k
[PROOF STEP]
by fastforce


[STATEMENT]
lemma sumset_assoc:
  shows "sumset (sumset A B) C = sumset A (sumset B C)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sumset (sumset A B) C = sumset A (sumset B C)
[PROOF STEP]
by (fastforce simp add: sumset_eq associative Bex_def)


[STATEMENT]
lemma det_col_add: "det (upd_col M i (a + b)) = det (upd_col M i a) + det (upd_col M i b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Square_Matrix.det (upd_col M i (a + b)) = Square_Matrix.det (upd_col M i a) + Square_Matrix.det (upd_col M i b)
[PROOF STEP]
using det_row_add[of "transpose M" i a b]
[PROOF STATE]
proof (prove)
using this:
Square_Matrix.det (upd_row (Square_Matrix.transpose M) i (a + b)) = Square_Matrix.det (upd_row (Square_Matrix.transpose M) i a) + Square_Matrix.det (upd_row (Square_Matrix.transpose M) i b)

goal (1 subgoal):
 1. Square_Matrix.det (upd_col M i (a + b)) = Square_Matrix.det (upd_col M i a) + Square_Matrix.det (upd_col M i b)
[PROOF STEP]
by (simp add: upd_row_transpose det_transpose)


[STATEMENT]
theorem card_partition_on_at_most_size:
  assumes "finite A"
  shows "card {P. partition_on A P \<and> card P \<le> k} = (\<Sum>j\<le>k. Stirling (card A) j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {P. partition_on A P \<and> card P \<le> k} = sum (Stirling (card A)) {..k}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card {P. partition_on A P \<and> card P \<le> k} = sum (Stirling (card A)) {..k}
[PROOF STEP]
have "card {P. partition_on A P \<and> card P \<le> k} = card (\<Union>j\<le>k. {P. partition_on A P \<and> card P = j})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {P. partition_on A P \<and> card P \<le> k} = card (\<Union>j\<le>k. {P. partition_on A P \<and> card P = j})
[PROOF STEP]
by (rule arg_cong[where f="card"]) auto
[PROOF STATE]
proof (state)
this:
card {P. partition_on A P \<and> card P \<le> k} = card (\<Union>j\<le>k. {P. partition_on A P \<and> card P = j})

goal (1 subgoal):
 1. card {P. partition_on A P \<and> card P \<le> k} = sum (Stirling (card A)) {..k}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card {P. partition_on A P \<and> card P \<le> k} = card (\<Union>j\<le>k. {P. partition_on A P \<and> card P = j})

goal (1 subgoal):
 1. card {P. partition_on A P \<and> card P \<le> k} = sum (Stirling (card A)) {..k}
[PROOF STEP]
have "\<dots> = (\<Sum>j\<le>k. card {P. partition_on A P \<and> card P = j})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (\<Union>j\<le>k. {P. partition_on A P \<and> card P = j}) = (\<Sum>j\<le>k. card {P. partition_on A P \<and> card P = j})
[PROOF STEP]
by (subst card_UN_disjoint) (auto simp add: \<open>finite A\<close> finitely_many_partition_on)
[PROOF STATE]
proof (state)
this:
card (\<Union>j\<le>k. {P. partition_on A P \<and> card P = j}) = (\<Sum>j\<le>k. card {P. partition_on A P \<and> card P = j})

goal (1 subgoal):
 1. card {P. partition_on A P \<and> card P \<le> k} = sum (Stirling (card A)) {..k}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card (\<Union>j\<le>k. {P. partition_on A P \<and> card P = j}) = (\<Sum>j\<le>k. card {P. partition_on A P \<and> card P = j})

goal (1 subgoal):
 1. card {P. partition_on A P \<and> card P \<le> k} = sum (Stirling (card A)) {..k}
[PROOF STEP]
have "(\<Sum>j\<le>k. card {P. partition_on A P \<and> card P = j}) = (\<Sum>j\<le>k. Stirling (card A) j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j\<le>k. card {P. partition_on A P \<and> card P = j}) = sum (Stirling (card A)) {..k}
[PROOF STEP]
using \<open>finite A\<close>
[PROOF STATE]
proof (prove)
using this:
finite A

goal (1 subgoal):
 1. (\<Sum>j\<le>k. card {P. partition_on A P \<and> card P = j}) = sum (Stirling (card A)) {..k}
[PROOF STEP]
by (simp add: card_partition_on)
[PROOF STATE]
proof (state)
this:
(\<Sum>j\<le>k. card {P. partition_on A P \<and> card P = j}) = sum (Stirling (card A)) {..k}

goal (1 subgoal):
 1. card {P. partition_on A P \<and> card P \<le> k} = sum (Stirling (card A)) {..k}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
card {P. partition_on A P \<and> card P \<le> k} = sum (Stirling (card A)) {..k}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
card {P. partition_on A P \<and> card P \<le> k} = sum (Stirling (card A)) {..k}

goal (1 subgoal):
 1. card {P. partition_on A P \<and> card P \<le> k} = sum (Stirling (card A)) {..k}
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
card {P. partition_on A P \<and> card P \<le> k} = sum (Stirling (card A)) {..k}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sum_indicator_eq_card:
  assumes "finite A"
  shows "(\<Sum>x \<in> A. indicator B x) = card (A Int B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum (indicator B) A = card (A \<inter> B)
[PROOF STEP]
using sum_mult_indicator [OF assms, of "\<lambda>x. 1::nat"]
[PROOF STATE]
proof (prove)
using this:
(\<Sum>x\<in>A. 1 * indicator ?B x) = (\<Sum>x\<in>A \<inter> ?B. 1)

goal (1 subgoal):
 1. sum (indicator B) A = card (A \<inter> B)
[PROOF STEP]
unfolding card_eq_sum
[PROOF STATE]
proof (prove)
using this:
(\<Sum>x\<in>A. 1 * indicator ?B x) = (\<Sum>x\<in>A \<inter> ?B. 1)

goal (1 subgoal):
 1. sum (indicator B) A = (\<Sum>x\<in>A \<inter> B. 1)
[PROOF STEP]
by simp


[STATEMENT]
lemma choose_linear_sum: "(\<Sum>i\<le>n. i * (n choose i)) = n * 2 ^ (n - 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<le>n. i * (n choose i)) = n * 2 ^ (n - 1)
[PROOF STEP]
proof (cases n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 0 \<Longrightarrow> (\<Sum>i\<le>n. i * (n choose i)) = n * 2 ^ (n - 1)
 2. \<And>nat. n = Suc nat \<Longrightarrow> (\<Sum>i\<le>n. i * (n choose i)) = n * 2 ^ (n - 1)
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
n = 0

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> (\<Sum>i\<le>n. i * (n choose i)) = n * 2 ^ (n - 1)
 2. \<And>nat. n = Suc nat \<Longrightarrow> (\<Sum>i\<le>n. i * (n choose i)) = n * 2 ^ (n - 1)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
n = 0

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

goal (1 subgoal):
 1. \<And>nat. n = Suc nat \<Longrightarrow> (\<Sum>i\<le>n. i * (n choose i)) = n * 2 ^ (n - 1)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>nat. n = Suc nat \<Longrightarrow> (\<Sum>i\<le>n. i * (n choose i)) = n * 2 ^ (n - 1)
[PROOF STEP]
case (Suc m)
[PROOF STATE]
proof (state)
this:
n = Suc m

goal (1 subgoal):
 1. \<And>nat. n = Suc nat \<Longrightarrow> (\<Sum>i\<le>n. i * (n choose i)) = n * 2 ^ (n - 1)
[PROOF STEP]
have "(\<Sum>i\<le>n. i * (n choose i)) = (\<Sum>i\<le>Suc m. i * (Suc m choose i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<le>n. i * (n choose i)) = (\<Sum>i\<le>Suc m. i * (Suc m choose i))
[PROOF STEP]
by (simp add: Suc)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>n. i * (n choose i)) = (\<Sum>i\<le>Suc m. i * (Suc m choose i))

goal (1 subgoal):
 1. \<And>nat. n = Suc nat \<Longrightarrow> (\<Sum>i\<le>n. i * (n choose i)) = n * 2 ^ (n - 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>n. i * (n choose i)) = (\<Sum>i\<le>Suc m. i * (Suc m choose i))

goal (1 subgoal):
 1. \<And>nat. n = Suc nat \<Longrightarrow> (\<Sum>i\<le>n. i * (n choose i)) = n * 2 ^ (n - 1)
[PROOF STEP]
have "\<dots> = Suc m * 2 ^ m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<le>Suc m. i * (Suc m choose i)) = Suc m * 2 ^ m
[PROOF STEP]
unfolding sum.atMost_Suc_shift Suc_times_binomial sum_distrib_left[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 * (Suc m choose 0) + Suc m * sum ((choose) m) {..m} = Suc m * 2 ^ m
[PROOF STEP]
by (simp add: choose_row_sum)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>Suc m. i * (Suc m choose i)) = Suc m * 2 ^ m

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

goal (1 subgoal):
 1. (\<Sum>i\<le>n. i * (n choose i)) = n * 2 ^ (n - 1)
[PROOF STEP]
using Suc
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i\<le>n. i * (n choose i)) = Suc m * 2 ^ m
n = Suc m

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma gchoose_row_sum_weighted:
  "(\<Sum>k = 0..m. (r gchoose k) * (r/2 - of_nat k)) = of_nat(Suc m) / 2 * (r gchoose (Suc m))"
  for r :: "'a::field_char_0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k = 0..m. (r gchoose k) * (r / (2::'a) - of_nat k)) = of_nat (Suc m) / (2::'a) * (r gchoose Suc m)
[PROOF STEP]
by (induct m) (simp_all add: field_simps distrib gbinomial_mult_1)


[STATEMENT]
lemma vector_smult_distrib: "(A *v ((a :: 'a :: comm_ring_1) *s x)) = a *s ((A *v x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A *v (a *s x) = a *s (A *v x)
[PROOF STEP]
unfolding matrix_vector_mult_def vector_scalar_mult_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i. \<Sum>j\<in>UNIV. A $h i $h j * (\<chi>i. a * x $h i) $h j) = (\<chi>i. a * (\<chi>i. \<Sum>j\<in>UNIV. A $h i $h j * x $h j) $h i)
[PROOF STEP]
by (simp add: ac_simps sum_distrib_left)


[STATEMENT]
lemma totient_prime_power_Suc:
  assumes "prime p"
  shows   "totient (p ^ Suc n) = p ^ n * (p - 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. totient (p ^ Suc n) = p ^ n * (p - 1)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. totient (p ^ Suc n) = p ^ n * (p - 1)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
prime p
[PROOF STEP]
have "totient (p ^ Suc n) = card ({0<..p ^ Suc n} - (*) p ` {0<..p ^ n})"
[PROOF STATE]
proof (prove)
using this:
prime p

goal (1 subgoal):
 1. totient (p ^ Suc n) = card ({0<..p ^ Suc n} - (*) p ` {0<..p ^ n})
[PROOF STEP]
unfolding totient_def
[PROOF STATE]
proof (prove)
using this:
prime p

goal (1 subgoal):
 1. card (totatives (p ^ Suc n)) = card ({0<..p ^ Suc n} - (*) p ` {0<..p ^ n})
[PROOF STEP]
by (subst totatives_prime_power_Suc) simp_all
[PROOF STATE]
proof (state)
this:
totient (p ^ Suc n) = card ({0<..p ^ Suc n} - (*) p ` {0<..p ^ n})

goal (1 subgoal):
 1. totient (p ^ Suc n) = p ^ n * (p - 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
totient (p ^ Suc n) = card ({0<..p ^ Suc n} - (*) p ` {0<..p ^ n})

goal (1 subgoal):
 1. totient (p ^ Suc n) = p ^ n * (p - 1)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
prime p
[PROOF STEP]
have "\<dots> = p ^ Suc n - card ((*) p ` {0<..p^n})"
[PROOF STATE]
proof (prove)
using this:
prime p

goal (1 subgoal):
 1. card ({0<..p ^ Suc n} - (*) p ` {0<..p ^ n}) = p ^ Suc n - card ((*) p ` {0<..p ^ n})
[PROOF STEP]
by (subst card_Diff_subset) (auto intro: prime_gt_0_nat)
[PROOF STATE]
proof (state)
this:
card ({0<..p ^ Suc n} - (*) p ` {0<..p ^ n}) = p ^ Suc n - card ((*) p ` {0<..p ^ n})

goal (1 subgoal):
 1. totient (p ^ Suc n) = p ^ n * (p - 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card ({0<..p ^ Suc n} - (*) p ` {0<..p ^ n}) = p ^ Suc n - card ((*) p ` {0<..p ^ n})

goal (1 subgoal):
 1. totient (p ^ Suc n) = p ^ n * (p - 1)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
prime p
[PROOF STEP]
have "card ((*) p ` {0<..p^n}) = p ^ n"
[PROOF STATE]
proof (prove)
using this:
prime p

goal (1 subgoal):
 1. card ((*) p ` {0<..p ^ n}) = p ^ n
[PROOF STEP]
by (subst card_image) (auto simp: inj_on_def)
[PROOF STATE]
proof (state)
this:
card ((*) p ` {0<..p ^ n}) = p ^ n

goal (1 subgoal):
 1. totient (p ^ Suc n) = p ^ n * (p - 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card ((*) p ` {0<..p ^ n}) = p ^ n

goal (1 subgoal):
 1. totient (p ^ Suc n) = p ^ n * (p - 1)
[PROOF STEP]
have "p ^ Suc n - p ^ n = p ^ n * (p - 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p ^ Suc n - p ^ n = p ^ n * (p - 1)
[PROOF STEP]
by (simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
p ^ Suc n - p ^ n = p ^ n * (p - 1)

goal (1 subgoal):
 1. totient (p ^ Suc n) = p ^ n * (p - 1)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
totient (p ^ Suc n) = p ^ n * (p - 1)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
totient (p ^ Suc n) = p ^ n * (p - 1)

goal (1 subgoal):
 1. totient (p ^ Suc n) = p ^ n * (p - 1)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
totient (p ^ Suc n) = p ^ n * (p - 1)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma append_rows_split:
  assumes k: "k\<le>dim_row A"
  shows "A = (mat_of_rows (dim_col A) [Matrix.row A i. i \<leftarrow> [0..<k]]) @\<^sub>r
             (mat_of_rows (dim_col A) [Matrix.row A i. i \<leftarrow> [k..<dim_row A]])" (is "?lhs = ?A1 @\<^sub>r ?A2")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A = mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])
[PROOF STEP]
proof (rule eq_matI)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])); j < dim_col (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]))\<rbrakk> \<Longrightarrow> A $$ (i, j) = (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])) $$ (i, j)
 2. dim_row A = dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]))
 3. dim_col A = dim_col (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]))
[PROOF STEP]
have "(?A1 @\<^sub>r ?A2) \<in> carrier_mat (k + (dim_row A-k)) (dim_col A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) \<in> carrier_mat (k + (dim_row A - k)) (dim_col A)
[PROOF STEP]
by (rule carrier_append_rows, insert k, auto)
[PROOF STATE]
proof (state)
this:
mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) \<in> carrier_mat (k + (dim_row A - k)) (dim_col A)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])); j < dim_col (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]))\<rbrakk> \<Longrightarrow> A $$ (i, j) = (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])) $$ (i, j)
 2. dim_row A = dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]))
 3. dim_col A = dim_col (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]))
[PROOF STEP]
hence A1_A2: "(?A1 @\<^sub>r ?A2) \<in> carrier_mat (dim_row A) (dim_col A)"
[PROOF STATE]
proof (prove)
using this:
mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) \<in> carrier_mat (k + (dim_row A - k)) (dim_col A)

goal (1 subgoal):
 1. mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) \<in> carrier_mat (dim_row A) (dim_col A)
[PROOF STEP]
using k
[PROOF STATE]
proof (prove)
using this:
mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) \<in> carrier_mat (k + (dim_row A - k)) (dim_col A)
k \<le> dim_row A

goal (1 subgoal):
 1. mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) \<in> carrier_mat (dim_row A) (dim_col A)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) \<in> carrier_mat (dim_row A) (dim_col A)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])); j < dim_col (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]))\<rbrakk> \<Longrightarrow> A $$ (i, j) = (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])) $$ (i, j)
 2. dim_row A = dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]))
 3. dim_col A = dim_col (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]))
[PROOF STEP]
thus "dim_row A = dim_row (?A1 @\<^sub>r ?A2)" and "dim_col A = dim_col (?A1 @\<^sub>r ?A2)"
[PROOF STATE]
proof (prove)
using this:
mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) \<in> carrier_mat (dim_row A) (dim_col A)

goal (1 subgoal):
 1. dim_row A = dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])) &&& dim_col A = dim_col (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
dim_row A = dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]))
dim_col A = dim_col (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]))

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])); j < dim_col (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]))\<rbrakk> \<Longrightarrow> A $$ (i, j) = (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])) $$ (i, j)
[PROOF STEP]
fix i j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])); j < dim_col (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]))\<rbrakk> \<Longrightarrow> A $$ (i, j) = (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])) $$ (i, j)
[PROOF STEP]
assume i: "i < dim_row (?A1 @\<^sub>r ?A2)" and j: "j < dim_col (?A1 @\<^sub>r ?A2)"
[PROOF STATE]
proof (state)
this:
i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]))
j < dim_col (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]))

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])); j < dim_col (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]))\<rbrakk> \<Longrightarrow> A $$ (i, j) = (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])) $$ (i, j)
[PROOF STEP]
have "(?A1 @\<^sub>r ?A2) $$ (i, j) = (if i < dim_row ?A1 then ?A1 $$(i,j) else ?A2$$(i-(dim_row ?A1),j))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])) $$ (i, j) = (if i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) then mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) $$ (i, j) else mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])), j))
[PROOF STEP]
by (rule append_rows_nth, insert k i j, auto simp add: append_rows_def)
[PROOF STATE]
proof (state)
this:
(mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])) $$ (i, j) = (if i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) then mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) $$ (i, j) else mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])), j))

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])); j < dim_col (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]))\<rbrakk> \<Longrightarrow> A $$ (i, j) = (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])) $$ (i, j)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])) $$ (i, j) = (if i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) then mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) $$ (i, j) else mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])), j))

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])); j < dim_col (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]))\<rbrakk> \<Longrightarrow> A $$ (i, j) = (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])) $$ (i, j)
[PROOF STEP]
have "... = A $$ (i,j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) then mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) $$ (i, j) else mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])), j)) = A $$ (i, j)
[PROOF STEP]
proof (cases "i<dim_row ?A1")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) \<Longrightarrow> (if i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) then mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) $$ (i, j) else mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])), j)) = A $$ (i, j)
 2. \<not> i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) \<Longrightarrow> (if i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) then mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) $$ (i, j) else mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])), j)) = A $$ (i, j)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]))

goal (2 subgoals):
 1. i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) \<Longrightarrow> (if i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) then mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) $$ (i, j) else mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])), j)) = A $$ (i, j)
 2. \<not> i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) \<Longrightarrow> (if i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) then mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) $$ (i, j) else mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])), j)) = A $$ (i, j)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]))

goal (1 subgoal):
 1. (if i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) then mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) $$ (i, j) else mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])), j)) = A $$ (i, j)
[PROOF STEP]
by (metis (no_types, lifting) Matrix.row_def add.left_neutral add.right_neutral append_rows_def
          index_mat(1) index_mat_four_block(3) index_vec index_zero_mat(3) j length_map length_upt
          mat_of_rows_carrier(2,3) mat_of_rows_def nth_map_upt prod.simps(2))
[PROOF STATE]
proof (state)
this:
(if i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) then mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) $$ (i, j) else mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])), j)) = A $$ (i, j)

goal (1 subgoal):
 1. \<not> i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) \<Longrightarrow> (if i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) then mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) $$ (i, j) else mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])), j)) = A $$ (i, j)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) \<Longrightarrow> (if i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) then mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) $$ (i, j) else mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])), j)) = A $$ (i, j)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]))

goal (1 subgoal):
 1. \<not> i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) \<Longrightarrow> (if i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) then mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) $$ (i, j) else mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])), j)) = A $$ (i, j)
[PROOF STEP]
let ?xs = "(map (Matrix.row A) [k..<dim_row A])"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) \<Longrightarrow> (if i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) then mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) $$ (i, j) else mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])), j)) = A $$ (i, j)
[PROOF STEP]
have dim_row_A1: "dim_row ?A1 = k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) = k
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) = k

goal (1 subgoal):
 1. \<not> i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) \<Longrightarrow> (if i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) then mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) $$ (i, j) else mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])), j)) = A $$ (i, j)
[PROOF STEP]
have "?A2 $$ (i-k,j) = ?xs ! (i-k) $v j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - k, j) = map (Matrix.row A) [k..<dim_row A] ! (i - k) $v j
[PROOF STEP]
by (rule mat_of_rows_index, insert i k False A1_A2 j, auto)
[PROOF STATE]
proof (state)
this:
mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - k, j) = map (Matrix.row A) [k..<dim_row A] ! (i - k) $v j

goal (1 subgoal):
 1. \<not> i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) \<Longrightarrow> (if i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) then mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) $$ (i, j) else mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])), j)) = A $$ (i, j)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - k, j) = map (Matrix.row A) [k..<dim_row A] ! (i - k) $v j

goal (1 subgoal):
 1. \<not> i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) \<Longrightarrow> (if i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) then mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) $$ (i, j) else mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])), j)) = A $$ (i, j)
[PROOF STEP]
have "... = A $$ (i,j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (Matrix.row A) [k..<dim_row A] ! (i - k) $v j = A $$ (i, j)
[PROOF STEP]
using A1_A2 False i j
[PROOF STATE]
proof (prove)
using this:
mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) \<in> carrier_mat (dim_row A) (dim_col A)
\<not> i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]))
i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]))
j < dim_col (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]))

goal (1 subgoal):
 1. map (Matrix.row A) [k..<dim_row A] ! (i - k) $v j = A $$ (i, j)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
map (Matrix.row A) [k..<dim_row A] ! (i - k) $v j = A $$ (i, j)

goal (1 subgoal):
 1. \<not> i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) \<Longrightarrow> (if i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) then mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) $$ (i, j) else mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])), j)) = A $$ (i, j)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - k, j) = A $$ (i, j)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - k, j) = A $$ (i, j)

goal (1 subgoal):
 1. (if i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) then mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) $$ (i, j) else mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])), j)) = A $$ (i, j)
[PROOF STEP]
using A1_A2 False i j
[PROOF STATE]
proof (prove)
using this:
mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - k, j) = A $$ (i, j)
mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) \<in> carrier_mat (dim_row A) (dim_col A)
\<not> i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]))
i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]))
j < dim_col (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]))

goal (1 subgoal):
 1. (if i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) then mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) $$ (i, j) else mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])), j)) = A $$ (i, j)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(if i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) then mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) $$ (i, j) else mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])), j)) = A $$ (i, j)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(if i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])) then mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) $$ (i, j) else mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]) $$ (i - dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k])), j)) = A $$ (i, j)

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < dim_row (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])); j < dim_col (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A]))\<rbrakk> \<Longrightarrow> A $$ (i, j) = (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])) $$ (i, j)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
show " A $$ (i, j) = (?A1 @\<^sub>r ?A2) $$ (i,j)"
[PROOF STATE]
proof (prove)
using this:
(mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])) $$ (i, j) = A $$ (i, j)

goal (1 subgoal):
 1. A $$ (i, j) = (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])) $$ (i, j)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
A $$ (i, j) = (mat_of_rows (dim_col A) (map (Matrix.row A) [0..<k]) @\<^sub>r mat_of_rows (dim_col A) (map (Matrix.row A) [k..<dim_row A])) $$ (i, j)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ceiling_log_eq_powr_iff: "\<lbrakk> x > 0; b > 1 \<rbrakk>
  \<Longrightarrow> \<lceil>log b x\<rceil> = int k + 1 \<longleftrightarrow> b powr k < x \<and> x \<le> b powr (k + 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < x; 1 < b\<rbrakk> \<Longrightarrow> (\<lceil>log b x\<rceil> = int k + 1) = (b powr real k < x \<and> x \<le> b powr real (k + 1))
[PROOF STEP]
by (auto simp: ceiling_eq_iff powr_less_iff le_powr_iff)


[STATEMENT]
theorem card_number_partitions_with_atmost_k_parts:
  shows "card {N. number_partition n N \<and> size N \<le> x} = Partition (n + x) x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {N. number_partition n N \<and> size N \<le> x} = Partition (n + x) x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card {N. number_partition n N \<and> size N \<le> x} = Partition (n + x) x
[PROOF STEP]
have "bij_betw count {N. number_partition n N \<and> size N \<le> x} {p. p partitions n \<and> sum p {..n} \<le> x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij_betw count {N. number_partition n N \<and> size N \<le> x} {p. p partitions n \<and> sum p {..n} \<le> x}
[PROOF STEP]
by (rule bij_betw_multiset_number_partition_with_atmost_size)
[PROOF STATE]
proof (state)
this:
bij_betw count {N. number_partition n N \<and> size N \<le> x} {p. p partitions n \<and> sum p {..n} \<le> x}

goal (1 subgoal):
 1. card {N. number_partition n N \<and> size N \<le> x} = Partition (n + x) x
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
bij_betw count {N. number_partition n N \<and> size N \<le> x} {p. p partitions n \<and> sum p {..n} \<le> x}
[PROOF STEP]
have "card {N. number_partition n N \<and> size N \<le> x} = card {p. p partitions n \<and> sum p {..n} \<le> x}"
[PROOF STATE]
proof (prove)
using this:
bij_betw count {N. number_partition n N \<and> size N \<le> x} {p. p partitions n \<and> sum p {..n} \<le> x}

goal (1 subgoal):
 1. card {N. number_partition n N \<and> size N \<le> x} = card {p. p partitions n \<and> sum p {..n} \<le> x}
[PROOF STEP]
by (rule bij_betw_same_card)
[PROOF STATE]
proof (state)
this:
card {N. number_partition n N \<and> size N \<le> x} = card {p. p partitions n \<and> sum p {..n} \<le> x}

goal (1 subgoal):
 1. card {N. number_partition n N \<and> size N \<le> x} = Partition (n + x) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card {N. number_partition n N \<and> size N \<le> x} = card {p. p partitions n \<and> sum p {..n} \<le> x}

goal (1 subgoal):
 1. card {N. number_partition n N \<and> size N \<le> x} = Partition (n + x) x
[PROOF STEP]
have "card {p. p partitions n \<and> sum p {..n} \<le> x} = Partition (n + x) x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {p. p partitions n \<and> sum p {..n} \<le> x} = Partition (n + x) x
[PROOF STEP]
by (rule card_partitions_atmost_k_parts)
[PROOF STATE]
proof (state)
this:
card {p. p partitions n \<and> sum p {..n} \<le> x} = Partition (n + x) x

goal (1 subgoal):
 1. card {N. number_partition n N \<and> size N \<le> x} = Partition (n + x) x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
card {N. number_partition n N \<and> size N \<le> x} = Partition (n + x) x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
card {N. number_partition n N \<and> size N \<le> x} = Partition (n + x) x

goal (1 subgoal):
 1. card {N. number_partition n N \<and> size N \<le> x} = Partition (n + x) x
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
card {N. number_partition n N \<and> size N \<le> x} = Partition (n + x) x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sums_zeta_of_nat_offset:
  fixes r :: nat
  assumes n: "n > 1"
  shows "(\<lambda>k. 1 / (r + k + 1) ^ n) sums (zeta (of_nat n) - (\<Sum>k=1..r. 1 / k ^ n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. complex_of_real (1 / real ((r + x + 1) ^ n))) sums (zeta (of_nat n) - complex_of_real (\<Sum>k = 1..r. 1 / real (k ^ n)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>x. complex_of_real (1 / real ((r + x + 1) ^ n))) sums (zeta (of_nat n) - complex_of_real (\<Sum>k = 1..r. 1 / real (k ^ n)))
[PROOF STEP]
have "(\<lambda>k. 1 / (k + 1) ^ n) sums zeta (of_nat n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. complex_of_real (1 / real ((x + 1) ^ n))) sums zeta (of_nat n)
[PROOF STEP]
using sums_zeta[of "of_nat n"] n
[PROOF STATE]
proof (prove)
using this:
1 < Re (of_nat n) \<Longrightarrow> (\<lambda>na. of_nat (Suc na) powr - of_nat n) sums zeta (of_nat n)
1 < n

goal (1 subgoal):
 1. (\<lambda>x. complex_of_real (1 / real ((x + 1) ^ n))) sums zeta (of_nat n)
[PROOF STEP]
by (simp add: powr_minus field_simps flip: of_nat_Suc)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. complex_of_real (1 / real ((x + 1) ^ n))) sums zeta (of_nat n)

goal (1 subgoal):
 1. (\<lambda>x. complex_of_real (1 / real ((r + x + 1) ^ n))) sums (zeta (of_nat n) - complex_of_real (\<Sum>k = 1..r. 1 / real (k ^ n)))
[PROOF STEP]
from sums_split_initial_segment[OF this, of r]
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>i. complex_of_real (1 / real ((i + r + 1) ^ n))) sums (zeta (of_nat n) - (\<Sum>i<r. complex_of_real (1 / real ((i + 1) ^ n))))
[PROOF STEP]
have "(\<lambda>k. 1 / (r + k + 1) ^ n) sums (zeta (of_nat n) - (\<Sum>k<r. 1 / Suc k ^ n))"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>i. complex_of_real (1 / real ((i + r + 1) ^ n))) sums (zeta (of_nat n) - (\<Sum>i<r. complex_of_real (1 / real ((i + 1) ^ n))))

goal (1 subgoal):
 1. (\<lambda>x. complex_of_real (1 / real ((r + x + 1) ^ n))) sums (zeta (of_nat n) - complex_of_real (\<Sum>k<r. 1 / real (Suc k ^ n)))
[PROOF STEP]
by (simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. complex_of_real (1 / real ((r + x + 1) ^ n))) sums (zeta (of_nat n) - complex_of_real (\<Sum>k<r. 1 / real (Suc k ^ n)))

goal (1 subgoal):
 1. (\<lambda>x. complex_of_real (1 / real ((r + x + 1) ^ n))) sums (zeta (of_nat n) - complex_of_real (\<Sum>k = 1..r. 1 / real (k ^ n)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<lambda>x. complex_of_real (1 / real ((r + x + 1) ^ n))) sums (zeta (of_nat n) - complex_of_real (\<Sum>k<r. 1 / real (Suc k ^ n)))

goal (1 subgoal):
 1. (\<lambda>x. complex_of_real (1 / real ((r + x + 1) ^ n))) sums (zeta (of_nat n) - complex_of_real (\<Sum>k = 1..r. 1 / real (k ^ n)))
[PROOF STEP]
have "(\<Sum>k<r. 1 / Suc k ^ n) = (\<Sum>k=1..r. 1 / k ^ n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k<r. 1 / real (Suc k ^ n)) = (\<Sum>k = 1..r. 1 / real (k ^ n))
[PROOF STEP]
by (intro sum.reindex_bij_witness[of _ "\<lambda>k. k - 1" Suc]) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>k<r. 1 / real (Suc k ^ n)) = (\<Sum>k = 1..r. 1 / real (k ^ n))

goal (1 subgoal):
 1. (\<lambda>x. complex_of_real (1 / real ((r + x + 1) ^ n))) sums (zeta (of_nat n) - complex_of_real (\<Sum>k = 1..r. 1 / real (k ^ n)))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>x. complex_of_real (1 / real ((r + x + 1) ^ n))) sums (zeta (of_nat n) - complex_of_real (\<Sum>k = 1..r. 1 / real (k ^ n)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. complex_of_real (1 / real ((r + x + 1) ^ n))) sums (zeta (of_nat n) - complex_of_real (\<Sum>k = 1..r. 1 / real (k ^ n)))

goal (1 subgoal):
 1. (\<lambda>x. complex_of_real (1 / real ((r + x + 1) ^ n))) sums (zeta (of_nat n) - complex_of_real (\<Sum>k = 1..r. 1 / real (k ^ n)))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<lambda>x. complex_of_real (1 / real ((r + x + 1) ^ n))) sums (zeta (of_nat n) - complex_of_real (\<Sum>k = 1..r. 1 / real (k ^ n)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma norm_sum_half:
  assumes "norm(a + b) \<ge> e"
    shows "norm a \<ge> e/2 \<or> norm b \<ge> e/2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. e / 2 \<le> norm a \<or> e / 2 \<le> norm b
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. e / 2 \<le> norm a \<or> e / 2 \<le> norm b
[PROOF STEP]
have "e \<le> norm (- a - b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. e \<le> norm (- a - b)
[PROOF STEP]
by (simp add: add.commute assms norm_minus_commute)
[PROOF STATE]
proof (state)
this:
e \<le> norm (- a - b)

goal (1 subgoal):
 1. e / 2 \<le> norm a \<or> e / 2 \<le> norm b
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
e \<le> norm (- a - b)

goal (1 subgoal):
 1. e / 2 \<le> norm a \<or> e / 2 \<le> norm b
[PROOF STEP]
using norm_triangle_ineq4 order_trans
[PROOF STATE]
proof (prove)
using this:
e \<le> norm (- a - b)
norm (?a - ?b) \<le> norm ?a + norm ?b
\<lbrakk>?x \<le> ?y; ?y \<le> ?z\<rbrakk> \<Longrightarrow> ?x \<le> ?z

goal (1 subgoal):
 1. e / 2 \<le> norm a \<or> e / 2 \<le> norm b
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
e / 2 \<le> norm a \<or> e / 2 \<le> norm b

goal:
No subgoals!
[PROOF STEP]
qed