[STATEMENT]
lemma find_base_vectors: assumes ref: "row_echelon_form A"
  and A: "A \<in> carrier_mat nr nc" shows
  "set (find_base_vectors A) \<subseteq> mat_kernel A"
  "0\<^sub>v nc \<notin> set (find_base_vectors A)"
  "kernel.basis nc A (set (find_base_vectors A))"
  "card (set (find_base_vectors A)) = nc - card { i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}"
  "length (pivot_positions A) = card { i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}"
  "kernel.dim nc A = nc - card { i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (set (find_base_vectors A) \<subseteq> mat_kernel A &&& 0\<^sub>v nc \<notin> set (find_base_vectors A) &&& vectorspace.basis class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) (set (find_base_vectors A))) &&& card (set (find_base_vectors A)) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc} &&& length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc} &&& vectorspace.dim class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (6 subgoals):
 1. set (find_base_vectors A) \<subseteq> mat_kernel A
 2. 0\<^sub>v nc \<notin> set (find_base_vectors A)
 3. vectorspace.basis class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) (set (find_base_vectors A))
 4. card (set (find_base_vectors A)) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 5. length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 6. vectorspace.dim class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
note non_pivot_base = non_pivot_base[OF ref A]
[PROOF STATE]
proof (state)
this:
\<lbrakk>?qj < nc; ?qj \<notin> snd ` set (pivot_positions A)\<rbrakk> \<Longrightarrow> non_pivot_base A (pivot_positions A) ?qj \<in> carrier_vec nc
\<lbrakk>?qj < nc; ?qj \<notin> snd ` set (pivot_positions A)\<rbrakk> \<Longrightarrow> non_pivot_base A (pivot_positions A) ?qj $ ?qj = (1::'a)
\<lbrakk>?qj < nc; ?qj \<notin> snd ` set (pivot_positions A)\<rbrakk> \<Longrightarrow> A *\<^sub>v non_pivot_base A (pivot_positions A) ?qj = 0\<^sub>v nr
\<lbrakk>?qj < nc; ?qj \<notin> snd ` set (pivot_positions A); ?qj' < nc; ?qj' \<notin> snd ` set (pivot_positions A); ?qj \<noteq> ?qj'\<rbrakk> \<Longrightarrow> non_pivot_base A (pivot_positions A) ?qj $ ?qj' = (0::'a)

goal (6 subgoals):
 1. set (find_base_vectors A) \<subseteq> mat_kernel A
 2. 0\<^sub>v nc \<notin> set (find_base_vectors A)
 3. vectorspace.basis class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) (set (find_base_vectors A))
 4. card (set (find_base_vectors A)) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 5. length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 6. vectorspace.dim class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
let ?B = "set (find_base_vectors A)"
[PROOF STATE]
proof (state)
goal (6 subgoals):
 1. set (find_base_vectors A) \<subseteq> mat_kernel A
 2. 0\<^sub>v nc \<notin> set (find_base_vectors A)
 3. vectorspace.basis class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) (set (find_base_vectors A))
 4. card (set (find_base_vectors A)) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 5. length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 6. vectorspace.dim class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
let ?pp = "set (pivot_positions A)"
[PROOF STATE]
proof (state)
goal (6 subgoals):
 1. set (find_base_vectors A) \<subseteq> mat_kernel A
 2. 0\<^sub>v nc \<notin> set (find_base_vectors A)
 3. vectorspace.basis class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) (set (find_base_vectors A))
 4. card (set (find_base_vectors A)) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 5. length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 6. vectorspace.dim class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
from A
[PROOF STATE]
proof (chain)
picking this:
A \<in> carrier_mat nr nc
[PROOF STEP]
have dim: "dim_row A = nr" "dim_col A = nc"
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat nr nc

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

goal (6 subgoals):
 1. set (find_base_vectors A) \<subseteq> mat_kernel A
 2. 0\<^sub>v nc \<notin> set (find_base_vectors A)
 3. vectorspace.basis class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) (set (find_base_vectors A))
 4. card (set (find_base_vectors A)) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 5. length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 6. vectorspace.dim class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
from ref[unfolded row_echelon_form_def]
[PROOF STATE]
proof (chain)
picking this:
\<exists>f. pivot_fun A f (dim_col A)
[PROOF STEP]
obtain p
  where pivot: "pivot_fun A p nc"
[PROOF STATE]
proof (prove)
using this:
\<exists>f. pivot_fun A f (dim_col A)

goal (1 subgoal):
 1. (\<And>p. pivot_fun A p nc \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using dim
[PROOF STATE]
proof (prove)
using this:
\<exists>f. pivot_fun A f (dim_col A)
dim_row A = nr
dim_col A = nc

goal (1 subgoal):
 1. (\<And>p. pivot_fun A p nc \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
pivot_fun A p nc

goal (6 subgoals):
 1. set (find_base_vectors A) \<subseteq> mat_kernel A
 2. 0\<^sub>v nc \<notin> set (find_base_vectors A)
 3. vectorspace.basis class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) (set (find_base_vectors A))
 4. card (set (find_base_vectors A)) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 5. length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 6. vectorspace.dim class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
note piv = pivot_funD[OF dim(1) pivot]
[PROOF STATE]
proof (state)
this:
?i < nr \<Longrightarrow> p ?i \<le> nc
\<lbrakk>?i < nr; ?j < p ?i\<rbrakk> \<Longrightarrow> A $$ (?i, ?j) = (0::'a)
\<lbrakk>?i < nr; Suc ?i < nr\<rbrakk> \<Longrightarrow> p ?i < p (Suc ?i) \<or> p (Suc ?i) = nc
\<lbrakk>?i < nr; p ?i < nc\<rbrakk> \<Longrightarrow> A $$ (?i, p ?i) = (1::'a)
\<lbrakk>?i < nr; p ?i < nc; ?i' < nr; ?i' \<noteq> ?i\<rbrakk> \<Longrightarrow> A $$ (?i', p ?i) = (0::'a)

goal (6 subgoals):
 1. set (find_base_vectors A) \<subseteq> mat_kernel A
 2. 0\<^sub>v nc \<notin> set (find_base_vectors A)
 3. vectorspace.basis class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) (set (find_base_vectors A))
 4. card (set (find_base_vectors A)) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 5. length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 6. vectorspace.dim class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
?i < nr \<Longrightarrow> p ?i \<le> nc
\<lbrakk>?i < nr; ?j < p ?i\<rbrakk> \<Longrightarrow> A $$ (?i, ?j) = (0::'a)
\<lbrakk>?i < nr; Suc ?i < nr\<rbrakk> \<Longrightarrow> p ?i < p (Suc ?i) \<or> p (Suc ?i) = nc
\<lbrakk>?i < nr; p ?i < nc\<rbrakk> \<Longrightarrow> A $$ (?i, p ?i) = (1::'a)
\<lbrakk>?i < nr; p ?i < nc; ?i' < nr; ?i' \<noteq> ?i\<rbrakk> \<Longrightarrow> A $$ (?i', p ?i) = (0::'a)

goal (6 subgoals):
 1. set (find_base_vectors A) \<subseteq> mat_kernel A
 2. 0\<^sub>v nc \<notin> set (find_base_vectors A)
 3. vectorspace.basis class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) (set (find_base_vectors A))
 4. card (set (find_base_vectors A)) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 5. length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 6. vectorspace.dim class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
fix v
[PROOF STATE]
proof (state)
goal (6 subgoals):
 1. set (find_base_vectors A) \<subseteq> mat_kernel A
 2. 0\<^sub>v nc \<notin> set (find_base_vectors A)
 3. vectorspace.basis class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) (set (find_base_vectors A))
 4. card (set (find_base_vectors A)) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 5. length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 6. vectorspace.dim class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
assume "v \<in> ?B"
[PROOF STATE]
proof (state)
this:
v \<in> set (find_base_vectors A)

goal (6 subgoals):
 1. set (find_base_vectors A) \<subseteq> mat_kernel A
 2. 0\<^sub>v nc \<notin> set (find_base_vectors A)
 3. vectorspace.basis class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) (set (find_base_vectors A))
 4. card (set (find_base_vectors A)) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 5. length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 6. vectorspace.dim class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
from this[unfolded find_base_vectors_def Let_def dim]
[PROOF STATE]
proof (chain)
picking this:
v \<in> set (map (non_pivot_base A (pivot_positions A)) (filter (\<lambda>j. j \<notin> set (map snd (pivot_positions A))) [0..<nc]))
[PROOF STEP]
obtain c where c: "c < nc" "c \<notin> snd ` ?pp"
      and res: "v = non_pivot_base A (pivot_positions A) c"
[PROOF STATE]
proof (prove)
using this:
v \<in> set (map (non_pivot_base A (pivot_positions A)) (filter (\<lambda>j. j \<notin> set (map snd (pivot_positions A))) [0..<nc]))

goal (1 subgoal):
 1. (\<And>c. \<lbrakk>c < nc; c \<notin> snd ` set (pivot_positions A); v = non_pivot_base A (pivot_positions A) c\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
c < nc
c \<notin> snd ` set (pivot_positions A)
v = non_pivot_base A (pivot_positions A) c

goal (6 subgoals):
 1. set (find_base_vectors A) \<subseteq> mat_kernel A
 2. 0\<^sub>v nc \<notin> set (find_base_vectors A)
 3. vectorspace.basis class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) (set (find_base_vectors A))
 4. card (set (find_base_vectors A)) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 5. length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 6. vectorspace.dim class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
from non_pivot_base[OF c, folded res] c
[PROOF STATE]
proof (chain)
picking this:
v \<in> carrier_vec nc
v $ c = (1::'a)
A *\<^sub>v v = 0\<^sub>v nr
\<lbrakk>?qj' < nc; ?qj' \<notin> snd ` set (pivot_positions A); c \<noteq> ?qj'\<rbrakk> \<Longrightarrow> v $ ?qj' = (0::'a)
c < nc
c \<notin> snd ` set (pivot_positions A)
[PROOF STEP]
have "v \<in> mat_kernel A" "v \<noteq> 0\<^sub>v nc"
[PROOF STATE]
proof (prove)
using this:
v \<in> carrier_vec nc
v $ c = (1::'a)
A *\<^sub>v v = 0\<^sub>v nr
\<lbrakk>?qj' < nc; ?qj' \<notin> snd ` set (pivot_positions A); c \<noteq> ?qj'\<rbrakk> \<Longrightarrow> v $ ?qj' = (0::'a)
c < nc
c \<notin> snd ` set (pivot_positions A)

goal (1 subgoal):
 1. v \<in> mat_kernel A &&& v \<noteq> 0\<^sub>v nc
[PROOF STEP]
by (intro mat_kernelI[OF A], auto)
[PROOF STATE]
proof (state)
this:
v \<in> mat_kernel A
v \<noteq> 0\<^sub>v nc

goal (6 subgoals):
 1. set (find_base_vectors A) \<subseteq> mat_kernel A
 2. 0\<^sub>v nc \<notin> set (find_base_vectors A)
 3. vectorspace.basis class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) (set (find_base_vectors A))
 4. card (set (find_base_vectors A)) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 5. length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 6. vectorspace.dim class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?v2 \<in> set (find_base_vectors A) \<Longrightarrow> ?v2 \<in> mat_kernel A
?v2 \<in> set (find_base_vectors A) \<Longrightarrow> ?v2 \<noteq> 0\<^sub>v nc

goal (6 subgoals):
 1. set (find_base_vectors A) \<subseteq> mat_kernel A
 2. 0\<^sub>v nc \<notin> set (find_base_vectors A)
 3. vectorspace.basis class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) (set (find_base_vectors A))
 4. card (set (find_base_vectors A)) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 5. length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 6. vectorspace.dim class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
thus sub: "?B \<subseteq> mat_kernel A" and
    "0\<^sub>v nc \<notin> ?B"
[PROOF STATE]
proof (prove)
using this:
?v2 \<in> set (find_base_vectors A) \<Longrightarrow> ?v2 \<in> mat_kernel A
?v2 \<in> set (find_base_vectors A) \<Longrightarrow> ?v2 \<noteq> 0\<^sub>v nc

goal (1 subgoal):
 1. set (find_base_vectors A) \<subseteq> mat_kernel A &&& 0\<^sub>v nc \<notin> set (find_base_vectors A)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set (find_base_vectors A) \<subseteq> mat_kernel A
0\<^sub>v nc \<notin> set (find_base_vectors A)

goal (4 subgoals):
 1. vectorspace.basis class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) (set (find_base_vectors A))
 2. card (set (find_base_vectors A)) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 3. length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 4. vectorspace.dim class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
set (find_base_vectors A) \<subseteq> mat_kernel A
0\<^sub>v nc \<notin> set (find_base_vectors A)

goal (4 subgoals):
 1. vectorspace.basis class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) (set (find_base_vectors A))
 2. card (set (find_base_vectors A)) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 3. length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 4. vectorspace.dim class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
fix j j'
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. vectorspace.basis class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) (set (find_base_vectors A))
 2. card (set (find_base_vectors A)) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 3. length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 4. vectorspace.dim class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
assume j: "j < nc" "j \<notin> snd ` ?pp" and j': "j' < nc" "j' \<notin> snd ` ?pp" and neq: "j' \<noteq> j"
[PROOF STATE]
proof (state)
this:
j < nc
j \<notin> snd ` set (pivot_positions A)
j' < nc
j' \<notin> snd ` set (pivot_positions A)
j' \<noteq> j

goal (4 subgoals):
 1. vectorspace.basis class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) (set (find_base_vectors A))
 2. card (set (find_base_vectors A)) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 3. length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 4. vectorspace.dim class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
from non_pivot_base(2)[OF j] non_pivot_base(4)[OF j' j neq]
[PROOF STATE]
proof (chain)
picking this:
non_pivot_base A (pivot_positions A) j $ j = (1::'a)
non_pivot_base A (pivot_positions A) j' $ j = (0::'a)
[PROOF STEP]
have "non_pivot_base A (pivot_positions A) j \<noteq> non_pivot_base A (pivot_positions A) j'"
[PROOF STATE]
proof (prove)
using this:
non_pivot_base A (pivot_positions A) j $ j = (1::'a)
non_pivot_base A (pivot_positions A) j' $ j = (0::'a)

goal (1 subgoal):
 1. non_pivot_base A (pivot_positions A) j \<noteq> non_pivot_base A (pivot_positions A) j'
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
non_pivot_base A (pivot_positions A) j \<noteq> non_pivot_base A (pivot_positions A) j'

goal (4 subgoals):
 1. vectorspace.basis class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) (set (find_base_vectors A))
 2. card (set (find_base_vectors A)) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 3. length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 4. vectorspace.dim class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>?j2 < nc; ?j2 \<notin> snd ` set (pivot_positions A); ?j'2 < nc; ?j'2 \<notin> snd ` set (pivot_positions A); ?j'2 \<noteq> ?j2\<rbrakk> \<Longrightarrow> non_pivot_base A (pivot_positions A) ?j2 \<noteq> non_pivot_base A (pivot_positions A) ?j'2

goal (4 subgoals):
 1. vectorspace.basis class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) (set (find_base_vectors A))
 2. card (set (find_base_vectors A)) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 3. length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 4. vectorspace.dim class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
hence inj: "inj_on (non_pivot_base A (pivot_positions A))
     (set [j\<leftarrow>[0..<nc] . j \<notin> snd ` ?pp])"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?j2 < nc; ?j2 \<notin> snd ` set (pivot_positions A); ?j'2 < nc; ?j'2 \<notin> snd ` set (pivot_positions A); ?j'2 \<noteq> ?j2\<rbrakk> \<Longrightarrow> non_pivot_base A (pivot_positions A) ?j2 \<noteq> non_pivot_base A (pivot_positions A) ?j'2

goal (1 subgoal):
 1. inj_on (non_pivot_base A (pivot_positions A)) (set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]))
[PROOF STEP]
unfolding inj_on_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?j2 < nc; ?j2 \<notin> snd ` set (pivot_positions A); ?j'2 < nc; ?j'2 \<notin> snd ` set (pivot_positions A); ?j'2 \<noteq> ?j2\<rbrakk> \<Longrightarrow> non_pivot_base A (pivot_positions A) ?j2 \<noteq> non_pivot_base A (pivot_positions A) ?j'2

goal (1 subgoal):
 1. \<forall>x\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). \<forall>y\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). non_pivot_base A (pivot_positions A) x = non_pivot_base A (pivot_positions A) y \<longrightarrow> x = y
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
inj_on (non_pivot_base A (pivot_positions A)) (set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]))

goal (4 subgoals):
 1. vectorspace.basis class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) (set (find_base_vectors A))
 2. card (set (find_base_vectors A)) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 3. length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 4. vectorspace.dim class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
note pp = pivot_positions[OF A pivot]
[PROOF STATE]
proof (state)
this:
set (pivot_positions A) = {(i, p i) |i. i < nr \<and> p i \<noteq> nc}
distinct (map fst (pivot_positions A))
distinct (map snd (pivot_positions A))
length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}

goal (4 subgoals):
 1. vectorspace.basis class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) (set (find_base_vectors A))
 2. card (set (find_base_vectors A)) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 3. length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 4. vectorspace.dim class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
have lc: "length (pivot_positions A) = card (snd ` ?pp)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (pivot_positions A) = card (snd ` set (pivot_positions A))
[PROOF STEP]
using distinct_card[OF pp(3)]
[PROOF STATE]
proof (prove)
using this:
card (set (map snd (pivot_positions A))) = length (map snd (pivot_positions A))

goal (1 subgoal):
 1. length (pivot_positions A) = card (snd ` set (pivot_positions A))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (pivot_positions A) = card (snd ` set (pivot_positions A))

goal (4 subgoals):
 1. vectorspace.basis class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) (set (find_base_vectors A))
 2. card (set (find_base_vectors A)) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 3. length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
 4. vectorspace.dim class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
show card: "card ?B = nc - card { i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}"
    "length (pivot_positions A) = card { i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (set (find_base_vectors A)) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc} &&& length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
unfolding find_base_vectors_def Let_def dim set_map  card_image[OF inj] pp(4)[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc])) = nc - length (pivot_positions A) &&& length (pivot_positions A) = length (pivot_positions A)
[PROOF STEP]
unfolding pp(1) lc
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (set (filter (\<lambda>j. j \<notin> snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) [0..<nc])) = nc - card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) &&& card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) = card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc})
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. card (set (filter (\<lambda>j. j \<notin> snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) [0..<nc])) = nc - card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc})
 2. card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) = card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc})
[PROOF STEP]
have "nc - card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc})
      = card {0 ..< nc} - card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nc - card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) = card {0..<nc} - card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
nc - card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) = card {0..<nc} - card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc})

goal (2 subgoals):
 1. card (set (filter (\<lambda>j. j \<notin> snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) [0..<nc])) = nc - card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc})
 2. card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) = card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc})
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
nc - card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) = card {0..<nc} - card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc})

goal (2 subgoals):
 1. card (set (filter (\<lambda>j. j \<notin> snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) [0..<nc])) = nc - card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc})
 2. card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) = card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc})
[PROOF STEP]
have "\<dots> = card ({0 ..< nc} - snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {0..<nc} - card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) = card ({0..<nc} - snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc})
[PROOF STEP]
by (rule card_Diff_subset[symmetric], insert piv(1), force+)
[PROOF STATE]
proof (state)
this:
card {0..<nc} - card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) = card ({0..<nc} - snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc})

goal (2 subgoals):
 1. card (set (filter (\<lambda>j. j \<notin> snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) [0..<nc])) = nc - card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc})
 2. card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) = card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc})
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card {0..<nc} - card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) = card ({0..<nc} - snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc})

goal (2 subgoals):
 1. card (set (filter (\<lambda>j. j \<notin> snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) [0..<nc])) = nc - card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc})
 2. card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) = card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc})
[PROOF STEP]
have "{0 ..< nc} - snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc} = (set [j\<leftarrow>[0..<nc] . j \<notin> snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {0..<nc} - snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc} = set (filter (\<lambda>j. j \<notin> snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) [0..<nc])
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{0..<nc} - snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc} = set (filter (\<lambda>j. j \<notin> snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) [0..<nc])

goal (2 subgoals):
 1. card (set (filter (\<lambda>j. j \<notin> snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) [0..<nc])) = nc - card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc})
 2. card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) = card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc})
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
nc - card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) = card (set (filter (\<lambda>j. j \<notin> snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) [0..<nc]))
[PROOF STEP]
show "card (set [j\<leftarrow>[0..<nc] . j \<notin> snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}]) =
      nc - card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc})"
[PROOF STATE]
proof (prove)
using this:
nc - card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) = card (set (filter (\<lambda>j. j \<notin> snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) [0..<nc]))

goal (1 subgoal):
 1. card (set (filter (\<lambda>j. j \<notin> snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) [0..<nc])) = nc - card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc})
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card (set (filter (\<lambda>j. j \<notin> snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) [0..<nc])) = nc - card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc})

goal (1 subgoal):
 1. card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) = card (snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc})
[PROOF STEP]
qed auto
[PROOF STATE]
proof (state)
this:
card (set (find_base_vectors A)) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}

goal (2 subgoals):
 1. vectorspace.basis class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) (set (find_base_vectors A))
 2. vectorspace.dim class_ring (module_vec TYPE('a) nc\<lparr>carrier := mat_kernel A\<rparr>) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
interpret kernel nr nc A
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix_Kernel.kernel nr nc A
[PROOF STEP]
by (unfold_locales, rule A)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. basis (set (find_base_vectors A))
 2. dim = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
show basis: "basis ?B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. basis (set (find_base_vectors A))
[PROOF STEP]
unfolding Ker.basis_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lin_indpt (set (find_base_vectors A)) \<and> span (set (find_base_vectors A)) = mat_kernel A \<and> set (find_base_vectors A) \<subseteq> mat_kernel A
[PROOF STEP]
proof (intro conjI)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. lin_indpt (set (find_base_vectors A))
 2. span (set (find_base_vectors A)) = mat_kernel A
 3. set (find_base_vectors A) \<subseteq> mat_kernel A
[PROOF STEP]
show "span ?B = mat_kernel A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. span (set (find_base_vectors A)) = mat_kernel A
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. span (set (find_base_vectors A)) \<subseteq> mat_kernel A
 2. mat_kernel A \<subseteq> span (set (find_base_vectors A))
[PROOF STEP]
show "span ?B \<subseteq> mat_kernel A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. span (set (find_base_vectors A)) \<subseteq> mat_kernel A
[PROOF STEP]
using sub
[PROOF STATE]
proof (prove)
using this:
set (find_base_vectors A) \<subseteq> mat_kernel A

goal (1 subgoal):
 1. span (set (find_base_vectors A)) \<subseteq> mat_kernel A
[PROOF STEP]
by (rule Ker.span_is_subset2)
[PROOF STATE]
proof (state)
this:
span (set (find_base_vectors A)) \<subseteq> mat_kernel A

goal (1 subgoal):
 1. mat_kernel A \<subseteq> span (set (find_base_vectors A))
[PROOF STEP]
show "mat_kernel A \<subseteq> Ker.span ?B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_kernel A \<subseteq> span (set (find_base_vectors A))
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> mat_kernel A \<Longrightarrow> x \<in> span (set (find_base_vectors A))
[PROOF STEP]
fix v
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> mat_kernel A \<Longrightarrow> x \<in> span (set (find_base_vectors A))
[PROOF STEP]
assume "v \<in> mat_kernel A"
[PROOF STATE]
proof (state)
this:
v \<in> mat_kernel A

goal (1 subgoal):
 1. \<And>x. x \<in> mat_kernel A \<Longrightarrow> x \<in> span (set (find_base_vectors A))
[PROOF STEP]
from mat_kernelD[OF A this]
[PROOF STATE]
proof (chain)
picking this:
v \<in> carrier_vec nc
A *\<^sub>v v = 0\<^sub>v nr
[PROOF STEP]
have v: "v \<in> carrier_vec nc" and Av: "A *\<^sub>v v = 0\<^sub>v nr"
[PROOF STATE]
proof (prove)
using this:
v \<in> carrier_vec nc
A *\<^sub>v v = 0\<^sub>v nr

goal (1 subgoal):
 1. v \<in> carrier_vec nc &&& A *\<^sub>v v = 0\<^sub>v nr
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
v \<in> carrier_vec nc
A *\<^sub>v v = 0\<^sub>v nr

goal (1 subgoal):
 1. \<And>x. x \<in> mat_kernel A \<Longrightarrow> x \<in> span (set (find_base_vectors A))
[PROOF STEP]
let ?bi = "non_pivot_base A (pivot_positions A)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> mat_kernel A \<Longrightarrow> x \<in> span (set (find_base_vectors A))
[PROOF STEP]
let ?ran = "set [j\<leftarrow>[0..<nc] . j \<notin> snd ` ?pp]"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> mat_kernel A \<Longrightarrow> x \<in> span (set (find_base_vectors A))
[PROOF STEP]
let ?ran' = "set [j\<leftarrow>[0..<nc] . j \<in> snd ` ?pp]"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> mat_kernel A \<Longrightarrow> x \<in> span (set (find_base_vectors A))
[PROOF STEP]
have dimv: "dim_vec v = nc"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec v = nc
[PROOF STEP]
using v
[PROOF STATE]
proof (prove)
using this:
v \<in> carrier_vec nc

goal (1 subgoal):
 1. dim_vec v = nc
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
dim_vec v = nc

goal (1 subgoal):
 1. \<And>x. x \<in> mat_kernel A \<Longrightarrow> x \<in> span (set (find_base_vectors A))
[PROOF STEP]
define I where "I = (\<lambda> b. SOME i. i \<in> ?ran \<and> ?bi i = b)"
[PROOF STATE]
proof (state)
this:
I = (\<lambda>b. SOME i. i \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<and> non_pivot_base A (pivot_positions A) i = b)

goal (1 subgoal):
 1. \<And>x. x \<in> mat_kernel A \<Longrightarrow> x \<in> span (set (find_base_vectors A))
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
I = (\<lambda>b. SOME i. i \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<and> non_pivot_base A (pivot_positions A) i = b)

goal (1 subgoal):
 1. \<And>x. x \<in> mat_kernel A \<Longrightarrow> x \<in> span (set (find_base_vectors A))
[PROOF STEP]
fix j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> mat_kernel A \<Longrightarrow> x \<in> span (set (find_base_vectors A))
[PROOF STEP]
assume j: "j \<in> ?ran"
[PROOF STATE]
proof (state)
this:
j \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc])

goal (1 subgoal):
 1. \<And>x. x \<in> mat_kernel A \<Longrightarrow> x \<in> span (set (find_base_vectors A))
[PROOF STEP]
hence "\<exists> i. i \<in> ?ran \<and> ?bi i = ?bi j"
[PROOF STATE]
proof (prove)
using this:
j \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc])

goal (1 subgoal):
 1. \<exists>i. i \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<and> non_pivot_base A (pivot_positions A) i = non_pivot_base A (pivot_positions A) j
[PROOF STEP]
unfolding find_base_vectors_def Let_def dim
[PROOF STATE]
proof (prove)
using this:
j \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc])

goal (1 subgoal):
 1. \<exists>i. i \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<and> non_pivot_base A (pivot_positions A) i = non_pivot_base A (pivot_positions A) j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>i. i \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<and> non_pivot_base A (pivot_positions A) i = non_pivot_base A (pivot_positions A) j

goal (1 subgoal):
 1. \<And>x. x \<in> mat_kernel A \<Longrightarrow> x \<in> span (set (find_base_vectors A))
[PROOF STEP]
from someI_ex[OF this]
[PROOF STATE]
proof (chain)
picking this:
(SOME x. x \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<and> non_pivot_base A (pivot_positions A) x = non_pivot_base A (pivot_positions A) j) \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<and> non_pivot_base A (pivot_positions A) (SOME x. x \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<and> non_pivot_base A (pivot_positions A) x = non_pivot_base A (pivot_positions A) j) = non_pivot_base A (pivot_positions A) j
[PROOF STEP]
have I: "I (?bi j) \<in> ?ran" and id: "?bi (I (?bi j)) = ?bi j"
[PROOF STATE]
proof (prove)
using this:
(SOME x. x \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<and> non_pivot_base A (pivot_positions A) x = non_pivot_base A (pivot_positions A) j) \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<and> non_pivot_base A (pivot_positions A) (SOME x. x \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<and> non_pivot_base A (pivot_positions A) x = non_pivot_base A (pivot_positions A) j) = non_pivot_base A (pivot_positions A) j

goal (1 subgoal):
 1. I (non_pivot_base A (pivot_positions A) j) \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) &&& non_pivot_base A (pivot_positions A) (I (non_pivot_base A (pivot_positions A) j)) = non_pivot_base A (pivot_positions A) j
[PROOF STEP]
unfolding I_def
[PROOF STATE]
proof (prove)
using this:
(SOME x. x \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<and> non_pivot_base A (pivot_positions A) x = non_pivot_base A (pivot_positions A) j) \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<and> non_pivot_base A (pivot_positions A) (SOME x. x \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<and> non_pivot_base A (pivot_positions A) x = non_pivot_base A (pivot_positions A) j) = non_pivot_base A (pivot_positions A) j

goal (1 subgoal):
 1. (SOME i. i \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<and> non_pivot_base A (pivot_positions A) i = non_pivot_base A (pivot_positions A) j) \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) &&& non_pivot_base A (pivot_positions A) (SOME i. i \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<and> non_pivot_base A (pivot_positions A) i = non_pivot_base A (pivot_positions A) j) = non_pivot_base A (pivot_positions A) j
[PROOF STEP]
by blast+
[PROOF STATE]
proof (state)
this:
I (non_pivot_base A (pivot_positions A) j) \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc])
non_pivot_base A (pivot_positions A) (I (non_pivot_base A (pivot_positions A) j)) = non_pivot_base A (pivot_positions A) j

goal (1 subgoal):
 1. \<And>x. x \<in> mat_kernel A \<Longrightarrow> x \<in> span (set (find_base_vectors A))
[PROOF STEP]
from inj_onD[OF inj id I j]
[PROOF STATE]
proof (chain)
picking this:
I (non_pivot_base A (pivot_positions A) j) = j
[PROOF STEP]
have "I (?bi j) = j"
[PROOF STATE]
proof (prove)
using this:
I (non_pivot_base A (pivot_positions A) j) = j

goal (1 subgoal):
 1. I (non_pivot_base A (pivot_positions A) j) = j
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
I (non_pivot_base A (pivot_positions A) j) = j

goal (1 subgoal):
 1. \<And>x. x \<in> mat_kernel A \<Longrightarrow> x \<in> span (set (find_base_vectors A))
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?j3 \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> I (non_pivot_base A (pivot_positions A) ?j3) = ?j3

goal (1 subgoal):
 1. \<And>x. x \<in> mat_kernel A \<Longrightarrow> x \<in> span (set (find_base_vectors A))
[PROOF STEP]
note I = this
[PROOF STATE]
proof (state)
this:
?j3 \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> I (non_pivot_base A (pivot_positions A) ?j3) = ?j3

goal (1 subgoal):
 1. \<And>x. x \<in> mat_kernel A \<Longrightarrow> x \<in> span (set (find_base_vectors A))
[PROOF STEP]
define a where "a = (\<lambda> b. v $ (I b))"
[PROOF STATE]
proof (state)
this:
a = (\<lambda>b. v $ I b)

goal (1 subgoal):
 1. \<And>x. x \<in> mat_kernel A \<Longrightarrow> x \<in> span (set (find_base_vectors A))
[PROOF STEP]
from Ker.lincomb_closed[OF sub]
[PROOF STATE]
proof (chain)
picking this:
?a \<in> set (find_base_vectors A) \<rightarrow> UNIV \<Longrightarrow> lincomb ?a (set (find_base_vectors A)) \<in> mat_kernel A
[PROOF STEP]
have diml: "dim_vec (lincomb a ?B) = nc"
[PROOF STATE]
proof (prove)
using this:
?a \<in> set (find_base_vectors A) \<rightarrow> UNIV \<Longrightarrow> lincomb ?a (set (find_base_vectors A)) \<in> mat_kernel A

goal (1 subgoal):
 1. dim_vec (lincomb a (set (find_base_vectors A))) = nc
[PROOF STEP]
unfolding mat_kernel_def
[PROOF STATE]
proof (prove)
using this:
?a \<in> set (find_base_vectors A) \<rightarrow> UNIV \<Longrightarrow> module.lincomb (NC.vs {v \<in> carrier_vec (dim_col A). A *\<^sub>v v = 0\<^sub>v (dim_row A)}) ?a (set (find_base_vectors A)) \<in> {v \<in> carrier_vec (dim_col A). A *\<^sub>v v = 0\<^sub>v (dim_row A)}

goal (1 subgoal):
 1. dim_vec (module.lincomb (NC.vs {v \<in> carrier_vec (dim_col A). A *\<^sub>v v = 0\<^sub>v (dim_row A)}) a (set (find_base_vectors A))) = nc
[PROOF STEP]
using dim lincomb_same
[PROOF STATE]
proof (prove)
using this:
?a \<in> set (find_base_vectors A) \<rightarrow> UNIV \<Longrightarrow> module.lincomb (NC.vs {v \<in> carrier_vec (dim_col A). A *\<^sub>v v = 0\<^sub>v (dim_row A)}) ?a (set (find_base_vectors A)) \<in> {v \<in> carrier_vec (dim_col A). A *\<^sub>v v = 0\<^sub>v (dim_row A)}
dim_row A = nr
dim_col A = nc
?S \<subseteq> mat_kernel A \<Longrightarrow> lincomb ?a ?S = NC.lincomb ?a ?S

goal (1 subgoal):
 1. dim_vec (module.lincomb (NC.vs {v \<in> carrier_vec (dim_col A). A *\<^sub>v v = 0\<^sub>v (dim_row A)}) a (set (find_base_vectors A))) = nc
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
dim_vec (lincomb a (set (find_base_vectors A))) = nc

goal (1 subgoal):
 1. \<And>x. x \<in> mat_kernel A \<Longrightarrow> x \<in> span (set (find_base_vectors A))
[PROOF STEP]
have "v = lincomb a ?B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v = lincomb a (set (find_base_vectors A))
[PROOF STEP]
proof (rule eq_vecI; unfold diml dimv)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i. i < nc \<Longrightarrow> v $ i = lincomb a (set (find_base_vectors A)) $ i
 2. nc = nc
[PROOF STEP]
fix j
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i. i < nc \<Longrightarrow> v $ i = lincomb a (set (find_base_vectors A)) $ i
 2. nc = nc
[PROOF STEP]
assume j: "j < nc"
[PROOF STATE]
proof (state)
this:
j < nc

goal (2 subgoals):
 1. \<And>i. i < nc \<Longrightarrow> v $ i = lincomb a (set (find_base_vectors A)) $ i
 2. nc = nc
[PROOF STEP]
have "Ker.lincomb a ?B $ j = (\<Sum>b\<in> ?B. a b * b $ j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lincomb a (set (find_base_vectors A)) $ j = (\<Sum>b\<in>set (find_base_vectors A). a b * b $ j)
[PROOF STEP]
by (rule lincomb_index[OF j sub])
[PROOF STATE]
proof (state)
this:
lincomb a (set (find_base_vectors A)) $ j = (\<Sum>b\<in>set (find_base_vectors A). a b * b $ j)

goal (2 subgoals):
 1. \<And>i. i < nc \<Longrightarrow> v $ i = lincomb a (set (find_base_vectors A)) $ i
 2. nc = nc
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
lincomb a (set (find_base_vectors A)) $ j = (\<Sum>b\<in>set (find_base_vectors A). a b * b $ j)

goal (2 subgoals):
 1. \<And>i. i < nc \<Longrightarrow> v $ i = lincomb a (set (find_base_vectors A)) $ i
 2. nc = nc
[PROOF STEP]
have "\<dots> = (\<Sum> i\<in> ?ran. v $ i * ?bi i $ j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>b\<in>set (find_base_vectors A). a b * b $ j) = (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j)
[PROOF STEP]
proof (subst sum.reindex_cong[OF inj])
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. set (find_base_vectors A) = non_pivot_base A (pivot_positions A) ` set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc])
 2. \<And>x. x \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> a (non_pivot_base A (pivot_positions A) x) * non_pivot_base A (pivot_positions A) x $ j = ?h x
 3. sum ?h (set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc])) = (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j)
[PROOF STEP]
show "?B = ?bi ` ?ran"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (find_base_vectors A) = non_pivot_base A (pivot_positions A) ` set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc])
[PROOF STEP]
unfolding find_base_vectors_def Let_def dim
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (map (non_pivot_base A (pivot_positions A)) (filter (\<lambda>j. j \<notin> set (map snd (pivot_positions A))) [0..<nc])) = non_pivot_base A (pivot_positions A) ` set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc])
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set (find_base_vectors A) = non_pivot_base A (pivot_positions A) ` set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc])

goal (2 subgoals):
 1. \<And>x. x \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> a (non_pivot_base A (pivot_positions A) x) * non_pivot_base A (pivot_positions A) x $ j = ?h x
 2. sum ?h (set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc])) = (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j)
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>x. x \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> a (non_pivot_base A (pivot_positions A) x) * non_pivot_base A (pivot_positions A) x $ j = ?h x
 2. sum ?h (set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc])) = (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j)
[PROOF STEP]
assume "i \<in> ?ran"
[PROOF STATE]
proof (state)
this:
i \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc])

goal (2 subgoals):
 1. \<And>x. x \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> a (non_pivot_base A (pivot_positions A) x) * non_pivot_base A (pivot_positions A) x $ j = ?h x
 2. sum ?h (set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc])) = (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j)
[PROOF STEP]
hence "I (?bi i) = i"
[PROOF STATE]
proof (prove)
using this:
i \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc])

goal (1 subgoal):
 1. I (non_pivot_base A (pivot_positions A) i) = i
[PROOF STEP]
by (rule I)
[PROOF STATE]
proof (state)
this:
I (non_pivot_base A (pivot_positions A) i) = i

goal (2 subgoals):
 1. \<And>x. x \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> a (non_pivot_base A (pivot_positions A) x) * non_pivot_base A (pivot_positions A) x $ j = ?h x
 2. sum ?h (set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc])) = (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j)
[PROOF STEP]
hence "a (?bi i) = v $ i"
[PROOF STATE]
proof (prove)
using this:
I (non_pivot_base A (pivot_positions A) i) = i

goal (1 subgoal):
 1. a (non_pivot_base A (pivot_positions A) i) = v $ i
[PROOF STEP]
unfolding a_def
[PROOF STATE]
proof (prove)
using this:
I (non_pivot_base A (pivot_positions A) i) = i

goal (1 subgoal):
 1. v $ I (non_pivot_base A (pivot_positions A) i) = v $ i
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a (non_pivot_base A (pivot_positions A) i) = v $ i

goal (2 subgoals):
 1. \<And>x. x \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> a (non_pivot_base A (pivot_positions A) x) * non_pivot_base A (pivot_positions A) x $ j = ?h x
 2. sum ?h (set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc])) = (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j)
[PROOF STEP]
thus "a (?bi i) * ?bi i $ j = v $ i * ?bi i $ j"
[PROOF STATE]
proof (prove)
using this:
a (non_pivot_base A (pivot_positions A) i) = v $ i

goal (1 subgoal):
 1. a (non_pivot_base A (pivot_positions A) i) * non_pivot_base A (pivot_positions A) i $ j = v $ i * non_pivot_base A (pivot_positions A) i $ j
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a (non_pivot_base A (pivot_positions A) i) * non_pivot_base A (pivot_positions A) i $ j = v $ i * non_pivot_base A (pivot_positions A) i $ j

goal (1 subgoal):
 1. (\<Sum>x\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ x * non_pivot_base A (pivot_positions A) x $ j) = (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j)
[PROOF STEP]
qed auto
[PROOF STATE]
proof (state)
this:
(\<Sum>b\<in>set (find_base_vectors A). a b * b $ j) = (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j)

goal (2 subgoals):
 1. \<And>i. i < nc \<Longrightarrow> v $ i = lincomb a (set (find_base_vectors A)) $ i
 2. nc = nc
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>b\<in>set (find_base_vectors A). a b * b $ j) = (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j)

goal (2 subgoals):
 1. \<And>i. i < nc \<Longrightarrow> v $ i = lincomb a (set (find_base_vectors A)) $ i
 2. nc = nc
[PROOF STEP]
have "\<dots> = v $ j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
proof (cases "j \<in> ?ran")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. j \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
 2. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
j \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc])

goal (2 subgoals):
 1. j \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
 2. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
hence nmem: "j \<notin> snd ` set (pivot_positions A)"
[PROOF STATE]
proof (prove)
using this:
j \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc])

goal (1 subgoal):
 1. j \<notin> snd ` set (pivot_positions A)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j \<notin> snd ` set (pivot_positions A)

goal (2 subgoals):
 1. j \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
 2. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
note npb = non_pivot_base[OF j nmem]
[PROOF STATE]
proof (state)
this:
non_pivot_base A (pivot_positions A) j \<in> carrier_vec nc
non_pivot_base A (pivot_positions A) j $ j = (1::'a)
A *\<^sub>v non_pivot_base A (pivot_positions A) j = 0\<^sub>v nr
\<lbrakk>?qj' < nc; ?qj' \<notin> snd ` set (pivot_positions A); j \<noteq> ?qj'\<rbrakk> \<Longrightarrow> non_pivot_base A (pivot_positions A) j $ ?qj' = (0::'a)

goal (2 subgoals):
 1. j \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
 2. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
have "(\<Sum> i\<in> ?ran. v $ i * (?bi i) $ j) =
              v $ j * ?bi j $ j + (\<Sum> i\<in> ?ran - {j}. v $ i * ?bi i $ j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j * non_pivot_base A (pivot_positions A) j $ j + (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) - {j}. v $ i * non_pivot_base A (pivot_positions A) i $ j)
[PROOF STEP]
by (subst sum.remove[OF _ True], auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j * non_pivot_base A (pivot_positions A) j $ j + (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) - {j}. v $ i * non_pivot_base A (pivot_positions A) i $ j)

goal (2 subgoals):
 1. j \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
 2. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j * non_pivot_base A (pivot_positions A) j $ j + (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) - {j}. v $ i * non_pivot_base A (pivot_positions A) i $ j)

goal (2 subgoals):
 1. j \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
 2. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
have "?bi j $ j = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. non_pivot_base A (pivot_positions A) j $ j = (1::'a)
[PROOF STEP]
using npb
[PROOF STATE]
proof (prove)
using this:
non_pivot_base A (pivot_positions A) j \<in> carrier_vec nc
non_pivot_base A (pivot_positions A) j $ j = (1::'a)
A *\<^sub>v non_pivot_base A (pivot_positions A) j = 0\<^sub>v nr
\<lbrakk>?qj' < nc; ?qj' \<notin> snd ` set (pivot_positions A); j \<noteq> ?qj'\<rbrakk> \<Longrightarrow> non_pivot_base A (pivot_positions A) j $ ?qj' = (0::'a)

goal (1 subgoal):
 1. non_pivot_base A (pivot_positions A) j $ j = (1::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
non_pivot_base A (pivot_positions A) j $ j = (1::'a)

goal (2 subgoals):
 1. j \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
 2. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
non_pivot_base A (pivot_positions A) j $ j = (1::'a)

goal (2 subgoals):
 1. j \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
 2. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
have "(\<Sum> i \<in> ?ran - {j}. v $ i * ?bi i $ j) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) - {j}. v $ i * non_pivot_base A (pivot_positions A) i $ j) = (0::'a)
[PROOF STEP]
using insert non_pivot_base(4)[OF _ _ j nmem]
[PROOF STATE]
proof (prove)
using this:
ListMem ?x ?xs \<Longrightarrow> ListMem ?x (?y # ?xs)
\<lbrakk>?qj < nc; ?qj \<notin> snd ` set (pivot_positions A); ?qj \<noteq> j\<rbrakk> \<Longrightarrow> non_pivot_base A (pivot_positions A) ?qj $ j = (0::'a)

goal (1 subgoal):
 1. (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) - {j}. v $ i * non_pivot_base A (pivot_positions A) i $ j) = (0::'a)
[PROOF STEP]
by (intro sum.neutral, auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) - {j}. v $ i * non_pivot_base A (pivot_positions A) i $ j) = (0::'a)

goal (2 subgoals):
 1. j \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
 2. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j * (1::'a) + (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j * (1::'a) + (0::'a)

goal (1 subgoal):
 1. (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j

goal (1 subgoal):
 1. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc])

goal (1 subgoal):
 1. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
with j
[PROOF STATE]
proof (chain)
picking this:
j < nc
j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc])
[PROOF STEP]
have jpp: "j \<in> snd ` ?pp"
[PROOF STATE]
proof (prove)
using this:
j < nc
j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc])

goal (1 subgoal):
 1. j \<in> snd ` set (pivot_positions A)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j \<in> snd ` set (pivot_positions A)

goal (1 subgoal):
 1. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
with j pp
[PROOF STATE]
proof (chain)
picking this:
j < nc
set (pivot_positions A) = {(i, p i) |i. i < nr \<and> p i \<noteq> nc}
distinct (map fst (pivot_positions A))
distinct (map snd (pivot_positions A))
length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
j \<in> snd ` set (pivot_positions A)
[PROOF STEP]
obtain i where i: "i < nr" and ji: "j = p i" and pi: "p i < nc"
[PROOF STATE]
proof (prove)
using this:
j < nc
set (pivot_positions A) = {(i, p i) |i. i < nr \<and> p i \<noteq> nc}
distinct (map fst (pivot_positions A))
distinct (map snd (pivot_positions A))
length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
j \<in> snd ` set (pivot_positions A)

goal (1 subgoal):
 1. (\<And>i. \<lbrakk>i < nr; j = p i; p i < nc\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i < nr
j = p i
p i < nc

goal (1 subgoal):
 1. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
from arg_cong[OF Av, of "\<lambda> u. u $ i"] i A
[PROOF STATE]
proof (chain)
picking this:
(A *\<^sub>v v) $ i = 0\<^sub>v nr $ i
i < nr
A \<in> carrier_mat nr nc
[PROOF STEP]
have "v $ j = v $ j - row A i \<bullet> v"
[PROOF STATE]
proof (prove)
using this:
(A *\<^sub>v v) $ i = 0\<^sub>v nr $ i
i < nr
A \<in> carrier_mat nr nc

goal (1 subgoal):
 1. v $ j = v $ j - row A i \<bullet> v
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
v $ j = v $ j - row A i \<bullet> v

goal (1 subgoal):
 1. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
v $ j = v $ j - row A i \<bullet> v

goal (1 subgoal):
 1. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
have "row A i \<bullet> v = (\<Sum> j = 0 ..< nc. A $$ (i,j) * v $ j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. row A i \<bullet> v = (\<Sum>j = 0..<nc. A $$ (i, j) * v $ j)
[PROOF STEP]
unfolding scalar_prod_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia = 0..<dim_vec v. row A i $ ia * v $ ia) = (\<Sum>j = 0..<nc. A $$ (i, j) * v $ j)
[PROOF STEP]
using v A i
[PROOF STATE]
proof (prove)
using this:
v \<in> carrier_vec nc
A \<in> carrier_mat nr nc
i < nr

goal (1 subgoal):
 1. (\<Sum>ia = 0..<dim_vec v. row A i $ ia * v $ ia) = (\<Sum>j = 0..<nc. A $$ (i, j) * v $ j)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
row A i \<bullet> v = (\<Sum>j = 0..<nc. A $$ (i, j) * v $ j)

goal (1 subgoal):
 1. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
row A i \<bullet> v = (\<Sum>j = 0..<nc. A $$ (i, j) * v $ j)

goal (1 subgoal):
 1. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
have "\<dots> = (\<Sum> j \<in> ?ran. A $$ (i,j) * v $ j) +  (\<Sum> j \<in> ?ran'. A $$ (i,j) * v $ j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j = 0..<nc. A $$ (i, j) * v $ j) = (\<Sum>j\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). A $$ (i, j) * v $ j) + (\<Sum>j\<in>set (filter (\<lambda>j. j \<in> snd ` set (pivot_positions A)) [0..<nc]). A $$ (i, j) * v $ j)
[PROOF STEP]
by (subst sum.union_disjoint[symmetric], auto intro: sum.cong)
[PROOF STATE]
proof (state)
this:
(\<Sum>j = 0..<nc. A $$ (i, j) * v $ j) = (\<Sum>j\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). A $$ (i, j) * v $ j) + (\<Sum>j\<in>set (filter (\<lambda>j. j \<in> snd ` set (pivot_positions A)) [0..<nc]). A $$ (i, j) * v $ j)

goal (1 subgoal):
 1. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>j = 0..<nc. A $$ (i, j) * v $ j) = (\<Sum>j\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). A $$ (i, j) * v $ j) + (\<Sum>j\<in>set (filter (\<lambda>j. j \<in> snd ` set (pivot_positions A)) [0..<nc]). A $$ (i, j) * v $ j)

goal (1 subgoal):
 1. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
have "(\<Sum> j \<in> ?ran'. A $$ (i,j) * v $ j) =
              A $$ (i,p i) * v $ j + (\<Sum> j \<in> ?ran' - {p i}. A $$ (i,j) * v $ j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j\<in>set (filter (\<lambda>j. j \<in> snd ` set (pivot_positions A)) [0..<nc]). A $$ (i, j) * v $ j) = A $$ (i, p i) * v $ j + (\<Sum>j\<in>set (filter (\<lambda>j. j \<in> snd ` set (pivot_positions A)) [0..<nc]) - {p i}. A $$ (i, j) * v $ j)
[PROOF STEP]
using jpp
[PROOF STATE]
proof (prove)
using this:
j \<in> snd ` set (pivot_positions A)

goal (1 subgoal):
 1. (\<Sum>j\<in>set (filter (\<lambda>j. j \<in> snd ` set (pivot_positions A)) [0..<nc]). A $$ (i, j) * v $ j) = A $$ (i, p i) * v $ j + (\<Sum>j\<in>set (filter (\<lambda>j. j \<in> snd ` set (pivot_positions A)) [0..<nc]) - {p i}. A $$ (i, j) * v $ j)
[PROOF STEP]
by (subst sum.remove, auto simp: ji i pi)
[PROOF STATE]
proof (state)
this:
(\<Sum>j\<in>set (filter (\<lambda>j. j \<in> snd ` set (pivot_positions A)) [0..<nc]). A $$ (i, j) * v $ j) = A $$ (i, p i) * v $ j + (\<Sum>j\<in>set (filter (\<lambda>j. j \<in> snd ` set (pivot_positions A)) [0..<nc]) - {p i}. A $$ (i, j) * v $ j)

goal (1 subgoal):
 1. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>j\<in>set (filter (\<lambda>j. j \<in> snd ` set (pivot_positions A)) [0..<nc]). A $$ (i, j) * v $ j) = A $$ (i, p i) * v $ j + (\<Sum>j\<in>set (filter (\<lambda>j. j \<in> snd ` set (pivot_positions A)) [0..<nc]) - {p i}. A $$ (i, j) * v $ j)

goal (1 subgoal):
 1. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
have "A $$ (i, p i) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A $$ (i, p i) = (1::'a)
[PROOF STEP]
using piv(4)[OF i] pi ji
[PROOF STATE]
proof (prove)
using this:
p i < nc \<Longrightarrow> A $$ (i, p i) = (1::'a)
p i < nc
j = p i

goal (1 subgoal):
 1. A $$ (i, p i) = (1::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A $$ (i, p i) = (1::'a)

goal (1 subgoal):
 1. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
A $$ (i, p i) = (1::'a)

goal (1 subgoal):
 1. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
have "(\<Sum> j \<in> ?ran' - {p i}. A $$ (i,j) * v $ j) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j\<in>set (filter (\<lambda>j. j \<in> snd ` set (pivot_positions A)) [0..<nc]) - {p i}. A $$ (i, j) * v $ j) = (0::'a)
[PROOF STEP]
proof (rule sum.neutral, intro ballI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> set (filter (\<lambda>j. j \<in> snd ` set (pivot_positions A)) [0..<nc]) - {p i} \<Longrightarrow> A $$ (i, x) * v $ x = (0::'a)
[PROOF STEP]
fix j'
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> set (filter (\<lambda>j. j \<in> snd ` set (pivot_positions A)) [0..<nc]) - {p i} \<Longrightarrow> A $$ (i, x) * v $ x = (0::'a)
[PROOF STEP]
assume "j' \<in> ?ran' - {p i}"
[PROOF STATE]
proof (state)
this:
j' \<in> set (filter (\<lambda>j. j \<in> snd ` set (pivot_positions A)) [0..<nc]) - {p i}

goal (1 subgoal):
 1. \<And>x. x \<in> set (filter (\<lambda>j. j \<in> snd ` set (pivot_positions A)) [0..<nc]) - {p i} \<Longrightarrow> A $$ (i, x) * v $ x = (0::'a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
j' \<in> set (filter (\<lambda>j. j \<in> snd ` set (pivot_positions A)) [0..<nc]) - {p i}
[PROOF STEP]
obtain i' where i': "i' < nr" and j': "j' = p i'" and pi': "p i' \<noteq> nc" and neq: "p i' \<noteq> p i"
[PROOF STATE]
proof (prove)
using this:
j' \<in> set (filter (\<lambda>j. j \<in> snd ` set (pivot_positions A)) [0..<nc]) - {p i}

goal (1 subgoal):
 1. (\<And>i'. \<lbrakk>i' < nr; j' = p i'; p i' \<noteq> nc; p i' \<noteq> p i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding pp
[PROOF STATE]
proof (prove)
using this:
j' \<in> set (filter (\<lambda>j. j \<in> snd ` {(i, p i) |i. i < nr \<and> p i \<noteq> nc}) [0..<nc]) - {p i}

goal (1 subgoal):
 1. (\<And>i'. \<lbrakk>i' < nr; j' = p i'; p i' \<noteq> nc; p i' \<noteq> p i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i' < nr
j' = p i'
p i' \<noteq> nc
p i' \<noteq> p i

goal (1 subgoal):
 1. \<And>x. x \<in> set (filter (\<lambda>j. j \<in> snd ` set (pivot_positions A)) [0..<nc]) - {p i} \<Longrightarrow> A $$ (i, x) * v $ x = (0::'a)
[PROOF STEP]
from pi' piv[OF i']
[PROOF STATE]
proof (chain)
picking this:
p i' \<noteq> nc
p i' \<le> nc
?j < p i' \<Longrightarrow> A $$ (i', ?j) = (0::'a)
Suc i' < nr \<Longrightarrow> p i' < p (Suc i') \<or> p (Suc i') = nc
p i' < nc \<Longrightarrow> A $$ (i', p i') = (1::'a)
\<lbrakk>p i' < nc; ?i' < nr; ?i' \<noteq> i'\<rbrakk> \<Longrightarrow> A $$ (?i', p i') = (0::'a)
[PROOF STEP]
have pi': "p i' < nc"
[PROOF STATE]
proof (prove)
using this:
p i' \<noteq> nc
p i' \<le> nc
?j < p i' \<Longrightarrow> A $$ (i', ?j) = (0::'a)
Suc i' < nr \<Longrightarrow> p i' < p (Suc i') \<or> p (Suc i') = nc
p i' < nc \<Longrightarrow> A $$ (i', p i') = (1::'a)
\<lbrakk>p i' < nc; ?i' < nr; ?i' \<noteq> i'\<rbrakk> \<Longrightarrow> A $$ (?i', p i') = (0::'a)

goal (1 subgoal):
 1. p i' < nc
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
p i' < nc

goal (1 subgoal):
 1. \<And>x. x \<in> set (filter (\<lambda>j. j \<in> snd ` set (pivot_positions A)) [0..<nc]) - {p i} \<Longrightarrow> A $$ (i, x) * v $ x = (0::'a)
[PROOF STEP]
from pp pi' neq j i' i
[PROOF STATE]
proof (chain)
picking this:
set (pivot_positions A) = {(i, p i) |i. i < nr \<and> p i \<noteq> nc}
distinct (map fst (pivot_positions A))
distinct (map snd (pivot_positions A))
length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
p i' < nc
p i' \<noteq> p i
j < nc
i' < nr
i < nr
[PROOF STEP]
have "i \<noteq> i'"
[PROOF STATE]
proof (prove)
using this:
set (pivot_positions A) = {(i, p i) |i. i < nr \<and> p i \<noteq> nc}
distinct (map fst (pivot_positions A))
distinct (map snd (pivot_positions A))
length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
p i' < nc
p i' \<noteq> p i
j < nc
i' < nr
i < nr

goal (1 subgoal):
 1. i \<noteq> i'
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i \<noteq> i'

goal (1 subgoal):
 1. \<And>x. x \<in> set (filter (\<lambda>j. j \<in> snd ` set (pivot_positions A)) [0..<nc]) - {p i} \<Longrightarrow> A $$ (i, x) * v $ x = (0::'a)
[PROOF STEP]
from piv(5)[OF i' pi' i this]
[PROOF STATE]
proof (chain)
picking this:
A $$ (i, p i') = (0::'a)
[PROOF STEP]
show "A $$ (i,j') * v $ j' = 0"
[PROOF STATE]
proof (prove)
using this:
A $$ (i, p i') = (0::'a)

goal (1 subgoal):
 1. A $$ (i, j') * v $ j' = (0::'a)
[PROOF STEP]
unfolding j'
[PROOF STATE]
proof (prove)
using this:
A $$ (i, p i') = (0::'a)

goal (1 subgoal):
 1. A $$ (i, p i') * v $ p i' = (0::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
A $$ (i, j') * v $ j' = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>j\<in>set (filter (\<lambda>j. j \<in> snd ` set (pivot_positions A)) [0..<nc]) - {p i}. A $$ (i, j) * v $ j) = (0::'a)

goal (1 subgoal):
 1. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>j\<in>set (filter (\<lambda>j. j \<in> snd ` set (pivot_positions A)) [0..<nc]) - {p i}. A $$ (i, j) * v $ j) = (0::'a)

goal (1 subgoal):
 1. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
have "(\<Sum> j \<in> ?ran. A $$ (i,j) * v $ j) = - (\<Sum> j \<in> ?ran. v $ j * - A $$ (i,j))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). A $$ (i, j) * v $ j) = - (\<Sum>j\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ j * - A $$ (i, j))
[PROOF STEP]
unfolding sum_negf[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). A $$ (i, j) * v $ j) = (\<Sum>x\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). - (v $ x * - A $$ (i, x)))
[PROOF STEP]
by (rule sum.cong, auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>j\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). A $$ (i, j) * v $ j) = - (\<Sum>j\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ j * - A $$ (i, j))

goal (1 subgoal):
 1. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
v $ j = v $ j - (- (\<Sum>j\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ j * - A $$ (i, j)) + ((1::'a) * v $ j + (0::'a)))
[PROOF STEP]
have vj: "v $ j = (\<Sum> j \<in> ?ran. v $ j * - A $$ (i,j))"
[PROOF STATE]
proof (prove)
using this:
v $ j = v $ j - (- (\<Sum>j\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ j * - A $$ (i, j)) + ((1::'a) * v $ j + (0::'a)))

goal (1 subgoal):
 1. v $ j = (\<Sum>j\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ j * - A $$ (i, j))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
v $ j = (\<Sum>j\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ j * - A $$ (i, j))

goal (1 subgoal):
 1. j \<notin> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j
[PROOF STEP]
unfolding vj j
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = (\<Sum>j\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ j * - A $$ (i, j))
[PROOF STEP]
proof (rule sum.cong[OF refl])
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> v $ x * non_pivot_base A (pivot_positions A) x $ j = v $ x * - A $$ (i, x)
[PROOF STEP]
fix j'
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> v $ x * non_pivot_base A (pivot_positions A) x $ j = v $ x * - A $$ (i, x)
[PROOF STEP]
assume j': "j' \<in> ?ran"
[PROOF STATE]
proof (state)
this:
j' \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc])

goal (1 subgoal):
 1. \<And>x. x \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> v $ x * non_pivot_base A (pivot_positions A) x $ j = v $ x * - A $$ (i, x)
[PROOF STEP]
from jpp j'
[PROOF STATE]
proof (chain)
picking this:
j \<in> snd ` set (pivot_positions A)
j' \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc])
[PROOF STEP]
have jj': "j \<noteq> j'"
[PROOF STATE]
proof (prove)
using this:
j \<in> snd ` set (pivot_positions A)
j' \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc])

goal (1 subgoal):
 1. j \<noteq> j'
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j \<noteq> j'

goal (1 subgoal):
 1. \<And>x. x \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> v $ x * non_pivot_base A (pivot_positions A) x $ j = v $ x * - A $$ (i, x)
[PROOF STEP]
let ?map = "map prod.swap (pivot_positions A)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> v $ x * non_pivot_base A (pivot_positions A) x $ j = v $ x * - A $$ (i, x)
[PROOF STEP]
from ji i j
[PROOF STATE]
proof (chain)
picking this:
j = p i
i < nr
j < nc
[PROOF STEP]
have "(i,j) \<in> set (pivot_positions A)"
[PROOF STATE]
proof (prove)
using this:
j = p i
i < nr
j < nc

goal (1 subgoal):
 1. (i, j) \<in> set (pivot_positions A)
[PROOF STEP]
unfolding pp
[PROOF STATE]
proof (prove)
using this:
j = p i
i < nr
j < nc

goal (1 subgoal):
 1. (i, j) \<in> {(i, p i) |i. i < nr \<and> p i \<noteq> nc}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(i, j) \<in> set (pivot_positions A)

goal (1 subgoal):
 1. \<And>x. x \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> v $ x * non_pivot_base A (pivot_positions A) x $ j = v $ x * - A $$ (i, x)
[PROOF STEP]
hence mem: "(j,i) \<in> set ?map"
[PROOF STATE]
proof (prove)
using this:
(i, j) \<in> set (pivot_positions A)

goal (1 subgoal):
 1. (j, i) \<in> set (map prod.swap (pivot_positions A))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(j, i) \<in> set (map prod.swap (pivot_positions A))

goal (1 subgoal):
 1. \<And>x. x \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> v $ x * non_pivot_base A (pivot_positions A) x $ j = v $ x * - A $$ (i, x)
[PROOF STEP]
from pp
[PROOF STATE]
proof (chain)
picking this:
set (pivot_positions A) = {(i, p i) |i. i < nr \<and> p i \<noteq> nc}
distinct (map fst (pivot_positions A))
distinct (map snd (pivot_positions A))
length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
have "distinct (map fst ?map)"
[PROOF STATE]
proof (prove)
using this:
set (pivot_positions A) = {(i, p i) |i. i < nr \<and> p i \<noteq> nc}
distinct (map fst (pivot_positions A))
distinct (map snd (pivot_positions A))
length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}

goal (1 subgoal):
 1. distinct (map fst (map prod.swap (pivot_positions A)))
[PROOF STEP]
unfolding map_map o_def prod.swap_def fst_conv
[PROOF STATE]
proof (prove)
using this:
set (pivot_positions A) = {(i, p i) |i. i < nr \<and> p i \<noteq> nc}
distinct (map fst (pivot_positions A))
distinct (map snd (pivot_positions A))
length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}

goal (1 subgoal):
 1. distinct (map snd (pivot_positions A))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
distinct (map fst (map prod.swap (pivot_positions A)))

goal (1 subgoal):
 1. \<And>x. x \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> v $ x * non_pivot_base A (pivot_positions A) x $ j = v $ x * - A $$ (i, x)
[PROOF STEP]
from map_of_is_SomeI[OF this mem]
[PROOF STATE]
proof (chain)
picking this:
map_of (map prod.swap (pivot_positions A)) j = Some i
[PROOF STEP]
have "map_of ?map j = Some i"
[PROOF STATE]
proof (prove)
using this:
map_of (map prod.swap (pivot_positions A)) j = Some i

goal (1 subgoal):
 1. map_of (map prod.swap (pivot_positions A)) j = Some i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
map_of (map prod.swap (pivot_positions A)) j = Some i

goal (1 subgoal):
 1. \<And>x. x \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> v $ x * non_pivot_base A (pivot_positions A) x $ j = v $ x * - A $$ (i, x)
[PROOF STEP]
hence "?bi j' $ j = - A $$ (i, j')"
[PROOF STATE]
proof (prove)
using this:
map_of (map prod.swap (pivot_positions A)) j = Some i

goal (1 subgoal):
 1. non_pivot_base A (pivot_positions A) j' $ j = - A $$ (i, j')
[PROOF STEP]
unfolding non_pivot_base_def Let_def dim
[PROOF STATE]
proof (prove)
using this:
map_of (map prod.swap (pivot_positions A)) j = Some i

goal (1 subgoal):
 1. vec nc (\<lambda>i. if i = j' then 1::'a else case map_of (map prod.swap (pivot_positions A)) i of None \<Rightarrow> 0::'a | Some j \<Rightarrow> - A $$ (j, j')) $ j = - A $$ (i, j')
[PROOF STEP]
using j jj'
[PROOF STATE]
proof (prove)
using this:
map_of (map prod.swap (pivot_positions A)) j = Some i
j < nc
j \<noteq> j'

goal (1 subgoal):
 1. vec nc (\<lambda>i. if i = j' then 1::'a else case map_of (map prod.swap (pivot_positions A)) i of None \<Rightarrow> 0::'a | Some j \<Rightarrow> - A $$ (j, j')) $ j = - A $$ (i, j')
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
non_pivot_base A (pivot_positions A) j' $ j = - A $$ (i, j')

goal (1 subgoal):
 1. \<And>x. x \<in> set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]) \<Longrightarrow> v $ x * non_pivot_base A (pivot_positions A) x $ j = v $ x * - A $$ (i, x)
[PROOF STEP]
thus "v $ j' * ?bi j' $ j = v $ j' * - A $$ (i,j')"
[PROOF STATE]
proof (prove)
using this:
non_pivot_base A (pivot_positions A) j' $ j = - A $$ (i, j')

goal (1 subgoal):
 1. v $ j' * non_pivot_base A (pivot_positions A) j' $ j = v $ j' * - A $$ (i, j')
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
v $ j' * non_pivot_base A (pivot_positions A) j' $ j = v $ j' * - A $$ (i, j')

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>set (filter (\<lambda>j. j \<notin> snd ` set (pivot_positions A)) [0..<nc]). v $ i * non_pivot_base A (pivot_positions A) i $ j) = v $ j

goal (2 subgoals):
 1. \<And>i. i < nc \<Longrightarrow> v $ i = lincomb a (set (find_base_vectors A)) $ i
 2. nc = nc
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
lincomb a (set (find_base_vectors A)) $ j = v $ j
[PROOF STEP]
show "v $ j = lincomb a ?B $ j"
[PROOF STATE]
proof (prove)
using this:
lincomb a (set (find_base_vectors A)) $ j = v $ j

goal (1 subgoal):
 1. v $ j = lincomb a (set (find_base_vectors A)) $ j
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
v $ j = lincomb a (set (find_base_vectors A)) $ j

goal (1 subgoal):
 1. nc = nc
[PROOF STEP]
qed auto
[PROOF STATE]
proof (state)
this:
v = lincomb a (set (find_base_vectors A))

goal (1 subgoal):
 1. \<And>x. x \<in> mat_kernel A \<Longrightarrow> x \<in> span (set (find_base_vectors A))
[PROOF STEP]
thus "v \<in> span ?B"
[PROOF STATE]
proof (prove)
using this:
v = lincomb a (set (find_base_vectors A))

goal (1 subgoal):
 1. v \<in> span (set (find_base_vectors A))
[PROOF STEP]
unfolding Ker.span_def
[PROOF STATE]
proof (prove)
using this:
v = lincomb a (set (find_base_vectors A))

goal (1 subgoal):
 1. v \<in> {lincomb a Aa |a Aa. finite Aa \<and> Aa \<subseteq> set (find_base_vectors A) \<and> a \<in> Aa \<rightarrow> UNIV}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
v \<in> span (set (find_base_vectors A))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
mat_kernel A \<subseteq> span (set (find_base_vectors A))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
span (set (find_base_vectors A)) = mat_kernel A

goal (2 subgoals):
 1. lin_indpt (set (find_base_vectors A))
 2. set (find_base_vectors A) \<subseteq> mat_kernel A
[PROOF STEP]
show "?B \<subseteq> mat_kernel A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (find_base_vectors A) \<subseteq> mat_kernel A
[PROOF STEP]
by (rule sub)
[PROOF STATE]
proof (state)
this:
set (find_base_vectors A) \<subseteq> mat_kernel A

goal (1 subgoal):
 1. lin_indpt (set (find_base_vectors A))
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
set (find_base_vectors A) \<subseteq> mat_kernel A

goal (1 subgoal):
 1. lin_indpt (set (find_base_vectors A))
[PROOF STEP]
fix a v
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. lin_indpt (set (find_base_vectors A))
[PROOF STEP]
assume lc: "lincomb a ?B = 0\<^sub>v nc" and vB: "v \<in> ?B"
[PROOF STATE]
proof (state)
this:
lincomb a (set (find_base_vectors A)) = 0\<^sub>v nc
v \<in> set (find_base_vectors A)

goal (1 subgoal):
 1. lin_indpt (set (find_base_vectors A))
[PROOF STEP]
from vB[unfolded find_base_vectors_def Let_def dim]
[PROOF STATE]
proof (chain)
picking this:
v \<in> set (map (non_pivot_base A (pivot_positions A)) (filter (\<lambda>j. j \<notin> set (map snd (pivot_positions A))) [0..<nc]))
[PROOF STEP]
obtain j where j: "j < nc" "j \<notin> snd ` ?pp" and v: "v = non_pivot_base A (pivot_positions A) j"
[PROOF STATE]
proof (prove)
using this:
v \<in> set (map (non_pivot_base A (pivot_positions A)) (filter (\<lambda>j. j \<notin> set (map snd (pivot_positions A))) [0..<nc]))

goal (1 subgoal):
 1. (\<And>j. \<lbrakk>j < nc; j \<notin> snd ` set (pivot_positions A); v = non_pivot_base A (pivot_positions A) j\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j < nc
j \<notin> snd ` set (pivot_positions A)
v = non_pivot_base A (pivot_positions A) j

goal (1 subgoal):
 1. lin_indpt (set (find_base_vectors A))
[PROOF STEP]
from arg_cong[OF lc, of "\<lambda> v. v $ j"] j
[PROOF STATE]
proof (chain)
picking this:
lincomb a (set (find_base_vectors A)) $ j = 0\<^sub>v nc $ j
j < nc
j \<notin> snd ` set (pivot_positions A)
[PROOF STEP]
have "0 = lincomb a ?B $ j"
[PROOF STATE]
proof (prove)
using this:
lincomb a (set (find_base_vectors A)) $ j = 0\<^sub>v nc $ j
j < nc
j \<notin> snd ` set (pivot_positions A)

goal (1 subgoal):
 1. (0::'a) = lincomb a (set (find_base_vectors A)) $ j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(0::'a) = lincomb a (set (find_base_vectors A)) $ j

goal (1 subgoal):
 1. lin_indpt (set (find_base_vectors A))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(0::'a) = lincomb a (set (find_base_vectors A)) $ j

goal (1 subgoal):
 1. lin_indpt (set (find_base_vectors A))
[PROOF STEP]
have "\<dots> = (\<Sum>v\<in>?B. a v * v $ j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lincomb a (set (find_base_vectors A)) $ j = (\<Sum>v\<in>set (find_base_vectors A). a v * v $ j)
[PROOF STEP]
by (subst lincomb_index[OF j(1) sub], simp)
[PROOF STATE]
proof (state)
this:
lincomb a (set (find_base_vectors A)) $ j = (\<Sum>v\<in>set (find_base_vectors A). a v * v $ j)

goal (1 subgoal):
 1. lin_indpt (set (find_base_vectors A))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
lincomb a (set (find_base_vectors A)) $ j = (\<Sum>v\<in>set (find_base_vectors A). a v * v $ j)

goal (1 subgoal):
 1. lin_indpt (set (find_base_vectors A))
[PROOF STEP]
have "\<dots> = a v * v $ j + (\<Sum>w\<in>?B - {v}. a w * w $ j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>v\<in>set (find_base_vectors A). a v * v $ j) = a v * v $ j + (\<Sum>w\<in>set (find_base_vectors A) - {v}. a w * w $ j)
[PROOF STEP]
by (subst sum.remove[OF _ vB], auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>v\<in>set (find_base_vectors A). a v * v $ j) = a v * v $ j + (\<Sum>w\<in>set (find_base_vectors A) - {v}. a w * w $ j)

goal (1 subgoal):
 1. lin_indpt (set (find_base_vectors A))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>v\<in>set (find_base_vectors A). a v * v $ j) = a v * v $ j + (\<Sum>w\<in>set (find_base_vectors A) - {v}. a w * w $ j)

goal (1 subgoal):
 1. lin_indpt (set (find_base_vectors A))
[PROOF STEP]
have "a v * v $ j = a v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a v * v $ j = a v
[PROOF STEP]
using non_pivot_base[OF j, folded v]
[PROOF STATE]
proof (prove)
using this:
v \<in> carrier_vec nc
v $ j = (1::'a)
A *\<^sub>v v = 0\<^sub>v nr
\<lbrakk>?qj' < nc; ?qj' \<notin> snd ` set (pivot_positions A); j \<noteq> ?qj'\<rbrakk> \<Longrightarrow> v $ ?qj' = (0::'a)

goal (1 subgoal):
 1. a v * v $ j = a v
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a v * v $ j = a v

goal (1 subgoal):
 1. lin_indpt (set (find_base_vectors A))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
a v * v $ j = a v

goal (1 subgoal):
 1. lin_indpt (set (find_base_vectors A))
[PROOF STEP]
have "(\<Sum>w\<in>?B - {v}. a w * w $ j) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>w\<in>set (find_base_vectors A) - {v}. a w * w $ j) = (0::'a)
[PROOF STEP]
proof (rule sum.neutral, intro ballI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> set (find_base_vectors A) - {v} \<Longrightarrow> a x * x $ j = (0::'a)
[PROOF STEP]
fix w
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> set (find_base_vectors A) - {v} \<Longrightarrow> a x * x $ j = (0::'a)
[PROOF STEP]
assume wB: "w \<in> ?B - {v}"
[PROOF STATE]
proof (state)
this:
w \<in> set (find_base_vectors A) - {v}

goal (1 subgoal):
 1. \<And>x. x \<in> set (find_base_vectors A) - {v} \<Longrightarrow> a x * x $ j = (0::'a)
[PROOF STEP]
from this[unfolded find_base_vectors_def Let_def dim]
[PROOF STATE]
proof (chain)
picking this:
w \<in> set (map (non_pivot_base A (pivot_positions A)) (filter (\<lambda>j. j \<notin> set (map snd (pivot_positions A))) [0..<nc])) - {v}
[PROOF STEP]
obtain j' where j': "j' < nc" "j' \<notin> snd ` ?pp" and w: "w = non_pivot_base A (pivot_positions A) j'"
[PROOF STATE]
proof (prove)
using this:
w \<in> set (map (non_pivot_base A (pivot_positions A)) (filter (\<lambda>j. j \<notin> set (map snd (pivot_positions A))) [0..<nc])) - {v}

goal (1 subgoal):
 1. (\<And>j'. \<lbrakk>j' < nc; j' \<notin> snd ` set (pivot_positions A); w = non_pivot_base A (pivot_positions A) j'\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j' < nc
j' \<notin> snd ` set (pivot_positions A)
w = non_pivot_base A (pivot_positions A) j'

goal (1 subgoal):
 1. \<And>x. x \<in> set (find_base_vectors A) - {v} \<Longrightarrow> a x * x $ j = (0::'a)
[PROOF STEP]
with wB v
[PROOF STATE]
proof (chain)
picking this:
w \<in> set (find_base_vectors A) - {v}
v = non_pivot_base A (pivot_positions A) j
j' < nc
j' \<notin> snd ` set (pivot_positions A)
w = non_pivot_base A (pivot_positions A) j'
[PROOF STEP]
have "j' \<noteq> j"
[PROOF STATE]
proof (prove)
using this:
w \<in> set (find_base_vectors A) - {v}
v = non_pivot_base A (pivot_positions A) j
j' < nc
j' \<notin> snd ` set (pivot_positions A)
w = non_pivot_base A (pivot_positions A) j'

goal (1 subgoal):
 1. j' \<noteq> j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j' \<noteq> j

goal (1 subgoal):
 1. \<And>x. x \<in> set (find_base_vectors A) - {v} \<Longrightarrow> a x * x $ j = (0::'a)
[PROOF STEP]
from non_pivot_base(4)[OF j' j this]
[PROOF STATE]
proof (chain)
picking this:
non_pivot_base A (pivot_positions A) j' $ j = (0::'a)
[PROOF STEP]
show "a w * w $ j = 0"
[PROOF STATE]
proof (prove)
using this:
non_pivot_base A (pivot_positions A) j' $ j = (0::'a)

goal (1 subgoal):
 1. a w * w $ j = (0::'a)
[PROOF STEP]
unfolding w
[PROOF STATE]
proof (prove)
using this:
non_pivot_base A (pivot_positions A) j' $ j = (0::'a)

goal (1 subgoal):
 1. a (non_pivot_base A (pivot_positions A) j') * non_pivot_base A (pivot_positions A) j' $ j = (0::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a w * w $ j = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>w\<in>set (find_base_vectors A) - {v}. a w * w $ j) = (0::'a)

goal (1 subgoal):
 1. lin_indpt (set (find_base_vectors A))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(0::'a) = a v + (0::'a)
[PROOF STEP]
have "a v = 0"
[PROOF STATE]
proof (prove)
using this:
(0::'a) = a v + (0::'a)

goal (1 subgoal):
 1. a v = (0::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a v = (0::'a)

goal (1 subgoal):
 1. lin_indpt (set (find_base_vectors A))
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>lincomb ?a3 (set (find_base_vectors A)) = 0\<^sub>v nc; ?v3 \<in> set (find_base_vectors A)\<rbrakk> \<Longrightarrow> ?a3 ?v3 = (0::'a)

goal (1 subgoal):
 1. lin_indpt (set (find_base_vectors A))
[PROOF STEP]
thus "\<not> lin_dep ?B"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>lincomb ?a3 (set (find_base_vectors A)) = 0\<^sub>v nc; ?v3 \<in> set (find_base_vectors A)\<rbrakk> \<Longrightarrow> ?a3 ?v3 = (0::'a)

goal (1 subgoal):
 1. lin_indpt (set (find_base_vectors A))
[PROOF STEP]
by (intro Ker.finite_lin_indpt2[OF finite_set sub], auto simp: class_field_def)
[PROOF STATE]
proof (state)
this:
lin_indpt (set (find_base_vectors A))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
basis (set (find_base_vectors A))

goal (1 subgoal):
 1. dim = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
show "dim = nc - card { i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
using Ker.dim_basis[OF finite_set basis] card
[PROOF STATE]
proof (prove)
using this:
dim = card (set (find_base_vectors A))
card (set (find_base_vectors A)) = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
length (pivot_positions A) = card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}

goal (1 subgoal):
 1. dim = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
dim = nc - card {i. i < nr \<and> row A i \<noteq> 0\<^sub>v nc}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma add_succ_right: "add m (succ n) = succ (add m n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. add m (succ n) = succ (add m n)
[PROOF STEP]
by (induct m) simp_all