[STATEMENT]
lemma  col_formula:
 fixes M1 and M2
 shows "\<forall>j.((j < (length M1)*(length M2))
         \<and> (mat (row_length M1) (length M1) M1)
         \<and> (mat (row_length M2) (length M2) M2)
         \<longrightarrow> col (M1 \<otimes> M2) j
                =  vec_vec_Tensor
                        (col M1 (j div length M2))
                        (col M2 (j mod length M2)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>j. j < length M1 * length M2 \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> col (M1 \<otimes> M2) j = vec_vec_Tensor (col M1 (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
apply (rule allI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>j. j < length M1 * length M2 \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> col (M1 \<otimes> M2) j = vec_vec_Tensor (col M1 (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
proof(induct M1)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>j. j < length [] * length M2 \<and> mat (row_length []) (length []) [] \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> col ([] \<otimes> M2) j = vec_vec_Tensor (col [] (j div length M2)) (col M2 (j mod length M2))
 2. \<And>a M1 j. (\<And>j. j < length M1 * length M2 \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> col (M1 \<otimes> M2) j = vec_vec_Tensor (col M1 (j div length M2)) (col M2 (j mod length M2))) \<Longrightarrow> j < length (a # M1) * length M2 \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> col (a # M1 \<otimes> M2) j = vec_vec_Tensor (col (a # M1) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. \<And>j. j < length [] * length M2 \<and> mat (row_length []) (length []) [] \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> col ([] \<otimes> M2) j = vec_vec_Tensor (col [] (j div length M2)) (col M2 (j mod length M2))
 2. \<And>a M1 j. (\<And>j. j < length M1 * length M2 \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> col (M1 \<otimes> M2) j = vec_vec_Tensor (col M1 (j div length M2)) (col M2 (j mod length M2))) \<Longrightarrow> j < length (a # M1) * length M2 \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> col (a # M1 \<otimes> M2) j = vec_vec_Tensor (col (a # M1) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. j < length [] * length M2 \<and> mat (row_length []) (length []) [] \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> col ([] \<otimes> M2) j = vec_vec_Tensor (col [] (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
using Nil
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. j < length [] * length M2 \<and> mat (row_length []) (length []) [] \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> col ([] \<otimes> M2) j = vec_vec_Tensor (col [] (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j < length [] * length M2 \<and> mat (row_length []) (length []) [] \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> col ([] \<otimes> M2) j = vec_vec_Tensor (col [] (j div length M2)) (col M2 (j mod length M2))

goal (1 subgoal):
 1. \<And>a M1 j. (\<And>j. j < length M1 * length M2 \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> col (M1 \<otimes> M2) j = vec_vec_Tensor (col M1 (j div length M2)) (col M2 (j mod length M2))) \<Longrightarrow> j < length (a # M1) * length M2 \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> col (a # M1 \<otimes> M2) j = vec_vec_Tensor (col (a # M1) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a M1 j. (\<And>j. j < length M1 * length M2 \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> col (M1 \<otimes> M2) j = vec_vec_Tensor (col M1 (j div length M2)) (col M2 (j mod length M2))) \<Longrightarrow> j < length (a # M1) * length M2 \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> col (a # M1 \<otimes> M2) j = vec_vec_Tensor (col (a # M1) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
case (Cons v M)
[PROOF STATE]
proof (state)
this:
?j < length M * length M2 \<and> mat (row_length M) (length M) M \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> col (M \<otimes> M2) ?j = vec_vec_Tensor (col M (?j div length M2)) (col M2 (?j mod length M2))

goal (1 subgoal):
 1. \<And>a M1 j. (\<And>j. j < length M1 * length M2 \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> col (M1 \<otimes> M2) j = vec_vec_Tensor (col M1 (j div length M2)) (col M2 (j mod length M2))) \<Longrightarrow> j < length (a # M1) * length M2 \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> col (a # M1 \<otimes> M2) j = vec_vec_Tensor (col (a # M1) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
have "j < (length (v#M))*(length M2)
       \<and> mat (row_length (v # M)) (length (v # M)) (v # M)
       \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow>
       (col (v # M \<otimes> M2) j
                 = vec_vec_Tensor
                            (col (v # M) (j div length M2))
                            (col M2 (j mod length M2)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
fix k
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
assume 0:"j < (length (v#M))*(length M2)
              \<and> mat (row_length (v # M)) (length (v # M)) (v # M)
              \<and> mat (row_length M2) (length M2) M2"
[PROOF STATE]
proof (state)
this:
j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2

goal (1 subgoal):
 1. j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2
[PROOF STEP]
have 1:"mat (row_length M) (length M) M"
[PROOF STATE]
proof (prove)
using this:
j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2

goal (1 subgoal):
 1. mat (row_length M) (length M) M
[PROOF STEP]
by (metis reduct_matrix)
[PROOF STATE]
proof (state)
this:
mat (row_length M) (length M) M

goal (1 subgoal):
 1. j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
have "j < (1+ length M)*(length M2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. j < (1 + length M) * length M2
[PROOF STEP]
using 0
[PROOF STATE]
proof (prove)
using this:
j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2

goal (1 subgoal):
 1. j < (1 + length M) * length M2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j < (1 + length M) * length M2

goal (1 subgoal):
 1. j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
j < (1 + length M) * length M2
[PROOF STEP]
have "j < (length M2)+  (length M)*(length M2)"
[PROOF STATE]
proof (prove)
using this:
j < (1 + length M) * length M2

goal (1 subgoal):
 1. j < length M2 + length M * length M2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j < length M2 + length M * length M2

goal (1 subgoal):
 1. j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
j < length M2 + length M * length M2
[PROOF STEP]
have 2:"j \<ge> (length M2)
                          \<Longrightarrow> j- (length M2) < (length M)*(length M2)"
[PROOF STATE]
proof (prove)
using this:
j < length M2 + length M * length M2

goal (1 subgoal):
 1. length M2 \<le> j \<Longrightarrow> j - length M2 < length M * length M2
[PROOF STEP]
using add_0_iff add_diff_inverse diff_is_0_eq
                   less_diff_conv less_imp_le linorder_cases add.commute
                   neq0_conv
[PROOF STATE]
proof (prove)
using this:
j < length M2 + length M * length M2
(?b = ?b + ?a) = (?a = (0::?'a))
\<not> ?a < ?b \<Longrightarrow> ?b + (?a - ?b) = ?a
(?m - ?n = 0) = (?m \<le> ?n)
(?i < ?j - ?k) = (?i + ?k < ?j)
?x < ?y \<Longrightarrow> ?x \<le> ?y
\<lbrakk>?x < ?y \<Longrightarrow> ?P; ?x = ?y \<Longrightarrow> ?P; ?y < ?x \<Longrightarrow> ?P\<rbrakk> \<Longrightarrow> ?P
?a + ?b = ?b + ?a
(?n \<noteq> 0) = (0 < ?n)

goal (1 subgoal):
 1. length M2 \<le> j \<Longrightarrow> j - length M2 < length M * length M2
[PROOF STEP]
by (metis (opaque_lifting, no_types))
[PROOF STATE]
proof (state)
this:
length M2 \<le> j \<Longrightarrow> j - length M2 < length M * length M2

goal (1 subgoal):
 1. j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
have 3:"(v#M)\<otimes>M2 = (vec_mat_Tensor v M2)@(M \<otimes> M2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v # M \<otimes> M2 = vec_mat_Tensor v M2 @ (M \<otimes> M2)
[PROOF STEP]
using Tensor.simps
[PROOF STATE]
proof (prove)
using this:
[] \<otimes> ?xs = []
?x # ?xs \<otimes> ?ys = vec_mat_Tensor ?x ?ys @ (?xs \<otimes> ?ys)

goal (1 subgoal):
 1. v # M \<otimes> M2 = vec_mat_Tensor v M2 @ (M \<otimes> M2)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
v # M \<otimes> M2 = vec_mat_Tensor v M2 @ (M \<otimes> M2)

goal (1 subgoal):
 1. j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
have "(col ((v#M)\<otimes>M2) j) = (col ((vec_mat_Tensor v M2)@(M \<otimes> M2)) j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. col (v # M \<otimes> M2) j = col (vec_mat_Tensor v M2 @ (M \<otimes> M2)) j
[PROOF STEP]
using col_def
[PROOF STATE]
proof (prove)
using this:
col ?m ?i \<equiv> ?m ! ?i

goal (1 subgoal):
 1. col (v # M \<otimes> M2) j = col (vec_mat_Tensor v M2 @ (M \<otimes> M2)) j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
col (v # M \<otimes> M2) j = col (vec_mat_Tensor v M2 @ (M \<otimes> M2)) j

goal (1 subgoal):
 1. j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
col (v # M \<otimes> M2) j = col (vec_mat_Tensor v M2 @ (M \<otimes> M2)) j
[PROOF STEP]
have "j < length (vec_mat_Tensor v M2)
                   \<Longrightarrow> (col ((v#M)\<otimes>M2) j) = (col (vec_mat_Tensor v M2) j)"
[PROOF STATE]
proof (prove)
using this:
col (v # M \<otimes> M2) j = col (vec_mat_Tensor v M2 @ (M \<otimes> M2)) j

goal (1 subgoal):
 1. j < length (vec_mat_Tensor v M2) \<Longrightarrow> col (v # M \<otimes> M2) j = col (vec_mat_Tensor v M2) j
[PROOF STEP]
unfolding col_def
[PROOF STATE]
proof (prove)
using this:
(v # M \<otimes> M2) ! j = (vec_mat_Tensor v M2 @ (M \<otimes> M2)) ! j

goal (1 subgoal):
 1. j < length (vec_mat_Tensor v M2) \<Longrightarrow> (v # M \<otimes> M2) ! j = vec_mat_Tensor v M2 ! j
[PROOF STEP]
using append_simpl
[PROOF STATE]
proof (prove)
using this:
(v # M \<otimes> M2) ! j = (vec_mat_Tensor v M2 @ (M \<otimes> M2)) ! j
?i < length ?xs \<longrightarrow> (?xs @ ?ys) ! ?i = ?xs ! ?i

goal (1 subgoal):
 1. j < length (vec_mat_Tensor v M2) \<Longrightarrow> (v # M \<otimes> M2) ! j = vec_mat_Tensor v M2 ! j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j < length (vec_mat_Tensor v M2) \<Longrightarrow> col (v # M \<otimes> M2) j = col (vec_mat_Tensor v M2) j

goal (1 subgoal):
 1. j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
j < length (vec_mat_Tensor v M2) \<Longrightarrow> col (v # M \<otimes> M2) j = col (vec_mat_Tensor v M2) j
[PROOF STEP]
have 4:"j < length M2 \<Longrightarrow>
                        (col ((v#M)\<otimes>M2) j) = (col (vec_mat_Tensor v M2) j)"
[PROOF STATE]
proof (prove)
using this:
j < length (vec_mat_Tensor v M2) \<Longrightarrow> col (v # M \<otimes> M2) j = col (vec_mat_Tensor v M2) j

goal (1 subgoal):
 1. j < length M2 \<Longrightarrow> col (v # M \<otimes> M2) j = col (vec_mat_Tensor v M2) j
[PROOF STEP]
using vec_mat_Tensor_length
[PROOF STATE]
proof (prove)
using this:
j < length (vec_mat_Tensor v M2) \<Longrightarrow> col (v # M \<otimes> M2) j = col (vec_mat_Tensor v M2) j
length (vec_mat_Tensor ?xs ?ys) = length ?ys

goal (1 subgoal):
 1. j < length M2 \<Longrightarrow> col (v # M \<otimes> M2) j = col (vec_mat_Tensor v M2) j
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
j < length M2 \<Longrightarrow> col (v # M \<otimes> M2) j = col (vec_mat_Tensor v M2) j

goal (1 subgoal):
 1. j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
j < length M2 \<Longrightarrow> col (v # M \<otimes> M2) j = col (vec_mat_Tensor v M2) j
[PROOF STEP]
have "j < length M2 \<Longrightarrow>
                  (col (vec_mat_Tensor v M2) j)
                                      =  vec_vec_Tensor v (col M2 j)"
[PROOF STATE]
proof (prove)
using this:
j < length M2 \<Longrightarrow> col (v # M \<otimes> M2) j = col (vec_mat_Tensor v M2) j

goal (1 subgoal):
 1. j < length M2 \<Longrightarrow> col (vec_mat_Tensor v M2) j = vec_vec_Tensor v (col M2 j)
[PROOF STEP]
using col_vec_mat_Tensor
[PROOF STATE]
proof (prove)
using this:
j < length M2 \<Longrightarrow> col (v # M \<otimes> M2) j = col (vec_mat_Tensor v M2) j
?j < length ?M \<Longrightarrow> col (vec_mat_Tensor ?v ?M) ?j = vec_vec_Tensor ?v (col ?M ?j)

goal (1 subgoal):
 1. j < length M2 \<Longrightarrow> col (vec_mat_Tensor v M2) j = vec_vec_Tensor v (col M2 j)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j < length M2 \<Longrightarrow> col (vec_mat_Tensor v M2) j = vec_vec_Tensor v (col M2 j)

goal (1 subgoal):
 1. j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
j < length M2 \<Longrightarrow> col (vec_mat_Tensor v M2) j = vec_vec_Tensor v (col M2 j)
[PROOF STEP]
have
           "j< length M2 \<Longrightarrow>
                 (col (vec_mat_Tensor v M2) j)
                            =  vec_vec_Tensor
                                            ((v#M)!(j div length M2))
                                            (col M2 (j mod (length M2)))"
[PROOF STATE]
proof (prove)
using this:
j < length M2 \<Longrightarrow> col (vec_mat_Tensor v M2) j = vec_vec_Tensor v (col M2 j)

goal (1 subgoal):
 1. j < length M2 \<Longrightarrow> col (vec_mat_Tensor v M2) j = vec_vec_Tensor ((v # M) ! (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j < length M2 \<Longrightarrow> col (vec_mat_Tensor v M2) j = vec_vec_Tensor ((v # M) ! (j div length M2)) (col M2 (j mod length M2))

goal (1 subgoal):
 1. j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
j < length M2 \<Longrightarrow> col (vec_mat_Tensor v M2) j = vec_vec_Tensor ((v # M) ! (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
have step_1:"j< length M2 \<Longrightarrow>
                 (col ((v#M)\<otimes> M2) j)
                             =  vec_vec_Tensor
                                             ((v#M)!(j div length M2))
                                             (col M2 (j mod (length M2)))"
[PROOF STATE]
proof (prove)
using this:
j < length M2 \<Longrightarrow> col (vec_mat_Tensor v M2) j = vec_vec_Tensor ((v # M) ! (j div length M2)) (col M2 (j mod length M2))

goal (1 subgoal):
 1. j < length M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor ((v # M) ! (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
using 4
[PROOF STATE]
proof (prove)
using this:
j < length M2 \<Longrightarrow> col (vec_mat_Tensor v M2) j = vec_vec_Tensor ((v # M) ! (j div length M2)) (col M2 (j mod length M2))
j < length M2 \<Longrightarrow> col (v # M \<otimes> M2) j = col (vec_mat_Tensor v M2) j

goal (1 subgoal):
 1. j < length M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor ((v # M) ! (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j < length M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor ((v # M) ! (j div length M2)) (col M2 (j mod length M2))

goal (1 subgoal):
 1. j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
have 4:"j \<ge> length M2
                  \<Longrightarrow> (col ((v#M)\<otimes>M2) j)= (M \<otimes> M2)!(j- (length M2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length M2 \<le> j \<Longrightarrow> col (v # M \<otimes> M2) j = (M \<otimes> M2) ! (j - length M2)
[PROOF STEP]
unfolding col_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length M2 \<le> j \<Longrightarrow> (v # M \<otimes> M2) ! j = (M \<otimes> M2) ! (j - length M2)
[PROOF STEP]
using 3 append_simpl2 vec_mat_Tensor_length
[PROOF STATE]
proof (prove)
using this:
v # M \<otimes> M2 = vec_mat_Tensor v M2 @ (M \<otimes> M2)
length ?xs \<le> ?i \<longrightarrow> (?xs @ ?ys) ! ?i = ?ys ! (?i - length ?xs)
length (vec_mat_Tensor ?xs ?ys) = length ?ys

goal (1 subgoal):
 1. length M2 \<le> j \<Longrightarrow> (v # M \<otimes> M2) ! j = (M \<otimes> M2) ! (j - length M2)
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
length M2 \<le> j \<Longrightarrow> col (v # M \<otimes> M2) j = (M \<otimes> M2) ! (j - length M2)

goal (1 subgoal):
 1. j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
length M2 \<le> j \<Longrightarrow> col (v # M \<otimes> M2) j = (M \<otimes> M2) ! (j - length M2)
[PROOF STEP]
have 5:
         "j \<ge> length M2 \<Longrightarrow>
              col (M \<otimes> M2) (j-length M2)
                     = vec_vec_Tensor
                                (col M ((j-length M2) div length M2))
                                (col M2 ((j- length M2) mod length M2))"
[PROOF STATE]
proof (prove)
using this:
length M2 \<le> j \<Longrightarrow> col (v # M \<otimes> M2) j = (M \<otimes> M2) ! (j - length M2)

goal (1 subgoal):
 1. length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col M ((j - length M2) div length M2)) (col M2 ((j - length M2) mod length M2))
[PROOF STEP]
using 1 0 2 Cons
[PROOF STATE]
proof (prove)
using this:
length M2 \<le> j \<Longrightarrow> col (v # M \<otimes> M2) j = (M \<otimes> M2) ! (j - length M2)
mat (row_length M) (length M) M
j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2
length M2 \<le> j \<Longrightarrow> j - length M2 < length M * length M2
?j < length M * length M2 \<and> mat (row_length M) (length M) M \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> col (M \<otimes> M2) ?j = vec_vec_Tensor (col M (?j div length M2)) (col M2 (?j mod length M2))

goal (1 subgoal):
 1. length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col M ((j - length M2) div length M2)) (col M2 ((j - length M2) mod length M2))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col M ((j - length M2) div length M2)) (col M2 ((j - length M2) mod length M2))

goal (1 subgoal):
 1. j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col M ((j - length M2) div length M2)) (col M2 ((j - length M2) mod length M2))
[PROOF STEP]
have 6:
         "j \<ge> length M2 \<Longrightarrow>
                 (j - length M2) div (length M2) + 1 = j div (length M2)"
[PROOF STATE]
proof (prove)
using this:
length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col M ((j - length M2) div length M2)) (col M2 ((j - length M2) mod length M2))

goal (1 subgoal):
 1. length M2 \<le> j \<Longrightarrow> (j - length M2) div length M2 + 1 = j div length M2
[PROOF STEP]
using 2  div_0 div_self
                   le_neq_implies_less less_nat_zero_code
                   monoid_add_class.add.right_neutral mult_0 mult_cancel2
                   add.commute nat_div neq0_conv div_add_self1 le_add_diff_inverse
[PROOF STATE]
proof (prove)
using this:
length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col M ((j - length M2) div length M2)) (col M2 ((j - length M2) mod length M2))
length M2 \<le> j \<Longrightarrow> j - length M2 < length M * length M2
(0::?'a) div ?a = (0::?'a)
?a \<noteq> (0::?'a) \<Longrightarrow> ?a div ?a = (1::?'a)
\<lbrakk>?m \<le> ?n; ?m \<noteq> ?n\<rbrakk> \<Longrightarrow> ?m < ?n
(?n < 0) = False
?a + (0::?'a) = ?a
0 * ?n = 0
(?m * ?k = ?n * ?k) = (?m = ?n \<or> ?k = 0)
?a + ?b = ?b + ?a
\<lbrakk>0 < ?b; ?b < ?a\<rbrakk> \<Longrightarrow> ?a div ?b = (?a - ?b) div ?b + 1
(?n \<noteq> 0) = (0 < ?n)
?b \<noteq> (0::?'a) \<Longrightarrow> (?b + ?a) div ?b = ?a div ?b + (1::?'a)
?b \<le> ?a \<Longrightarrow> ?b + (?a - ?b) = ?a

goal (1 subgoal):
 1. length M2 \<le> j \<Longrightarrow> (j - length M2) div length M2 + 1 = j div length M2
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
length M2 \<le> j \<Longrightarrow> (j - length M2) div length M2 + 1 = j div length M2

goal (1 subgoal):
 1. j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
length M2 \<le> j \<Longrightarrow> (j - length M2) div length M2 + 1 = j div length M2
[PROOF STEP]
have
           "j \<ge> length M2 \<Longrightarrow>
                    ((j- length M2) mod length M2) = j mod (length M2)"
[PROOF STATE]
proof (prove)
using this:
length M2 \<le> j \<Longrightarrow> (j - length M2) div length M2 + 1 = j div length M2

goal (1 subgoal):
 1. length M2 \<le> j \<Longrightarrow> (j - length M2) mod length M2 = j mod length M2
[PROOF STEP]
using le_mod_geq
[PROOF STATE]
proof (prove)
using this:
length M2 \<le> j \<Longrightarrow> (j - length M2) div length M2 + 1 = j div length M2
?n \<le> ?m \<Longrightarrow> ?m mod ?n = (?m - ?n) mod ?n

goal (1 subgoal):
 1. length M2 \<le> j \<Longrightarrow> (j - length M2) mod length M2 = j mod length M2
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
length M2 \<le> j \<Longrightarrow> (j - length M2) mod length M2 = j mod length M2

goal (1 subgoal):
 1. j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
with 6
[PROOF STATE]
proof (chain)
picking this:
length M2 \<le> j \<Longrightarrow> (j - length M2) div length M2 + 1 = j div length M2
length M2 \<le> j \<Longrightarrow> (j - length M2) mod length M2 = j mod length M2
[PROOF STEP]
have 7:
         "j \<ge> length M2 \<Longrightarrow>
              col (M \<otimes> M2) (j-length M2)
                     = vec_vec_Tensor (col M ((j-length M2) div length M2))
                                (col M2 (j mod length M2))"
[PROOF STATE]
proof (prove)
using this:
length M2 \<le> j \<Longrightarrow> (j - length M2) div length M2 + 1 = j div length M2
length M2 \<le> j \<Longrightarrow> (j - length M2) mod length M2 = j mod length M2

goal (1 subgoal):
 1. length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col M ((j - length M2) div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
using 5
[PROOF STATE]
proof (prove)
using this:
length M2 \<le> j \<Longrightarrow> (j - length M2) div length M2 + 1 = j div length M2
length M2 \<le> j \<Longrightarrow> (j - length M2) mod length M2 = j mod length M2
length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col M ((j - length M2) div length M2)) (col M2 ((j - length M2) mod length M2))

goal (1 subgoal):
 1. length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col M ((j - length M2) div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col M ((j - length M2) div length M2)) (col M2 (j mod length M2))

goal (1 subgoal):
 1. j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col M ((j - length M2) div length M2)) (col M2 (j mod length M2))

goal (1 subgoal):
 1. j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
have "k<(length M) \<Longrightarrow> (col M k) = (col (v#M) (k+1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k < length M \<Longrightarrow> col M k = col (v # M) (k + 1)
[PROOF STEP]
unfolding col_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k < length M \<Longrightarrow> M ! k = (v # M) ! (k + 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
k < length M \<Longrightarrow> col M k = col (v # M) (k + 1)

goal (1 subgoal):
 1. j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col M ((j - length M2) div length M2)) (col M2 (j mod length M2))
k < length M \<Longrightarrow> col M k = col (v # M) (k + 1)
[PROOF STEP]
have "j \<ge> length M2 \<Longrightarrow>
              col (M \<otimes> M2) (j-length M2)
                     = vec_vec_Tensor (col (v#M) (j div length M2))
                                (col M2 (j mod length M2))"
[PROOF STATE]
proof (prove)
using this:
length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col M ((j - length M2) div length M2)) (col M2 (j mod length M2))
k < length M \<Longrightarrow> col M k = col (v # M) (k + 1)

goal (1 subgoal):
 1. length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>length M2 \<le> j; length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col M ((j - length M2) div length M2)) (col M2 (j mod length M2)); k < length M \<Longrightarrow> col M k = col (v # M) (k + 1)\<rbrakk> \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
assume temp:"j \<ge> length M2 "
[PROOF STATE]
proof (state)
this:
length M2 \<le> j

goal (1 subgoal):
 1. \<lbrakk>length M2 \<le> j; length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col M ((j - length M2) div length M2)) (col M2 (j mod length M2)); k < length M \<Longrightarrow> col M k = col (v # M) (k + 1)\<rbrakk> \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
have " j- (length M2) < (length M)*(length M2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. j - length M2 < length M * length M2
[PROOF STEP]
using 2 temp
[PROOF STATE]
proof (prove)
using this:
length M2 \<le> j \<Longrightarrow> j - length M2 < length M * length M2
length M2 \<le> j

goal (1 subgoal):
 1. j - length M2 < length M * length M2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j - length M2 < length M * length M2

goal (1 subgoal):
 1. \<lbrakk>length M2 \<le> j; length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col M ((j - length M2) div length M2)) (col M2 (j mod length M2)); k < length M \<Longrightarrow> col M k = col (v # M) (k + 1)\<rbrakk> \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
j - length M2 < length M * length M2
[PROOF STEP]
have "(j- (length M2)) div (length M2) < (length M)"
[PROOF STATE]
proof (prove)
using this:
j - length M2 < length M * length M2

goal (1 subgoal):
 1. (j - length M2) div length M2 < length M
[PROOF STEP]
using div_right_ineq mult.commute
[PROOF STATE]
proof (prove)
using this:
j - length M2 < length M * length M2
?x < ?y * ?z \<Longrightarrow> ?x div ?y < ?z
?a * ?b = ?b * ?a

goal (1 subgoal):
 1. (j - length M2) div length M2 < length M
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
(j - length M2) div length M2 < length M

goal (1 subgoal):
 1. \<lbrakk>length M2 \<le> j; length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col M ((j - length M2) div length M2)) (col M2 (j mod length M2)); k < length M \<Longrightarrow> col M k = col (v # M) (k + 1)\<rbrakk> \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(j - length M2) div length M2 < length M

goal (1 subgoal):
 1. \<lbrakk>length M2 \<le> j; length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col M ((j - length M2) div length M2)) (col M2 (j mod length M2)); k < length M \<Longrightarrow> col M k = col (v # M) (k + 1)\<rbrakk> \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
have
                 "((j- (length M2)) div (length M2)<(length M)
                     \<longrightarrow> (col M ((j- (length M2)) div (length M2)))
                          = (col (v#M) ((j- (length M2)) div (length M2)+1)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (j - length M2) div length M2 < length M \<longrightarrow> col M ((j - length M2) div length M2) = col (v # M) ((j - length M2) div length M2 + 1)
[PROOF STEP]
unfolding col_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (j - length M2) div length M2 < length M \<longrightarrow> M ! ((j - length M2) div length M2) = (v # M) ! ((j - length M2) div length M2 + 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(j - length M2) div length M2 < length M \<longrightarrow> col M ((j - length M2) div length M2) = col (v # M) ((j - length M2) div length M2 + 1)

goal (1 subgoal):
 1. \<lbrakk>length M2 \<le> j; length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col M ((j - length M2) div length M2)) (col M2 (j mod length M2)); k < length M \<Longrightarrow> col M k = col (v # M) (k + 1)\<rbrakk> \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(j - length M2) div length M2 < length M
(j - length M2) div length M2 < length M \<longrightarrow> col M ((j - length M2) div length M2) = col (v # M) ((j - length M2) div length M2 + 1)
[PROOF STEP]
have temp1:
                      "(col (v#M) (((j-length M2) div length M2)+1))
                                  = (col M (((j-length M2) div length M2)))"
[PROOF STATE]
proof (prove)
using this:
(j - length M2) div length M2 < length M
(j - length M2) div length M2 < length M \<longrightarrow> col M ((j - length M2) div length M2) = col (v # M) ((j - length M2) div length M2 + 1)

goal (1 subgoal):
 1. col (v # M) ((j - length M2) div length M2 + 1) = col M ((j - length M2) div length M2)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
col (v # M) ((j - length M2) div length M2 + 1) = col M ((j - length M2) div length M2)

goal (1 subgoal):
 1. \<lbrakk>length M2 \<le> j; length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col M ((j - length M2) div length M2)) (col M2 (j mod length M2)); k < length M \<Longrightarrow> col M k = col (v # M) (k + 1)\<rbrakk> \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
col (v # M) ((j - length M2) div length M2 + 1) = col M ((j - length M2) div length M2)
[PROOF STEP]
have "(col (v#M) (((j-length M2) div length M2)+1))
                                   = (col (v#M) (j div length M2))"
[PROOF STATE]
proof (prove)
using this:
col (v # M) ((j - length M2) div length M2 + 1) = col M ((j - length M2) div length M2)

goal (1 subgoal):
 1. col (v # M) ((j - length M2) div length M2 + 1) = col (v # M) (j div length M2)
[PROOF STEP]
using 6 temp
[PROOF STATE]
proof (prove)
using this:
col (v # M) ((j - length M2) div length M2 + 1) = col M ((j - length M2) div length M2)
length M2 \<le> j \<Longrightarrow> (j - length M2) div length M2 + 1 = j div length M2
length M2 \<le> j

goal (1 subgoal):
 1. col (v # M) ((j - length M2) div length M2 + 1) = col (v # M) (j div length M2)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
col (v # M) ((j - length M2) div length M2 + 1) = col (v # M) (j div length M2)

goal (1 subgoal):
 1. \<lbrakk>length M2 \<le> j; length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col M ((j - length M2) div length M2)) (col M2 (j mod length M2)); k < length M \<Longrightarrow> col M k = col (v # M) (k + 1)\<rbrakk> \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
col (v # M) ((j - length M2) div length M2 + 1) = col (v # M) (j div length M2)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
col (v # M) ((j - length M2) div length M2 + 1) = col (v # M) (j div length M2)

goal (1 subgoal):
 1. col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
using temp1 7
[PROOF STATE]
proof (prove)
using this:
col (v # M) ((j - length M2) div length M2 + 1) = col (v # M) (j div length M2)
col (v # M) ((j - length M2) div length M2 + 1) = col M ((j - length M2) div length M2)
length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col M ((j - length M2) div length M2)) (col M2 (j mod length M2))

goal (1 subgoal):
 1. col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
by (metis temp)
[PROOF STATE]
proof (state)
this:
col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))

goal (1 subgoal):
 1. j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
have "j \<ge> length M2 \<Longrightarrow>
              col ((v#M) \<otimes> M2) j
                     = vec_vec_Tensor (col (v#M) (j div length M2))
                                (col M2 (j mod length M2))"
[PROOF STATE]
proof (prove)
using this:
length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))

goal (1 subgoal):
 1. length M2 \<le> j \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
using col_def 4
[PROOF STATE]
proof (prove)
using this:
length M2 \<le> j \<Longrightarrow> col (M \<otimes> M2) (j - length M2) = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
col ?m ?i \<equiv> ?m ! ?i
length M2 \<le> j \<Longrightarrow> col (v # M \<otimes> M2) j = (M \<otimes> M2) ! (j - length M2)

goal (1 subgoal):
 1. length M2 \<le> j \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
length M2 \<le> j \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))

goal (1 subgoal):
 1. j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
length M2 \<le> j \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
length M2 \<le> j \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))

goal (1 subgoal):
 1. col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
using step_1  col_def le_refl nat_less_le nat_neq_iff
[PROOF STATE]
proof (prove)
using this:
length M2 \<le> j \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
j < length M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor ((v # M) ! (j div length M2)) (col M2 (j mod length M2))
col ?m ?i \<equiv> ?m ! ?i
?n \<le> ?n
(?m < ?n) = (?m \<le> ?n \<and> ?m \<noteq> ?n)
(?m \<noteq> ?n) = (?m < ?n \<or> ?n < ?m)

goal (1 subgoal):
 1. col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
by (metis)
[PROOF STATE]
proof (state)
this:
col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))

goal (1 subgoal):
 1. \<And>a M1 j. (\<And>j. j < length M1 * length M2 \<and> mat (row_length M1) (length M1) M1 \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> col (M1 \<otimes> M2) j = vec_vec_Tensor (col M1 (j div length M2)) (col M2 (j mod length M2))) \<Longrightarrow> j < length (a # M1) * length M2 \<and> mat (row_length (a # M1)) (length (a # M1)) (a # M1) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> col (a # M1 \<otimes> M2) j = vec_vec_Tensor (col (a # M1) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<Longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))

goal (1 subgoal):
 1. j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j < length (v # M) * length M2 \<and> mat (row_length (v # M)) (length (v # M)) (v # M) \<and> mat (row_length M2) (length M2) M2 \<longrightarrow> col (v # M \<otimes> M2) j = vec_vec_Tensor (col (v # M) (j div length M2)) (col M2 (j mod length M2))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma "(-x < -y) = (y < (x::real))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (- x < - y) = (y < x)
[PROOF STEP]
by arith


[STATEMENT]
lemma mod_exp_aux_code [code]:
  "mod_exp_aux m y x n =
     (if n = 0 then y
      else if n = 1 then (x * y) mod m
      else if even n then mod_exp_aux m y ((x * x) mod m) (n div 2)
      else mod_exp_aux m ((x * y) mod m) ((x * x) mod m) (n div 2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mod_exp_aux m y x n = (if n = 0 then y else if n = 1 then x * y mod m else if even n then mod_exp_aux m y (x * x mod m) (n div 2) else mod_exp_aux m (x * y mod m) (x * x mod m) (n div 2))
[PROOF STEP]
unfolding mod_exp_aux_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. efficient_funpow (\<lambda>x y. x * y mod m) y x n = (if n = 0 then y else if n = 1 then x * y mod m else if even n then efficient_funpow (\<lambda>x y. x * y mod m) y (x * x mod m) (n div 2) else efficient_funpow (\<lambda>x y. x * y mod m) (x * y mod m) (x * x mod m) (n div 2))
[PROOF STEP]
by (rule efficient_funpow_code)


[STATEMENT]
lemma mrbst_join_reduce:
  "t1 \<noteq> \<langle>\<rangle> \<Longrightarrow> t2 \<noteq> \<langle>\<rangle> \<Longrightarrow> mrbst_join t1 t2 =
     do {
        b \<leftarrow> bernoulli_pmf (size t1 / (size t1 + size t2));
        if b then
          (case t1 of \<langle>l, x, r\<rangle> \<Rightarrow> map_pmf (\<lambda>r'. \<langle>l, x, r'\<rangle>) (mrbst_join r t2))
        else
          (case t2 of \<langle>l, x, r\<rangle> \<Rightarrow> map_pmf (\<lambda>l'. \<langle>l', x, r\<rangle>) (mrbst_join t1 l))
      }"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>t1 \<noteq> \<langle>\<rangle>; t2 \<noteq> \<langle>\<rangle>\<rbrakk> \<Longrightarrow> mrbst_join t1 t2 = bernoulli_pmf (real (size t1) / real (size t1 + size t2)) \<bind> (\<lambda>b. if b then case t1 of \<langle>l, x, r\<rangle> \<Rightarrow> map_pmf (Node l x) (mrbst_join r t2) else case t2 of \<langle>l, x, r\<rangle> \<Rightarrow> map_pmf (\<lambda>l'. \<langle>l', x, r\<rangle>) (mrbst_join t1 l))
[PROOF STEP]
by (subst mrbst_join.simps) auto


[STATEMENT]
lemma "(-10::int) mod -3 = -1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. - 10 mod - 3 = - 1
[PROOF STEP]
by simp


[STATEMENT]
lemma real_inner_inner: "real_of (inner x x * inner y y) = real_of (inner x x) * real_of (inner y y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_of (inner x x * inner y y) = real_of (inner x x) * real_of (inner y y)
[PROOF STEP]
by (metis real_scalar_mult real_scalar_mult2)


[STATEMENT]
lemma sum_if_then_else_simps[simp]:
  fixes q :: "('a::semiring_0)" and i :: "'n::finite"
  shows "(\<Sum>j\<in>UNIV. f j * (if j = i then q else 0)) = f i * q"
    and "(\<Sum>j\<in>UNIV. f j * (if i = j then q else 0)) = f i * q"
    and "(\<Sum>j\<in>UNIV. (if i = j then q else 0) * f j) = q * f i"
    and "(\<Sum>j\<in>UNIV. (if j = i then q else 0) * f j) = q * f i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<Sum>j\<in>UNIV. f j * (if j = i then q else (0::'a))) = f i * q &&& (\<Sum>j\<in>UNIV. f j * (if i = j then q else (0::'a))) = f i * q) &&& (\<Sum>j\<in>UNIV. (if i = j then q else (0::'a)) * f j) = q * f i &&& (\<Sum>j\<in>UNIV. (if j = i then q else (0::'a)) * f j) = q * f i
[PROOF STEP]
by (auto simp: finite_sum_univ_singleton[of _ i])


[STATEMENT]
lemma prod_mset_conv:
  fixes f :: "'a \<Rightarrow> 'b::{comm_monoid_mult}"
  shows "prod_mset (image_mset f A) = prod (\<lambda>x. f x^(count A x)) (set_mset A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Prod>\<^sub># (image_mset f A) = (\<Prod>x\<in>set_mset A. f x ^ count A x)
[PROOF STEP]
proof (induction A rule: disj_induct_mset)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<Prod>\<^sub># (image_mset f {#}) = (\<Prod>x\<in>set_mset {#}. f x ^ count {#} x)
 2. \<And>n M x. \<lbrakk>\<Prod>\<^sub># (image_mset f M) = (\<Prod>x\<in>set_mset M. f x ^ count M x); x \<notin># M; 0 < n\<rbrakk> \<Longrightarrow> \<Prod>\<^sub># (image_mset f (M + replicate_mset n x)) = (\<Prod>xa\<in>set_mset (M + replicate_mset n x). f xa ^ count (M + replicate_mset n x) xa)
[PROOF STEP]
case 1
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. \<Prod>\<^sub># (image_mset f {#}) = (\<Prod>x\<in>set_mset {#}. f x ^ count {#} x)
 2. \<And>n M x. \<lbrakk>\<Prod>\<^sub># (image_mset f M) = (\<Prod>x\<in>set_mset M. f x ^ count M x); x \<notin># M; 0 < n\<rbrakk> \<Longrightarrow> \<Prod>\<^sub># (image_mset f (M + replicate_mset n x)) = (\<Prod>xa\<in>set_mset (M + replicate_mset n x). f xa ^ count (M + replicate_mset n x) xa)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Prod>\<^sub># (image_mset f {#}) = (\<Prod>x\<in>set_mset {#}. f x ^ count {#} x)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<Prod>\<^sub># (image_mset f {#}) = (\<Prod>x\<in>set_mset {#}. f x ^ count {#} x)

goal (1 subgoal):
 1. \<And>n M x. \<lbrakk>\<Prod>\<^sub># (image_mset f M) = (\<Prod>x\<in>set_mset M. f x ^ count M x); x \<notin># M; 0 < n\<rbrakk> \<Longrightarrow> \<Prod>\<^sub># (image_mset f (M + replicate_mset n x)) = (\<Prod>xa\<in>set_mset (M + replicate_mset n x). f xa ^ count (M + replicate_mset n x) xa)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n M x. \<lbrakk>\<Prod>\<^sub># (image_mset f M) = (\<Prod>x\<in>set_mset M. f x ^ count M x); x \<notin># M; 0 < n\<rbrakk> \<Longrightarrow> \<Prod>\<^sub># (image_mset f (M + replicate_mset n x)) = (\<Prod>xa\<in>set_mset (M + replicate_mset n x). f xa ^ count (M + replicate_mset n x) xa)
[PROOF STEP]
case (2 n M x)
[PROOF STATE]
proof (state)
this:
\<Prod>\<^sub># (image_mset f M) = (\<Prod>x\<in>set_mset M. f x ^ count M x)
x \<notin># M
0 < n

goal (1 subgoal):
 1. \<And>n M x. \<lbrakk>\<Prod>\<^sub># (image_mset f M) = (\<Prod>x\<in>set_mset M. f x ^ count M x); x \<notin># M; 0 < n\<rbrakk> \<Longrightarrow> \<Prod>\<^sub># (image_mset f (M + replicate_mset n x)) = (\<Prod>xa\<in>set_mset (M + replicate_mset n x). f xa ^ count (M + replicate_mset n x) xa)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<Prod>\<^sub># (image_mset f M) = (\<Prod>x\<in>set_mset M. f x ^ count M x)
x \<notin># M
0 < n

goal (1 subgoal):
 1. \<And>n M x. \<lbrakk>\<Prod>\<^sub># (image_mset f M) = (\<Prod>x\<in>set_mset M. f x ^ count M x); x \<notin># M; 0 < n\<rbrakk> \<Longrightarrow> \<Prod>\<^sub># (image_mset f (M + replicate_mset n x)) = (\<Prod>xa\<in>set_mset (M + replicate_mset n x). f xa ^ count (M + replicate_mset n x) xa)
[PROOF STEP]
have "count M x = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. count M x = 0
[PROOF STEP]
using 2
[PROOF STATE]
proof (prove)
using this:
\<Prod>\<^sub># (image_mset f M) = (\<Prod>x\<in>set_mset M. f x ^ count M x)
x \<notin># M
0 < n

goal (1 subgoal):
 1. count M x = 0
[PROOF STEP]
by (simp add: count_eq_zero_iff)
[PROOF STATE]
proof (state)
this:
count M x = 0

goal (1 subgoal):
 1. \<And>n M x. \<lbrakk>\<Prod>\<^sub># (image_mset f M) = (\<Prod>x\<in>set_mset M. f x ^ count M x); x \<notin># M; 0 < n\<rbrakk> \<Longrightarrow> \<Prod>\<^sub># (image_mset f (M + replicate_mset n x)) = (\<Prod>xa\<in>set_mset (M + replicate_mset n x). f xa ^ count (M + replicate_mset n x) xa)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
count M x = 0

goal (1 subgoal):
 1. \<And>n M x. \<lbrakk>\<Prod>\<^sub># (image_mset f M) = (\<Prod>x\<in>set_mset M. f x ^ count M x); x \<notin># M; 0 < n\<rbrakk> \<Longrightarrow> \<Prod>\<^sub># (image_mset f (M + replicate_mset n x)) = (\<Prod>xa\<in>set_mset (M + replicate_mset n x). f xa ^ count (M + replicate_mset n x) xa)
[PROOF STEP]
have "\<And>y. y \<in> set_mset M \<Longrightarrow> y \<noteq> x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>y. y \<in># M \<Longrightarrow> y \<noteq> x
[PROOF STEP]
using 2
[PROOF STATE]
proof (prove)
using this:
\<Prod>\<^sub># (image_mset f M) = (\<Prod>x\<in>set_mset M. f x ^ count M x)
x \<notin># M
0 < n

goal (1 subgoal):
 1. \<And>y. y \<in># M \<Longrightarrow> y \<noteq> x
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
?y \<in># M \<Longrightarrow> ?y \<noteq> x

goal (1 subgoal):
 1. \<And>n M x. \<lbrakk>\<Prod>\<^sub># (image_mset f M) = (\<Prod>x\<in>set_mset M. f x ^ count M x); x \<notin># M; 0 < n\<rbrakk> \<Longrightarrow> \<Prod>\<^sub># (image_mset f (M + replicate_mset n x)) = (\<Prod>xa\<in>set_mset (M + replicate_mset n x). f xa ^ count (M + replicate_mset n x) xa)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<Prod>\<^sub># (image_mset f M) = (\<Prod>x\<in>set_mset M. f x ^ count M x)
x \<notin># M
0 < n
count M x = 0
?y \<in># M \<Longrightarrow> ?y \<noteq> x
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
\<Prod>\<^sub># (image_mset f M) = (\<Prod>x\<in>set_mset M. f x ^ count M x)
x \<notin># M
0 < n
count M x = 0
?y \<in># M \<Longrightarrow> ?y \<noteq> x

goal (1 subgoal):
 1. \<Prod>\<^sub># (image_mset f (M + replicate_mset n x)) = (\<Prod>xa\<in>set_mset (M + replicate_mset n x). f xa ^ count (M + replicate_mset n x) xa)
[PROOF STEP]
by (simp add:algebra_simps)
[PROOF STATE]
proof (state)
this:
\<Prod>\<^sub># (image_mset f (M + replicate_mset n x)) = (\<Prod>xa\<in>set_mset (M + replicate_mset n x). f xa ^ count (M + replicate_mset n x) xa)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sum_upto_minus1:
  assumes "x \<ge> 1"
  shows   "sum_upto f (x - 1) = (sum_upto f x - f (nat \<lfloor>x\<rfloor>) :: 'a :: ab_group_add)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_upto f (x - 1) = sum_upto f x - f (nat \<lfloor>x\<rfloor>)
[PROOF STEP]
using sum_upto_plus1[of "x - 1" f] assms
[PROOF STATE]
proof (prove)
using this:
0 \<le> x - 1 \<Longrightarrow> sum_upto f (x - 1 + 1) = sum_upto f (x - 1) + f (Suc (nat \<lfloor>x - 1\<rfloor>))
1 \<le> x

goal (1 subgoal):
 1. sum_upto f (x - 1) = sum_upto f x - f (nat \<lfloor>x\<rfloor>)
[PROOF STEP]
by (simp add: algebra_simps nat_diff_distrib)


[STATEMENT]
lemma binomial_eq_0: "n < k \<Longrightarrow> n choose k = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n < k \<Longrightarrow> n choose k = 0
[PROOF STEP]
by (auto simp add: binomial_def dest: subset_eq_atLeast0_lessThan_card)


[STATEMENT]
lemma D_eq: "D = {x. \<exists>y \<in> A. (x = (y * a) mod p \<and> (y * a) mod p \<le> (int p - 1) div 2)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. D = {x. \<exists>y\<in>A. x = y * a mod int p \<and> y * a mod int p \<le> (int p - 1) div 2}
[PROOF STEP]
by (auto simp add: D_def C_def B_def A_def)


[STATEMENT]
theorem to_contra_form: "Trueprop A \<equiv> (\<not>A \<Longrightarrow> False)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<equiv> (\<not> A \<Longrightarrow> False)
[PROOF STEP]
by (rule equal_intr_rule) auto


[STATEMENT]
lemma zmod_zminus_eq_conv: "
  ((a::int) mod - m = b mod - m) = (a mod m = b mod m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a mod - m = b mod - m) = (a mod m = b mod m)
[PROOF STEP]
apply (insert linorder_less_linear[of 0 m], elim disjE)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. 0 < m \<Longrightarrow> (a mod - m = b mod - m) = (a mod m = b mod m)
 2. 0 = m \<Longrightarrow> (a mod - m = b mod - m) = (a mod m = b mod m)
 3. m < 0 \<Longrightarrow> (a mod - m = b mod - m) = (a mod m = b mod m)
[PROOF STEP]
apply (blast dest: zmod_zminus_eq_conv_pos)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. 0 = m \<Longrightarrow> (a mod - m = b mod - m) = (a mod m = b mod m)
 2. m < 0 \<Longrightarrow> (a mod - m = b mod - m) = (a mod m = b mod m)
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m < 0 \<Longrightarrow> (a mod - m = b mod - m) = (a mod m = b mod m)
[PROOF STEP]
apply (simp add: zmod_zminus_eq_conv_pos[of "-m", symmetric])
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma power_div_nat:
  assumes "c \<le> b"
  assumes "a > 0"
  shows  "(a :: nat) ^ b div a ^ c = a ^ (b - c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a ^ b div a ^ c = a ^ (b - c)
[PROOF STEP]
by (metis assms nonzero_mult_div_cancel_right le_add_diff_inverse2 less_not_refl2 power_add power_not_zero)


[STATEMENT]
lemma mtx_idx_valid[simp]: "\<lbrakk>i < (N::nat); j < M\<rbrakk> \<Longrightarrow> i * M + j < N * M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>i < N; j < M\<rbrakk> \<Longrightarrow> i * M + j < N * M
[PROOF STEP]
by (rule mlex_bound)


[STATEMENT]
lemma add_rat_roots: "ipoly (poly_add_rat r p) x = 0 \<longleftrightarrow> ipoly p (x - of_rat r) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (ipoly (poly_add_rat r p) x = (0::'a)) = (ipoly p (x - of_rat r) = (0::'a))
[PROOF STEP]
unfolding ipoly_add_rat
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (of_int (snd (quotient_of r)) ^ degree p * ipoly p (x - of_rat r) = (0::'a)) = (ipoly p (x - of_rat r) = (0::'a))
[PROOF STEP]
using quotient_of_nonzero
[PROOF STATE]
proof (prove)
using this:
0 < snd (quotient_of ?r)
snd (quotient_of ?r) \<noteq> 0

goal (1 subgoal):
 1. (of_int (snd (quotient_of r)) ^ degree p * ipoly p (x - of_rat r) = (0::'a)) = (ipoly p (x - of_rat r) = (0::'a))
[PROOF STEP]
by auto


[STATEMENT]
lemma root_info_condD: "root_info_cond ri p \<Longrightarrow> a \<le> b \<Longrightarrow> root_info.l_r ri a b = card {x. root_cond (p,a,b) x}"
  "root_info_cond ri p \<Longrightarrow> root_info.number_root ri a = card {x. x \<le> real_of_rat a \<and> ipoly p x = 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lbrakk>root_info_cond ri p; a \<le> b\<rbrakk> \<Longrightarrow> root_info.l_r ri a b = card {x. root_cond (p, a, b) x}) &&& (root_info_cond ri p \<Longrightarrow> root_info.number_root ri a = card {x. x \<le> real_of_rat a \<and> poly (real_of_int_poly p) x = 0})
[PROOF STEP]
unfolding root_info_cond_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lbrakk>(\<forall>a b. a \<le> b \<longrightarrow> root_info.l_r ri a b = card {x. root_cond (p, a, b) x}) \<and> (\<forall>a. root_info.number_root ri a = card {x. x \<le> real_of_rat a \<and> poly (real_of_int_poly p) x = 0}); a \<le> b\<rbrakk> \<Longrightarrow> root_info.l_r ri a b = card {x. root_cond (p, a, b) x}) &&& ((\<forall>a b. a \<le> b \<longrightarrow> root_info.l_r ri a b = card {x. root_cond (p, a, b) x}) \<and> (\<forall>a. root_info.number_root ri a = card {x. x \<le> real_of_rat a \<and> poly (real_of_int_poly p) x = 0}) \<Longrightarrow> root_info.number_root ri a = card {x. x \<le> real_of_rat a \<and> poly (real_of_int_poly p) x = 0})
[PROOF STEP]
by auto


[STATEMENT]
lemma from_vec_mult[simp]: "from_vec (M ** N) = from_vec M * from_vec N"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. from_vec (M ** N) = from_vec M * from_vec N
[PROOF STEP]
by transfer (simp add: matrix_matrix_mult_def fun_eq_iff vec_eq_iff)


[STATEMENT]
lemma show7:
  fixes d::"nat\<Rightarrow>real" and a b::"nat\<Rightarrow>int " and q p::int
  assumes "q \<ge>1" and "p \<ge> 1" and a: "\<forall>n. a n \<ge> 1" and "\<forall>n. b n \<ge> 1"
    and assumerational:"(\<lambda> n. b (n+1) / a (n+1) ) sums (p/q)"
  shows "q*((\<Prod>j=1..n. of_int( a j)))*( suminf (\<lambda> (j::nat). (b (j+n+1)/ a (j+n+1 )))) \<ge> 1 "
    (is "?L \<ge> _")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 \<le> real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1)))
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 1 \<le> real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1)))
[PROOF STEP]
define LL where "LL=?L"
[PROOF STATE]
proof (state)
this:
LL = real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1)))

goal (1 subgoal):
 1. 1 \<le> real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1)))
[PROOF STEP]
define aa where "aa=(\<Prod>j = 1..n. real_of_int (a j))"
[PROOF STATE]
proof (state)
this:
aa = (\<Prod>j = 1..n. real_of_int (a j))

goal (1 subgoal):
 1. 1 \<le> real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1)))
[PROOF STEP]
define ff where "ff=(\<lambda>i. real_of_int (b (i+1)) / real_of_int (a (i+1)))"
[PROOF STATE]
proof (state)
this:
ff = (\<lambda>i. real_of_int (b (i + 1)) / real_of_int (a (i + 1)))

goal (1 subgoal):
 1. 1 \<le> real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1)))
[PROOF STEP]
have "?L > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 0 < real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1)))
[PROOF STEP]
have "aa > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < aa
[PROOF STEP]
unfolding aa_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < (\<Prod>j = 1..n. real_of_int (a j))
[PROOF STEP]
using a
[PROOF STATE]
proof (prove)
using this:
\<forall>n. 1 \<le> a n

goal (1 subgoal):
 1. 0 < (\<Prod>j = 1..n. real_of_int (a j))
[PROOF STEP]
by (induction n) (simp_all add: int_one_le_iff_zero_less prod_pos)
[PROOF STATE]
proof (state)
this:
0 < aa

goal (1 subgoal):
 1. 0 < real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1)))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
0 < aa

goal (1 subgoal):
 1. 0 < real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1)))
[PROOF STEP]
have "(\<Sum>j. ff (j + n)) > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < (\<Sum>j. ff (j + n))
[PROOF STEP]
proof (rule suminf_pos)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. summable (\<lambda>j. ff (j + n))
 2. \<And>na. 0 < ff (na + n)
[PROOF STEP]
have "summable ff"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. summable ff
[PROOF STEP]
unfolding ff_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. summable (\<lambda>i. real_of_int (b (i + 1)) / real_of_int (a (i + 1)))
[PROOF STEP]
using assumerational
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. real_of_int (b (n + 1)) / real_of_int (a (n + 1))) sums (real_of_int p / real_of_int q)

goal (1 subgoal):
 1. summable (\<lambda>i. real_of_int (b (i + 1)) / real_of_int (a (i + 1)))
[PROOF STEP]
using summable_def
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. real_of_int (b (n + 1)) / real_of_int (a (n + 1))) sums (real_of_int p / real_of_int q)
summable ?f = (\<exists>s. ?f sums s)

goal (1 subgoal):
 1. summable (\<lambda>i. real_of_int (b (i + 1)) / real_of_int (a (i + 1)))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
summable ff

goal (2 subgoals):
 1. summable (\<lambda>j. ff (j + n))
 2. \<And>na. 0 < ff (na + n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
summable ff
[PROOF STEP]
show " summable (\<lambda>j. ff (j + n))"
[PROOF STATE]
proof (prove)
using this:
summable ff

goal (1 subgoal):
 1. summable (\<lambda>j. ff (j + n))
[PROOF STEP]
using summable_iff_shift[of ff n]
[PROOF STATE]
proof (prove)
using this:
summable ff
summable (\<lambda>na. ff (na + n)) = summable ff

goal (1 subgoal):
 1. summable (\<lambda>j. ff (j + n))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
summable (\<lambda>j. ff (j + n))

goal (1 subgoal):
 1. \<And>na. 0 < ff (na + n)
[PROOF STEP]
show "\<And>i. 0 < ff (i + n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. 0 < ff (i + n)
[PROOF STEP]
unfolding ff_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. 0 < real_of_int (b (i + n + 1)) / real_of_int (a (i + n + 1))
[PROOF STEP]
using a assms(4) int_one_le_iff_zero_less
[PROOF STATE]
proof (prove)
using this:
\<forall>n. 1 \<le> a n
\<forall>n. 1 \<le> b n
(1 \<le> ?z) = (0 < ?z)

goal (1 subgoal):
 1. \<And>i. 0 < real_of_int (b (i + n + 1)) / real_of_int (a (i + n + 1))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < ff (?i + n)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
0 < (\<Sum>j. ff (j + n))

goal (1 subgoal):
 1. 0 < real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1)))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
0 < aa
0 < (\<Sum>j. ff (j + n))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
0 < aa
0 < (\<Sum>j. ff (j + n))

goal (1 subgoal):
 1. 0 < real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1)))
[PROOF STEP]
unfolding aa_def ff_def
[PROOF STATE]
proof (prove)
using this:
0 < (\<Prod>j = 1..n. real_of_int (a j))
0 < (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1)))

goal (1 subgoal):
 1. 0 < real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1)))
[PROOF STEP]
using \<open>q\<ge>1\<close>
[PROOF STATE]
proof (prove)
using this:
0 < (\<Prod>j = 1..n. real_of_int (a j))
0 < (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1)))
1 \<le> q

goal (1 subgoal):
 1. 0 < real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1)))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1)))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
0 < real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1)))

goal (1 subgoal):
 1. 1 \<le> real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1)))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
0 < real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1)))

goal (1 subgoal):
 1. 1 \<le> real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1)))
[PROOF STEP]
have "?L \<in> \<int>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1))) \<in> \<int>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1))) \<in> \<int>
[PROOF STEP]
have "?L = aa *(p -q* ( \<Sum>j=1..n. b j / a j))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1))) = aa * (real_of_int p - real_of_int q * (\<Sum>j = 1..n. real_of_int (b j) / real_of_int (a j)))
[PROOF STEP]
unfolding aa_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1))) = (\<Prod>j = 1..n. real_of_int (a j)) * (real_of_int p - real_of_int q * (\<Sum>j = 1..n. real_of_int (b j) / real_of_int (a j)))
[PROOF STEP]
using a assms assumerational int_one_le_iff_zero_less showpre7
[PROOF STATE]
proof (prove)
using this:
\<forall>n. 1 \<le> a n
1 \<le> q
1 \<le> p
\<forall>n. 1 \<le> a n
\<forall>n. 1 \<le> b n
(\<lambda>n. real_of_int (b (n + 1)) / real_of_int (a (n + 1))) sums (real_of_int p / real_of_int q)
(\<lambda>n. real_of_int (b (n + 1)) / real_of_int (a (n + 1))) sums (real_of_int p / real_of_int q)
(1 \<le> ?z) = (0 < ?z)
\<lbrakk>0 < ?q; 0 < ?p; \<forall>n. 0 < ?a n; \<forall>n. 0 < ?b n; (\<lambda>n. real_of_int (?b (n + 1)) / real_of_int (?a (n + 1))) sums (real_of_int ?p / real_of_int ?q)\<rbrakk> \<Longrightarrow> real_of_int (?q * (\<Prod>j = 1..?n. of_int (?a j))) * (\<Sum>j. real_of_int (?b (j + ?n + 1)) / real_of_int (?a (j + ?n + 1))) = (\<Prod>j = 1..?n. real_of_int (?a j)) * (real_of_int ?p - real_of_int ?q * (\<Sum>j = 1..?n. real_of_int (?b j) / real_of_int (?a j)))

goal (1 subgoal):
 1. real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1))) = (\<Prod>j = 1..n. real_of_int (a j)) * (real_of_int p - real_of_int q * (\<Sum>j = 1..n. real_of_int (b j) / real_of_int (a j)))
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1))) = aa * (real_of_int p - real_of_int q * (\<Sum>j = 1..n. real_of_int (b j) / real_of_int (a j)))

goal (1 subgoal):
 1. real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1))) \<in> \<int>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1))) = aa * (real_of_int p - real_of_int q * (\<Sum>j = 1..n. real_of_int (b j) / real_of_int (a j)))

goal (1 subgoal):
 1. real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1))) \<in> \<int>
[PROOF STEP]
have "... = aa * p - q * (\<Sum>j=1..n. aa * b j / a j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. aa * (real_of_int p - real_of_int q * (\<Sum>j = 1..n. real_of_int (b j) / real_of_int (a j))) = aa * real_of_int p - real_of_int q * (\<Sum>j = 1..n. aa * real_of_int (b j) / real_of_int (a j))
[PROOF STEP]
by (auto simp add:algebra_simps sum_distrib_left)
[PROOF STATE]
proof (state)
this:
aa * (real_of_int p - real_of_int q * (\<Sum>j = 1..n. real_of_int (b j) / real_of_int (a j))) = aa * real_of_int p - real_of_int q * (\<Sum>j = 1..n. aa * real_of_int (b j) / real_of_int (a j))

goal (1 subgoal):
 1. real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1))) \<in> \<int>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
aa * (real_of_int p - real_of_int q * (\<Sum>j = 1..n. real_of_int (b j) / real_of_int (a j))) = aa * real_of_int p - real_of_int q * (\<Sum>j = 1..n. aa * real_of_int (b j) / real_of_int (a j))

goal (1 subgoal):
 1. real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1))) \<in> \<int>
[PROOF STEP]
have "... = prod a {1..n} * p - q * (\<Sum>j = 1..n. b j * prod a ({1..n} - {j}))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. aa * real_of_int p - real_of_int q * (\<Sum>j = 1..n. aa * real_of_int (b j) / real_of_int (a j)) = real_of_int (prod a {1..n} * p - q * (\<Sum>j = 1..n. b j * prod a ({1..n} - {j})))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. aa * real_of_int p - real_of_int q * (\<Sum>j = 1..n. aa * real_of_int (b j) / real_of_int (a j)) = real_of_int (prod a {1..n} * p - q * (\<Sum>j = 1..n. b j * prod a ({1..n} - {j})))
[PROOF STEP]
have "(\<Sum>j=1..n. aa * b j / a j) = (\<Sum>j=1..n. b j * prod a ({1..n} - {j}))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j = 1..n. aa * real_of_int (b j) / real_of_int (a j)) = real_of_int (\<Sum>j = 1..n. b j * prod a ({1..n} - {j}))
[PROOF STEP]
unfolding of_int_sum
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j = 1..n. aa * real_of_int (b j) / real_of_int (a j)) = (\<Sum>x = 1..n. real_of_int (b x * prod a ({1..n} - {x})))
[PROOF STEP]
proof (rule sum.cong)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. {1..n} = {1..n}
 2. \<And>x. x \<in> {1..n} \<Longrightarrow> aa * real_of_int (b x) / real_of_int (a x) = real_of_int (b x * prod a ({1..n} - {x}))
[PROOF STEP]
fix j
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. {1..n} = {1..n}
 2. \<And>x. x \<in> {1..n} \<Longrightarrow> aa * real_of_int (b x) / real_of_int (a x) = real_of_int (b x * prod a ({1..n} - {x}))
[PROOF STEP]
assume "j \<in> {1..n}"
[PROOF STATE]
proof (state)
this:
j \<in> {1..n}

goal (2 subgoals):
 1. {1..n} = {1..n}
 2. \<And>x. x \<in> {1..n} \<Longrightarrow> aa * real_of_int (b x) / real_of_int (a x) = real_of_int (b x * prod a ({1..n} - {x}))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
j \<in> {1..n}
[PROOF STEP]
have "(\<Prod>i = 1..n. real_of_int (a i)) = a j * (\<Prod>i\<in>{1..n} - {j}. real_of_int (a i))"
[PROOF STATE]
proof (prove)
using this:
j \<in> {1..n}

goal (1 subgoal):
 1. (\<Prod>i = 1..n. real_of_int (a i)) = real_of_int (a j) * (\<Prod>i\<in>{1..n} - {j}. real_of_int (a i))
[PROOF STEP]
by (meson finite_atLeastAtMost prod.remove)
[PROOF STATE]
proof (state)
this:
(\<Prod>i = 1..n. real_of_int (a i)) = real_of_int (a j) * (\<Prod>i\<in>{1..n} - {j}. real_of_int (a i))

goal (2 subgoals):
 1. {1..n} = {1..n}
 2. \<And>x. x \<in> {1..n} \<Longrightarrow> aa * real_of_int (b x) / real_of_int (a x) = real_of_int (b x * prod a ({1..n} - {x}))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<Prod>i = 1..n. real_of_int (a i)) = real_of_int (a j) * (\<Prod>i\<in>{1..n} - {j}. real_of_int (a i))
[PROOF STEP]
have "aa / real_of_int (a j) = prod a ({1..n} - {j})"
[PROOF STATE]
proof (prove)
using this:
(\<Prod>i = 1..n. real_of_int (a i)) = real_of_int (a j) * (\<Prod>i\<in>{1..n} - {j}. real_of_int (a i))

goal (1 subgoal):
 1. aa / real_of_int (a j) = real_of_int (prod a ({1..n} - {j}))
[PROOF STEP]
unfolding aa_def
[PROOF STATE]
proof (prove)
using this:
(\<Prod>i = 1..n. real_of_int (a i)) = real_of_int (a j) * (\<Prod>i\<in>{1..n} - {j}. real_of_int (a i))

goal (1 subgoal):
 1. (\<Prod>j = 1..n. real_of_int (a j)) / real_of_int (a j) = real_of_int (prod a ({1..n} - {j}))
[PROOF STEP]
using a[rule_format,of j]
[PROOF STATE]
proof (prove)
using this:
(\<Prod>i = 1..n. real_of_int (a i)) = real_of_int (a j) * (\<Prod>i\<in>{1..n} - {j}. real_of_int (a i))
1 \<le> a j

goal (1 subgoal):
 1. (\<Prod>j = 1..n. real_of_int (a j)) / real_of_int (a j) = real_of_int (prod a ({1..n} - {j}))
[PROOF STEP]
by (auto simp add:field_simps)
[PROOF STATE]
proof (state)
this:
aa / real_of_int (a j) = real_of_int (prod a ({1..n} - {j}))

goal (2 subgoals):
 1. {1..n} = {1..n}
 2. \<And>x. x \<in> {1..n} \<Longrightarrow> aa * real_of_int (b x) / real_of_int (a x) = real_of_int (b x * prod a ({1..n} - {x}))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
aa / real_of_int (a j) = real_of_int (prod a ({1..n} - {j}))
[PROOF STEP]
show "aa * b j / a j = b j * prod a ({1..n} - {j})"
[PROOF STATE]
proof (prove)
using this:
aa / real_of_int (a j) = real_of_int (prod a ({1..n} - {j}))

goal (1 subgoal):
 1. aa * real_of_int (b j) / real_of_int (a j) = real_of_int (b j * prod a ({1..n} - {j}))
[PROOF STEP]
by (metis mult.commute of_int_mult times_divide_eq_right)
[PROOF STATE]
proof (state)
this:
aa * real_of_int (b j) / real_of_int (a j) = real_of_int (b j * prod a ({1..n} - {j}))

goal (1 subgoal):
 1. {1..n} = {1..n}
[PROOF STEP]
qed simp
[PROOF STATE]
proof (state)
this:
(\<Sum>j = 1..n. aa * real_of_int (b j) / real_of_int (a j)) = real_of_int (\<Sum>j = 1..n. b j * prod a ({1..n} - {j}))

goal (1 subgoal):
 1. aa * real_of_int p - real_of_int q * (\<Sum>j = 1..n. aa * real_of_int (b j) / real_of_int (a j)) = real_of_int (prod a {1..n} * p - q * (\<Sum>j = 1..n. b j * prod a ({1..n} - {j})))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<Sum>j = 1..n. aa * real_of_int (b j) / real_of_int (a j)) = real_of_int (\<Sum>j = 1..n. b j * prod a ({1..n} - {j}))

goal (1 subgoal):
 1. aa * real_of_int p - real_of_int q * (\<Sum>j = 1..n. aa * real_of_int (b j) / real_of_int (a j)) = real_of_int (prod a {1..n} * p - q * (\<Sum>j = 1..n. b j * prod a ({1..n} - {j})))
[PROOF STEP]
have "aa * p = (\<Prod>j = 1..n.  (a j)) *  p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. aa * real_of_int p = real_of_int (prod a {1..n} * p)
[PROOF STEP]
unfolding aa_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>j = 1..n. real_of_int (a j)) * real_of_int p = real_of_int (prod a {1..n} * p)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
aa * real_of_int p = real_of_int (prod a {1..n} * p)

goal (1 subgoal):
 1. aa * real_of_int p - real_of_int q * (\<Sum>j = 1..n. aa * real_of_int (b j) / real_of_int (a j)) = real_of_int (prod a {1..n} * p - q * (\<Sum>j = 1..n. b j * prod a ({1..n} - {j})))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>j = 1..n. aa * real_of_int (b j) / real_of_int (a j)) = real_of_int (\<Sum>j = 1..n. b j * prod a ({1..n} - {j}))
aa * real_of_int p = real_of_int (prod a {1..n} * p)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>j = 1..n. aa * real_of_int (b j) / real_of_int (a j)) = real_of_int (\<Sum>j = 1..n. b j * prod a ({1..n} - {j}))
aa * real_of_int p = real_of_int (prod a {1..n} * p)

goal (1 subgoal):
 1. aa * real_of_int p - real_of_int q * (\<Sum>j = 1..n. aa * real_of_int (b j) / real_of_int (a j)) = real_of_int (prod a {1..n} * p - q * (\<Sum>j = 1..n. b j * prod a ({1..n} - {j})))
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
aa * real_of_int p - real_of_int q * (\<Sum>j = 1..n. aa * real_of_int (b j) / real_of_int (a j)) = real_of_int (prod a {1..n} * p - q * (\<Sum>j = 1..n. b j * prod a ({1..n} - {j})))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
aa * real_of_int p - real_of_int q * (\<Sum>j = 1..n. aa * real_of_int (b j) / real_of_int (a j)) = real_of_int (prod a {1..n} * p - q * (\<Sum>j = 1..n. b j * prod a ({1..n} - {j})))

goal (1 subgoal):
 1. real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1))) \<in> \<int>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
aa * real_of_int p - real_of_int q * (\<Sum>j = 1..n. aa * real_of_int (b j) / real_of_int (a j)) = real_of_int (prod a {1..n} * p - q * (\<Sum>j = 1..n. b j * prod a ({1..n} - {j})))

goal (1 subgoal):
 1. real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1))) \<in> \<int>
[PROOF STEP]
have "... \<in> \<int>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_of_int (prod a {1..n} * p - q * (\<Sum>j = 1..n. b j * prod a ({1..n} - {j}))) \<in> \<int>
[PROOF STEP]
using Ints_of_int
[PROOF STATE]
proof (prove)
using this:
of_int ?z \<in> \<int>

goal (1 subgoal):
 1. real_of_int (prod a {1..n} * p - q * (\<Sum>j = 1..n. b j * prod a ({1..n} - {j}))) \<in> \<int>
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
real_of_int (prod a {1..n} * p - q * (\<Sum>j = 1..n. b j * prod a ({1..n} - {j}))) \<in> \<int>

goal (1 subgoal):
 1. real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1))) \<in> \<int>
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1))) \<in> \<int>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1))) \<in> \<int>

goal (1 subgoal):
 1. real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1))) \<in> \<int>
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1))) \<in> \<int>

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1))) \<in> \<int>

goal (1 subgoal):
 1. 1 \<le> real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1)))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
0 < real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1)))
real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1))) \<in> \<int>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
0 < real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1)))
real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1))) \<in> \<int>

goal (1 subgoal):
 1. 1 \<le> real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1)))
[PROOF STEP]
apply (fold LL_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < LL; LL \<in> \<int>\<rbrakk> \<Longrightarrow> 1 \<le> LL
[PROOF STEP]
by (metis Ints_cases int_one_le_iff_zero_less not_less of_int_0_less_iff of_int_less_1_iff)
[PROOF STATE]
proof (state)
this:
1 \<le> real_of_int (q * (\<Prod>j = 1..n. of_int (a j))) * (\<Sum>j. real_of_int (b (j + n + 1)) / real_of_int (a (j + n + 1)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma alt_group_is_sign_kernel:
  "carrier (alt_group n) = kernel (sym_group n) sign_img sign"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. carrier (alt_group n) = kernel (sym_group n) sign_img sign
[PROOF STEP]
unfolding alt_group_def sym_group_def sign_img_def kernel_def sign_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. carrier (\<lparr>carrier = {p. p permutes {1..n}}, monoid.mult = (\<circ>), one = id\<rparr>\<lparr>carrier := {p. p permutes {1..n} \<and> evenperm p}\<rparr>) = {x \<in> carrier \<lparr>carrier = {p. p permutes {1..n}}, monoid.mult = (\<circ>), one = id\<rparr>. (if evenperm x then 1 else - 1) = \<one>\<^bsub>\<lparr>carrier = {- 1, 1}, monoid.mult = (*), one = 1\<rparr>\<^esub>}
[PROOF STEP]
by auto


[STATEMENT]
lemma open_contains_cball_eq: "open S \<Longrightarrow> (\<forall>x. x \<in> S \<longleftrightarrow> (\<exists>e>0. cball x e \<subseteq> S))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. open S \<Longrightarrow> \<forall>x. (x \<in> S) = (\<exists>e>0. cball x e \<subseteq> S)
[PROOF STEP]
by (metis open_contains_cball subset_eq order_less_imp_le centre_in_cball)


[STATEMENT]
lemma vec_eq_iff: "(x = y) \<longleftrightarrow> (\<forall>i. x$i = y$i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x = y) = (\<forall>i. x $ i = y $ i)
[PROOF STEP]
by (simp add: vec_nth_inject [symmetric] fun_eq_iff)


[STATEMENT]
lemma cod_MkCell [simp]:
    assumes "arr (MkCell A B f)"
    shows "cod (MkCell A B f) = MkCell A B (partial_magma.cod (Hom A B) f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cod (MkCell A B f) = MkCell A B (partial_magma.cod (Hom A B) f)
[PROOF STEP]
using assms arr_char cod_char
[PROOF STATE]
proof (prove)
using this:
arr (MkCell A B f)
arr ?\<mu> = (?\<mu> \<noteq> Null \<and> Src ?\<mu> \<in> Obj \<and> Trg ?\<mu> \<in> Obj \<and> partial_magma.arr (Hom (Src ?\<mu>) (Trg ?\<mu>)) (Map ?\<mu>))
cod ?\<mu> = (if arr ?\<mu> then MkCell (Src ?\<mu>) (Trg ?\<mu>) (partial_magma.cod (Hom (Src ?\<mu>) (Trg ?\<mu>)) (Map ?\<mu>)) else Null)

goal (1 subgoal):
 1. cod (MkCell A B f) = MkCell A B (partial_magma.cod (Hom A B) f)
[PROOF STEP]
by simp


[STATEMENT]
lemma spectrum_root_char_poly: assumes A: "(A :: 'a :: field mat) \<in> carrier_mat n n"
  shows "spectrum A = {k. poly (char_poly A) k = 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. spectrum A = {k. poly (char_poly A) k = (0::'a)}
[PROOF STEP]
unfolding spectrum_def eigenvalue_root_char_poly[OF A, symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Collect (eigenvalue A) = {k. eigenvalue A k}
[PROOF STEP]
by auto


[STATEMENT]
lemma "min_wpl (\<lambda>i j. nat(i+j)) 0 4 = 10"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. min_wpl (\<lambda>i j. nat (i + j)) 0 4 = 10
[PROOF STEP]
by eval


[STATEMENT]
lemma "((\<lambda>x::real. exp (exp (-x/(1+exp (-x)))) * exp (-x/(1+exp (-x/(1+exp (-x))))) *
           exp (exp (-x+exp (-x/(1+exp (-x))))) / (exp (-x/(1+exp (-x))))^2 - exp x + x)
         \<longlongrightarrow> 2) at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. exp (exp (- x / (1 + exp (- x)))) * exp (- x / (1 + exp (- x / (1 + exp (- x))))) * exp (exp (- x + exp (- x / (1 + exp (- x))))) / (exp (- x / (1 + exp (- x))))\<^sup>2 - exp x + x) \<longlongrightarrow> 2) at_top
[PROOF STEP]
by real_asymp


[STATEMENT]
lemma sints32:"sints 32 = {i. - (2 ^ 31) \<le> i \<and> i < 2 ^ 31}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sints 32 = {i. - (2 ^ 31) \<le> i \<and> i < 2 ^ 31}
[PROOF STEP]
using sints_def[of 32] range_sbintrunc[of 31]
[PROOF STATE]
proof (prove)
using this:
sints 32 = range (signed_take_bit (32 - 1))
range (signed_take_bit 31) = {i. - (2 ^ 31) \<le> i \<and> i < 2 ^ 31}

goal (1 subgoal):
 1. sints 32 = {i. - (2 ^ 31) \<le> i \<and> i < 2 ^ 31}
[PROOF STEP]
by auto


[STATEMENT]
lemma isometry_quasi_isometry_between:
  assumes "isometry f"
  shows "1 0-quasi_isometry_between UNIV UNIV f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 0 -quasi_isometry_between UNIV UNIV f
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
isometry f

goal (1 subgoal):
 1. 1 0 -quasi_isometry_between UNIV UNIV f
[PROOF STEP]
unfolding quasi_isometry_between_def quasi_isometry_on_def isometry_def isometry_on_def surj_def
[PROOF STATE]
proof (prove)
using this:
(\<forall>x\<in>UNIV. \<forall>y\<in>UNIV. dist (f x) (f y) = dist x y) \<and> (\<forall>y. \<exists>x. y = f x)

goal (1 subgoal):
 1. (1 \<le> 1 \<and> 0 \<le> 0 \<and> (\<forall>x\<in>UNIV. \<forall>y\<in>UNIV. dist (f x) (f y) \<le> 1 * dist x y + 0 \<and> 1 / 1 * dist x y - 0 \<le> dist (f x) (f y))) \<and> range f \<subseteq> UNIV \<and> (\<forall>y\<in>UNIV. \<exists>x\<in>UNIV. dist (f x) y \<le> 0)
[PROOF STEP]
by (auto) metis


[STATEMENT]
lemma expectation_geometric_pmf:
  assumes "p \<in> {0<..1}"
  shows   "measure_pmf.expectation (geometric_pmf p) real = (1 - p) / p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation (local.geometric_pmf p) real = (1 - p) / p
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. measure_pmf.expectation (local.geometric_pmf p) real = (1 - p) / p
[PROOF STEP]
have "(\<lambda>n. p * ((1 - p) ^ n * n)) sums (p * ((1 - p) / p^2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. p * ((1 - p) ^ n * real n)) sums (p * ((1 - p) / p\<^sup>2))
[PROOF STEP]
using assms geometric_sums_times_n[of "1-p"]
[PROOF STATE]
proof (prove)
using this:
p \<in> {0<..1}
norm (1 - p) < 1 \<Longrightarrow> (\<lambda>n. (1 - p) ^ n * real n) sums ((1 - p) / (1 - (1 - p))\<^sup>2)

goal (1 subgoal):
 1. (\<lambda>n. p * ((1 - p) ^ n * real n)) sums (p * ((1 - p) / p\<^sup>2))
[PROOF STEP]
by (intro sums_mult) auto
[PROOF STATE]
proof (state)
this:
(\<lambda>n. p * ((1 - p) ^ n * real n)) sums (p * ((1 - p) / p\<^sup>2))

goal (1 subgoal):
 1. measure_pmf.expectation (local.geometric_pmf p) real = (1 - p) / p
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<lambda>n. p * ((1 - p) ^ n * real n)) sums (p * ((1 - p) / p\<^sup>2))

goal (1 subgoal):
 1. measure_pmf.expectation (local.geometric_pmf p) real = (1 - p) / p
[PROOF STEP]
have "(\<lambda>n. p * ((1 - p) ^ n * n)) = (\<lambda>n. (1 - p) ^ n * p  * real n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. p * ((1 - p) ^ n * real n)) = (\<lambda>n. (1 - p) ^ n * p * real n)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>n. p * ((1 - p) ^ n * real n)) = (\<lambda>n. (1 - p) ^ n * p * real n)

goal (1 subgoal):
 1. measure_pmf.expectation (local.geometric_pmf p) real = (1 - p) / p
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>n. p * ((1 - p) ^ n * real n)) sums (p * ((1 - p) / p\<^sup>2))
(\<lambda>n. p * ((1 - p) ^ n * real n)) = (\<lambda>n. (1 - p) ^ n * p * real n)
[PROOF STEP]
have *: "(\<lambda>n. (1 - p) ^ n * p  * real n) sums ((1 - p) / p)"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. p * ((1 - p) ^ n * real n)) sums (p * ((1 - p) / p\<^sup>2))
(\<lambda>n. p * ((1 - p) ^ n * real n)) = (\<lambda>n. (1 - p) ^ n * p * real n)

goal (1 subgoal):
 1. (\<lambda>n. (1 - p) ^ n * p * real n) sums ((1 - p) / p)
[PROOF STEP]
using assms sums_subst
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. p * ((1 - p) ^ n * real n)) sums (p * ((1 - p) / p\<^sup>2))
(\<lambda>n. p * ((1 - p) ^ n * real n)) = (\<lambda>n. (1 - p) ^ n * p * real n)
p \<in> {0<..1}
\<lbrakk>?f = ?g; ?g sums ?z\<rbrakk> \<Longrightarrow> ?f sums ?z

goal (1 subgoal):
 1. (\<lambda>n. (1 - p) ^ n * p * real n) sums ((1 - p) / p)
[PROOF STEP]
by (auto simp add: power2_eq_square)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. (1 - p) ^ n * p * real n) sums ((1 - p) / p)

goal (1 subgoal):
 1. measure_pmf.expectation (local.geometric_pmf p) real = (1 - p) / p
[PROOF STEP]
have "measure_pmf.expectation (geometric_pmf p) real =
        (\<integral>n. pmf (geometric_pmf p) n * real n \<partial>count_space UNIV)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation (local.geometric_pmf p) real = LINT n|count_space UNIV. pmf (local.geometric_pmf p) n * real n
[PROOF STEP]
unfolding measure_pmf_eq_density
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integral\<^sup>L (density (count_space UNIV) (\<lambda>x. ennreal (pmf (local.geometric_pmf p) x))) real = LINT n|count_space UNIV. pmf (local.geometric_pmf p) n * real n
[PROOF STEP]
by (subst integral_density) auto
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (local.geometric_pmf p) real = LINT n|count_space UNIV. pmf (local.geometric_pmf p) n * real n

goal (1 subgoal):
 1. measure_pmf.expectation (local.geometric_pmf p) real = (1 - p) / p
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (local.geometric_pmf p) real = LINT n|count_space UNIV. pmf (local.geometric_pmf p) n * real n

goal (1 subgoal):
 1. measure_pmf.expectation (local.geometric_pmf p) real = (1 - p) / p
[PROOF STEP]
have "integrable (count_space UNIV) (\<lambda>n. pmf (geometric_pmf p) n * real n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integrable (count_space UNIV) (\<lambda>n. pmf (local.geometric_pmf p) n * real n)
[PROOF STEP]
using * assms
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. (1 - p) ^ n * p * real n) sums ((1 - p) / p)
p \<in> {0<..1}

goal (1 subgoal):
 1. integrable (count_space UNIV) (\<lambda>n. pmf (local.geometric_pmf p) n * real n)
[PROOF STEP]
unfolding integrable_count_space_nat_iff
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. (1 - p) ^ n * p * real n) sums ((1 - p) / p)
p \<in> {0<..1}

goal (1 subgoal):
 1. summable (\<lambda>x. norm (pmf (local.geometric_pmf p) x * real x))
[PROOF STEP]
by (simp add: sums_iff)
[PROOF STATE]
proof (state)
this:
integrable (count_space UNIV) (\<lambda>n. pmf (local.geometric_pmf p) n * real n)

goal (1 subgoal):
 1. measure_pmf.expectation (local.geometric_pmf p) real = (1 - p) / p
[PROOF STEP]
hence "(\<integral>n. pmf (geometric_pmf p) n * real n \<partial>count_space UNIV) = (1 - p) / p"
[PROOF STATE]
proof (prove)
using this:
integrable (count_space UNIV) (\<lambda>n. pmf (local.geometric_pmf p) n * real n)

goal (1 subgoal):
 1. LINT n|count_space UNIV. pmf (local.geometric_pmf p) n * real n = (1 - p) / p
[PROOF STEP]
using * assms
[PROOF STATE]
proof (prove)
using this:
integrable (count_space UNIV) (\<lambda>n. pmf (local.geometric_pmf p) n * real n)
(\<lambda>n. (1 - p) ^ n * p * real n) sums ((1 - p) / p)
p \<in> {0<..1}

goal (1 subgoal):
 1. LINT n|count_space UNIV. pmf (local.geometric_pmf p) n * real n = (1 - p) / p
[PROOF STEP]
by (subst integral_count_space_nat) (simp_all add: sums_iff)
[PROOF STATE]
proof (state)
this:
LINT n|count_space UNIV. pmf (local.geometric_pmf p) n * real n = (1 - p) / p

goal (1 subgoal):
 1. measure_pmf.expectation (local.geometric_pmf p) real = (1 - p) / p
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
measure_pmf.expectation (local.geometric_pmf p) real = (1 - p) / p
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
measure_pmf.expectation (local.geometric_pmf p) real = (1 - p) / p

goal (1 subgoal):
 1. measure_pmf.expectation (local.geometric_pmf p) real = (1 - p) / p
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (local.geometric_pmf p) real = (1 - p) / p

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in complete_lattice) INF_set_fold:
  "\<Sqinter>(f ` set xs) = fold (inf \<circ> f) xs top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Sqinter> (f ` set xs) = fold ((\<sqinter>) \<circ> f) xs \<top>
[PROOF STEP]
using Inf_set_fold [of "map f xs"]
[PROOF STATE]
proof (prove)
using this:
\<Sqinter> set (map f xs) = fold (\<sqinter>) (map f xs) \<top>

goal (1 subgoal):
 1. \<Sqinter> (f ` set xs) = fold ((\<sqinter>) \<circ> f) xs \<top>
[PROOF STEP]
by (simp add: fold_map)