[STATEMENT]
lemma eq_lattice_imp_mat_mult_invertible_cols:
  assumes fs: "set fs \<subseteq> carrier_vec n"
  and gs: "set gs \<subseteq> carrier_vec n"  and ind_fs: "lin_indep fs" (*fs is a basis*)
  and length_fs: "length fs = n" and length_gs: "length gs = n" (*For the moment, only valid for square matrices*)
  and l: "lattice_of fs = lattice_of gs"
shows "\<exists>Q \<in> carrier_mat n n. invertible_mat Q \<and> mat_of_cols n fs = mat_of_cols n gs * Q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>Q\<in>carrier_mat n n. invertible_mat Q \<and> mat_of_cols n fs = mat_of_cols n gs * Q
[PROOF STEP]
proof (cases "n=0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 0 \<Longrightarrow> \<exists>Q\<in>carrier_mat n n. invertible_mat Q \<and> mat_of_cols n fs = mat_of_cols n gs * Q
 2. n \<noteq> 0 \<Longrightarrow> \<exists>Q\<in>carrier_mat n n. invertible_mat Q \<and> mat_of_cols n fs = mat_of_cols n gs * Q
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
n = 0

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> \<exists>Q\<in>carrier_mat n n. invertible_mat Q \<and> mat_of_cols n fs = mat_of_cols n gs * Q
 2. n \<noteq> 0 \<Longrightarrow> \<exists>Q\<in>carrier_mat n n. invertible_mat Q \<and> mat_of_cols n fs = mat_of_cols n gs * Q
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>Q\<in>carrier_mat n n. invertible_mat Q \<and> mat_of_cols n fs = mat_of_cols n gs * Q
[PROOF STEP]
by (rule bexI[of _ "1\<^sub>m 0"], insert True assms, auto)
[PROOF STATE]
proof (state)
this:
\<exists>Q\<in>carrier_mat n n. invertible_mat Q \<and> mat_of_cols n fs = mat_of_cols n gs * Q

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> \<exists>Q\<in>carrier_mat n n. invertible_mat Q \<and> mat_of_cols n fs = mat_of_cols n gs * Q
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> \<exists>Q\<in>carrier_mat n n. invertible_mat Q \<and> mat_of_cols n fs = mat_of_cols n gs * Q
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
n \<noteq> 0

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> \<exists>Q\<in>carrier_mat n n. invertible_mat Q \<and> mat_of_cols n fs = mat_of_cols n gs * Q
[PROOF STEP]
hence n: "0<n"
[PROOF STATE]
proof (prove)
using this:
n \<noteq> 0

goal (1 subgoal):
 1. 0 < n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 < n

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> \<exists>Q\<in>carrier_mat n n. invertible_mat Q \<and> mat_of_cols n fs = mat_of_cols n gs * Q
[PROOF STEP]
have ind_RAT_fs: "gs.lin_indpt (set (RAT fs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gs.lin_indpt (set (map of_int_hom.vec_hom fs))
[PROOF STEP]
using ind_fs
[PROOF STATE]
proof (prove)
using this:
gs.lin_indpt_list (map of_int_hom.vec_hom fs)

goal (1 subgoal):
 1. gs.lin_indpt (set (map of_int_hom.vec_hom fs))
[PROOF STEP]
by (simp add: cof_vec_space.lin_indpt_list_def)
[PROOF STATE]
proof (state)
this:
gs.lin_indpt (set (map of_int_hom.vec_hom fs))

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> \<exists>Q\<in>carrier_mat n n. invertible_mat Q \<and> mat_of_cols n fs = mat_of_cols n gs * Q
[PROOF STEP]
have fs_carrier: "mat_of_cols n fs \<in> carrier_mat n n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_of_cols n fs \<in> carrier_mat n n
[PROOF STEP]
by (simp add: length_fs carrier_matI)
[PROOF STATE]
proof (state)
this:
mat_of_cols n fs \<in> carrier_mat n n

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> \<exists>Q\<in>carrier_mat n n. invertible_mat Q \<and> mat_of_cols n fs = mat_of_cols n gs * Q
[PROOF STEP]
let ?f = "(\<lambda>i. SOME x. x\<in>carrier_vec (length gs) \<and> (mat_of_cols n gs) *\<^sub>v x = fs ! i)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> \<exists>Q\<in>carrier_mat n n. invertible_mat Q \<and> mat_of_cols n fs = mat_of_cols n gs * Q
[PROOF STEP]
let ?cols_Q = "map ?f [0..<length fs]"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> \<exists>Q\<in>carrier_mat n n. invertible_mat Q \<and> mat_of_cols n fs = mat_of_cols n gs * Q
[PROOF STEP]
let ?Q = "mat_of_cols n ?cols_Q"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> \<exists>Q\<in>carrier_mat n n. invertible_mat Q \<and> mat_of_cols n fs = mat_of_cols n gs * Q
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>Q\<in>carrier_mat n n. invertible_mat Q \<and> mat_of_cols n fs = mat_of_cols n gs * Q
[PROOF STEP]
proof (rule bexI[of _ ?Q], rule conjI)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME Q. Q \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v Q = fs ! i) [0..<length fs]))
 2. mat_of_cols n fs = mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME Q. Q \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v Q = fs ! i) [0..<length fs])
 3. mat_of_cols n (map (\<lambda>i. SOME Q. Q \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v Q = fs ! i) [0..<length fs]) \<in> carrier_mat n n
[PROOF STEP]
show Q: "?Q \<in> carrier_mat n n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) \<in> carrier_mat n n
[PROOF STEP]
using length_fs
[PROOF STATE]
proof (prove)
using this:
length fs = n

goal (1 subgoal):
 1. mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) \<in> carrier_mat n n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) \<in> carrier_mat n n

goal (2 subgoals):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME Q. Q \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v Q = fs ! i) [0..<length fs]))
 2. mat_of_cols n fs = mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME Q. Q \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v Q = fs ! i) [0..<length fs])
[PROOF STEP]
show fs_gs_Q: "mat_of_cols n fs = mat_of_cols n gs * ?Q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_of_cols n fs = mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])
[PROOF STEP]
proof (rule mat_col_eqI)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) \<Longrightarrow> col (mat_of_cols n fs) i = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) i
 2. dim_row (mat_of_cols n fs) = dim_row (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
 3. dim_col (mat_of_cols n fs) = dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
fix j
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) \<Longrightarrow> col (mat_of_cols n fs) i = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) i
 2. dim_row (mat_of_cols n fs) = dim_row (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
 3. dim_col (mat_of_cols n fs) = dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
assume j: "j < dim_col (mat_of_cols n gs * ?Q)"
[PROOF STATE]
proof (state)
this:
j < dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) \<Longrightarrow> col (mat_of_cols n fs) i = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) i
 2. dim_row (mat_of_cols n fs) = dim_row (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
 3. dim_col (mat_of_cols n fs) = dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
have j2: "j<n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. j < n
[PROOF STEP]
using j Q length_gs
[PROOF STATE]
proof (prove)
using this:
j < dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) \<in> carrier_mat n n
length gs = n

goal (1 subgoal):
 1. j < n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j < n

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) \<Longrightarrow> col (mat_of_cols n fs) i = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) i
 2. dim_row (mat_of_cols n fs) = dim_row (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
 3. dim_col (mat_of_cols n fs) = dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
have fs_j_in_gs: "fs ! j \<in> lattice_of gs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fs ! j \<in> lattice_of gs
[PROOF STEP]
using fs l basis_in_latticeI j
[PROOF STATE]
proof (prove)
using this:
set fs \<subseteq> carrier_vec n
lattice_of fs = lattice_of gs
\<lbrakk>set ?fs \<subseteq> carrier_vec n; ?f \<in> set ?fs\<rbrakk> \<Longrightarrow> ?f \<in> lattice_of ?fs
j < dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))

goal (1 subgoal):
 1. fs ! j \<in> lattice_of gs
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
fs ! j \<in> lattice_of gs

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) \<Longrightarrow> col (mat_of_cols n fs) i = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) i
 2. dim_row (mat_of_cols n fs) = dim_row (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
 3. dim_col (mat_of_cols n fs) = dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
have fs_j_carrier_vec: "fs ! j \<in> carrier_vec n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fs ! j \<in> carrier_vec n
[PROOF STEP]
using fs_j_in_gs gs lattice_of_as_mat_mult
[PROOF STATE]
proof (prove)
using this:
fs ! j \<in> lattice_of gs
set gs \<subseteq> carrier_vec n
set ?fs \<subseteq> carrier_vec ?n \<Longrightarrow> vec_module.lattice_of ?n ?fs = {y \<in> carrier_vec ?n. \<exists>x\<in>carrier_vec (length ?fs). mat_of_cols ?n ?fs *\<^sub>v x = y}

goal (1 subgoal):
 1. fs ! j \<in> carrier_vec n
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
fs ! j \<in> carrier_vec n

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) \<Longrightarrow> col (mat_of_cols n fs) i = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) i
 2. dim_row (mat_of_cols n fs) = dim_row (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
 3. dim_col (mat_of_cols n fs) = dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
let ?x = "SOME x. x\<in>carrier_vec (length gs) \<and> (mat_of_cols n gs) *\<^sub>v x = fs ! j"
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) \<Longrightarrow> col (mat_of_cols n fs) i = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) i
 2. dim_row (mat_of_cols n fs) = dim_row (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
 3. dim_col (mat_of_cols n fs) = dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
have "?x\<in>carrier_vec (length gs) \<and> (mat_of_cols n gs) *\<^sub>v ?x = fs ! j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j) \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j) = fs ! j
[PROOF STEP]
by (rule someI_ex, insert fs_j_in_gs lattice_of_as_mat_mult[OF gs], auto)
[PROOF STATE]
proof (state)
this:
(SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j) \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j) = fs ! j

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) \<Longrightarrow> col (mat_of_cols n fs) i = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) i
 2. dim_row (mat_of_cols n fs) = dim_row (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
 3. dim_col (mat_of_cols n fs) = dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
hence x: "?x \<in> carrier_vec (length gs)"
        and gs_x: "(mat_of_cols n gs) *\<^sub>v ?x = fs ! j"
[PROOF STATE]
proof (prove)
using this:
(SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j) \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j) = fs ! j

goal (1 subgoal):
 1. (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j) \<in> carrier_vec (length gs) &&& mat_of_cols n gs *\<^sub>v (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j) = fs ! j
[PROOF STEP]
by blast+
[PROOF STATE]
proof (state)
this:
(SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j) \<in> carrier_vec (length gs)
mat_of_cols n gs *\<^sub>v (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j) = fs ! j

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) \<Longrightarrow> col (mat_of_cols n fs) i = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) i
 2. dim_row (mat_of_cols n fs) = dim_row (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
 3. dim_col (mat_of_cols n fs) = dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
have "col ?Q j = ?cols_Q ! j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. col (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) j = map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs] ! j
[PROOF STEP]
proof (rule col_mat_of_cols)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. j < length (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])
 2. map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs] ! j \<in> carrier_vec n
[PROOF STEP]
show "j < length (map ?f [0..<length fs])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. j < length (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])
[PROOF STEP]
using length_fs j2
[PROOF STATE]
proof (prove)
using this:
length fs = n
j < n

goal (1 subgoal):
 1. j < length (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j < length (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])

goal (1 subgoal):
 1. map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs] ! j \<in> carrier_vec n
[PROOF STEP]
have "map ?f [0..<length fs] ! j = ?f ([0..<length fs] ! j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs] ! j = (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! ([0..<length fs] ! j))
[PROOF STEP]
by (rule nth_map, insert j2 length_fs, auto)
[PROOF STATE]
proof (state)
this:
map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs] ! j = (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! ([0..<length fs] ! j))

goal (1 subgoal):
 1. map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs] ! j \<in> carrier_vec n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs] ! j = (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! ([0..<length fs] ! j))

goal (1 subgoal):
 1. map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs] ! j \<in> carrier_vec n
[PROOF STEP]
have "... = ?f j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! ([0..<length fs] ! j)) = (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j)
[PROOF STEP]
by (simp add: length_fs j2)
[PROOF STATE]
proof (state)
this:
(SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! ([0..<length fs] ! j)) = (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j)

goal (1 subgoal):
 1. map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs] ! j \<in> carrier_vec n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! ([0..<length fs] ! j)) = (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j)

goal (1 subgoal):
 1. map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs] ! j \<in> carrier_vec n
[PROOF STEP]
have "... \<in> carrier_vec n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j) \<in> carrier_vec n
[PROOF STEP]
using x length_gs
[PROOF STATE]
proof (prove)
using this:
(SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j) \<in> carrier_vec (length gs)
length gs = n

goal (1 subgoal):
 1. (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j) \<in> carrier_vec n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j) \<in> carrier_vec n

goal (1 subgoal):
 1. map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs] ! j \<in> carrier_vec n
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs] ! j \<in> carrier_vec n
[PROOF STEP]
show "map ?f [0..<length fs] ! j \<in> carrier_vec n"
[PROOF STATE]
proof (prove)
using this:
map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs] ! j \<in> carrier_vec n

goal (1 subgoal):
 1. map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs] ! j \<in> carrier_vec n
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs] ! j \<in> carrier_vec n

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
col (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) j = map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs] ! j

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) \<Longrightarrow> col (mat_of_cols n fs) i = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) i
 2. dim_row (mat_of_cols n fs) = dim_row (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
 3. dim_col (mat_of_cols n fs) = dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
col (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) j = map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs] ! j

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) \<Longrightarrow> col (mat_of_cols n fs) i = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) i
 2. dim_row (mat_of_cols n fs) = dim_row (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
 3. dim_col (mat_of_cols n fs) = dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
have "... = ?f ([0..<length fs] ! j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs] ! j = (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! ([0..<length fs] ! j))
[PROOF STEP]
by (rule nth_map, insert j2 length_fs, auto)
[PROOF STATE]
proof (state)
this:
map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs] ! j = (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! ([0..<length fs] ! j))

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) \<Longrightarrow> col (mat_of_cols n fs) i = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) i
 2. dim_row (mat_of_cols n fs) = dim_row (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
 3. dim_col (mat_of_cols n fs) = dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs] ! j = (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! ([0..<length fs] ! j))

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) \<Longrightarrow> col (mat_of_cols n fs) i = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) i
 2. dim_row (mat_of_cols n fs) = dim_row (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
 3. dim_col (mat_of_cols n fs) = dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
have "... = ?x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! ([0..<length fs] ! j)) = (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j)
[PROOF STEP]
by (simp add: length_fs j2)
[PROOF STATE]
proof (state)
this:
(SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! ([0..<length fs] ! j)) = (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j)

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) \<Longrightarrow> col (mat_of_cols n fs) i = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) i
 2. dim_row (mat_of_cols n fs) = dim_row (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
 3. dim_col (mat_of_cols n fs) = dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
col (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) j = (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j)
[PROOF STEP]
have col_Qj_x: "col ?Q j = ?x"
[PROOF STATE]
proof (prove)
using this:
col (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) j = (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j)

goal (1 subgoal):
 1. col (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) j = (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
col (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) j = (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j)

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) \<Longrightarrow> col (mat_of_cols n fs) i = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) i
 2. dim_row (mat_of_cols n fs) = dim_row (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
 3. dim_col (mat_of_cols n fs) = dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
have "col (mat_of_cols n fs) j = fs ! j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. col (mat_of_cols n fs) j = fs ! j
[PROOF STEP]
by (metis (no_types, lifting) j Q fs length_fs carrier_matD(2) cols_mat_of_cols cols_nth
            index_mult_mat(3) mat_of_cols_carrier(3))
[PROOF STATE]
proof (state)
this:
col (mat_of_cols n fs) j = fs ! j

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) \<Longrightarrow> col (mat_of_cols n fs) i = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) i
 2. dim_row (mat_of_cols n fs) = dim_row (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
 3. dim_col (mat_of_cols n fs) = dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
col (mat_of_cols n fs) j = fs ! j

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) \<Longrightarrow> col (mat_of_cols n fs) i = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) i
 2. dim_row (mat_of_cols n fs) = dim_row (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
 3. dim_col (mat_of_cols n fs) = dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
have "... = (mat_of_cols n gs) *\<^sub>v ?x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fs ! j = mat_of_cols n gs *\<^sub>v (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j)
[PROOF STEP]
using gs_x
[PROOF STATE]
proof (prove)
using this:
mat_of_cols n gs *\<^sub>v (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j) = fs ! j

goal (1 subgoal):
 1. fs ! j = mat_of_cols n gs *\<^sub>v (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
fs ! j = mat_of_cols n gs *\<^sub>v (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j)

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) \<Longrightarrow> col (mat_of_cols n fs) i = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) i
 2. dim_row (mat_of_cols n fs) = dim_row (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
 3. dim_col (mat_of_cols n fs) = dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
fs ! j = mat_of_cols n gs *\<^sub>v (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j)

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) \<Longrightarrow> col (mat_of_cols n fs) i = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) i
 2. dim_row (mat_of_cols n fs) = dim_row (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
 3. dim_col (mat_of_cols n fs) = dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
have "... = (mat_of_cols n gs) *\<^sub>v (col ?Q j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_of_cols n gs *\<^sub>v (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j) = mat_of_cols n gs *\<^sub>v col (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) j
[PROOF STEP]
unfolding col_Qj_x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_of_cols n gs *\<^sub>v (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j) = mat_of_cols n gs *\<^sub>v (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
mat_of_cols n gs *\<^sub>v (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j) = mat_of_cols n gs *\<^sub>v col (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) j

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) \<Longrightarrow> col (mat_of_cols n fs) i = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) i
 2. dim_row (mat_of_cols n fs) = dim_row (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
 3. dim_col (mat_of_cols n fs) = dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
mat_of_cols n gs *\<^sub>v (SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! j) = mat_of_cols n gs *\<^sub>v col (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) j

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) \<Longrightarrow> col (mat_of_cols n fs) i = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) i
 2. dim_row (mat_of_cols n fs) = dim_row (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
 3. dim_col (mat_of_cols n fs) = dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
have "... = col (mat_of_cols n gs * ?Q) j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_of_cols n gs *\<^sub>v col (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) j = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) j
[PROOF STEP]
by (rule col_mult2[symmetric, OF _ Q j2], insert length_gs mat_of_cols_def, auto)
[PROOF STATE]
proof (state)
this:
mat_of_cols n gs *\<^sub>v col (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) j = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) j

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) \<Longrightarrow> col (mat_of_cols n fs) i = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) i
 2. dim_row (mat_of_cols n fs) = dim_row (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
 3. dim_col (mat_of_cols n fs) = dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
col (mat_of_cols n fs) j = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) j
[PROOF STEP]
show "col (mat_of_cols n fs) j = col (mat_of_cols n gs * ?Q) j"
[PROOF STATE]
proof (prove)
using this:
col (mat_of_cols n fs) j = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) j

goal (1 subgoal):
 1. col (mat_of_cols n fs) j = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) j
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
col (mat_of_cols n fs) j = col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) j

goal (2 subgoals):
 1. dim_row (mat_of_cols n fs) = dim_row (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
 2. dim_col (mat_of_cols n fs) = dim_col (mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
qed (insert length_gs gs, auto)
[PROOF STATE]
proof (state)
this:
mat_of_cols n fs = mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])

goal (1 subgoal):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME Q. Q \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v Q = fs ! i) [0..<length fs]))
[PROOF STEP]
show "invertible_mat ?Q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
(* Sketch of the proof:
      1) fs = gs * Q, proved previously
      2) gs = fs * Q', similar proof as the previous one.
      3) fs = fs * Q' * Q
      4) fs * (?Q' * ?Q - 1\<^sub>m n) = 0\<^sub>m n n and hence (?Q' * ?Q - 1\<^sub>m n) = 0 since fs independent
      5) det ?Q' = det ?Q = det 1 = 1, then det ?Q = \<plusminus>1 and ?Q invertible since the determinant
         divides a unit.
    *)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
let ?f' = "(\<lambda>i. SOME x. x\<in>carrier_vec (length fs) \<and> (mat_of_cols n fs) *\<^sub>v x = gs ! i)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
let ?cols_Q' = "map ?f' [0..<length gs]"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
let ?Q' = "mat_of_cols n ?cols_Q'"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
have Q': "?Q' \<in> carrier_mat n n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) \<in> carrier_mat n n
[PROOF STEP]
using length_gs
[PROOF STATE]
proof (prove)
using this:
length gs = n

goal (1 subgoal):
 1. mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) \<in> carrier_mat n n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) \<in> carrier_mat n n

goal (1 subgoal):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
have gs_fs_Q': "mat_of_cols n gs = mat_of_cols n fs * ?Q'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_of_cols n gs = mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])
[PROOF STEP]
proof (rule mat_col_eqI)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) \<Longrightarrow> col (mat_of_cols n gs) i = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) i
 2. dim_row (mat_of_cols n gs) = dim_row (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
 3. dim_col (mat_of_cols n gs) = dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
[PROOF STEP]
fix j
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) \<Longrightarrow> col (mat_of_cols n gs) i = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) i
 2. dim_row (mat_of_cols n gs) = dim_row (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
 3. dim_col (mat_of_cols n gs) = dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
[PROOF STEP]
assume j: "j < dim_col (mat_of_cols n fs * ?Q')"
[PROOF STATE]
proof (state)
this:
j < dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) \<Longrightarrow> col (mat_of_cols n gs) i = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) i
 2. dim_row (mat_of_cols n gs) = dim_row (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
 3. dim_col (mat_of_cols n gs) = dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
[PROOF STEP]
have j2: "j<n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. j < n
[PROOF STEP]
using j Q length_gs
[PROOF STATE]
proof (prove)
using this:
j < dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) \<in> carrier_mat n n
length gs = n

goal (1 subgoal):
 1. j < n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j < n

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) \<Longrightarrow> col (mat_of_cols n gs) i = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) i
 2. dim_row (mat_of_cols n gs) = dim_row (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
 3. dim_col (mat_of_cols n gs) = dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
[PROOF STEP]
have gs_j_in_fs: "gs ! j \<in> lattice_of fs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gs ! j \<in> lattice_of fs
[PROOF STEP]
using gs l basis_in_latticeI j
[PROOF STATE]
proof (prove)
using this:
set gs \<subseteq> carrier_vec n
lattice_of fs = lattice_of gs
\<lbrakk>set ?fs \<subseteq> carrier_vec n; ?f \<in> set ?fs\<rbrakk> \<Longrightarrow> ?f \<in> lattice_of ?fs
j < dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))

goal (1 subgoal):
 1. gs ! j \<in> lattice_of fs
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
gs ! j \<in> lattice_of fs

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) \<Longrightarrow> col (mat_of_cols n gs) i = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) i
 2. dim_row (mat_of_cols n gs) = dim_row (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
 3. dim_col (mat_of_cols n gs) = dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
[PROOF STEP]
have gs_j_carrier_vec: "gs ! j \<in> carrier_vec n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gs ! j \<in> carrier_vec n
[PROOF STEP]
using gs_j_in_fs fs lattice_of_as_mat_mult
[PROOF STATE]
proof (prove)
using this:
gs ! j \<in> lattice_of fs
set fs \<subseteq> carrier_vec n
set ?fs \<subseteq> carrier_vec ?n \<Longrightarrow> vec_module.lattice_of ?n ?fs = {y \<in> carrier_vec ?n. \<exists>x\<in>carrier_vec (length ?fs). mat_of_cols ?n ?fs *\<^sub>v x = y}

goal (1 subgoal):
 1. gs ! j \<in> carrier_vec n
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
gs ! j \<in> carrier_vec n

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) \<Longrightarrow> col (mat_of_cols n gs) i = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) i
 2. dim_row (mat_of_cols n gs) = dim_row (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
 3. dim_col (mat_of_cols n gs) = dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
[PROOF STEP]
let ?x = "SOME x. x\<in>carrier_vec (length fs) \<and> (mat_of_cols n fs) *\<^sub>v x = gs ! j"
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) \<Longrightarrow> col (mat_of_cols n gs) i = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) i
 2. dim_row (mat_of_cols n gs) = dim_row (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
 3. dim_col (mat_of_cols n gs) = dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
[PROOF STEP]
have "?x\<in>carrier_vec (length fs) \<and> (mat_of_cols n fs) *\<^sub>v ?x = gs ! j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j) \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j) = gs ! j
[PROOF STEP]
by (rule someI_ex, insert gs_j_in_fs lattice_of_as_mat_mult[OF fs], auto)
[PROOF STATE]
proof (state)
this:
(SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j) \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j) = gs ! j

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) \<Longrightarrow> col (mat_of_cols n gs) i = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) i
 2. dim_row (mat_of_cols n gs) = dim_row (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
 3. dim_col (mat_of_cols n gs) = dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
[PROOF STEP]
hence x: "?x \<in> carrier_vec (length fs)"
          and fs_x: "(mat_of_cols n fs) *\<^sub>v ?x = gs ! j"
[PROOF STATE]
proof (prove)
using this:
(SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j) \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j) = gs ! j

goal (1 subgoal):
 1. (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j) \<in> carrier_vec (length fs) &&& mat_of_cols n fs *\<^sub>v (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j) = gs ! j
[PROOF STEP]
by blast+
[PROOF STATE]
proof (state)
this:
(SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j) \<in> carrier_vec (length fs)
mat_of_cols n fs *\<^sub>v (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j) = gs ! j

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) \<Longrightarrow> col (mat_of_cols n gs) i = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) i
 2. dim_row (mat_of_cols n gs) = dim_row (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
 3. dim_col (mat_of_cols n gs) = dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
[PROOF STEP]
have "col ?Q' j = ?cols_Q' ! j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. col (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) j = map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs] ! j
[PROOF STEP]
proof (rule col_mat_of_cols)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. j < length (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])
 2. map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs] ! j \<in> carrier_vec n
[PROOF STEP]
show "j < length (map ?f' [0..<length gs])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. j < length (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])
[PROOF STEP]
using length_gs j2
[PROOF STATE]
proof (prove)
using this:
length gs = n
j < n

goal (1 subgoal):
 1. j < length (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j < length (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])

goal (1 subgoal):
 1. map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs] ! j \<in> carrier_vec n
[PROOF STEP]
have "map ?f' [0..<length gs] ! j = ?f' ([0..<length gs] ! j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs] ! j = (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! ([0..<length gs] ! j))
[PROOF STEP]
by (rule nth_map, insert j2 length_gs, auto)
[PROOF STATE]
proof (state)
this:
map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs] ! j = (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! ([0..<length gs] ! j))

goal (1 subgoal):
 1. map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs] ! j \<in> carrier_vec n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs] ! j = (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! ([0..<length gs] ! j))

goal (1 subgoal):
 1. map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs] ! j \<in> carrier_vec n
[PROOF STEP]
have "... = ?f' j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! ([0..<length gs] ! j)) = (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j)
[PROOF STEP]
by (simp add: length_gs j2)
[PROOF STATE]
proof (state)
this:
(SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! ([0..<length gs] ! j)) = (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j)

goal (1 subgoal):
 1. map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs] ! j \<in> carrier_vec n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! ([0..<length gs] ! j)) = (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j)

goal (1 subgoal):
 1. map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs] ! j \<in> carrier_vec n
[PROOF STEP]
have "... \<in> carrier_vec n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j) \<in> carrier_vec n
[PROOF STEP]
using x length_fs
[PROOF STATE]
proof (prove)
using this:
(SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j) \<in> carrier_vec (length fs)
length fs = n

goal (1 subgoal):
 1. (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j) \<in> carrier_vec n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j) \<in> carrier_vec n

goal (1 subgoal):
 1. map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs] ! j \<in> carrier_vec n
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs] ! j \<in> carrier_vec n
[PROOF STEP]
show "map ?f' [0..<length gs] ! j \<in> carrier_vec n"
[PROOF STATE]
proof (prove)
using this:
map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs] ! j \<in> carrier_vec n

goal (1 subgoal):
 1. map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs] ! j \<in> carrier_vec n
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs] ! j \<in> carrier_vec n

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
col (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) j = map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs] ! j

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) \<Longrightarrow> col (mat_of_cols n gs) i = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) i
 2. dim_row (mat_of_cols n gs) = dim_row (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
 3. dim_col (mat_of_cols n gs) = dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
col (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) j = map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs] ! j

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) \<Longrightarrow> col (mat_of_cols n gs) i = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) i
 2. dim_row (mat_of_cols n gs) = dim_row (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
 3. dim_col (mat_of_cols n gs) = dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
[PROOF STEP]
have "... = ?f' ([0..<length gs] ! j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs] ! j = (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! ([0..<length gs] ! j))
[PROOF STEP]
by (rule nth_map, insert j2 length_gs, auto)
[PROOF STATE]
proof (state)
this:
map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs] ! j = (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! ([0..<length gs] ! j))

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) \<Longrightarrow> col (mat_of_cols n gs) i = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) i
 2. dim_row (mat_of_cols n gs) = dim_row (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
 3. dim_col (mat_of_cols n gs) = dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs] ! j = (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! ([0..<length gs] ! j))

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) \<Longrightarrow> col (mat_of_cols n gs) i = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) i
 2. dim_row (mat_of_cols n gs) = dim_row (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
 3. dim_col (mat_of_cols n gs) = dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
[PROOF STEP]
have "... = ?x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! ([0..<length gs] ! j)) = (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j)
[PROOF STEP]
by (simp add: length_gs j2)
[PROOF STATE]
proof (state)
this:
(SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! ([0..<length gs] ! j)) = (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j)

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) \<Longrightarrow> col (mat_of_cols n gs) i = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) i
 2. dim_row (mat_of_cols n gs) = dim_row (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
 3. dim_col (mat_of_cols n gs) = dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
col (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) j = (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j)
[PROOF STEP]
have col_Qj_x: "col ?Q' j = ?x"
[PROOF STATE]
proof (prove)
using this:
col (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) j = (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j)

goal (1 subgoal):
 1. col (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) j = (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
col (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) j = (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j)

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) \<Longrightarrow> col (mat_of_cols n gs) i = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) i
 2. dim_row (mat_of_cols n gs) = dim_row (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
 3. dim_col (mat_of_cols n gs) = dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
[PROOF STEP]
have "col (mat_of_cols n gs) j = gs ! j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. col (mat_of_cols n gs) j = gs ! j
[PROOF STEP]
by (simp add: length_gs gs_j_carrier_vec j2)
[PROOF STATE]
proof (state)
this:
col (mat_of_cols n gs) j = gs ! j

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) \<Longrightarrow> col (mat_of_cols n gs) i = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) i
 2. dim_row (mat_of_cols n gs) = dim_row (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
 3. dim_col (mat_of_cols n gs) = dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
col (mat_of_cols n gs) j = gs ! j

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) \<Longrightarrow> col (mat_of_cols n gs) i = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) i
 2. dim_row (mat_of_cols n gs) = dim_row (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
 3. dim_col (mat_of_cols n gs) = dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
[PROOF STEP]
have "... = (mat_of_cols n fs) *\<^sub>v ?x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gs ! j = mat_of_cols n fs *\<^sub>v (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j)
[PROOF STEP]
using fs_x
[PROOF STATE]
proof (prove)
using this:
mat_of_cols n fs *\<^sub>v (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j) = gs ! j

goal (1 subgoal):
 1. gs ! j = mat_of_cols n fs *\<^sub>v (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
gs ! j = mat_of_cols n fs *\<^sub>v (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j)

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) \<Longrightarrow> col (mat_of_cols n gs) i = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) i
 2. dim_row (mat_of_cols n gs) = dim_row (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
 3. dim_col (mat_of_cols n gs) = dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
gs ! j = mat_of_cols n fs *\<^sub>v (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j)

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) \<Longrightarrow> col (mat_of_cols n gs) i = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) i
 2. dim_row (mat_of_cols n gs) = dim_row (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
 3. dim_col (mat_of_cols n gs) = dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
[PROOF STEP]
have "... = (mat_of_cols n fs) *\<^sub>v (col ?Q' j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_of_cols n fs *\<^sub>v (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j) = mat_of_cols n fs *\<^sub>v col (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) j
[PROOF STEP]
unfolding col_Qj_x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_of_cols n fs *\<^sub>v (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j) = mat_of_cols n fs *\<^sub>v (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
mat_of_cols n fs *\<^sub>v (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j) = mat_of_cols n fs *\<^sub>v col (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) j

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) \<Longrightarrow> col (mat_of_cols n gs) i = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) i
 2. dim_row (mat_of_cols n gs) = dim_row (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
 3. dim_col (mat_of_cols n gs) = dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
mat_of_cols n fs *\<^sub>v (SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! j) = mat_of_cols n fs *\<^sub>v col (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) j

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) \<Longrightarrow> col (mat_of_cols n gs) i = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) i
 2. dim_row (mat_of_cols n gs) = dim_row (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
 3. dim_col (mat_of_cols n gs) = dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
[PROOF STEP]
have "... = col (mat_of_cols n fs * ?Q') j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_of_cols n fs *\<^sub>v col (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) j = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) j
[PROOF STEP]
by (rule col_mult2[symmetric, OF _ Q' j2], insert length_fs mat_of_cols_def, auto)
[PROOF STATE]
proof (state)
this:
mat_of_cols n fs *\<^sub>v col (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) j = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) j

goal (3 subgoals):
 1. \<And>i. i < dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) \<Longrightarrow> col (mat_of_cols n gs) i = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) i
 2. dim_row (mat_of_cols n gs) = dim_row (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
 3. dim_col (mat_of_cols n gs) = dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
col (mat_of_cols n gs) j = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) j
[PROOF STEP]
show "col (mat_of_cols n gs) j = col (mat_of_cols n fs * ?Q') j"
[PROOF STATE]
proof (prove)
using this:
col (mat_of_cols n gs) j = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) j

goal (1 subgoal):
 1. col (mat_of_cols n gs) j = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) j
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
col (mat_of_cols n gs) j = col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) j

goal (2 subgoals):
 1. dim_row (mat_of_cols n gs) = dim_row (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
 2. dim_col (mat_of_cols n gs) = dim_col (mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]))
[PROOF STEP]
qed (insert length_fs fs, auto)
[PROOF STATE]
proof (state)
this:
mat_of_cols n gs = mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])

goal (1 subgoal):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
have det_fs_not_zero: "rat_of_int (det (mat_of_cols n fs)) \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rat_of_int (det (mat_of_cols n fs)) \<noteq> 0
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. rat_of_int (det (mat_of_cols n fs)) \<noteq> 0
[PROOF STEP]
let ?A = "(of_int_hom.mat_hom (mat_of_cols n fs)):: rat mat"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. rat_of_int (det (mat_of_cols n fs)) \<noteq> 0
[PROOF STEP]
have "rat_of_int (det (mat_of_cols n fs)) = det ?A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rat_of_int (det (mat_of_cols n fs)) = det (of_int_hom.mat_hom (mat_of_cols n fs))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
rat_of_int (det (mat_of_cols n fs)) = det (of_int_hom.mat_hom (mat_of_cols n fs))

goal (1 subgoal):
 1. rat_of_int (det (mat_of_cols n fs)) \<noteq> 0
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
rat_of_int (det (mat_of_cols n fs)) = det (of_int_hom.mat_hom (mat_of_cols n fs))

goal (1 subgoal):
 1. rat_of_int (det (mat_of_cols n fs)) \<noteq> 0
[PROOF STEP]
have "det ?A \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (of_int_hom.mat_hom (mat_of_cols n fs)) \<noteq> 0
[PROOF STEP]
proof (rule gs.lin_indpt_cols_imp_det_not_0[of ?A])
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. of_int_hom.mat_hom (mat_of_cols n fs) \<in> carrier_mat n n
 2. gs.lin_indpt (set (cols (of_int_hom.mat_hom (mat_of_cols n fs))))
 3. distinct (cols (of_int_hom.mat_hom (mat_of_cols n fs)))
[PROOF STEP]
have c_eq: "(set (cols ?A)) = set (RAT fs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (cols (of_int_hom.mat_hom (mat_of_cols n fs))) = set (map of_int_hom.vec_hom fs)
[PROOF STEP]
by (metis assms(3) cof_vec_space.lin_indpt_list_def cols_mat_of_cols fs mat_of_cols_map)
[PROOF STATE]
proof (state)
this:
set (cols (of_int_hom.mat_hom (mat_of_cols n fs))) = set (map of_int_hom.vec_hom fs)

goal (3 subgoals):
 1. of_int_hom.mat_hom (mat_of_cols n fs) \<in> carrier_mat n n
 2. gs.lin_indpt (set (cols (of_int_hom.mat_hom (mat_of_cols n fs))))
 3. distinct (cols (of_int_hom.mat_hom (mat_of_cols n fs)))
[PROOF STEP]
show "?A \<in> carrier_mat n n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_int_hom.mat_hom (mat_of_cols n fs) \<in> carrier_mat n n
[PROOF STEP]
by (simp add: fs_carrier)
[PROOF STATE]
proof (state)
this:
of_int_hom.mat_hom (mat_of_cols n fs) \<in> carrier_mat n n

goal (2 subgoals):
 1. gs.lin_indpt (set (cols (of_int_hom.mat_hom (mat_of_cols n fs))))
 2. distinct (cols (of_int_hom.mat_hom (mat_of_cols n fs)))
[PROOF STEP]
show "gs.lin_indpt (set (cols ?A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gs.lin_indpt (set (cols (of_int_hom.mat_hom (mat_of_cols n fs))))
[PROOF STEP]
using ind_RAT_fs c_eq
[PROOF STATE]
proof (prove)
using this:
gs.lin_indpt (set (map of_int_hom.vec_hom fs))
set (cols (of_int_hom.mat_hom (mat_of_cols n fs))) = set (map of_int_hom.vec_hom fs)

goal (1 subgoal):
 1. gs.lin_indpt (set (cols (of_int_hom.mat_hom (mat_of_cols n fs))))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
gs.lin_indpt (set (cols (of_int_hom.mat_hom (mat_of_cols n fs))))

goal (1 subgoal):
 1. distinct (cols (of_int_hom.mat_hom (mat_of_cols n fs)))
[PROOF STEP]
show "distinct (cols ?A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct (cols (of_int_hom.mat_hom (mat_of_cols n fs)))
[PROOF STEP]
by (metis ind_fs cof_vec_space.lin_indpt_list_def cols_mat_of_cols fs mat_of_cols_map)
[PROOF STATE]
proof (state)
this:
distinct (cols (of_int_hom.mat_hom (mat_of_cols n fs)))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
det (of_int_hom.mat_hom (mat_of_cols n fs)) \<noteq> 0

goal (1 subgoal):
 1. rat_of_int (det (mat_of_cols n fs)) \<noteq> 0
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
rat_of_int (det (mat_of_cols n fs)) = det (of_int_hom.mat_hom (mat_of_cols n fs))
det (of_int_hom.mat_hom (mat_of_cols n fs)) \<noteq> 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
rat_of_int (det (mat_of_cols n fs)) = det (of_int_hom.mat_hom (mat_of_cols n fs))
det (of_int_hom.mat_hom (mat_of_cols n fs)) \<noteq> 0

goal (1 subgoal):
 1. rat_of_int (det (mat_of_cols n fs)) \<noteq> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
rat_of_int (det (mat_of_cols n fs)) \<noteq> 0

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
rat_of_int (det (mat_of_cols n fs)) \<noteq> 0

goal (1 subgoal):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
have Q'Q: "?Q' * ?Q \<in> carrier_mat n n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) \<in> carrier_mat n n
[PROOF STEP]
using Q Q' mult_carrier_mat
[PROOF STATE]
proof (prove)
using this:
mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) \<in> carrier_mat n n
mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) \<in> carrier_mat n n
\<lbrakk>?A \<in> carrier_mat ?nr ?n; ?B \<in> carrier_mat ?n ?nc\<rbrakk> \<Longrightarrow> ?A * ?B \<in> carrier_mat ?nr ?nc

goal (1 subgoal):
 1. mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) \<in> carrier_mat n n
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) \<in> carrier_mat n n

goal (1 subgoal):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
have fs_fs_Q'Q: "mat_of_cols n fs = mat_of_cols n fs * ?Q' * ?Q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_of_cols n fs = mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])
[PROOF STEP]
using gs_fs_Q' fs_gs_Q
[PROOF STATE]
proof (prove)
using this:
mat_of_cols n gs = mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])
mat_of_cols n fs = mat_of_cols n gs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])

goal (1 subgoal):
 1. mat_of_cols n fs = mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
mat_of_cols n fs = mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])

goal (1 subgoal):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
hence "0\<^sub>m n n = mat_of_cols n fs * ?Q' * ?Q - mat_of_cols n fs"
[PROOF STATE]
proof (prove)
using this:
mat_of_cols n fs = mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])

goal (1 subgoal):
 1. 0\<^sub>m n n = mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) - mat_of_cols n fs
[PROOF STEP]
using length_fs
[PROOF STATE]
proof (prove)
using this:
mat_of_cols n fs = mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])
length fs = n

goal (1 subgoal):
 1. 0\<^sub>m n n = mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) - mat_of_cols n fs
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0\<^sub>m n n = mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) - mat_of_cols n fs

goal (1 subgoal):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
0\<^sub>m n n = mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) - mat_of_cols n fs

goal (1 subgoal):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
have "... = mat_of_cols n fs * ?Q' * ?Q - mat_of_cols n fs * 1\<^sub>m n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) - mat_of_cols n fs = mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) - mat_of_cols n fs * 1\<^sub>m n
[PROOF STEP]
using fs_carrier
[PROOF STATE]
proof (prove)
using this:
mat_of_cols n fs \<in> carrier_mat n n

goal (1 subgoal):
 1. mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) - mat_of_cols n fs = mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) - mat_of_cols n fs * 1\<^sub>m n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) - mat_of_cols n fs = mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) - mat_of_cols n fs * 1\<^sub>m n

goal (1 subgoal):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) - mat_of_cols n fs = mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) - mat_of_cols n fs * 1\<^sub>m n

goal (1 subgoal):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
have "... = mat_of_cols n fs * (?Q' * ?Q) - mat_of_cols n fs * 1\<^sub>m n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) - mat_of_cols n fs * 1\<^sub>m n = mat_of_cols n fs * (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) - mat_of_cols n fs * 1\<^sub>m n
[PROOF STEP]
using Q Q' fs_carrier
[PROOF STATE]
proof (prove)
using this:
mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) \<in> carrier_mat n n
mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) \<in> carrier_mat n n
mat_of_cols n fs \<in> carrier_mat n n

goal (1 subgoal):
 1. mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) - mat_of_cols n fs * 1\<^sub>m n = mat_of_cols n fs * (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) - mat_of_cols n fs * 1\<^sub>m n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) - mat_of_cols n fs * 1\<^sub>m n = mat_of_cols n fs * (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) - mat_of_cols n fs * 1\<^sub>m n

goal (1 subgoal):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
mat_of_cols n fs * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) - mat_of_cols n fs * 1\<^sub>m n = mat_of_cols n fs * (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) - mat_of_cols n fs * 1\<^sub>m n

goal (1 subgoal):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
have "... = mat_of_cols n fs * (?Q' * ?Q - 1\<^sub>m n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_of_cols n fs * (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) - mat_of_cols n fs * 1\<^sub>m n = mat_of_cols n fs * (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) - 1\<^sub>m n)
[PROOF STEP]
by (rule mult_minus_distrib_mat[symmetric, OF fs_carrier Q'Q], auto)
[PROOF STATE]
proof (state)
this:
mat_of_cols n fs * (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) - mat_of_cols n fs * 1\<^sub>m n = mat_of_cols n fs * (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) - 1\<^sub>m n)

goal (1 subgoal):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
0\<^sub>m n n = mat_of_cols n fs * (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) - 1\<^sub>m n)
[PROOF STEP]
have "mat_of_cols n fs * (?Q' * ?Q - 1\<^sub>m n) = 0\<^sub>m n n"
[PROOF STATE]
proof (prove)
using this:
0\<^sub>m n n = mat_of_cols n fs * (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) - 1\<^sub>m n)

goal (1 subgoal):
 1. mat_of_cols n fs * (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) - 1\<^sub>m n) = 0\<^sub>m n n
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
mat_of_cols n fs * (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]) - 1\<^sub>m n) = 0\<^sub>m n n

goal (1 subgoal):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
have "det (?Q' * ?Q) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) = 1
[PROOF STEP]
by (smt Determinant.det_mult Q Q' Q'Q fs_fs_Q'Q assoc_mult_mat det_fs_not_zero
            fs_carrier mult_cancel_left2 of_int_code(2))
[PROOF STATE]
proof (state)
this:
det (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) = 1

goal (1 subgoal):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
hence det_Q'_Q_1: "det ?Q * det ?Q' = 1"
[PROOF STATE]
proof (prove)
using this:
det (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs]) * mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) = 1

goal (1 subgoal):
 1. det (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) * det (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) = 1
[PROOF STEP]
by (metis (no_types, lifting) Determinant.det_mult Groups.mult_ac(2) Q Q')
[PROOF STATE]
proof (state)
this:
det (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) * det (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) = 1

goal (1 subgoal):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
hence "det ?Q = 1 \<or> det ?Q = -1"
[PROOF STATE]
proof (prove)
using this:
det (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) * det (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length fs) \<and> mat_of_cols n fs *\<^sub>v x = gs ! i) [0..<length gs])) = 1

goal (1 subgoal):
 1. det (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) = 1 \<or> det (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) = - 1
[PROOF STEP]
by (rule pos_zmult_eq_1_iff_lemma)
[PROOF STATE]
proof (state)
this:
det (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) = 1 \<or> det (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) = - 1

goal (1 subgoal):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
det (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) = 1 \<or> det (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) = - 1

goal (1 subgoal):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
using invertible_iff_is_unit_JNF[OF Q]
[PROOF STATE]
proof (prove)
using this:
det (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) = 1 \<or> det (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) = - 1
invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])) = is_unit (det (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs])))

goal (1 subgoal):
 1. invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
invertible_mat (mat_of_cols n (map (\<lambda>i. SOME x. x \<in> carrier_vec (length gs) \<and> mat_of_cols n gs *\<^sub>v x = fs ! i) [0..<length fs]))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>Q\<in>carrier_mat n n. invertible_mat Q \<and> mat_of_cols n fs = mat_of_cols n gs * Q

goal:
No subgoals!
[PROOF STEP]
qed