[STATEMENT]
lemma octo_inverse_mult: "inverse (x * y) = inverse y * inverse x" for x y::octo
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inverse (x * y) = inverse y * inverse x
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. inverse (x * y) = inverse y * inverse x
[PROOF STEP]
have "inverse (x * y) = (cnj y * cnj x) /\<^sub>R (norm (x * y) ^ 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inverse (x * y) = Octonions.cnj y * Octonions.cnj x /\<^sub>R (norm (x * y))\<^sup>2
[PROOF STEP]
by (simp add: octo_inverse_cnj)
[PROOF STATE]
proof (state)
this:
inverse (x * y) = Octonions.cnj y * Octonions.cnj x /\<^sub>R (norm (x * y))\<^sup>2

goal (1 subgoal):
 1. inverse (x * y) = inverse y * inverse x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
inverse (x * y) = Octonions.cnj y * Octonions.cnj x /\<^sub>R (norm (x * y))\<^sup>2

goal (1 subgoal):
 1. inverse (x * y) = inverse y * inverse x
[PROOF STEP]
have "\<dots> = (cnj y /\<^sub>R norm y ^ 2) * (cnj x /\<^sub>R norm x ^ 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Octonions.cnj y * Octonions.cnj x /\<^sub>R (norm (x * y))\<^sup>2 = Octonions.cnj y /\<^sub>R (norm y)\<^sup>2 * (Octonions.cnj x /\<^sub>R (norm x)\<^sup>2)
[PROOF STEP]
by (simp add: octo_mult_scaleR_left octo_mult_scaleR_right multiplicative_norm_octo
                   power2_eq_square)
[PROOF STATE]
proof (state)
this:
Octonions.cnj y * Octonions.cnj x /\<^sub>R (norm (x * y))\<^sup>2 = Octonions.cnj y /\<^sub>R (norm y)\<^sup>2 * (Octonions.cnj x /\<^sub>R (norm x)\<^sup>2)

goal (1 subgoal):
 1. inverse (x * y) = inverse y * inverse x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Octonions.cnj y * Octonions.cnj x /\<^sub>R (norm (x * y))\<^sup>2 = Octonions.cnj y /\<^sub>R (norm y)\<^sup>2 * (Octonions.cnj x /\<^sub>R (norm x)\<^sup>2)

goal (1 subgoal):
 1. inverse (x * y) = inverse y * inverse x
[PROOF STEP]
have "\<dots> = inverse y * inverse x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Octonions.cnj y /\<^sub>R (norm y)\<^sup>2 * (Octonions.cnj x /\<^sub>R (norm x)\<^sup>2) = inverse y * inverse x
[PROOF STEP]
by (simp add: octo_inverse_cnj)
[PROOF STATE]
proof (state)
this:
Octonions.cnj y /\<^sub>R (norm y)\<^sup>2 * (Octonions.cnj x /\<^sub>R (norm x)\<^sup>2) = inverse y * inverse x

goal (1 subgoal):
 1. inverse (x * y) = inverse y * inverse x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
inverse (x * y) = inverse y * inverse x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
inverse (x * y) = inverse y * inverse x

goal (1 subgoal):
 1. inverse (x * y) = inverse y * inverse x
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
inverse (x * y) = inverse y * inverse x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma vderiv_on_mtx_vec_multI[poly_derivatives]:
  assumes "D u = u' on T" and "D A = A' on T"
      and "g = (\<lambda>t. A t *\<^sub>V u' t + A' t *\<^sub>V u t )"
    shows "D (\<lambda>t. A t *\<^sub>V u t) = g on T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1.  D (\<lambda>t. A t *\<^sub>V u t) = g on T
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
 D u = u' on T
 D A = A' on T
g = (\<lambda>t. A t *\<^sub>V u' t + A' t *\<^sub>V u t)

goal (1 subgoal):
 1.  D (\<lambda>t. A t *\<^sub>V u t) = g on T
[PROOF STEP]
unfolding has_vderiv_on_def has_vector_derivative_def
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>T. D u \<mapsto> (\<lambda>xa. xa *\<^sub>R u' x) at x within T
\<forall>x\<in>T. D A \<mapsto> (\<lambda>xa. xa *\<^sub>R A' x) at x within T
g = (\<lambda>t. A t *\<^sub>V u' t + A' t *\<^sub>V u t)

goal (1 subgoal):
 1. \<forall>x\<in>T. D (\<lambda>t. A t *\<^sub>V u t) \<mapsto> (\<lambda>xa. xa *\<^sub>R g x) at x within T
[PROOF STEP]
apply clarify
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>\<forall>x\<in>T. D u \<mapsto> (\<lambda>xa. xa *\<^sub>R u' x) at x within T; \<forall>x\<in>T. D A \<mapsto> (\<lambda>xa. xa *\<^sub>R A' x) at x within T; g = (\<lambda>t. A t *\<^sub>V u' t + A' t *\<^sub>V u t); x \<in> T\<rbrakk> \<Longrightarrow> D (\<lambda>t. A t *\<^sub>V u t) \<mapsto> (\<lambda>xa. xa *\<^sub>R (A x *\<^sub>V u' x + A' x *\<^sub>V u x)) at x within T
[PROOF STEP]
apply(erule_tac x=x in ballE, simp_all)+
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>g = (\<lambda>t. A t *\<^sub>V u' t + A' t *\<^sub>V u t); x \<in> T; D u \<mapsto> (\<lambda>xa. xa *\<^sub>R u' x) at x within T; D A \<mapsto> (\<lambda>xa. xa *\<^sub>R A' x) at x within T\<rbrakk> \<Longrightarrow> D (\<lambda>t. A t *\<^sub>V u t) \<mapsto> (\<lambda>xa. xa *\<^sub>R (A x *\<^sub>V u' x + A' x *\<^sub>V u x)) at x within T
[PROOF STEP]
apply(rule derivative_eq_intros)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>x. \<lbrakk>g = (\<lambda>t. A t *\<^sub>V u' t + A' t *\<^sub>V u t); x \<in> T; D u \<mapsto> (\<lambda>xa. xa *\<^sub>R u' x) at x within T; D A \<mapsto> (\<lambda>xa. xa *\<^sub>R A' x) at x within T\<rbrakk> \<Longrightarrow> D A \<mapsto> ?f'9 x at x within T
 2. \<And>x. \<lbrakk>g = (\<lambda>t. A t *\<^sub>V u' t + A' t *\<^sub>V u t); x \<in> T; D u \<mapsto> (\<lambda>xa. xa *\<^sub>R u' x) at x within T; D A \<mapsto> (\<lambda>xa. xa *\<^sub>R A' x) at x within T\<rbrakk> \<Longrightarrow> D u \<mapsto> ?g'9 x at x within T
 3. \<And>x. \<lbrakk>g = (\<lambda>t. A t *\<^sub>V u' t + A' t *\<^sub>V u t); x \<in> T; D u \<mapsto> (\<lambda>xa. xa *\<^sub>R u' x) at x within T; D A \<mapsto> (\<lambda>xa. xa *\<^sub>R A' x) at x within T\<rbrakk> \<Longrightarrow> (\<lambda>h. A x *\<^sub>V ?g'9 x h + ?f'9 x h *\<^sub>V u x) = (\<lambda>xa. xa *\<^sub>R (A x *\<^sub>V u' x + A' x *\<^sub>V u x))
[PROOF STEP]
by (auto simp: fun_eq_iff mtx_vec_scaleR_commute pth_6 scaleR_mtx_vec_assoc)


[STATEMENT]
lemma not_prime_eq_prod_nat:
  assumes "m > 1" "\<not> prime (m::nat)"
  shows   "\<exists>n k. n = m * k \<and> 1 < m \<and> m < n \<and> 1 < k \<and> k < n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>n k. n = m * k \<and> 1 < m \<and> m < n \<and> 1 < k \<and> k < n
[PROOF STEP]
using assms irreducible_altdef[of m]
[PROOF STATE]
proof (prove)
using this:
1 < m
\<not> prime m
irreducible m = (m \<noteq> 0 \<and> \<not> is_unit m \<and> (\<forall>b. b dvd m \<longrightarrow> m dvd b \<or> is_unit b))

goal (1 subgoal):
 1. \<exists>n k. n = m * k \<and> 1 < m \<and> m < n \<and> 1 < k \<and> k < n
[PROOF STEP]
by (auto simp: prime_elem_iff_irreducible irreducible_altdef)


[STATEMENT]
lemma matrix_construction_is_kronecker_product_R:
  fixes qs1 :: "real poly list"
  fixes subs1 subs2 :: "(nat list*nat list) list"
  fixes signs1 signs2 :: "rat list list"
    (* n1 is the number of polynomials in the "1" sets *)
  assumes "\<And>l i. l \<in> set subs1 \<Longrightarrow> (i \<in> set (fst l) \<or> i \<in> set (snd l)) \<Longrightarrow> i < n1"
  assumes "\<And>j. j \<in> set signs1 \<Longrightarrow> length j = n1"
  shows "(matrix_A_R (signs_smash signs1 signs2) (subsets_smash_R n1 subs1 subs2)) =
    kronecker_product (matrix_A_R signs1 subs1) (matrix_A_R signs2 subs2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M_mat_R (signs_smash signs1 signs2) (subsets_smash_R n1 subs1 subs2) = kronecker_product (M_mat_R signs1 subs1) (M_mat_R signs2 subs2)
[PROOF STEP]
unfolding mat_eq_iff dim_row_matrix_A_R dim_col_matrix_A_R
    length_subsets_smash_R length_signs_smash dim_kronecker
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length subs1 * length subs2 = length subs1 * length subs2 \<and> length signs1 * length signs2 = length signs1 * length signs2 \<and> (\<forall>i j. i < length subs1 * length subs2 \<longrightarrow> j < length signs1 * length signs2 \<longrightarrow> M_mat_R (signs_smash signs1 signs2) (subsets_smash_R n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat_R signs1 subs1) (M_mat_R signs2 subs2) $$ (i, j))
[PROOF STEP]
proof safe
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> M_mat_R (signs_smash signs1 signs2) (subsets_smash_R n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat_R signs1 subs1) (M_mat_R signs2 subs2) $$ (i, j)
[PROOF STEP]
fix i j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> M_mat_R (signs_smash signs1 signs2) (subsets_smash_R n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat_R signs1 subs1) (M_mat_R signs2 subs2) $$ (i, j)
[PROOF STEP]
assume i: "i < length subs1 * length subs2"
[PROOF STATE]
proof (state)
this:
i < length subs1 * length subs2

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> M_mat_R (signs_smash signs1 signs2) (subsets_smash_R n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat_R signs1 subs1) (M_mat_R signs2 subs2) $$ (i, j)
[PROOF STEP]
assume j: "j < length signs1 * length signs2"
[PROOF STATE]
proof (state)
this:
j < length signs1 * length signs2

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> M_mat_R (signs_smash signs1 signs2) (subsets_smash_R n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat_R signs1 subs1) (M_mat_R signs2 subs2) $$ (i, j)
[PROOF STEP]
have ld: "i div length subs2 < length subs1"
    "j div length signs2 < length signs1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i div length subs2 < length subs1 &&& j div length signs2 < length signs1
[PROOF STEP]
using i j less_mult_imp_div_less
[PROOF STATE]
proof (prove)
using this:
i < length subs1 * length subs2
j < length signs1 * length signs2
?m < ?i * ?n \<Longrightarrow> ?m div ?n < ?i

goal (1 subgoal):
 1. i div length subs2 < length subs1 &&& j div length signs2 < length signs1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i div length subs2 < length subs1
j div length signs2 < length signs1

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> M_mat_R (signs_smash signs1 signs2) (subsets_smash_R n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat_R signs1 subs1) (M_mat_R signs2 subs2) $$ (i, j)
[PROOF STEP]
have lm: "i mod length subs2 < length subs2"
    "j mod length signs2 < length signs2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i mod length subs2 < length subs2 &&& j mod length signs2 < length signs2
[PROOF STEP]
using i j less_mult_imp_mod_less
[PROOF STATE]
proof (prove)
using this:
i < length subs1 * length subs2
j < length signs1 * length signs2
?m < ?n * ?i \<Longrightarrow> ?m mod ?i < ?i

goal (1 subgoal):
 1. i mod length subs2 < length subs2 &&& j mod length signs2 < length signs2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i mod length subs2 < length subs2
j mod length signs2 < length signs2

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> M_mat_R (signs_smash signs1 signs2) (subsets_smash_R n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat_R signs1 subs1) (M_mat_R signs2 subs2) $$ (i, j)
[PROOF STEP]
have n1: "n1 = length (signs1 ! (j div length signs2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n1 = length (signs1 ! (j div length signs2))
[PROOF STEP]
using assms(2) ld(2) nth_mem
[PROOF STATE]
proof (prove)
using this:
?j \<in> set signs1 \<Longrightarrow> length ?j = n1
j div length signs2 < length signs1
?n < length ?xs \<Longrightarrow> ?xs ! ?n \<in> set ?xs

goal (1 subgoal):
 1. n1 = length (signs1 ! (j div length signs2))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
n1 = length (signs1 ! (j div length signs2))

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> M_mat_R (signs_smash signs1 signs2) (subsets_smash_R n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat_R signs1 subs1) (M_mat_R signs2 subs2) $$ (i, j)
[PROOF STEP]
have 1: "matrix_A_R (signs_smash signs1 signs2) (subsets_smash_R n1 subs1 subs2) $$ (i, j) =
    z_R (subsets_smash_R n1 subs1 subs2 ! i) (signs_smash signs1 signs2 ! j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M_mat_R (signs_smash signs1 signs2) (subsets_smash_R n1 subs1 subs2) $$ (i, j) = z_R (subsets_smash_R n1 subs1 subs2 ! i) (signs_smash signs1 signs2 ! j)
[PROOF STEP]
unfolding mat_of_rows_list_def matrix_A_R_def mtx_row_R_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat (length (map (\<lambda>index_list. map (z_R index_list) (signs_smash signs1 signs2)) (subsets_smash_R n1 subs1 subs2))) (length (signs_smash signs1 signs2)) (\<lambda>(i, y). map (\<lambda>index_list. map (z_R index_list) (signs_smash signs1 signs2)) (subsets_smash_R n1 subs1 subs2) ! i ! y) $$ (i, j) = z_R (subsets_smash_R n1 subs1 subs2 ! i) (signs_smash signs1 signs2 ! j)
[PROOF STEP]
using i j
[PROOF STATE]
proof (prove)
using this:
i < length subs1 * length subs2
j < length signs1 * length signs2

goal (1 subgoal):
 1. mat (length (map (\<lambda>index_list. map (z_R index_list) (signs_smash signs1 signs2)) (subsets_smash_R n1 subs1 subs2))) (length (signs_smash signs1 signs2)) (\<lambda>(i, y). map (\<lambda>index_list. map (z_R index_list) (signs_smash signs1 signs2)) (subsets_smash_R n1 subs1 subs2) ! i ! y) $$ (i, j) = z_R (subsets_smash_R n1 subs1 subs2 ! i) (signs_smash signs1 signs2 ! j)
[PROOF STEP]
by (auto simp add: length_signs_smash length_subsets_smash_R)
[PROOF STATE]
proof (state)
this:
M_mat_R (signs_smash signs1 signs2) (subsets_smash_R n1 subs1 subs2) $$ (i, j) = z_R (subsets_smash_R n1 subs1 subs2 ! i) (signs_smash signs1 signs2 ! j)

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> M_mat_R (signs_smash signs1 signs2) (subsets_smash_R n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat_R signs1 subs1) (M_mat_R signs2 subs2) $$ (i, j)
[PROOF STEP]
have 2: " ... = z_R ((fst (subs1 ! (i div length subs2)) @ map ((+) n1) (fst(subs2 ! (i mod length subs2)))),
  (snd (subs1 ! (i div length subs2)) @ map ((+) n1) (snd (subs2 ! (i mod length subs2)))))
     (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z_R (subsets_smash_R n1 subs1 subs2 ! i) (signs_smash signs1 signs2 ! j) = z_R (fst (subs1 ! (i div length subs2)) @ map ((+) n1) (fst (subs2 ! (i mod length subs2))), snd (subs1 ! (i div length subs2)) @ map ((+) n1) (snd (subs2 ! (i mod length subs2)))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2))
[PROOF STEP]
unfolding signs_smash_def subsets_smash_R_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z_R (concat (map (\<lambda>l1. map (\<lambda>l2. (fst l1 @ map ((+) n1) (fst l2), snd l1 @ map ((+) n1) (snd l2))) subs2) subs1) ! i) (concat (map (\<lambda>l1. map ((@) l1) signs2) signs1) ! j) = z_R (fst (subs1 ! (i div length subs2)) @ map ((+) n1) (fst (subs2 ! (i mod length subs2))), snd (subs1 ! (i div length subs2)) @ map ((+) n1) (snd (subs2 ! (i mod length subs2)))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2))
[PROOF STEP]
apply (subst length_eq_concat)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>x. x \<in> set (map (\<lambda>l1. map (\<lambda>l2. (fst l1 @ map ((+) n1) (fst l2), snd l1 @ map ((+) n1) (snd l2))) subs2) subs1) \<Longrightarrow> length x = ?n
 2. i < ?n * length (map (\<lambda>l1. map (\<lambda>l2. (fst l1 @ map ((+) n1) (fst l2), snd l1 @ map ((+) n1) (snd l2))) subs2) subs1)
 3. z_R (map (\<lambda>l1. map (\<lambda>l2. (fst l1 @ map ((+) n1) (fst l2), snd l1 @ map ((+) n1) (snd l2))) subs2) subs1 ! (i div ?n) ! (i mod ?n)) (concat (map (\<lambda>l1. map ((@) l1) signs2) signs1) ! j) = z_R (fst (subs1 ! (i div length subs2)) @ map ((+) n1) (fst (subs2 ! (i mod length subs2))), snd (subs1 ! (i div length subs2)) @ map ((+) n1) (snd (subs2 ! (i mod length subs2)))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2))
[PROOF STEP]
using i
[PROOF STATE]
proof (prove)
using this:
i < length subs1 * length subs2

goal (3 subgoals):
 1. \<And>x. x \<in> set (map (\<lambda>l1. map (\<lambda>l2. (fst l1 @ map ((+) n1) (fst l2), snd l1 @ map ((+) n1) (snd l2))) subs2) subs1) \<Longrightarrow> length x = ?n
 2. i < ?n * length (map (\<lambda>l1. map (\<lambda>l2. (fst l1 @ map ((+) n1) (fst l2), snd l1 @ map ((+) n1) (snd l2))) subs2) subs1)
 3. z_R (map (\<lambda>l1. map (\<lambda>l2. (fst l1 @ map ((+) n1) (fst l2), snd l1 @ map ((+) n1) (snd l2))) subs2) subs1 ! (i div ?n) ! (i mod ?n)) (concat (map (\<lambda>l1. map ((@) l1) signs2) signs1) ! j) = z_R (fst (subs1 ! (i div length subs2)) @ map ((+) n1) (fst (subs2 ! (i mod length subs2))), snd (subs1 ! (i div length subs2)) @ map ((+) n1) (snd (subs2 ! (i mod length subs2)))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2))
[PROOF STEP]
apply (auto simp add: mult.commute)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i < length subs1 * length subs2 \<Longrightarrow> z_R (map (\<lambda>l1. map (\<lambda>l2. (fst l1 @ map ((+) n1) (fst l2), snd l1 @ map ((+) n1) (snd l2))) subs2) subs1 ! (i div length subs2) ! (i mod length subs2)) (concat (map (\<lambda>l1. map ((@) l1) signs2) signs1) ! j) = z_R (fst (subs1 ! (i div length subs2)) @ map ((+) n1) (fst (subs2 ! (i mod length subs2))), snd (subs1 ! (i div length subs2)) @ map ((+) n1) (snd (subs2 ! (i mod length subs2)))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2))
[PROOF STEP]
apply (subst length_eq_concat)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>x. \<lbrakk>i < length subs1 * length subs2; x \<in> set (map (\<lambda>l1. map ((@) l1) signs2) signs1)\<rbrakk> \<Longrightarrow> length x = ?n11
 2. i < length subs1 * length subs2 \<Longrightarrow> j < ?n11 * length (map (\<lambda>l1. map ((@) l1) signs2) signs1)
 3. i < length subs1 * length subs2 \<Longrightarrow> z_R (map (\<lambda>l1. map (\<lambda>l2. (fst l1 @ map ((+) n1) (fst l2), snd l1 @ map ((+) n1) (snd l2))) subs2) subs1 ! (i div length subs2) ! (i mod length subs2)) (map (\<lambda>l1. map ((@) l1) signs2) signs1 ! (j div ?n11) ! (j mod ?n11)) = z_R (fst (subs1 ! (i div length subs2)) @ map ((+) n1) (fst (subs2 ! (i mod length subs2))), snd (subs1 ! (i div length subs2)) @ map ((+) n1) (snd (subs2 ! (i mod length subs2)))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2))
[PROOF STEP]
using j
[PROOF STATE]
proof (prove)
using this:
j < length signs1 * length signs2

goal (3 subgoals):
 1. \<And>x. \<lbrakk>i < length subs1 * length subs2; x \<in> set (map (\<lambda>l1. map ((@) l1) signs2) signs1)\<rbrakk> \<Longrightarrow> length x = ?n11
 2. i < length subs1 * length subs2 \<Longrightarrow> j < ?n11 * length (map (\<lambda>l1. map ((@) l1) signs2) signs1)
 3. i < length subs1 * length subs2 \<Longrightarrow> z_R (map (\<lambda>l1. map (\<lambda>l2. (fst l1 @ map ((+) n1) (fst l2), snd l1 @ map ((+) n1) (snd l2))) subs2) subs1 ! (i div length subs2) ! (i mod length subs2)) (map (\<lambda>l1. map ((@) l1) signs2) signs1 ! (j div ?n11) ! (j mod ?n11)) = z_R (fst (subs1 ! (i div length subs2)) @ map ((+) n1) (fst (subs2 ! (i mod length subs2))), snd (subs1 ! (i div length subs2)) @ map ((+) n1) (snd (subs2 ! (i mod length subs2)))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2))
[PROOF STEP]
apply (auto simp add: mult.commute)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> z_R (map (\<lambda>l1. map (\<lambda>l2. (fst l1 @ map ((+) n1) (fst l2), snd l1 @ map ((+) n1) (snd l2))) subs2) subs1 ! (i div length subs2) ! (i mod length subs2)) (map (\<lambda>l1. map ((@) l1) signs2) signs1 ! (j div length signs2) ! (j mod length signs2)) = z_R (fst (subs1 ! (i div length subs2)) @ map ((+) n1) (fst (subs2 ! (i mod length subs2))), snd (subs1 ! (i div length subs2)) @ map ((+) n1) (snd (subs2 ! (i mod length subs2)))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2))
[PROOF STEP]
using ld lm
[PROOF STATE]
proof (prove)
using this:
i div length subs2 < length subs1
j div length signs2 < length signs1
i mod length subs2 < length subs2
j mod length signs2 < length signs2

goal (1 subgoal):
 1. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> z_R (map (\<lambda>l1. map (\<lambda>l2. (fst l1 @ map ((+) n1) (fst l2), snd l1 @ map ((+) n1) (snd l2))) subs2) subs1 ! (i div length subs2) ! (i mod length subs2)) (map (\<lambda>l1. map ((@) l1) signs2) signs1 ! (j div length signs2) ! (j mod length signs2)) = z_R (fst (subs1 ! (i div length subs2)) @ map ((+) n1) (fst (subs2 ! (i mod length subs2))), snd (subs1 ! (i div length subs2)) @ map ((+) n1) (snd (subs2 ! (i mod length subs2)))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
z_R (subsets_smash_R n1 subs1 subs2 ! i) (signs_smash signs1 signs2 ! j) = z_R (fst (subs1 ! (i div length subs2)) @ map ((+) n1) (fst (subs2 ! (i mod length subs2))), snd (subs1 ! (i div length subs2)) @ map ((+) n1) (snd (subs2 ! (i mod length subs2)))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2))

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> M_mat_R (signs_smash signs1 signs2) (subsets_smash_R n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat_R signs1 subs1) (M_mat_R signs2 subs2) $$ (i, j)
[PROOF STEP]
have 3: "... =
  z_R (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) *
  z_R (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z_R (fst (subs1 ! (i div length subs2)) @ map ((+) n1) (fst (subs2 ! (i mod length subs2))), snd (subs1 ! (i div length subs2)) @ map ((+) n1) (snd (subs2 ! (i mod length subs2)))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2)) = z_R (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z_R (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))
[PROOF STEP]
unfolding n1
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z_R (fst (subs1 ! (i div length subs2)) @ map ((+) (length (signs1 ! (j div length signs2)))) (fst (subs2 ! (i mod length subs2))), snd (subs1 ! (i div length subs2)) @ map ((+) (length (signs1 ! (j div length signs2)))) (snd (subs2 ! (i mod length subs2)))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2)) = z_R (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z_R (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))
[PROOF STEP]
apply (subst z_append_R)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>ia. ia \<in> set (fst (subs1 ! (i div length subs2))) \<Longrightarrow> ia < length (signs1 ! (j div length signs2))
 2. \<And>ia. ia \<in> set (snd (subs1 ! (i div length subs2))) \<Longrightarrow> ia < length (signs1 ! (j div length signs2))
 3. z_R (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z_R (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2)) = z_R (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z_R (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))
[PROOF STEP]
apply (auto simp add: n1[symmetric])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>ia. ia \<in> set (fst (subs1 ! (i div length subs2))) \<Longrightarrow> ia < n1
 2. \<And>ia. ia \<in> set (snd (subs1 ! (i div length subs2))) \<Longrightarrow> ia < n1
[PROOF STEP]
using assms(1) ld(1) nth_mem
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?l \<in> set subs1; ?i \<in> set (fst ?l) \<or> ?i \<in> set (snd ?l)\<rbrakk> \<Longrightarrow> ?i < n1
i div length subs2 < length subs1
?n < length ?xs \<Longrightarrow> ?xs ! ?n \<in> set ?xs

goal (2 subgoals):
 1. \<And>ia. ia \<in> set (fst (subs1 ! (i div length subs2))) \<Longrightarrow> ia < n1
 2. \<And>ia. ia \<in> set (snd (subs1 ! (i div length subs2))) \<Longrightarrow> ia < n1
[PROOF STEP]
apply blast
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>ia. ia \<in> set (snd (subs1 ! (i div length subs2))) \<Longrightarrow> ia < n1
[PROOF STEP]
using assms(1) ld(1) nth_mem
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?l \<in> set subs1; ?i \<in> set (fst ?l) \<or> ?i \<in> set (snd ?l)\<rbrakk> \<Longrightarrow> ?i < n1
i div length subs2 < length subs1
?n < length ?xs \<Longrightarrow> ?xs ! ?n \<in> set ?xs

goal (1 subgoal):
 1. \<And>ia. ia \<in> set (snd (subs1 ! (i div length subs2))) \<Longrightarrow> ia < n1
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
z_R (fst (subs1 ! (i div length subs2)) @ map ((+) n1) (fst (subs2 ! (i mod length subs2))), snd (subs1 ! (i div length subs2)) @ map ((+) n1) (snd (subs2 ! (i mod length subs2)))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2)) = z_R (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z_R (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> M_mat_R (signs_smash signs1 signs2) (subsets_smash_R n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat_R signs1 subs1) (M_mat_R signs2 subs2) $$ (i, j)
[PROOF STEP]
have 4: "kronecker_product (matrix_A_R signs1 subs1) (matrix_A_R signs2 subs2) $$ (i,j) =
    z_R (subs1 ! (i div length subs2))
     (signs1 ! (j div length signs2)) *
    z_R (subs2 ! (i mod length subs2))
     (signs2 ! (j mod length signs2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. kronecker_product (M_mat_R signs1 subs1) (M_mat_R signs2 subs2) $$ (i, j) = z_R (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z_R (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))
[PROOF STEP]
unfolding kronecker_product_def matrix_A_R_def mat_of_rows_list_def mtx_row_R_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (let ra = dim_row (mat (length (map (\<lambda>index_list. map (z_R index_list) signs1) subs1)) (length signs1) (\<lambda>(i, y). map (\<lambda>index_list. map (z_R index_list) signs1) subs1 ! i ! y)); ca = dim_col (mat (length (map (\<lambda>index_list. map (z_R index_list) signs1) subs1)) (length signs1) (\<lambda>(i, y). map (\<lambda>index_list. map (z_R index_list) signs1) subs1 ! i ! y)); rb = dim_row (mat (length (map (\<lambda>index_list. map (z_R index_list) signs2) subs2)) (length signs2) (\<lambda>(i, y). map (\<lambda>index_list. map (z_R index_list) signs2) subs2 ! i ! y)); cb = dim_col (mat (length (map (\<lambda>index_list. map (z_R index_list) signs2) subs2)) (length signs2) (\<lambda>(i, y). map (\<lambda>index_list. map (z_R index_list) signs2) subs2 ! i ! y)) in mat (ra * rb) (ca * cb) (\<lambda>(i, j). mat (length (map (\<lambda>index_list. map (z_R index_list) signs1) subs1)) (length signs1) (\<lambda>(i, y). map (\<lambda>index_list. map (z_R index_list) signs1) subs1 ! i ! y) $$ (i div rb, j div cb) * mat (length (map (\<lambda>index_list. map (z_R index_list) signs2) subs2)) (length signs2) (\<lambda>(i, y). map (\<lambda>index_list. map (z_R index_list) signs2) subs2 ! i ! y) $$ (i mod rb, j mod cb))) $$ (i, j) = z_R (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z_R (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))
[PROOF STEP]
using i j
[PROOF STATE]
proof (prove)
using this:
i < length subs1 * length subs2
j < length signs1 * length signs2

goal (1 subgoal):
 1. (let ra = dim_row (mat (length (map (\<lambda>index_list. map (z_R index_list) signs1) subs1)) (length signs1) (\<lambda>(i, y). map (\<lambda>index_list. map (z_R index_list) signs1) subs1 ! i ! y)); ca = dim_col (mat (length (map (\<lambda>index_list. map (z_R index_list) signs1) subs1)) (length signs1) (\<lambda>(i, y). map (\<lambda>index_list. map (z_R index_list) signs1) subs1 ! i ! y)); rb = dim_row (mat (length (map (\<lambda>index_list. map (z_R index_list) signs2) subs2)) (length signs2) (\<lambda>(i, y). map (\<lambda>index_list. map (z_R index_list) signs2) subs2 ! i ! y)); cb = dim_col (mat (length (map (\<lambda>index_list. map (z_R index_list) signs2) subs2)) (length signs2) (\<lambda>(i, y). map (\<lambda>index_list. map (z_R index_list) signs2) subs2 ! i ! y)) in mat (ra * rb) (ca * cb) (\<lambda>(i, j). mat (length (map (\<lambda>index_list. map (z_R index_list) signs1) subs1)) (length signs1) (\<lambda>(i, y). map (\<lambda>index_list. map (z_R index_list) signs1) subs1 ! i ! y) $$ (i div rb, j div cb) * mat (length (map (\<lambda>index_list. map (z_R index_list) signs2) subs2)) (length signs2) (\<lambda>(i, y). map (\<lambda>index_list. map (z_R index_list) signs2) subs2 ! i ! y) $$ (i mod rb, j mod cb))) $$ (i, j) = z_R (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z_R (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))
[PROOF STEP]
apply (auto simp add: Let_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> mat (length subs1) (length signs1) (\<lambda>(i, y). map (\<lambda>index_list. map (z_R index_list) signs1) subs1 ! i ! y) $$ (i div length subs2, j div length signs2) * mat (length subs2) (length signs2) (\<lambda>(i, y). map (\<lambda>index_list. map (z_R index_list) signs2) subs2 ! i ! y) $$ (i mod length subs2, j mod length signs2) = z_R (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z_R (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))
[PROOF STEP]
apply (subst index_mat(1)[OF ld])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> (case (i div length subs2, j div length signs2) of (i, x) \<Rightarrow> map (\<lambda>index_list. map (z_R index_list) signs1) subs1 ! i ! x) * mat (length subs2) (length signs2) (\<lambda>(i, y). map (\<lambda>index_list. map (z_R index_list) signs2) subs2 ! i ! y) $$ (i mod length subs2, j mod length signs2) = z_R (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z_R (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))
[PROOF STEP]
apply (subst index_mat(1)[OF lm])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> (case (i div length subs2, j div length signs2) of (i, x) \<Rightarrow> map (\<lambda>index_list. map (z_R index_list) signs1) subs1 ! i ! x) * (case (i mod length subs2, j mod length signs2) of (i, x) \<Rightarrow> map (\<lambda>index_list. map (z_R index_list) signs2) subs2 ! i ! x) = z_R (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z_R (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))
[PROOF STEP]
using ld lm
[PROOF STATE]
proof (prove)
using this:
i div length subs2 < length subs1
j div length signs2 < length signs1
i mod length subs2 < length subs2
j mod length signs2 < length signs2

goal (1 subgoal):
 1. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> (case (i div length subs2, j div length signs2) of (i, x) \<Rightarrow> map (\<lambda>index_list. map (z_R index_list) signs1) subs1 ! i ! x) * (case (i mod length subs2, j mod length signs2) of (i, x) \<Rightarrow> map (\<lambda>index_list. map (z_R index_list) signs2) subs2 ! i ! x) = z_R (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z_R (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
kronecker_product (M_mat_R signs1 subs1) (M_mat_R signs2 subs2) $$ (i, j) = z_R (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z_R (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length subs1 * length subs2; j < length signs1 * length signs2\<rbrakk> \<Longrightarrow> M_mat_R (signs_smash signs1 signs2) (subsets_smash_R n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat_R signs1 subs1) (M_mat_R signs2 subs2) $$ (i, j)
[PROOF STEP]
show "matrix_A_R (signs_smash signs1 signs2) (subsets_smash_R n1 subs1 subs2) $$ (i, j) =
        kronecker_product (matrix_A_R signs1 subs1) (matrix_A_R signs2 subs2) $$ (i, j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M_mat_R (signs_smash signs1 signs2) (subsets_smash_R n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat_R signs1 subs1) (M_mat_R signs2 subs2) $$ (i, j)
[PROOF STEP]
using 1 2 3 4
[PROOF STATE]
proof (prove)
using this:
M_mat_R (signs_smash signs1 signs2) (subsets_smash_R n1 subs1 subs2) $$ (i, j) = z_R (subsets_smash_R n1 subs1 subs2 ! i) (signs_smash signs1 signs2 ! j)
z_R (subsets_smash_R n1 subs1 subs2 ! i) (signs_smash signs1 signs2 ! j) = z_R (fst (subs1 ! (i div length subs2)) @ map ((+) n1) (fst (subs2 ! (i mod length subs2))), snd (subs1 ! (i div length subs2)) @ map ((+) n1) (snd (subs2 ! (i mod length subs2)))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2))
z_R (fst (subs1 ! (i div length subs2)) @ map ((+) n1) (fst (subs2 ! (i mod length subs2))), snd (subs1 ! (i div length subs2)) @ map ((+) n1) (snd (subs2 ! (i mod length subs2)))) (signs1 ! (j div length signs2) @ signs2 ! (j mod length signs2)) = z_R (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z_R (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))
kronecker_product (M_mat_R signs1 subs1) (M_mat_R signs2 subs2) $$ (i, j) = z_R (subs1 ! (i div length subs2)) (signs1 ! (j div length signs2)) * z_R (subs2 ! (i mod length subs2)) (signs2 ! (j mod length signs2))

goal (1 subgoal):
 1. M_mat_R (signs_smash signs1 signs2) (subsets_smash_R n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat_R signs1 subs1) (M_mat_R signs2 subs2) $$ (i, j)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
M_mat_R (signs_smash signs1 signs2) (subsets_smash_R n1 subs1 subs2) $$ (i, j) = kronecker_product (M_mat_R signs1 subs1) (M_mat_R signs2 subs2) $$ (i, j)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma card_Compl:
  fixes S :: "('a :: finite) set"
  shows "card (-S) = card (UNIV :: 'a set) - card S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (- S) = card UNIV - card S
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card (- S) = card UNIV - card S
[PROOF STEP]
have "card S + card (-S) = card (UNIV :: 'a set)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card S + card (- S) = card UNIV
[PROOF STEP]
by(rule card_Un_disjoint[of S "-S", simplified Compl_partition, symmetric])
      (auto)
[PROOF STATE]
proof (state)
this:
card S + card (- S) = card UNIV

goal (1 subgoal):
 1. card (- S) = card UNIV - card S
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
card S + card (- S) = card UNIV

goal (1 subgoal):
 1. card (- S) = card UNIV - card S
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card (- S) = card UNIV - card S

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Pythagoras:
  fixes A B C :: "'a :: real_inner"
  assumes "orthogonal (A - C) (B - C)"
  shows "(dist B C) ^ 2 + (dist C A) ^ 2 = (dist A B) ^ 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (dist B C)\<^sup>2 + (dist C A)\<^sup>2 = (dist A B)\<^sup>2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (dist B C)\<^sup>2 + (dist C A)\<^sup>2 = (dist A B)\<^sup>2
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
orthogonal (A - C) (B - C)
[PROOF STEP]
have "cos (angle A C B) = 0"
[PROOF STATE]
proof (prove)
using this:
orthogonal (A - C) (B - C)

goal (1 subgoal):
 1. cos (angle A C B) = 0
[PROOF STEP]
by (metis orthogonal_iff_angle cos_pi_half)
[PROOF STATE]
proof (state)
this:
cos (angle A C B) = 0

goal (1 subgoal):
 1. (dist B C)\<^sup>2 + (dist C A)\<^sup>2 = (dist A B)\<^sup>2
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
cos (angle A C B) = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
cos (angle A C B) = 0

goal (1 subgoal):
 1. (dist B C)\<^sup>2 + (dist C A)\<^sup>2 = (dist A B)\<^sup>2
[PROOF STEP]
by (simp add: cosine_law_triangle[of A B C] dist_commute)
[PROOF STATE]
proof (state)
this:
(dist B C)\<^sup>2 + (dist C A)\<^sup>2 = (dist A B)\<^sup>2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma var_sum_pairwise_indep:
  fixes f :: "'b \<Rightarrow> 'a \<Rightarrow> real"
  assumes "finite I"
  assumes "\<And>i. i \<in> I \<Longrightarrow> f i \<in> borel_measurable M"
  assumes "\<And>i. i \<in> I \<Longrightarrow> integrable M (\<lambda>\<omega>. f i \<omega>^2)"
  assumes "\<And>i j. i \<in> I \<Longrightarrow> j \<in> I \<Longrightarrow> i \<noteq> j \<Longrightarrow> indep_var borel (f i) borel (f j)"
  shows "variance (\<lambda>\<omega>. (\<Sum>i \<in> I. f i \<omega>)) = (\<Sum>i \<in> I. variance (f i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. expectation (\<lambda>x. (f i x - expectation (f i))\<^sup>2))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. expectation (\<lambda>x. (f i x - expectation (f i))\<^sup>2))
[PROOF STEP]
have "\<And>i j. i \<in> I \<Longrightarrow> j \<in> I - {i} \<Longrightarrow> covariance (f i) (f j) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i \<in> I; j \<in> I - {i}\<rbrakk> \<Longrightarrow> covariance (f i) (f j) = 0
[PROOF STEP]
using covar_indep_eq_zero assms(4) square_integrable_imp_integrable[OF assms(2,3)]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>integrable M ?f; integrable M ?g; indep_var borel ?f borel ?g\<rbrakk> \<Longrightarrow> covariance ?f ?g = 0
\<lbrakk>?i12 \<in> I; ?j12 \<in> I; ?i12 \<noteq> ?j12\<rbrakk> \<Longrightarrow> indep_var borel (f ?i12) borel (f ?j12)
\<lbrakk>?i13 \<in> I; ?i13 \<in> I\<rbrakk> \<Longrightarrow> integrable M (f ?i13)

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i \<in> I; j \<in> I - {i}\<rbrakk> \<Longrightarrow> covariance (f i) (f j) = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i12 \<in> I; ?j12 \<in> I - {?i12}\<rbrakk> \<Longrightarrow> covariance (f ?i12) (f ?j12) = 0

goal (1 subgoal):
 1. expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. expectation (\<lambda>x. (f i x - expectation (f i))\<^sup>2))
[PROOF STEP]
hence a:"(\<Sum>i \<in> I. \<Sum>j \<in> I - {i}. covariance (f i) (f j)) = 0"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?i12 \<in> I; ?j12 \<in> I - {?i12}\<rbrakk> \<Longrightarrow> covariance (f ?i12) (f ?j12) = 0

goal (1 subgoal):
 1. (\<Sum>i\<in>I. \<Sum>j\<in>I - {i}. covariance (f i) (f j)) = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>I. \<Sum>j\<in>I - {i}. covariance (f i) (f j)) = 0

goal (1 subgoal):
 1. expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. expectation (\<lambda>x. (f i x - expectation (f i))\<^sup>2))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i\<in>I. \<Sum>j\<in>I - {i}. covariance (f i) (f j)) = 0

goal (1 subgoal):
 1. expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. expectation (\<lambda>x. (f i x - expectation (f i))\<^sup>2))
[PROOF STEP]
by (simp add: var_sum_2[OF assms(1,2,3)])
[PROOF STATE]
proof (state)
this:
expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. expectation (\<lambda>x. (f i x - expectation (f i))\<^sup>2))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma arbitrary_intersection_of_Int:
   "\<lbrakk>(arbitrary intersection_of P) S; (arbitrary intersection_of P) T\<rbrakk>
           \<Longrightarrow> (arbitrary intersection_of P) (S \<inter> T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(arbitrary intersection_of P) S; (arbitrary intersection_of P) T\<rbrakk> \<Longrightarrow> (arbitrary intersection_of P) (S \<inter> T)
[PROOF STEP]
using arbitrary_intersection_of_Inter [of "{S,T}"]
[PROOF STATE]
proof (prove)
using this:
(\<And>Sa. Sa \<in> {S, T} \<Longrightarrow> (arbitrary intersection_of ?P) Sa) \<Longrightarrow> (arbitrary intersection_of ?P) (\<Inter> {S, T})

goal (1 subgoal):
 1. \<lbrakk>(arbitrary intersection_of P) S; (arbitrary intersection_of P) T\<rbrakk> \<Longrightarrow> (arbitrary intersection_of P) (S \<inter> T)
[PROOF STEP]
by auto


[STATEMENT]
lemma normalized_vec_norm :
  fixes v :: "complex vec"
  assumes dim_v: "v \<in> carrier_vec n"
    and neq0: "v \<noteq> 0\<^sub>v n"
  shows "vec_normalize v \<bullet>c vec_normalize v = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inner_prod (vec_normalize v) (vec_normalize v) = 1
[PROOF STEP]
unfolding vec_normalize_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inner_prod (if v = 0\<^sub>v (dim_vec v) then v else 1 / vec_norm v \<cdot>\<^sub>v v) (if v = 0\<^sub>v (dim_vec v) then v else 1 / vec_norm v \<cdot>\<^sub>v v) = 1
[PROOF STEP]
proof (simp, rule conjI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. v = 0\<^sub>v (dim_vec v) \<longrightarrow> inner_prod v v = 1
 2. v \<noteq> 0\<^sub>v (dim_vec v) \<longrightarrow> vec_norm v \<noteq> 0 \<and> inner_prod (1 / vec_norm v \<cdot>\<^sub>v v) v = vec_norm v
[PROOF STEP]
show "v = 0\<^sub>v (dim_vec v) \<longrightarrow> v \<bullet>c v = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v = 0\<^sub>v (dim_vec v) \<longrightarrow> inner_prod v v = 1
[PROOF STEP]
using neq0 dim_v
[PROOF STATE]
proof (prove)
using this:
v \<noteq> 0\<^sub>v n
v \<in> carrier_vec n

goal (1 subgoal):
 1. v = 0\<^sub>v (dim_vec v) \<longrightarrow> inner_prod v v = 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
v = 0\<^sub>v (dim_vec v) \<longrightarrow> inner_prod v v = 1

goal (1 subgoal):
 1. v \<noteq> 0\<^sub>v (dim_vec v) \<longrightarrow> vec_norm v \<noteq> 0 \<and> inner_prod (1 / vec_norm v \<cdot>\<^sub>v v) v = vec_norm v
[PROOF STEP]
have dim_a: "(vec_normalize v) \<in> carrier_vec n" "conjugate (vec_normalize v) \<in> carrier_vec n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_normalize v \<in> carrier_vec n &&& conjugate (vec_normalize v) \<in> carrier_vec n
[PROOF STEP]
using dim_v vec_normalize_def
[PROOF STATE]
proof (prove)
using this:
v \<in> carrier_vec n
vec_normalize ?v = (if ?v = 0\<^sub>v (dim_vec ?v) then ?v else 1 / vec_norm ?v \<cdot>\<^sub>v ?v)

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

goal (1 subgoal):
 1. v \<noteq> 0\<^sub>v (dim_vec v) \<longrightarrow> vec_norm v \<noteq> 0 \<and> inner_prod (1 / vec_norm v \<cdot>\<^sub>v v) v = vec_norm v
[PROOF STEP]
note dim = dim_v dim_a
[PROOF STATE]
proof (state)
this:
v \<in> carrier_vec n
vec_normalize v \<in> carrier_vec n
conjugate (vec_normalize v) \<in> carrier_vec n

goal (1 subgoal):
 1. v \<noteq> 0\<^sub>v (dim_vec v) \<longrightarrow> vec_norm v \<noteq> 0 \<and> inner_prod (1 / vec_norm v \<cdot>\<^sub>v v) v = vec_norm v
[PROOF STEP]
have nvge0: "vec_norm v > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < vec_norm v
[PROOF STEP]
using vec_norm_ge_0 neq0 dim_v
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?v \<in> carrier_vec ?n; ?v \<noteq> 0\<^sub>v ?n\<rbrakk> \<Longrightarrow> 0 < vec_norm ?v
v \<noteq> 0\<^sub>v n
v \<in> carrier_vec n

goal (1 subgoal):
 1. 0 < vec_norm v
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < vec_norm v

goal (1 subgoal):
 1. v \<noteq> 0\<^sub>v (dim_vec v) \<longrightarrow> vec_norm v \<noteq> 0 \<and> inner_prod (1 / vec_norm v \<cdot>\<^sub>v v) v = vec_norm v
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 < vec_norm v
[PROOF STEP]
have vvvv: "v \<bullet>c v = (vec_norm v) * (vec_norm v)"
[PROOF STATE]
proof (prove)
using this:
0 < vec_norm v

goal (1 subgoal):
 1. inner_prod v v = vec_norm v * vec_norm v
[PROOF STEP]
unfolding vec_norm_def
[PROOF STATE]
proof (prove)
using this:
0 < csqrt (inner_prod v v)

goal (1 subgoal):
 1. inner_prod v v = csqrt (inner_prod v v) * csqrt (inner_prod v v)
[PROOF STEP]
by (metis power2_csqrt power2_eq_square)
[PROOF STATE]
proof (state)
this:
inner_prod v v = vec_norm v * vec_norm v

goal (1 subgoal):
 1. v \<noteq> 0\<^sub>v (dim_vec v) \<longrightarrow> vec_norm v \<noteq> 0 \<and> inner_prod (1 / vec_norm v \<cdot>\<^sub>v v) v = vec_norm v
[PROOF STEP]
from nvge0
[PROOF STATE]
proof (chain)
picking this:
0 < vec_norm v
[PROOF STEP]
have "conjugate (vec_norm v) = vec_norm v"
[PROOF STATE]
proof (prove)
using this:
0 < vec_norm v

goal (1 subgoal):
 1. conjugate (vec_norm v) = vec_norm v
[PROOF STEP]
by (simp add: complex_eq_iff complex_is_Real_iff less_complex_def)
[PROOF STATE]
proof (state)
this:
conjugate (vec_norm v) = vec_norm v

goal (1 subgoal):
 1. v \<noteq> 0\<^sub>v (dim_vec v) \<longrightarrow> vec_norm v \<noteq> 0 \<and> inner_prod (1 / vec_norm v \<cdot>\<^sub>v v) v = vec_norm v
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
conjugate (vec_norm v) = vec_norm v
[PROOF STEP]
have "v \<bullet>c (1 / vec_norm v \<cdot>\<^sub>v v) = 1 / vec_norm v * (v \<bullet>c v)"
[PROOF STATE]
proof (prove)
using this:
conjugate (vec_norm v) = vec_norm v

goal (1 subgoal):
 1. inner_prod (1 / vec_norm v \<cdot>\<^sub>v v) v = 1 / vec_norm v * inner_prod v v
[PROOF STEP]
by (subst conjugate_smult_vec, auto)
[PROOF STATE]
proof (state)
this:
inner_prod (1 / vec_norm v \<cdot>\<^sub>v v) v = 1 / vec_norm v * inner_prod v v

goal (1 subgoal):
 1. v \<noteq> 0\<^sub>v (dim_vec v) \<longrightarrow> vec_norm v \<noteq> 0 \<and> inner_prod (1 / vec_norm v \<cdot>\<^sub>v v) v = vec_norm v
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
inner_prod (1 / vec_norm v \<cdot>\<^sub>v v) v = 1 / vec_norm v * inner_prod v v

goal (1 subgoal):
 1. v \<noteq> 0\<^sub>v (dim_vec v) \<longrightarrow> vec_norm v \<noteq> 0 \<and> inner_prod (1 / vec_norm v \<cdot>\<^sub>v v) v = vec_norm v
[PROOF STEP]
have "\<dots> = 1 / vec_norm v * vec_norm v * vec_norm v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 / vec_norm v * inner_prod v v = 1 / vec_norm v * vec_norm v * vec_norm v
[PROOF STEP]
using vvvv
[PROOF STATE]
proof (prove)
using this:
inner_prod v v = vec_norm v * vec_norm v

goal (1 subgoal):
 1. 1 / vec_norm v * inner_prod v v = 1 / vec_norm v * vec_norm v * vec_norm v
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
1 / vec_norm v * inner_prod v v = 1 / vec_norm v * vec_norm v * vec_norm v

goal (1 subgoal):
 1. v \<noteq> 0\<^sub>v (dim_vec v) \<longrightarrow> vec_norm v \<noteq> 0 \<and> inner_prod (1 / vec_norm v \<cdot>\<^sub>v v) v = vec_norm v
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 / vec_norm v * inner_prod v v = 1 / vec_norm v * vec_norm v * vec_norm v

goal (1 subgoal):
 1. v \<noteq> 0\<^sub>v (dim_vec v) \<longrightarrow> vec_norm v \<noteq> 0 \<and> inner_prod (1 / vec_norm v \<cdot>\<^sub>v v) v = vec_norm v
[PROOF STEP]
have "\<dots> = vec_norm v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 / vec_norm v * vec_norm v * vec_norm v = vec_norm v
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
1 / vec_norm v * vec_norm v * vec_norm v = vec_norm v

goal (1 subgoal):
 1. v \<noteq> 0\<^sub>v (dim_vec v) \<longrightarrow> vec_norm v \<noteq> 0 \<and> inner_prod (1 / vec_norm v \<cdot>\<^sub>v v) v = vec_norm v
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
inner_prod (1 / vec_norm v \<cdot>\<^sub>v v) v = vec_norm v
[PROOF STEP]
have "v \<bullet>c (1 / vec_norm v \<cdot>\<^sub>v v) = vec_norm v"
[PROOF STATE]
proof (prove)
using this:
inner_prod (1 / vec_norm v \<cdot>\<^sub>v v) v = vec_norm v

goal (1 subgoal):
 1. inner_prod (1 / vec_norm v \<cdot>\<^sub>v v) v = vec_norm v
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
inner_prod (1 / vec_norm v \<cdot>\<^sub>v v) v = vec_norm v

goal (1 subgoal):
 1. v \<noteq> 0\<^sub>v (dim_vec v) \<longrightarrow> vec_norm v \<noteq> 0 \<and> inner_prod (1 / vec_norm v \<cdot>\<^sub>v v) v = vec_norm v
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
inner_prod (1 / vec_norm v \<cdot>\<^sub>v v) v = vec_norm v
[PROOF STEP]
show "v \<noteq> 0\<^sub>v (dim_vec v) \<longrightarrow> vec_norm v \<noteq> 0 \<and> v \<bullet>c (1 / vec_norm v \<cdot>\<^sub>v v) = vec_norm v"
[PROOF STATE]
proof (prove)
using this:
inner_prod (1 / vec_norm v \<cdot>\<^sub>v v) v = vec_norm v

goal (1 subgoal):
 1. v \<noteq> 0\<^sub>v (dim_vec v) \<longrightarrow> vec_norm v \<noteq> 0 \<and> inner_prod (1 / vec_norm v \<cdot>\<^sub>v v) v = vec_norm v
[PROOF STEP]
using neq0 nvge0
[PROOF STATE]
proof (prove)
using this:
inner_prod (1 / vec_norm v \<cdot>\<^sub>v v) v = vec_norm v
v \<noteq> 0\<^sub>v n
0 < vec_norm v

goal (1 subgoal):
 1. v \<noteq> 0\<^sub>v (dim_vec v) \<longrightarrow> vec_norm v \<noteq> 0 \<and> inner_prod (1 / vec_norm v \<cdot>\<^sub>v v) v = vec_norm v
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
v \<noteq> 0\<^sub>v (dim_vec v) \<longrightarrow> vec_norm v \<noteq> 0 \<and> inner_prod (1 / vec_norm v \<cdot>\<^sub>v v) v = vec_norm v

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma liminf_minus_ennreal:
  fixes u v::"nat \<Rightarrow> ennreal"
  shows "(\<And>n. v n \<le> u n) \<Longrightarrow> liminf (\<lambda>n. u n - v n) \<le> limsup u - limsup v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>n. v n \<le> u n) \<Longrightarrow> liminf (\<lambda>n. u n - v n) \<le> limsup u - limsup v
[PROOF STEP]
unfolding liminf_SUP_INF limsup_INF_SUP
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>n. v n \<le> u n) \<Longrightarrow> (SUP n. INF n\<in>{n..}. u n - v n) \<le> (INF n. Sup (u ` {n..})) - (INF n. Sup (v ` {n..}))
[PROOF STEP]
including ennreal.lifting
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>n. v n \<le> u n) \<Longrightarrow> (SUP n. INF n\<in>{n..}. u n - v n) \<le> (INF n. Sup (u ` {n..})) - (INF n. Sup (v ` {n..}))
[PROOF STEP]
proof (transfer, clarsimp)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>v u. \<lbrakk>\<forall>x. 0 \<le> v x; \<forall>x. 0 \<le> u x; \<And>n. v n \<le> u n\<rbrakk> \<Longrightarrow> (SUP n. INF n\<in>{n..}. max 0 (u n - v n)) \<le> max 0 ((INF x. max 0 (Sup (u ` {x..}))) - (INF x. max 0 (Sup (v ` {x..}))))
[PROOF STEP]
fix v u :: "nat \<Rightarrow> ereal"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>v u. \<lbrakk>\<forall>x. 0 \<le> v x; \<forall>x. 0 \<le> u x; \<And>n. v n \<le> u n\<rbrakk> \<Longrightarrow> (SUP n. INF n\<in>{n..}. max 0 (u n - v n)) \<le> max 0 ((INF x. max 0 (Sup (u ` {x..}))) - (INF x. max 0 (Sup (v ` {x..}))))
[PROOF STEP]
assume *: "\<forall>x. 0 \<le> v x" "\<forall>x. 0 \<le> u x" "\<And>n. v n \<le> u n"
[PROOF STATE]
proof (state)
this:
\<forall>x. 0 \<le> v x
\<forall>x. 0 \<le> u x
v ?n \<le> u ?n

goal (1 subgoal):
 1. \<And>v u. \<lbrakk>\<forall>x. 0 \<le> v x; \<forall>x. 0 \<le> u x; \<And>n. v n \<le> u n\<rbrakk> \<Longrightarrow> (SUP n. INF n\<in>{n..}. max 0 (u n - v n)) \<le> max 0 ((INF x. max 0 (Sup (u ` {x..}))) - (INF x. max 0 (Sup (v ` {x..}))))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<forall>x. 0 \<le> v x
\<forall>x. 0 \<le> u x
v ?n \<le> u ?n

goal (1 subgoal):
 1. \<And>v u. \<lbrakk>\<forall>x. 0 \<le> v x; \<forall>x. 0 \<le> u x; \<And>n. v n \<le> u n\<rbrakk> \<Longrightarrow> (SUP n. INF n\<in>{n..}. max 0 (u n - v n)) \<le> max 0 ((INF x. max 0 (Sup (u ` {x..}))) - (INF x. max 0 (Sup (v ` {x..}))))
[PROOF STEP]
have "0 \<le> limsup u - limsup v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> limsup u - limsup v
[PROOF STEP]
using *
[PROOF STATE]
proof (prove)
using this:
\<forall>x. 0 \<le> v x
\<forall>x. 0 \<le> u x
v ?n \<le> u ?n

goal (1 subgoal):
 1. 0 \<le> limsup u - limsup v
[PROOF STEP]
by (intro ereal_diff_positive Limsup_mono always_eventually) simp
[PROOF STATE]
proof (state)
this:
0 \<le> limsup u - limsup v

goal (1 subgoal):
 1. \<And>v u. \<lbrakk>\<forall>x. 0 \<le> v x; \<forall>x. 0 \<le> u x; \<And>n. v n \<le> u n\<rbrakk> \<Longrightarrow> (SUP n. INF n\<in>{n..}. max 0 (u n - v n)) \<le> max 0 ((INF x. max 0 (Sup (u ` {x..}))) - (INF x. max 0 (Sup (v ` {x..}))))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
0 \<le> limsup u - limsup v

goal (1 subgoal):
 1. \<And>v u. \<lbrakk>\<forall>x. 0 \<le> v x; \<forall>x. 0 \<le> u x; \<And>n. v n \<le> u n\<rbrakk> \<Longrightarrow> (SUP n. INF n\<in>{n..}. max 0 (u n - v n)) \<le> max 0 ((INF x. max 0 (Sup (u ` {x..}))) - (INF x. max 0 (Sup (v ` {x..}))))
[PROOF STEP]
have "0 \<le> Sup (u ` {x..})" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> Sup (u ` {x..})
[PROOF STEP]
using *
[PROOF STATE]
proof (prove)
using this:
\<forall>x. 0 \<le> v x
\<forall>x. 0 \<le> u x
v ?n \<le> u ?n

goal (1 subgoal):
 1. 0 \<le> Sup (u ` {x..})
[PROOF STEP]
by (intro SUP_upper2[of x]) auto
[PROOF STATE]
proof (state)
this:
0 \<le> Sup (u ` {?x..})

goal (1 subgoal):
 1. \<And>v u. \<lbrakk>\<forall>x. 0 \<le> v x; \<forall>x. 0 \<le> u x; \<And>n. v n \<le> u n\<rbrakk> \<Longrightarrow> (SUP n. INF n\<in>{n..}. max 0 (u n - v n)) \<le> max 0 ((INF x. max 0 (Sup (u ` {x..}))) - (INF x. max 0 (Sup (v ` {x..}))))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
0 \<le> Sup (u ` {?x..})

goal (1 subgoal):
 1. \<And>v u. \<lbrakk>\<forall>x. 0 \<le> v x; \<forall>x. 0 \<le> u x; \<And>n. v n \<le> u n\<rbrakk> \<Longrightarrow> (SUP n. INF n\<in>{n..}. max 0 (u n - v n)) \<le> max 0 ((INF x. max 0 (Sup (u ` {x..}))) - (INF x. max 0 (Sup (v ` {x..}))))
[PROOF STEP]
have "0 \<le> Sup (v ` {x..})" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> Sup (v ` {x..})
[PROOF STEP]
using *
[PROOF STATE]
proof (prove)
using this:
\<forall>x. 0 \<le> v x
\<forall>x. 0 \<le> u x
v ?n \<le> u ?n

goal (1 subgoal):
 1. 0 \<le> Sup (v ` {x..})
[PROOF STEP]
by (intro SUP_upper2[of x]) auto
[PROOF STATE]
proof (state)
this:
0 \<le> Sup (v ` {?x..})

goal (1 subgoal):
 1. \<And>v u. \<lbrakk>\<forall>x. 0 \<le> v x; \<forall>x. 0 \<le> u x; \<And>n. v n \<le> u n\<rbrakk> \<Longrightarrow> (SUP n. INF n\<in>{n..}. max 0 (u n - v n)) \<le> max 0 ((INF x. max 0 (Sup (u ` {x..}))) - (INF x. max 0 (Sup (v ` {x..}))))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<forall>x. 0 \<le> v x
\<forall>x. 0 \<le> u x
v ?n \<le> u ?n
0 \<le> limsup u - limsup v
0 \<le> Sup (u ` {?x..})
0 \<le> Sup (v ` {?x..})
[PROOF STEP]
show "(SUP n. INF n\<in>{n..}. max 0 (u n - v n))
            \<le> max 0 ((INF x. max 0 (Sup (u ` {x..}))) - (INF x. max 0 (Sup (v ` {x..}))))"
[PROOF STATE]
proof (prove)
using this:
\<forall>x. 0 \<le> v x
\<forall>x. 0 \<le> u x
v ?n \<le> u ?n
0 \<le> limsup u - limsup v
0 \<le> Sup (u ` {?x..})
0 \<le> Sup (v ` {?x..})

goal (1 subgoal):
 1. (SUP n. INF n\<in>{n..}. max 0 (u n - v n)) \<le> max 0 ((INF x. max 0 (Sup (u ` {x..}))) - (INF x. max 0 (Sup (v ` {x..}))))
[PROOF STEP]
by (auto simp: * ereal_diff_positive max.absorb2 liminf_SUP_INF[symmetric] limsup_INF_SUP[symmetric] ereal_liminf_limsup_minus)
[PROOF STATE]
proof (state)
this:
(SUP n. INF n\<in>{n..}. max 0 (u n - v n)) \<le> max 0 ((INF x. max 0 (Sup (u ` {x..}))) - (INF x. max 0 (Sup (v ` {x..}))))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma hd_sorted_list_of_fset:
  "s \<noteq> {||} \<Longrightarrow> hd (sorted_list_of_fset s) = (fMin s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. s \<noteq> {||} \<Longrightarrow> hd (sorted_list_of_fset s) = fMin s
[PROOF STEP]
apply (insert exists_fset_of_list[of s])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>s \<noteq> {||}; \<exists>l. s = fset_of_list l\<rbrakk> \<Longrightarrow> hd (sorted_list_of_fset s) = fMin s
[PROOF STEP]
apply (erule exE)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>l. \<lbrakk>s \<noteq> {||}; s = fset_of_list l\<rbrakk> \<Longrightarrow> hd (sorted_list_of_fset s) = fMin s
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>l. \<lbrakk>fset_of_list l \<noteq> {||}; s = fset_of_list l\<rbrakk> \<Longrightarrow> hd (sorted_list_of_fset (fset_of_list l)) = fMin (fset_of_list l)
[PROOF STEP]
apply (simp add: sorted_list_of_fset_sort fMin_Min hd_sort_remdups)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>l. \<lbrakk>fset_of_list l \<noteq> {||}; s = fset_of_list l\<rbrakk> \<Longrightarrow> hd (sort l) = Min (set l)
[PROOF STEP]
by (metis fset_of_list_simps(1) hd_sort_Min)


[STATEMENT]
lemma inverse_powr: "(1/a).^b = a.^-b" if "a > 0" for a b :: real
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (1 / a) .^ b = a .^ - b
[PROOF STEP]
by (smt that powr_divide powr_minus_divide powr_one_eq_one)


[STATEMENT]
lemma closed_segment_subset_interval: "is_interval T \<Longrightarrow> a \<in> T \<Longrightarrow> b \<in> T \<Longrightarrow> closed_segment a b \<subseteq> T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>is_interval T; a \<in> T; b \<in> T\<rbrakk> \<Longrightarrow> {a--b} \<subseteq> T
[PROOF STEP]
by (rule closed_segment_subset) (auto intro!: closed_segment_subset is_interval_convex)


[STATEMENT]
lemma homeomorphic_maps_prod:
   "homeomorphic_maps (prod_topology X Y) (prod_topology X' Y') (\<lambda>(x,y). (f x, g y)) (\<lambda>(x,y). (f' x, g' y)) \<longleftrightarrow>
        topspace(prod_topology X Y) = {} \<and>
        topspace(prod_topology X' Y') = {} \<or>
        homeomorphic_maps X X' f f' \<and>
        homeomorphic_maps Y Y' g g'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. homeomorphic_maps (prod_topology X Y) (prod_topology X' Y') (\<lambda>(x, y). (f x, g y)) (\<lambda>(x, y). (f' x, g' y)) = (topspace (prod_topology X Y) = {} \<and> topspace (prod_topology X' Y') = {} \<or> homeomorphic_maps X X' f f' \<and> homeomorphic_maps Y Y' g g')
[PROOF STEP]
unfolding homeomorphic_maps_def continuous_map_prod_top
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((topspace (prod_topology X Y) = {} \<or> continuous_map X X' f \<and> continuous_map Y Y' g) \<and> (topspace (prod_topology X' Y') = {} \<or> continuous_map X' X f' \<and> continuous_map Y' Y g') \<and> (\<forall>x\<in>topspace (prod_topology X Y). (case case x of (x, y) \<Rightarrow> (f x, g y) of (x, y) \<Rightarrow> (f' x, g' y)) = x) \<and> (\<forall>y\<in>topspace (prod_topology X' Y'). (case case y of (x, y) \<Rightarrow> (f' x, g' y) of (x, y) \<Rightarrow> (f x, g y)) = y)) = (topspace (prod_topology X Y) = {} \<and> topspace (prod_topology X' Y') = {} \<or> (continuous_map X X' f \<and> continuous_map X' X f' \<and> (\<forall>x\<in>topspace X. f' (f x) = x) \<and> (\<forall>y\<in>topspace X'. f (f' y) = y)) \<and> continuous_map Y Y' g \<and> continuous_map Y' Y g' \<and> (\<forall>x\<in>topspace Y. g' (g x) = x) \<and> (\<forall>y\<in>topspace Y'. g (g' y) = y))
[PROOF STEP]
by (auto simp: continuous_map_def homeomorphic_maps_def continuous_map_prod_top)


[STATEMENT]
lemma polyhedron_imp_convex:
  fixes S :: "'a :: euclidean_space set"
  shows "polyhedron S \<Longrightarrow> convex S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. polyhedron S \<Longrightarrow> convex S
[PROOF STEP]
by (metis convex_Inter convex_halfspace_le polyhedron_def)


[STATEMENT]
lemma cis_divide: "cis a / cis b = cis (a - b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cis a / cis b = cis (a - b)
[PROOF STEP]
by (simp add: divide_complex_def cis_mult)


[STATEMENT]
lemma orthogonal_basis_exists:
  fixes V :: "('a::euclidean_space) set"
  shows "\<exists>B. independent B \<and> B \<subseteq> span V \<and> V \<subseteq> span B \<and>
  (card B = dim V) \<and> pairwise orthogonal B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>B. independent B \<and> B \<subseteq> span V \<and> V \<subseteq> span B \<and> card B = dim V \<and> pairwise orthogonal B
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>B. independent B \<and> B \<subseteq> span V \<and> V \<subseteq> span B \<and> card B = dim V \<and> pairwise orthogonal B
[PROOF STEP]
from basis_exists[of V]
[PROOF STATE]
proof (chain)
picking this:
(\<And>B. \<lbrakk>B \<subseteq> V; independent B; V \<subseteq> span B; card B = dim V\<rbrakk> \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis
[PROOF STEP]
obtain B where
    B: "B \<subseteq> V" "independent B" "V \<subseteq> span B" "card B = dim V"
[PROOF STATE]
proof (prove)
using this:
(\<And>B. \<lbrakk>B \<subseteq> V; independent B; V \<subseteq> span B; card B = dim V\<rbrakk> \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. (\<And>B. \<lbrakk>B \<subseteq> V; independent B; V \<subseteq> span B; card B = dim V\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
B \<subseteq> V
independent B
V \<subseteq> span B
card B = dim V

goal (1 subgoal):
 1. \<exists>B. independent B \<and> B \<subseteq> span V \<and> V \<subseteq> span B \<and> card B = dim V \<and> pairwise orthogonal B
[PROOF STEP]
from B
[PROOF STATE]
proof (chain)
picking this:
B \<subseteq> V
independent B
V \<subseteq> span B
card B = dim V
[PROOF STEP]
have fB: "finite B" "card B = dim V"
[PROOF STATE]
proof (prove)
using this:
B \<subseteq> V
independent B
V \<subseteq> span B
card B = dim V

goal (1 subgoal):
 1. finite B &&& card B = dim V
[PROOF STEP]
using independent_bound
[PROOF STATE]
proof (prove)
using this:
B \<subseteq> V
independent B
V \<subseteq> span B
card B = dim V
independent ?S \<Longrightarrow> finite ?S \<and> card ?S \<le> DIM(?'a)

goal (1 subgoal):
 1. finite B &&& card B = dim V
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite B
card B = dim V

goal (1 subgoal):
 1. \<exists>B. independent B \<and> B \<subseteq> span V \<and> V \<subseteq> span B \<and> card B = dim V \<and> pairwise orthogonal B
[PROOF STEP]
from basis_orthogonal[OF fB(1)]
[PROOF STATE]
proof (chain)
picking this:
\<exists>C. finite C \<and> card C \<le> card B \<and> span C = span B \<and> pairwise orthogonal C
[PROOF STEP]
obtain C where
    C: "finite C" "card C \<le> card B" "span C = span B" "pairwise orthogonal C"
[PROOF STATE]
proof (prove)
using this:
\<exists>C. finite C \<and> card C \<le> card B \<and> span C = span B \<and> pairwise orthogonal C

goal (1 subgoal):
 1. (\<And>C. \<lbrakk>finite C; card C \<le> card B; span C = span B; pairwise orthogonal C\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
finite C
card C \<le> card B
span C = span B
pairwise orthogonal C

goal (1 subgoal):
 1. \<exists>B. independent B \<and> B \<subseteq> span V \<and> V \<subseteq> span B \<and> card B = dim V \<and> pairwise orthogonal B
[PROOF STEP]
from C B
[PROOF STATE]
proof (chain)
picking this:
finite C
card C \<le> card B
span C = span B
pairwise orthogonal C
B \<subseteq> V
independent B
V \<subseteq> span B
card B = dim V
[PROOF STEP]
have CSV: "C \<subseteq> span V"
[PROOF STATE]
proof (prove)
using this:
finite C
card C \<le> card B
span C = span B
pairwise orthogonal C
B \<subseteq> V
independent B
V \<subseteq> span B
card B = dim V

goal (1 subgoal):
 1. C \<subseteq> span V
[PROOF STEP]
by (metis span_superset span_mono subset_trans)
[PROOF STATE]
proof (state)
this:
C \<subseteq> span V

goal (1 subgoal):
 1. \<exists>B. independent B \<and> B \<subseteq> span V \<and> V \<subseteq> span B \<and> card B = dim V \<and> pairwise orthogonal B
[PROOF STEP]
from span_mono[OF B(3)] C
[PROOF STATE]
proof (chain)
picking this:
span V \<subseteq> span (span B)
finite C
card C \<le> card B
span C = span B
pairwise orthogonal C
[PROOF STEP]
have SVC: "span V \<subseteq> span C"
[PROOF STATE]
proof (prove)
using this:
span V \<subseteq> span (span B)
finite C
card C \<le> card B
span C = span B
pairwise orthogonal C

goal (1 subgoal):
 1. span V \<subseteq> span C
[PROOF STEP]
by (simp add: span_span)
[PROOF STATE]
proof (state)
this:
span V \<subseteq> span C

goal (1 subgoal):
 1. \<exists>B. independent B \<and> B \<subseteq> span V \<and> V \<subseteq> span B \<and> card B = dim V \<and> pairwise orthogonal B
[PROOF STEP]
from card_le_dim_spanning[OF CSV SVC C(1)] C(2,3) fB
[PROOF STATE]
proof (chain)
picking this:
card C \<le> dim (span V) \<Longrightarrow> independent C
card C \<le> card B
span C = span B
finite B
card B = dim V
[PROOF STEP]
have iC: "independent C"
[PROOF STATE]
proof (prove)
using this:
card C \<le> dim (span V) \<Longrightarrow> independent C
card C \<le> card B
span C = span B
finite B
card B = dim V

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

goal (1 subgoal):
 1. \<exists>B. independent B \<and> B \<subseteq> span V \<and> V \<subseteq> span B \<and> card B = dim V \<and> pairwise orthogonal B
[PROOF STEP]
from C fB
[PROOF STATE]
proof (chain)
picking this:
finite C
card C \<le> card B
span C = span B
pairwise orthogonal C
finite B
card B = dim V
[PROOF STEP]
have "card C \<le> dim V"
[PROOF STATE]
proof (prove)
using this:
finite C
card C \<le> card B
span C = span B
pairwise orthogonal C
finite B
card B = dim V

goal (1 subgoal):
 1. card C \<le> dim V
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card C \<le> dim V

goal (1 subgoal):
 1. \<exists>B. independent B \<and> B \<subseteq> span V \<and> V \<subseteq> span B \<and> card B = dim V \<and> pairwise orthogonal B
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
card C \<le> dim V

goal (1 subgoal):
 1. \<exists>B. independent B \<and> B \<subseteq> span V \<and> V \<subseteq> span B \<and> card B = dim V \<and> pairwise orthogonal B
[PROOF STEP]
have "dim V \<le> card C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim V \<le> card C
[PROOF STEP]
using span_card_ge_dim[OF CSV SVC C(1)]
[PROOF STATE]
proof (prove)
using this:
dim (span V) \<le> card C

goal (1 subgoal):
 1. dim V \<le> card C
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
dim V \<le> card C

goal (1 subgoal):
 1. \<exists>B. independent B \<and> B \<subseteq> span V \<and> V \<subseteq> span B \<and> card B = dim V \<and> pairwise orthogonal B
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
card C \<le> dim V
dim V \<le> card C
[PROOF STEP]
have CdV: "card C = dim V"
[PROOF STATE]
proof (prove)
using this:
card C \<le> dim V
dim V \<le> card C

goal (1 subgoal):
 1. card C = dim V
[PROOF STEP]
using C(1)
[PROOF STATE]
proof (prove)
using this:
card C \<le> dim V
dim V \<le> card C
finite C

goal (1 subgoal):
 1. card C = dim V
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card C = dim V

goal (1 subgoal):
 1. \<exists>B. independent B \<and> B \<subseteq> span V \<and> V \<subseteq> span B \<and> card B = dim V \<and> pairwise orthogonal B
[PROOF STEP]
from C B CSV CdV iC
[PROOF STATE]
proof (chain)
picking this:
finite C
card C \<le> card B
span C = span B
pairwise orthogonal C
B \<subseteq> V
independent B
V \<subseteq> span B
card B = dim V
C \<subseteq> span V
card C = dim V
independent C
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
finite C
card C \<le> card B
span C = span B
pairwise orthogonal C
B \<subseteq> V
independent B
V \<subseteq> span B
card B = dim V
C \<subseteq> span V
card C = dim V
independent C

goal (1 subgoal):
 1. \<exists>B. independent B \<and> B \<subseteq> span V \<and> V \<subseteq> span B \<and> card B = dim V \<and> pairwise orthogonal B
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>B. independent B \<and> B \<subseteq> span V \<and> V \<subseteq> span B \<and> card B = dim V \<and> pairwise orthogonal B

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mult_ffact:
  "a * ffact n a = ffact (Suc n) a + of_nat n * ffact n a"
    for a :: "'a :: comm_ring_1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a * ffact n a = ffact (Suc n) a + of_nat n * ffact n a
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a * ffact n a = ffact (Suc n) a + of_nat n * ffact n a
[PROOF STEP]
have "ffact (Suc n) a + of_nat n * (ffact n a) = (a - of_nat n) * (ffact n a) + of_nat n * (ffact n a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ffact (Suc n) a + of_nat n * ffact n a = (a - of_nat n) * ffact n a + of_nat n * ffact n a
[PROOF STEP]
using ffact_Suc_rev [of n]
[PROOF STATE]
proof (prove)
using this:
ffact (Suc n) ?m = (?m - of_nat n) * ffact n ?m

goal (1 subgoal):
 1. ffact (Suc n) a + of_nat n * ffact n a = (a - of_nat n) * ffact n a + of_nat n * ffact n a
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ffact (Suc n) a + of_nat n * ffact n a = (a - of_nat n) * ffact n a + of_nat n * ffact n a

goal (1 subgoal):
 1. a * ffact n a = ffact (Suc n) a + of_nat n * ffact n a
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ffact (Suc n) a + of_nat n * ffact n a = (a - of_nat n) * ffact n a + of_nat n * ffact n a

goal (1 subgoal):
 1. a * ffact n a = ffact (Suc n) a + of_nat n * ffact n a
[PROOF STEP]
have "\<dots> = a * ffact n a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a - of_nat n) * ffact n a + of_nat n * ffact n a = a * ffact n a
[PROOF STEP]
using ffact_add_diff_assoc
[PROOF STATE]
proof (prove)
using this:
(?a - of_nat ?n) * ffact ?n ?a + of_nat ?n * ffact ?n ?a = ?a * ffact ?n ?a

goal (1 subgoal):
 1. (a - of_nat n) * ffact n a + of_nat n * ffact n a = a * ffact n a
[PROOF STEP]
by (simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
(a - of_nat n) * ffact n a + of_nat n * ffact n a = a * ffact n a

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

goal (1 subgoal):
 1. a * ffact n a = ffact (Suc n) a + of_nat n * ffact n a
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a * ffact n a = ffact (Suc n) a + of_nat n * ffact n a

goal:
No subgoals!
[PROOF STEP]
qed


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

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

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

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

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

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

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

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

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma infinite_cball:
  fixes a :: "'a::euclidean_space"
  assumes "r > 0"
  shows "infinite (cball a r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infinite (cball a r)
[PROOF STEP]
using uncountable_cball[OF assms, THEN uncountable_infinite,of a]
[PROOF STATE]
proof (prove)
using this:
infinite (cball a r)

goal (1 subgoal):
 1. infinite (cball a r)
[PROOF STEP]
.


[STATEMENT]
lemma (in module) lincomb_diff:
  assumes A_fin: "finite A" and AinC: "A\<subseteq>carrier M" and a_fun: "a\<in>A\<rightarrow>carrier R" and
    b_fun: "b\<in>A\<rightarrow>carrier R"
  shows "lincomb (\<lambda>v. a v \<ominus>\<^bsub>R\<^esub> b v) A = lincomb a A \<ominus>\<^bsub>M\<^esub> lincomb b A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lincomb (\<lambda>v. a v \<ominus> b v) A = lincomb a A \<ominus>\<^bsub>M\<^esub> lincomb b A
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. lincomb (\<lambda>v. a v \<ominus> b v) A = lincomb a A \<ominus>\<^bsub>M\<^esub> lincomb b A
[PROOF STEP]
from A_fin AinC
[PROOF STATE]
proof (chain)
picking this:
finite A
A \<subseteq> carrier M
[PROOF STEP]
interpret mh: mod_hom R "func_space A" M  "(\<lambda>a. lincomb a A)"
[PROOF STATE]
proof (prove)
using this:
finite A
A \<subseteq> carrier M

goal (1 subgoal):
 1. mod_hom R (func_space A) M (\<lambda>a. lincomb a A)
[PROOF STEP]
by (rule
    lincomb_is_mod_hom)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. lincomb (\<lambda>v. a v \<ominus> b v) A = lincomb a A \<ominus>\<^bsub>M\<^esub> lincomb b A
[PROOF STEP]
let ?a="restrict a A"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. lincomb (\<lambda>v. a v \<ominus> b v) A = lincomb a A \<ominus>\<^bsub>M\<^esub> lincomb b A
[PROOF STEP]
let ?b="restrict b A"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. lincomb (\<lambda>v. a v \<ominus> b v) A = lincomb a A \<ominus>\<^bsub>M\<^esub> lincomb b A
[PROOF STEP]
from a_fun b_fun
[PROOF STATE]
proof (chain)
picking this:
a \<in> A \<rightarrow> carrier R
b \<in> A \<rightarrow> carrier R
[PROOF STEP]
have ainC: "?a\<in>carrier (LinearCombinations.ring.func_space R A)"
    and binC: "?b\<in>carrier (LinearCombinations.ring.func_space R A)"
[PROOF STATE]
proof (prove)
using this:
a \<in> A \<rightarrow> carrier R
b \<in> A \<rightarrow> carrier R

goal (1 subgoal):
 1. restrict a A \<in> carrier (func_space A) &&& restrict b A \<in> carrier (func_space A)
[PROOF STEP]
by (unfold func_space_def, auto)
[PROOF STATE]
proof (state)
this:
restrict a A \<in> carrier (func_space A)
restrict b A \<in> carrier (func_space A)

goal (1 subgoal):
 1. lincomb (\<lambda>v. a v \<ominus> b v) A = lincomb a A \<ominus>\<^bsub>M\<^esub> lincomb b A
[PROOF STEP]
from a_fun b_fun ainC binC A_fin AinC
[PROOF STATE]
proof (chain)
picking this:
a \<in> A \<rightarrow> carrier R
b \<in> A \<rightarrow> carrier R
restrict a A \<in> carrier (func_space A)
restrict b A \<in> carrier (func_space A)
finite A
A \<subseteq> carrier M
[PROOF STEP]
have 1: "LinearCombinations.module.lincomb M (?a\<ominus>\<^bsub>(func_space A)\<^esub> ?b) A
    = LinearCombinations.module.lincomb M (\<lambda>x.  a x \<ominus>\<^bsub>R\<^esub> b x) A"
[PROOF STATE]
proof (prove)
using this:
a \<in> A \<rightarrow> carrier R
b \<in> A \<rightarrow> carrier R
restrict a A \<in> carrier (func_space A)
restrict b A \<in> carrier (func_space A)
finite A
A \<subseteq> carrier M

goal (1 subgoal):
 1. lincomb (restrict a A \<ominus>\<^bsub>func_space A\<^esub> restrict b A) A = lincomb (\<lambda>x. a x \<ominus> b x) A
[PROOF STEP]
apply (subst mh.M.M.minus_eq)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<in> A \<rightarrow> carrier R; b \<in> A \<rightarrow> carrier R; restrict a A \<in> carrier (func_space A); restrict b A \<in> carrier (func_space A); finite A; A \<subseteq> carrier M\<rbrakk> \<Longrightarrow> lincomb (restrict a A \<oplus>\<^bsub>func_space A\<^esub> \<ominus>\<^bsub>func_space A\<^esub> restrict b A) A = lincomb (\<lambda>x. a x \<ominus> b x) A
[PROOF STEP]
apply (intro lincomb_cong, auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>v. \<lbrakk>a \<in> A \<rightarrow> carrier R; b \<in> A \<rightarrow> carrier R; restrict a A \<in> carrier (func_space A); restrict b A \<in> carrier (func_space A); finite A; A \<subseteq> carrier M; v \<in> A\<rbrakk> \<Longrightarrow> (restrict a A \<oplus>\<^bsub>func_space A\<^esub> \<ominus>\<^bsub>func_space A\<^esub> restrict b A) v = a v \<ominus> b v
[PROOF STEP]
apply (subst func_space_neg, auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>v. \<lbrakk>a \<in> A \<rightarrow> carrier R; b \<in> A \<rightarrow> carrier R; restrict a A \<in> carrier (func_space A); restrict b A \<in> carrier (func_space A); finite A; A \<subseteq> carrier M; v \<in> A\<rbrakk> \<Longrightarrow> (restrict a A \<oplus>\<^bsub>func_space A\<^esub> (\<lambda>v. if v \<in> A then \<ominus> restrict b A v else undefined)) v = a v \<ominus> b v
[PROOF STEP]
apply (simp add: restrict_def func_space_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>v. \<lbrakk>a \<in> A \<rightarrow> carrier R; b \<in> A \<rightarrow> carrier R; (\<lambda>x. if x \<in> A then a x else undefined) \<in> A \<rightarrow>\<^sub>E carrier R; (\<lambda>x. if x \<in> A then b x else undefined) \<in> A \<rightarrow>\<^sub>E carrier R; finite A; A \<subseteq> carrier M; v \<in> A\<rbrakk> \<Longrightarrow> a v \<oplus> \<ominus> b v = a v \<ominus> b v
[PROOF STEP]
by (subst R.minus_eq, auto)
[PROOF STATE]
proof (state)
this:
lincomb (restrict a A \<ominus>\<^bsub>func_space A\<^esub> restrict b A) A = lincomb (\<lambda>x. a x \<ominus> b x) A

goal (1 subgoal):
 1. lincomb (\<lambda>v. a v \<ominus> b v) A = lincomb a A \<ominus>\<^bsub>M\<^esub> lincomb b A
[PROOF STEP]
from a_fun b_fun A_fin AinC
[PROOF STATE]
proof (chain)
picking this:
a \<in> A \<rightarrow> carrier R
b \<in> A \<rightarrow> carrier R
finite A
A \<subseteq> carrier M
[PROOF STEP]
have 2: "LinearCombinations.module.lincomb M ?a A \<ominus>\<^bsub>M\<^esub>
      LinearCombinations.module.lincomb M ?b A = LinearCombinations.module.lincomb M a A \<ominus>\<^bsub>M\<^esub>
      LinearCombinations.module.lincomb M b A"
[PROOF STATE]
proof (prove)
using this:
a \<in> A \<rightarrow> carrier R
b \<in> A \<rightarrow> carrier R
finite A
A \<subseteq> carrier M

goal (1 subgoal):
 1. lincomb (restrict a A) A \<ominus>\<^bsub>M\<^esub> lincomb (restrict b A) A = lincomb a A \<ominus>\<^bsub>M\<^esub> lincomb b A
[PROOF STEP]
by (simp cong: lincomb_cong)
[PROOF STATE]
proof (state)
this:
lincomb (restrict a A) A \<ominus>\<^bsub>M\<^esub> lincomb (restrict b A) A = lincomb a A \<ominus>\<^bsub>M\<^esub> lincomb b A

goal (1 subgoal):
 1. lincomb (\<lambda>v. a v \<ominus> b v) A = lincomb a A \<ominus>\<^bsub>M\<^esub> lincomb b A
[PROOF STEP]
from ainC binC
[PROOF STATE]
proof (chain)
picking this:
restrict a A \<in> carrier (func_space A)
restrict b A \<in> carrier (func_space A)
[PROOF STEP]
have "LinearCombinations.module.lincomb M (?a\<ominus>\<^bsub>(LinearCombinations.ring.func_space R A)\<^esub> ?b) A
    = LinearCombinations.module.lincomb M ?a A \<ominus>\<^bsub>M\<^esub>
      LinearCombinations.module.lincomb M ?b A"
[PROOF STATE]
proof (prove)
using this:
restrict a A \<in> carrier (func_space A)
restrict b A \<in> carrier (func_space A)

goal (1 subgoal):
 1. lincomb (restrict a A \<ominus>\<^bsub>func_space A\<^esub> restrict b A) A = lincomb (restrict a A) A \<ominus>\<^bsub>M\<^esub> lincomb (restrict b A) A
[PROOF STEP]
by (simp cong: lincomb_cong)
[PROOF STATE]
proof (state)
this:
lincomb (restrict a A \<ominus>\<^bsub>func_space A\<^esub> restrict b A) A = lincomb (restrict a A) A \<ominus>\<^bsub>M\<^esub> lincomb (restrict b A) A

goal (1 subgoal):
 1. lincomb (\<lambda>v. a v \<ominus> b v) A = lincomb a A \<ominus>\<^bsub>M\<^esub> lincomb b A
[PROOF STEP]
with 1 2
[PROOF STATE]
proof (chain)
picking this:
lincomb (restrict a A \<ominus>\<^bsub>func_space A\<^esub> restrict b A) A = lincomb (\<lambda>x. a x \<ominus> b x) A
lincomb (restrict a A) A \<ominus>\<^bsub>M\<^esub> lincomb (restrict b A) A = lincomb a A \<ominus>\<^bsub>M\<^esub> lincomb b A
lincomb (restrict a A \<ominus>\<^bsub>func_space A\<^esub> restrict b A) A = lincomb (restrict a A) A \<ominus>\<^bsub>M\<^esub> lincomb (restrict b A) A
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
lincomb (restrict a A \<ominus>\<^bsub>func_space A\<^esub> restrict b A) A = lincomb (\<lambda>x. a x \<ominus> b x) A
lincomb (restrict a A) A \<ominus>\<^bsub>M\<^esub> lincomb (restrict b A) A = lincomb a A \<ominus>\<^bsub>M\<^esub> lincomb b A
lincomb (restrict a A \<ominus>\<^bsub>func_space A\<^esub> restrict b A) A = lincomb (restrict a A) A \<ominus>\<^bsub>M\<^esub> lincomb (restrict b A) A

goal (1 subgoal):
 1. lincomb (\<lambda>v. a v \<ominus> b v) A = lincomb a A \<ominus>\<^bsub>M\<^esub> lincomb b A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
lincomb (\<lambda>v. a v \<ominus> b v) A = lincomb a A \<ominus>\<^bsub>M\<^esub> lincomb b A

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma content_cbox_cart:
   "cbox a b \<noteq> {} \<Longrightarrow> content(cbox a b) = prod (\<lambda>i. b$i - a$i) UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cbox a b \<noteq> {} \<Longrightarrow> content (cbox a b) = (\<Prod>i\<in>UNIV. b $ i - a $ i)
[PROOF STEP]
by (simp add: content_cbox_if Basis_vec_def cart_eq_inner_axis axis_eq_axis prod.UNION_disjoint)