[STATEMENT]
lemma powrat_less_1_cancel_iff [simp]:
  assumes x0: "0 < x" and x1: "x < 1"
  shows "(x pow\<^sub>\<rat> r < x pow\<^sub>\<rat> s) = (s < r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x pow\<^sub>\<rat> r < x pow\<^sub>\<rat> s) = (s < r)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x pow\<^sub>\<rat> r < x pow\<^sub>\<rat> s \<Longrightarrow> s < r
 2. s < r \<Longrightarrow> x pow\<^sub>\<rat> r < x pow\<^sub>\<rat> s
[PROOF STEP]
assume xrs: "x pow\<^sub>\<rat> r < x pow\<^sub>\<rat> s"
[PROOF STATE]
proof (state)
this:
x pow\<^sub>\<rat> r < x pow\<^sub>\<rat> s

goal (2 subgoals):
 1. x pow\<^sub>\<rat> r < x pow\<^sub>\<rat> s \<Longrightarrow> s < r
 2. s < r \<Longrightarrow> x pow\<^sub>\<rat> r < x pow\<^sub>\<rat> s
[PROOF STEP]
have invx: "1 < 1/x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 < 1 / x
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < x
x < 1

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

goal (2 subgoals):
 1. x pow\<^sub>\<rat> r < x pow\<^sub>\<rat> s \<Longrightarrow> s < r
 2. s < r \<Longrightarrow> x pow\<^sub>\<rat> r < x pow\<^sub>\<rat> s
[PROOF STEP]
have  "r < s \<or> r \<ge> s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r < s \<or> s \<le> r
[PROOF STEP]
using leI
[PROOF STATE]
proof (prove)
using this:
\<not> ?x < ?y \<Longrightarrow> ?y \<le> ?x

goal (1 subgoal):
 1. r < s \<or> s \<le> r
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
r < s \<or> s \<le> r

goal (2 subgoals):
 1. x pow\<^sub>\<rat> r < x pow\<^sub>\<rat> s \<Longrightarrow> s < r
 2. s < r \<Longrightarrow> x pow\<^sub>\<rat> r < x pow\<^sub>\<rat> s
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
r < s \<or> s \<le> r
[PROOF STEP]
show "s < r"
[PROOF STATE]
proof (prove)
using this:
r < s \<or> s \<le> r

goal (1 subgoal):
 1. s < r
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. r < s \<Longrightarrow> s < r
 2. s \<le> r \<Longrightarrow> s < r
[PROOF STEP]
assume "r < s"
[PROOF STATE]
proof (state)
this:
r < s

goal (2 subgoals):
 1. r < s \<Longrightarrow> s < r
 2. s \<le> r \<Longrightarrow> s < r
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
r < s
[PROOF STEP]
have " inverse x pow\<^sub>\<rat> r < inverse x pow\<^sub>\<rat> s"
[PROOF STATE]
proof (prove)
using this:
r < s

goal (1 subgoal):
 1. inverse x pow\<^sub>\<rat> r < inverse x pow\<^sub>\<rat> s
[PROOF STEP]
using invx
[PROOF STATE]
proof (prove)
using this:
r < s
1 < 1 / x

goal (1 subgoal):
 1. inverse x pow\<^sub>\<rat> r < inverse x pow\<^sub>\<rat> s
[PROOF STEP]
by (simp add: inverse_eq_divide)
[PROOF STATE]
proof (state)
this:
inverse x pow\<^sub>\<rat> r < inverse x pow\<^sub>\<rat> s

goal (2 subgoals):
 1. r < s \<Longrightarrow> s < r
 2. s \<le> r \<Longrightarrow> s < r
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
inverse x pow\<^sub>\<rat> r < inverse x pow\<^sub>\<rat> s
[PROOF STEP]
have " x pow\<^sub>\<rat> s < x pow\<^sub>\<rat> r"
[PROOF STATE]
proof (prove)
using this:
inverse x pow\<^sub>\<rat> r < inverse x pow\<^sub>\<rat> s

goal (1 subgoal):
 1. x pow\<^sub>\<rat> s < x pow\<^sub>\<rat> r
[PROOF STEP]
by (simp add: powrat_gt_zero powrat_inverse x0)
[PROOF STATE]
proof (state)
this:
x pow\<^sub>\<rat> s < x pow\<^sub>\<rat> r

goal (2 subgoals):
 1. r < s \<Longrightarrow> s < r
 2. s \<le> r \<Longrightarrow> s < r
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x pow\<^sub>\<rat> s < x pow\<^sub>\<rat> r
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
x pow\<^sub>\<rat> s < x pow\<^sub>\<rat> r

goal (1 subgoal):
 1. s < r
[PROOF STEP]
using xrs
[PROOF STATE]
proof (prove)
using this:
x pow\<^sub>\<rat> s < x pow\<^sub>\<rat> r
x pow\<^sub>\<rat> r < x pow\<^sub>\<rat> s

goal (1 subgoal):
 1. s < r
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
s < r

goal (1 subgoal):
 1. s \<le> r \<Longrightarrow> s < r
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. s \<le> r \<Longrightarrow> s < r
[PROOF STEP]
assume "r \<ge> s"
[PROOF STATE]
proof (state)
this:
s \<le> r

goal (1 subgoal):
 1. s \<le> r \<Longrightarrow> s < r
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
s \<le> r
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
s \<le> r

goal (1 subgoal):
 1. s < r
[PROOF STEP]
using less_eq_rat_def xrs
[PROOF STATE]
proof (prove)
using this:
s \<le> r
(?x \<le> ?y) = (?x < ?y \<or> ?x = ?y)
x pow\<^sub>\<rat> r < x pow\<^sub>\<rat> s

goal (1 subgoal):
 1. s < r
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
s < r

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
s < r

goal (1 subgoal):
 1. s < r \<Longrightarrow> x pow\<^sub>\<rat> r < x pow\<^sub>\<rat> s
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. s < r \<Longrightarrow> x pow\<^sub>\<rat> r < x pow\<^sub>\<rat> s
[PROOF STEP]
assume sr: "s < r"
[PROOF STATE]
proof (state)
this:
s < r

goal (1 subgoal):
 1. s < r \<Longrightarrow> x pow\<^sub>\<rat> r < x pow\<^sub>\<rat> s
[PROOF STEP]
have invx: "1 < 1/x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 < 1 / x
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < x
x < 1

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

goal (1 subgoal):
 1. s < r \<Longrightarrow> x pow\<^sub>\<rat> r < x pow\<^sub>\<rat> s
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
1 < 1 / x
[PROOF STEP]
have " inverse x pow\<^sub>\<rat> s < inverse x pow\<^sub>\<rat> r"
[PROOF STATE]
proof (prove)
using this:
1 < 1 / x

goal (1 subgoal):
 1. inverse x pow\<^sub>\<rat> s < inverse x pow\<^sub>\<rat> r
[PROOF STEP]
using invx sr
[PROOF STATE]
proof (prove)
using this:
1 < 1 / x
1 < 1 / x
s < r

goal (1 subgoal):
 1. inverse x pow\<^sub>\<rat> s < inverse x pow\<^sub>\<rat> r
[PROOF STEP]
by (simp add: inverse_eq_divide)
[PROOF STATE]
proof (state)
this:
inverse x pow\<^sub>\<rat> s < inverse x pow\<^sub>\<rat> r

goal (1 subgoal):
 1. s < r \<Longrightarrow> x pow\<^sub>\<rat> r < x pow\<^sub>\<rat> s
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
inverse x pow\<^sub>\<rat> s < inverse x pow\<^sub>\<rat> r
[PROOF STEP]
show "x pow\<^sub>\<rat> r < x pow\<^sub>\<rat> s"
[PROOF STATE]
proof (prove)
using this:
inverse x pow\<^sub>\<rat> s < inverse x pow\<^sub>\<rat> r

goal (1 subgoal):
 1. x pow\<^sub>\<rat> r < x pow\<^sub>\<rat> s
[PROOF STEP]
by (simp add: powrat_gt_zero powrat_inverse x0)
[PROOF STATE]
proof (state)
this:
x pow\<^sub>\<rat> r < x pow\<^sub>\<rat> s

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma is_nextElem_nth2: " \<exists> i j. i < length ls \<and> j < length ls \<and> ls!i = x \<and> ls!j = y
   \<and> (Suc i) mod (length ls) = j \<Longrightarrow> is_nextElem ls x y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>i j. i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j \<Longrightarrow> is_nextElem ls x y
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>i j. i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j \<Longrightarrow> is_nextElem ls x y
[PROOF STEP]
assume "\<exists> i j. i < length ls \<and> j < length ls \<and> ls!i = x \<and> ls!j = y \<and> (Suc i) mod (length ls) = j"
[PROOF STATE]
proof (state)
this:
\<exists>i j. i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j

goal (1 subgoal):
 1. \<exists>i j. i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j \<Longrightarrow> is_nextElem ls x y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>i j. i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j
[PROOF STEP]
obtain i j where vors: "i < length ls \<and> j < length ls \<and> ls!i = x \<and> ls!j = y
    \<and> (Suc i) mod (length ls) = j"
[PROOF STATE]
proof (prove)
using this:
\<exists>i j. i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j

goal (1 subgoal):
 1. (\<And>i j. i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j

goal (1 subgoal):
 1. \<exists>i j. i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j \<Longrightarrow> is_nextElem ls x y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j

goal (1 subgoal):
 1. is_nextElem ls x y
[PROOF STEP]
proof (cases "Suc i = length ls")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j; Suc i = |ls|\<rbrakk> \<Longrightarrow> is_nextElem ls x y
 2. \<lbrakk>i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j; Suc i \<noteq> |ls|\<rbrakk> \<Longrightarrow> is_nextElem ls x y
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
Suc i = |ls|

goal (2 subgoals):
 1. \<lbrakk>i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j; Suc i = |ls|\<rbrakk> \<Longrightarrow> is_nextElem ls x y
 2. \<lbrakk>i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j; Suc i \<noteq> |ls|\<rbrakk> \<Longrightarrow> is_nextElem ls x y
[PROOF STEP]
with vors
[PROOF STATE]
proof (chain)
picking this:
i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j
Suc i = |ls|
[PROOF STEP]
have "j = 0"
[PROOF STATE]
proof (prove)
using this:
i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j
Suc i = |ls|

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

goal (2 subgoals):
 1. \<lbrakk>i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j; Suc i = |ls|\<rbrakk> \<Longrightarrow> is_nextElem ls x y
 2. \<lbrakk>i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j; Suc i \<noteq> |ls|\<rbrakk> \<Longrightarrow> is_nextElem ls x y
[PROOF STEP]
(*ls ! i = last ls*)
[PROOF STATE]
proof (state)
this:
j = 0

goal (2 subgoals):
 1. \<lbrakk>i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j; Suc i = |ls|\<rbrakk> \<Longrightarrow> is_nextElem ls x y
 2. \<lbrakk>i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j; Suc i \<noteq> |ls|\<rbrakk> \<Longrightarrow> is_nextElem ls x y
[PROOF STEP]
with True vors
[PROOF STATE]
proof (chain)
picking this:
Suc i = |ls|
i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j
j = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Suc i = |ls|
i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j
j = 0

goal (1 subgoal):
 1. is_nextElem ls x y
[PROOF STEP]
apply (auto simp: is_nextElem_def)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>Suc i = |ls|; j = 0; ls \<noteq> []; x = ls ! i; y = ls ! 0; \<not> is_sublist [ls ! i, ls ! 0] ls\<rbrakk> \<Longrightarrow> ls ! i = last ls
 2. \<lbrakk>Suc i = |ls|; j = 0; ls \<noteq> []; x = ls ! i; y = ls ! 0; \<not> is_sublist [ls ! i, ls ! 0] ls\<rbrakk> \<Longrightarrow> ls ! 0 = hd ls
[PROOF STEP]
apply (cases ls rule: rev_exhaust)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<lbrakk>Suc i = |ls|; j = 0; ls \<noteq> []; x = ls ! i; y = ls ! 0; \<not> is_sublist [ls ! i, ls ! 0] ls; ls = []\<rbrakk> \<Longrightarrow> ls ! i = last ls
 2. \<And>ys ya. \<lbrakk>Suc i = |ls|; j = 0; ls \<noteq> []; x = ls ! i; y = ls ! 0; \<not> is_sublist [ls ! i, ls ! 0] ls; ls = ys @ [ya]\<rbrakk> \<Longrightarrow> ls ! i = last ls
 3. \<lbrakk>Suc i = |ls|; j = 0; ls \<noteq> []; x = ls ! i; y = ls ! 0; \<not> is_sublist [ls ! i, ls ! 0] ls\<rbrakk> \<Longrightarrow> ls ! 0 = hd ls
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Suc i = |ls|; j = 0; ls \<noteq> []; x = ls ! i; y = ls ! 0; \<not> is_sublist [ls ! i, ls ! 0] ls\<rbrakk> \<Longrightarrow> ls ! 0 = hd ls
[PROOF STEP]
apply (cases ls)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>Suc i = |ls|; j = 0; ls \<noteq> []; x = ls ! i; y = ls ! 0; \<not> is_sublist [ls ! i, ls ! 0] ls; ls = []\<rbrakk> \<Longrightarrow> ls ! 0 = hd ls
 2. \<And>a list. \<lbrakk>Suc i = |ls|; j = 0; ls \<noteq> []; x = ls ! i; y = ls ! 0; \<not> is_sublist [ls ! i, ls ! 0] ls; ls = a # list\<rbrakk> \<Longrightarrow> ls ! 0 = hd ls
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
is_nextElem ls x y

goal (1 subgoal):
 1. \<lbrakk>i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j; Suc i \<noteq> |ls|\<rbrakk> \<Longrightarrow> is_nextElem ls x y
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j; Suc i \<noteq> |ls|\<rbrakk> \<Longrightarrow> is_nextElem ls x y
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
Suc i \<noteq> |ls|

goal (1 subgoal):
 1. \<lbrakk>i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j; Suc i \<noteq> |ls|\<rbrakk> \<Longrightarrow> is_nextElem ls x y
[PROOF STEP]
with vors
[PROOF STATE]
proof (chain)
picking this:
i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j
Suc i \<noteq> |ls|
[PROOF STEP]
have "is_sublist [x,y] ls"
[PROOF STATE]
proof (prove)
using this:
i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j
Suc i \<noteq> |ls|

goal (1 subgoal):
 1. is_sublist [x, y] ls
[PROOF STEP]
apply (rule_tac is_sublist_nth2)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j; Suc i \<noteq> |ls|\<rbrakk> \<Longrightarrow> \<exists>i j. i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i = j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
is_sublist [x, y] ls

goal (1 subgoal):
 1. \<lbrakk>i < |ls| \<and> j < |ls| \<and> ls ! i = x \<and> ls ! j = y \<and> Suc i mod |ls| = j; Suc i \<noteq> |ls|\<rbrakk> \<Longrightarrow> is_nextElem ls x y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
is_sublist [x, y] ls
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
is_sublist [x, y] ls

goal (1 subgoal):
 1. is_nextElem ls x y
[PROOF STEP]
by (simp add: is_nextElem_def)
[PROOF STATE]
proof (state)
this:
is_nextElem ls x y

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
is_nextElem ls x y

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma res_ri2: "x \<le> y \<Longrightarrow> z \<cdot> (z \<rightarrow> x) \<le> z \<cdot> (z \<rightarrow> y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<le> y \<Longrightarrow> z \<cdot> (z \<rightarrow> x) \<le> z \<cdot> (z \<rightarrow> y)
[PROOF STEP]
by (metis local.res_i2 resr_eq residuated_multr)


[STATEMENT]
lemma mem_permute_set:
  shows "x \<in> p \<bullet> S \<longleftrightarrow> (- p \<bullet> x) \<in> S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x \<in> p \<bullet> S) = (- p \<bullet> x \<in> S)
[PROOF STEP]
by (metis mem_permute_iff permute_minus_cancel(2))


[STATEMENT]
lemma SA_car:
"carrier (SA n) = semialg_functions n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. carrier (SA n) = semialg_functions n
[PROOF STEP]
unfolding SA_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. carrier (function_ring (carrier (Q\<^sub>p\<^bsup>n\<^esup>)) Q\<^sub>p\<lparr>carrier := semialg_functions n\<rparr>) = semialg_functions n
[PROOF STEP]
by simp


[STATEMENT]
lemma filtermap_ln_at_right: "filtermap ln (at_right (0::real)) = at_bot"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. filtermap ln (at_right 0) = at_bot
[PROOF STEP]
by (auto intro!: filtermap_fun_inverse[where g="\<lambda>x. exp x"] ln_at_0
      simp: filterlim_at exp_at_bot)


[STATEMENT]
lemma (in is_functor) umap_of_ArrVal_vdomain:
  assumes "u : c \<mapsto>\<^bsub>\<BB>\<^esub> \<FF>\<lparr>ObjMap\<rparr>\<lparr>r\<rparr>"
  shows "\<D>\<^sub>\<circ> (umap_of \<FF> c r u d\<lparr>ArrVal\<rparr>) = Hom \<AA> r d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<D>\<^sub>\<circ> (umap_of \<FF> c r u d\<lparr>ArrVal\<rparr>) = Hom \<AA> r d
[PROOF STEP]
unfolding umap_of_components[OF assms]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<D>\<^sub>\<circ> (\<lambda>f'\<in>\<^sub>\<circ>Hom \<AA> r d. \<FF>\<lparr>ArrMap\<rparr>\<lparr>f'\<rparr> \<circ>\<^sub>A\<^bsub>\<BB>\<^esub> u) = Hom \<AA> r d
[PROOF STEP]
by simp


[STATEMENT]
lemma ltrm_rep_X_pow:
  assumes "p \<in> carrier P"
  shows "ltrm p = (lcf p)\<odot>\<^bsub>P\<^esub>(X[^]\<^bsub>P\<^esub>(degree p))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. monom P (p (deg R p)) (deg R p) = p (deg R p) \<odot>\<^bsub>P\<^esub> X_poly R [^]\<^bsub>P\<^esub> deg R p
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. monom P (p (deg R p)) (deg R p) = p (deg R p) \<odot>\<^bsub>P\<^esub> X_poly R [^]\<^bsub>P\<^esub> deg R p
[PROOF STEP]
have "ltrm p =  monom P (lcf p) (degree p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. monom P (p (deg R p)) (deg R p) = monom P (p (deg R p)) (deg R p)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
p \<in> carrier P

goal (1 subgoal):
 1. monom P (p (deg R p)) (deg R p) = monom P (p (deg R p)) (deg R p)
[PROOF STEP]
unfolding leading_term_def
[PROOF STATE]
proof (prove)
using this:
p \<in> carrier P

goal (1 subgoal):
 1. monom P (p (deg R p)) (deg R p) = monom P (p (deg R p)) (deg R p)
[PROOF STEP]
by (simp add: P_def)
[PROOF STATE]
proof (state)
this:
monom P (p (deg R p)) (deg R p) = monom P (p (deg R p)) (deg R p)

goal (1 subgoal):
 1. monom P (p (deg R p)) (deg R p) = p (deg R p) \<odot>\<^bsub>P\<^esub> X_poly R [^]\<^bsub>P\<^esub> deg R p
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
monom P (p (deg R p)) (deg R p) = monom P (p (deg R p)) (deg R p)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
monom P (p (deg R p)) (deg R p) = monom P (p (deg R p)) (deg R p)

goal (1 subgoal):
 1. monom P (p (deg R p)) (deg R p) = p (deg R p) \<odot>\<^bsub>P\<^esub> X_poly R [^]\<^bsub>P\<^esub> deg R p
[PROOF STEP]
using monom_rep_X_pow P_def assms
[PROOF STATE]
proof (prove)
using this:
monom P (p (deg R p)) (deg R p) = monom P (p (deg R p)) (deg R p)
?a \<in> carrier R \<Longrightarrow> monom P ?a ?n = ?a \<odot>\<^bsub>P\<^esub> X_poly R [^]\<^bsub>P\<^esub> ?n
P \<equiv> UP R
p \<in> carrier P

goal (1 subgoal):
 1. monom P (p (deg R p)) (deg R p) = p (deg R p) \<odot>\<^bsub>P\<^esub> X_poly R [^]\<^bsub>P\<^esub> deg R p
[PROOF STEP]
by (simp add: cfs_closed)
[PROOF STATE]
proof (state)
this:
monom P (p (deg R p)) (deg R p) = p (deg R p) \<odot>\<^bsub>P\<^esub> X_poly R [^]\<^bsub>P\<^esub> deg R p

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ni_idempotent:
  "ni(ni(x)) = ni(x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ni (ni x) = ni x
[PROOF STEP]
by (simp add: n_n_L ni_def)


[STATEMENT]
lemma example1:
  assumes "R>1"
  shows "winding_number (part_circlepath 0 R 0 pi +++ linepath (-R) R) \<i> = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. winding_number (part_circlepath 0 R 0 pi +++ (\<lambda>x. complex_of_real (linepath (- R) R x))) \<i> = 1
[PROOF STEP]
proof (eval_winding,simp_all)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<i> \<notin> path_image (part_circlepath 0 R 0 pi)
 2. \<i> \<notin> closed_segment (- complex_of_real R) (complex_of_real R)
 3. - complex_of_real (cindex_pathE (part_circlepath 0 R 0 pi) \<i>) - complex_of_real (cindex_pathE (linepath (- complex_of_real R) (complex_of_real R)) \<i>) = 2
[PROOF STEP]
define CR where  "CR \<equiv>part_circlepath 0 R 0 pi"
[PROOF STATE]
proof (state)
this:
CR \<equiv> part_circlepath 0 R 0 pi

goal (3 subgoals):
 1. \<i> \<notin> path_image (part_circlepath 0 R 0 pi)
 2. \<i> \<notin> closed_segment (- complex_of_real R) (complex_of_real R)
 3. - complex_of_real (cindex_pathE (part_circlepath 0 R 0 pi) \<i>) - complex_of_real (cindex_pathE (linepath (- complex_of_real R) (complex_of_real R)) \<i>) = 2
[PROOF STEP]
define L where "L\<equiv> linepath (- (complex_of_real R)) R"
[PROOF STATE]
proof (state)
this:
L \<equiv> linepath (- complex_of_real R) (complex_of_real R)

goal (3 subgoals):
 1. \<i> \<notin> path_image (part_circlepath 0 R 0 pi)
 2. \<i> \<notin> closed_segment (- complex_of_real R) (complex_of_real R)
 3. - complex_of_real (cindex_pathE (part_circlepath 0 R 0 pi) \<i>) - complex_of_real (cindex_pathE (linepath (- complex_of_real R) (complex_of_real R)) \<i>) = 2
[PROOF STEP]
show "\<i> \<notin> path_image CR"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<i> \<notin> path_image CR
[PROOF STEP]
unfolding CR_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<i> \<notin> path_image (part_circlepath 0 R 0 pi)
[PROOF STEP]
using \<open>R>1\<close>
[PROOF STATE]
proof (prove)
using this:
1 < R

goal (1 subgoal):
 1. \<i> \<notin> path_image (part_circlepath 0 R 0 pi)
[PROOF STEP]
by (intro not_on_circlepathI,auto)
[PROOF STATE]
proof (state)
this:
\<i> \<notin> path_image CR

goal (2 subgoals):
 1. \<i> \<notin> closed_segment (- complex_of_real R) (complex_of_real R)
 2. - complex_of_real (cindex_pathE (part_circlepath 0 R 0 pi) \<i>) - complex_of_real (cindex_pathE (linepath (- complex_of_real R) (complex_of_real R)) \<i>) = 2
[PROOF STEP]
show *:"\<i> \<notin> closed_segment (- (of_real R)) R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<i> \<notin> closed_segment (- complex_of_real R) (complex_of_real R)
[PROOF STEP]
using \<open>R>1\<close> complex_eq_iff
[PROOF STATE]
proof (prove)
using this:
1 < R
(?x = ?y) = (Re ?x = Re ?y \<and> Im ?x = Im ?y)

goal (1 subgoal):
 1. \<i> \<notin> closed_segment (- complex_of_real R) (complex_of_real R)
[PROOF STEP]
by (intro not_on_closed_segmentI,auto)
[PROOF STATE]
proof (state)
this:
\<i> \<notin> closed_segment (- complex_of_real R) (complex_of_real R)

goal (1 subgoal):
 1. - complex_of_real (cindex_pathE (part_circlepath 0 R 0 pi) \<i>) - complex_of_real (cindex_pathE (linepath (- complex_of_real R) (complex_of_real R)) \<i>) = 2
[PROOF STEP]
from cindex_pathE_linepath[OF this]
[PROOF STATE]
proof (chain)
picking this:
cindex_pathE (linepath (- complex_of_real R) (complex_of_real R)) \<i> = (let c1 = Re (- complex_of_real R) - Re \<i>; c2 = Re (complex_of_real R) - Re \<i>; c3 = Im (- complex_of_real R) * Re (complex_of_real R) + Re \<i> * Im (complex_of_real R) + Im \<i> * Re (- complex_of_real R) - Im \<i> * Re (complex_of_real R) - Im (complex_of_real R) * Re (- complex_of_real R) - Re \<i> * Im (- complex_of_real R); d1 = Im (- complex_of_real R) - Im \<i>; d2 = Im (complex_of_real R) - Im \<i> in if 0 < c1 \<and> c2 < 0 \<or> c1 < 0 \<and> 0 < c2 then if 0 < c3 then 1 else - 1 else if (c1 = 0) = (c2 \<noteq> 0) \<and> (c1 = 0 \<longrightarrow> d1 \<noteq> 0) \<and> (c2 = 0 \<longrightarrow> d2 \<noteq> 0) then if c1 = 0 \<and> (0 < c2) = (0 < d1) \<or> c2 = 0 \<and> (0 < c1) = (d2 < 0) then 1 / 2 else - 1 / 2 else 0)
[PROOF STEP]
have "cindex_pathE L \<i> = -1"
[PROOF STATE]
proof (prove)
using this:
cindex_pathE (linepath (- complex_of_real R) (complex_of_real R)) \<i> = (let c1 = Re (- complex_of_real R) - Re \<i>; c2 = Re (complex_of_real R) - Re \<i>; c3 = Im (- complex_of_real R) * Re (complex_of_real R) + Re \<i> * Im (complex_of_real R) + Im \<i> * Re (- complex_of_real R) - Im \<i> * Re (complex_of_real R) - Im (complex_of_real R) * Re (- complex_of_real R) - Re \<i> * Im (- complex_of_real R); d1 = Im (- complex_of_real R) - Im \<i>; d2 = Im (complex_of_real R) - Im \<i> in if 0 < c1 \<and> c2 < 0 \<or> c1 < 0 \<and> 0 < c2 then if 0 < c3 then 1 else - 1 else if (c1 = 0) = (c2 \<noteq> 0) \<and> (c1 = 0 \<longrightarrow> d1 \<noteq> 0) \<and> (c2 = 0 \<longrightarrow> d2 \<noteq> 0) then if c1 = 0 \<and> (0 < c2) = (0 < d1) \<or> c2 = 0 \<and> (0 < c1) = (d2 < 0) then 1 / 2 else - 1 / 2 else 0)

goal (1 subgoal):
 1. cindex_pathE L \<i> = - 1
[PROOF STEP]
unfolding L_def
[PROOF STATE]
proof (prove)
using this:
cindex_pathE (linepath (- complex_of_real R) (complex_of_real R)) \<i> = (let c1 = Re (- complex_of_real R) - Re \<i>; c2 = Re (complex_of_real R) - Re \<i>; c3 = Im (- complex_of_real R) * Re (complex_of_real R) + Re \<i> * Im (complex_of_real R) + Im \<i> * Re (- complex_of_real R) - Im \<i> * Re (complex_of_real R) - Im (complex_of_real R) * Re (- complex_of_real R) - Re \<i> * Im (- complex_of_real R); d1 = Im (- complex_of_real R) - Im \<i>; d2 = Im (complex_of_real R) - Im \<i> in if 0 < c1 \<and> c2 < 0 \<or> c1 < 0 \<and> 0 < c2 then if 0 < c3 then 1 else - 1 else if (c1 = 0) = (c2 \<noteq> 0) \<and> (c1 = 0 \<longrightarrow> d1 \<noteq> 0) \<and> (c2 = 0 \<longrightarrow> d2 \<noteq> 0) then if c1 = 0 \<and> (0 < c2) = (0 < d1) \<or> c2 = 0 \<and> (0 < c1) = (d2 < 0) then 1 / 2 else - 1 / 2 else 0)

goal (1 subgoal):
 1. cindex_pathE (linepath (- complex_of_real R) (complex_of_real R)) \<i> = - 1
[PROOF STEP]
using \<open>R>1\<close>
[PROOF STATE]
proof (prove)
using this:
cindex_pathE (linepath (- complex_of_real R) (complex_of_real R)) \<i> = (let c1 = Re (- complex_of_real R) - Re \<i>; c2 = Re (complex_of_real R) - Re \<i>; c3 = Im (- complex_of_real R) * Re (complex_of_real R) + Re \<i> * Im (complex_of_real R) + Im \<i> * Re (- complex_of_real R) - Im \<i> * Re (complex_of_real R) - Im (complex_of_real R) * Re (- complex_of_real R) - Re \<i> * Im (- complex_of_real R); d1 = Im (- complex_of_real R) - Im \<i>; d2 = Im (complex_of_real R) - Im \<i> in if 0 < c1 \<and> c2 < 0 \<or> c1 < 0 \<and> 0 < c2 then if 0 < c3 then 1 else - 1 else if (c1 = 0) = (c2 \<noteq> 0) \<and> (c1 = 0 \<longrightarrow> d1 \<noteq> 0) \<and> (c2 = 0 \<longrightarrow> d2 \<noteq> 0) then if c1 = 0 \<and> (0 < c2) = (0 < d1) \<or> c2 = 0 \<and> (0 < c1) = (d2 < 0) then 1 / 2 else - 1 / 2 else 0)
1 < R

goal (1 subgoal):
 1. cindex_pathE (linepath (- complex_of_real R) (complex_of_real R)) \<i> = - 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
cindex_pathE L \<i> = - 1

goal (1 subgoal):
 1. - complex_of_real (cindex_pathE (part_circlepath 0 R 0 pi) \<i>) - complex_of_real (cindex_pathE (linepath (- complex_of_real R) (complex_of_real R)) \<i>) = 2
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
cindex_pathE L \<i> = - 1

goal (1 subgoal):
 1. - complex_of_real (cindex_pathE (part_circlepath 0 R 0 pi) \<i>) - complex_of_real (cindex_pathE (linepath (- complex_of_real R) (complex_of_real R)) \<i>) = 2
[PROOF STEP]
have "cindex_pathE CR \<i> = -1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cindex_pathE CR \<i> = - 1
[PROOF STEP]
unfolding CR_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cindex_pathE (part_circlepath 0 R 0 pi) \<i> = - 1
[PROOF STEP]
using \<open>R>1\<close>
[PROOF STATE]
proof (prove)
using this:
1 < R

goal (1 subgoal):
 1. cindex_pathE (part_circlepath 0 R 0 pi) \<i> = - 1
[PROOF STEP]
apply (subst cindex_pathE_part_circlepath)
[PROOF STATE]
proof (prove)
goal (6 subgoals):
 1. 1 < R \<Longrightarrow> cmod (0 - \<i>) \<noteq> R
 2. 1 < R \<Longrightarrow> 0 < R
 3. 1 < R \<Longrightarrow> 0 \<le> 0
 4. 1 < R \<Longrightarrow> 0 < pi
 5. 1 < R \<Longrightarrow> pi \<le> 2 * pi
 6. 1 < R \<Longrightarrow> (if \<bar>Re 0 - Re \<i>\<bar> < R then let \<theta> = arccos ((Re \<i> - Re 0) / R); \<beta> = 2 * pi - \<theta> in jumpF_pathstart (part_circlepath 0 R 0 pi) \<i> + (if 0 < \<theta> \<and> \<theta> < pi then if Im \<i> < R * sin \<theta> + Im 0 then - 1 else 1 else 0) + (if 0 < \<beta> \<and> \<beta> < pi then if Im \<i> < R * sin \<beta> + Im 0 then 1 else - 1 else 0) - jumpF_pathfinish (part_circlepath 0 R 0 pi) \<i> else if \<bar>Re 0 - Re \<i>\<bar> = R then jumpF_pathstart (part_circlepath 0 R 0 pi) \<i> - jumpF_pathfinish (part_circlepath 0 R 0 pi) \<i> else 0) = - 1
[PROOF STEP]
by (simp_all add:jumpF_pathstart_part_circlepath jumpF_pathfinish_part_circlepath)
[PROOF STATE]
proof (state)
this:
cindex_pathE CR \<i> = - 1

goal (1 subgoal):
 1. - complex_of_real (cindex_pathE (part_circlepath 0 R 0 pi) \<i>) - complex_of_real (cindex_pathE (linepath (- complex_of_real R) (complex_of_real R)) \<i>) = 2
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
cindex_pathE L \<i> = - 1
cindex_pathE CR \<i> = - 1
[PROOF STEP]
show "- complex_of_real (cindex_pathE CR \<i>) - cindex_pathE L \<i> = 2"
[PROOF STATE]
proof (prove)
using this:
cindex_pathE L \<i> = - 1
cindex_pathE CR \<i> = - 1

goal (1 subgoal):
 1. - complex_of_real (cindex_pathE CR \<i>) - complex_of_real (cindex_pathE L \<i>) = 2
[PROOF STEP]
unfolding L_def CR_def
[PROOF STATE]
proof (prove)
using this:
cindex_pathE (linepath (- complex_of_real R) (complex_of_real R)) \<i> = - 1
cindex_pathE (part_circlepath 0 R 0 pi) \<i> = - 1

goal (1 subgoal):
 1. - complex_of_real (cindex_pathE (part_circlepath 0 R 0 pi) \<i>) - complex_of_real (cindex_pathE (linepath (- complex_of_real R) (complex_of_real R)) \<i>) = 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
- complex_of_real (cindex_pathE CR \<i>) - complex_of_real (cindex_pathE L \<i>) = 2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in vec_space) basis_completion: fixes v :: "'a :: field vec"
  assumes v: "v \<in> carrier_vec n"
      and v0: "v \<noteq> 0\<^sub>v n"
  shows
    "basis (set (basis_completion v))"
    "set (basis_completion v) \<subseteq> carrier_vec n"
    "span (set (basis_completion v)) = carrier_vec n"
    "distinct (basis_completion v)"
    "\<not> lin_dep (set (basis_completion v))"
    "length (basis_completion v) = n"
    "hd (basis_completion v) = v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (basis (set (basis_completion v)) &&& set (basis_completion v) \<subseteq> carrier_vec n &&& local.span (set (basis_completion v)) = carrier_vec n) &&& (distinct (basis_completion v) &&& lin_indpt (set (basis_completion v))) &&& length (basis_completion v) = n &&& hd (basis_completion v) = v
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
let ?b = "basis_completion v"
[PROOF STATE]
proof (state)
goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
note d = basis_completion_def Let_def
[PROOF STATE]
proof (state)
this:
basis_completion ?v \<equiv> let n = dim_vec ?v; drop_index = hd (concat (map (\<lambda>i. if ?v $ i \<noteq> (0::?'a) then [i] else []) [0..<n])) in Let (concat (map (\<lambda>i. if i \<noteq> drop_index then [unit_vec n i] else []) [0..<n])) ((#) ?v)
Let ?s ?f \<equiv> ?f ?s

goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
from v
[PROOF STATE]
proof (chain)
picking this:
v \<in> carrier_vec n
[PROOF STEP]
have dim: "dim_vec v = n"
[PROOF STATE]
proof (prove)
using this:
v \<in> carrier_vec n

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

goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
let ?is = "[ i . i <- [0..<n], v $ i \<noteq> 0]"
[PROOF STATE]
proof (state)
goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
assume empty: "set ?is = {}"
[PROOF STATE]
proof (state)
this:
set (concat (map (\<lambda>i. if v $ i \<noteq> (0::'a) then [i] else []) [0..<n])) = {}

goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
have "v = 0\<^sub>v n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v = 0\<^sub>v n
[PROOF STEP]
by (rule eq_vecI, insert empty v, auto)
[PROOF STATE]
proof (state)
this:
v = 0\<^sub>v n

goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
set (concat (map (\<lambda>i. if v $ i \<noteq> (0::'a) then [i] else []) [0..<n])) = {} \<Longrightarrow> v = 0\<^sub>v n

goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
with v0
[PROOF STATE]
proof (chain)
picking this:
v \<noteq> 0\<^sub>v n
set (concat (map (\<lambda>i. if v $ i \<noteq> (0::'a) then [i] else []) [0..<n])) = {} \<Longrightarrow> v = 0\<^sub>v n
[PROOF STEP]
obtain k ids where id: "?is = k # ids" and mem: "k \<in> set ?is"
[PROOF STATE]
proof (prove)
using this:
v \<noteq> 0\<^sub>v n
set (concat (map (\<lambda>i. if v $ i \<noteq> (0::'a) then [i] else []) [0..<n])) = {} \<Longrightarrow> v = 0\<^sub>v n

goal (1 subgoal):
 1. (\<And>k ids. \<lbrakk>concat (map (\<lambda>i. if v $ i \<noteq> (0::'a) then [i] else []) [0..<n]) = k # ids; k \<in> set (concat (map (\<lambda>i. if v $ i \<noteq> (0::'a) then [i] else []) [0..<n]))\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (cases ?is, auto)
[PROOF STATE]
proof (state)
this:
concat (map (\<lambda>i. if v $ i \<noteq> (0::'a) then [i] else []) [0..<n]) = k # ids
k \<in> set (concat (map (\<lambda>i. if v $ i \<noteq> (0::'a) then [i] else []) [0..<n]))

goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
from mem
[PROOF STATE]
proof (chain)
picking this:
k \<in> set (concat (map (\<lambda>i. if v $ i \<noteq> (0::'a) then [i] else []) [0..<n]))
[PROOF STEP]
have vk: "v $ k \<noteq> 0" and k: "k < n"
[PROOF STATE]
proof (prove)
using this:
k \<in> set (concat (map (\<lambda>i. if v $ i \<noteq> (0::'a) then [i] else []) [0..<n]))

goal (1 subgoal):
 1. v $ k \<noteq> (0::'a) &&& k < n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
v $ k \<noteq> (0::'a)
k < n

goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
v $ k \<noteq> (0::'a)
k < n

goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
assume i: "\<not> i < k"
[PROOF STATE]
proof (state)
this:
\<not> i < k

goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
have id: "k # [Suc k..<n] = [k ..< n]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k # [Suc k..<n] = [k..<n]
[PROOF STEP]
using k
[PROOF STATE]
proof (prove)
using this:
k < n

goal (1 subgoal):
 1. k # [Suc k..<n] = [k..<n]
[PROOF STEP]
by (simp add: upt_conv_Cons)
[PROOF STATE]
proof (state)
this:
k # [Suc k..<n] = [k..<n]

goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
from i
[PROOF STATE]
proof (chain)
picking this:
\<not> i < k
[PROOF STEP]
have "i < n \<Longrightarrow> (k # [Suc k..<n]) ! (i - k) = i"
[PROOF STATE]
proof (prove)
using this:
\<not> i < k

goal (1 subgoal):
 1. i < n \<Longrightarrow> (k # [Suc k..<n]) ! (i - k) = i
[PROOF STEP]
unfolding id
[PROOF STATE]
proof (prove)
using this:
\<not> i < k

goal (1 subgoal):
 1. i < n \<Longrightarrow> [k..<n] ! (i - k) = i
[PROOF STEP]
by (subst nth_upt, auto)
[PROOF STATE]
proof (state)
this:
i < n \<Longrightarrow> (k # [Suc k..<n]) ! (i - k) = i

goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>\<not> ?i3 < k; ?i3 < n\<rbrakk> \<Longrightarrow> (k # [Suc k..<n]) ! (?i3 - k) = ?i3

goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
hence split: "[0 ..< n] = [0 ..< k] @ k # [Suc k ..< n]"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> ?i3 < k; ?i3 < n\<rbrakk> \<Longrightarrow> (k # [Suc k..<n]) ! (?i3 - k) = ?i3

goal (1 subgoal):
 1. [0..<n] = [0..<k] @ k # [Suc k..<n]
[PROOF STEP]
by (intro nth_equalityI, insert k, auto simp: nth_append)
[PROOF STATE]
proof (state)
this:
[0..<n] = [0..<k] @ k # [Suc k..<n]

goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
[0..<n] = [0..<k] @ k # [Suc k..<n]

goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
fix as
[PROOF STATE]
proof (state)
goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
assume "k \<notin> set as"
[PROOF STATE]
proof (state)
this:
k \<notin> set as

goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
hence "[unit_vec n i. i <- as, i \<noteq> k] = [unit_vec n i. i <- as]"
[PROOF STATE]
proof (prove)
using this:
k \<notin> set as

goal (1 subgoal):
 1. concat (map (\<lambda>i. if i \<noteq> k then [unit_vec n i] else []) as) = map (unit_vec n) as
[PROOF STEP]
by (induct as, auto)
[PROOF STATE]
proof (state)
this:
concat (map (\<lambda>i. if i \<noteq> k then [unit_vec n i] else []) as) = map (unit_vec n) as

goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
k \<notin> set ?as5 \<Longrightarrow> concat (map (\<lambda>i. if i \<noteq> k then [unit_vec n i] else []) ?as5) = map (unit_vec n) ?as5

goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
note conv = this
[PROOF STATE]
proof (state)
this:
k \<notin> set ?as5 \<Longrightarrow> concat (map (\<lambda>i. if i \<noteq> k then [unit_vec n i] else []) ?as5) = map (unit_vec n) ?as5

goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
have b_all: "?b = v # [unit_vec n i. i <- [0..<n], i \<noteq> k]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. basis_completion v = v # concat (map (\<lambda>i. if i \<noteq> k then [unit_vec n i] else []) [0..<n])
[PROOF STEP]
unfolding d dim id
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v # concat (map (\<lambda>i. if i \<noteq> hd (k # ids) then [unit_vec n i] else []) [0..<n]) = v # concat (map (\<lambda>i. if i \<noteq> k then [unit_vec n i] else []) [0..<n])
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
basis_completion v = v # concat (map (\<lambda>i. if i \<noteq> k then [unit_vec n i] else []) [0..<n])

goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
basis_completion v = v # concat (map (\<lambda>i. if i \<noteq> k then [unit_vec n i] else []) [0..<n])

goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
have "[unit_vec n i. i <- [0..<n], i \<noteq> k] = [unit_vec n i. i <- [0..<k]] @ [unit_vec n i. i <- [Suc k..<n]]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. concat (map (\<lambda>i. if i \<noteq> k then [unit_vec n i] else []) [0..<n]) = map (unit_vec n) [0..<k] @ map (unit_vec n) [Suc k..<n]
[PROOF STEP]
unfolding split
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. concat (map (\<lambda>i. if i \<noteq> k then [unit_vec n i] else []) ([0..<k] @ k # [Suc k..<n])) = map (unit_vec n) [0..<k] @ map (unit_vec n) [Suc k..<n]
[PROOF STEP]
by (auto simp: conv)
[PROOF STATE]
proof (state)
this:
concat (map (\<lambda>i. if i \<noteq> k then [unit_vec n i] else []) [0..<n]) = map (unit_vec n) [0..<k] @ map (unit_vec n) [Suc k..<n]

goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
basis_completion v = v # map (unit_vec n) [0..<k] @ map (unit_vec n) [Suc k..<n]
[PROOF STEP]
have b: "?b = v # [unit_vec n i. i <- [0..<k]] @ [unit_vec n i. i <- [Suc k..<n]]"
[PROOF STATE]
proof (prove)
using this:
basis_completion v = v # map (unit_vec n) [0..<k] @ map (unit_vec n) [Suc k..<n]

goal (1 subgoal):
 1. basis_completion v = v # map (unit_vec n) [0..<k] @ map (unit_vec n) [Suc k..<n]
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
basis_completion v = v # map (unit_vec n) [0..<k] @ map (unit_vec n) [Suc k..<n]

goal (7 subgoals):
 1. basis (set (basis_completion v))
 2. set (basis_completion v) \<subseteq> carrier_vec n
 3. local.span (set (basis_completion v)) = carrier_vec n
 4. distinct (basis_completion v)
 5. lin_indpt (set (basis_completion v))
 6. length (basis_completion v) = n
 7. hd (basis_completion v) = v
[PROOF STEP]
show carr: "set ?b \<subseteq> carrier_vec n" (is "?S \<subseteq> _")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (basis_completion v) \<subseteq> carrier_vec n
[PROOF STEP]
unfolding b
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (v # map (unit_vec n) [0..<k] @ map (unit_vec n) [Suc k..<n]) \<subseteq> carrier_vec n
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
v \<in> carrier_vec n
v \<noteq> 0\<^sub>v n

goal (1 subgoal):
 1. set (v # map (unit_vec n) [0..<k] @ map (unit_vec n) [Suc k..<n]) \<subseteq> carrier_vec n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set (basis_completion v) \<subseteq> carrier_vec n

goal (6 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. distinct (basis_completion v)
 4. lin_indpt (set (basis_completion v))
 5. length (basis_completion v) = n
 6. hd (basis_completion v) = v
[PROOF STEP]
show "hd ?b = v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. hd (basis_completion v) = v
[PROOF STEP]
unfolding b
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. hd (v # map (unit_vec n) [0..<k] @ map (unit_vec n) [Suc k..<n]) = v
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
hd (basis_completion v) = v

goal (5 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. distinct (basis_completion v)
 4. lin_indpt (set (basis_completion v))
 5. length (basis_completion v) = n
[PROOF STEP]
show len: "length (basis_completion v) = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (basis_completion v) = n
[PROOF STEP]
unfolding b
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (v # map (unit_vec n) [0..<k] @ map (unit_vec n) [Suc k..<n]) = n
[PROOF STEP]
using k
[PROOF STATE]
proof (prove)
using this:
k < n

goal (1 subgoal):
 1. length (v # map (unit_vec n) [0..<k] @ map (unit_vec n) [Suc k..<n]) = n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (basis_completion v) = n

goal (4 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. distinct (basis_completion v)
 4. lin_indpt (set (basis_completion v))
[PROOF STEP]
define I where "I = (\<lambda> i. if i < k then i else Suc i)"
[PROOF STATE]
proof (state)
this:
I = (\<lambda>i. if i < k then i else Suc i)

goal (4 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. distinct (basis_completion v)
 4. lin_indpt (set (basis_completion v))
[PROOF STEP]
have I: "\<And> i. I i \<noteq> k" "\<And> i. Suc i < n \<Longrightarrow> I i < n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>i. I i \<noteq> k) &&& (\<And>i. Suc i < n \<Longrightarrow> I i < n)
[PROOF STEP]
unfolding I_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>i. (if i < k then i else Suc i) \<noteq> k) &&& (\<And>i. Suc i < n \<Longrightarrow> (if i < k then i else Suc i) < n)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
I ?i2 \<noteq> k
Suc ?i2 < n \<Longrightarrow> I ?i2 < n

goal (4 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. distinct (basis_completion v)
 4. lin_indpt (set (basis_completion v))
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
I ?i2 \<noteq> k
Suc ?i2 < n \<Longrightarrow> I ?i2 < n

goal (4 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. distinct (basis_completion v)
 4. lin_indpt (set (basis_completion v))
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. distinct (basis_completion v)
 4. lin_indpt (set (basis_completion v))
[PROOF STEP]
assume i: "i < n"
[PROOF STATE]
proof (state)
this:
i < n

goal (4 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. distinct (basis_completion v)
 4. lin_indpt (set (basis_completion v))
[PROOF STEP]
have "?b ! i = (if i = 0 then v else unit_vec n (I (i - 1)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. basis_completion v ! i = (if i = 0 then v else unit_vec n (I (i - 1)))
[PROOF STEP]
unfolding b I_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (v # map (unit_vec n) [0..<k] @ map (unit_vec n) [Suc k..<n]) ! i = (if i = 0 then v else unit_vec n (if i - 1 < k then i - 1 else Suc (i - 1)))
[PROOF STEP]
using i
[PROOF STATE]
proof (prove)
using this:
i < n

goal (1 subgoal):
 1. (v # map (unit_vec n) [0..<k] @ map (unit_vec n) [Suc k..<n]) ! i = (if i = 0 then v else unit_vec n (if i - 1 < k then i - 1 else Suc (i - 1)))
[PROOF STEP]
by (auto split: if_splits simp: nth_append)
[PROOF STATE]
proof (state)
this:
basis_completion v ! i = (if i = 0 then v else unit_vec n (I (i - 1)))

goal (4 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. distinct (basis_completion v)
 4. lin_indpt (set (basis_completion v))
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?i4 < n \<Longrightarrow> basis_completion v ! ?i4 = (if ?i4 = 0 then v else unit_vec n (I (?i4 - 1)))

goal (4 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. distinct (basis_completion v)
 4. lin_indpt (set (basis_completion v))
[PROOF STEP]
note bi = this
[PROOF STATE]
proof (state)
this:
?i4 < n \<Longrightarrow> basis_completion v ! ?i4 = (if ?i4 = 0 then v else unit_vec n (I (?i4 - 1)))

goal (4 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. distinct (basis_completion v)
 4. lin_indpt (set (basis_completion v))
[PROOF STEP]
show dist: "distinct ?b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct (basis_completion v)
[PROOF STEP]
unfolding distinct_conv_nth len
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i<n. \<forall>j<n. i \<noteq> j \<longrightarrow> basis_completion v ! i \<noteq> basis_completion v ! j
[PROOF STEP]
proof (intro allI impI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < n; j < n; i \<noteq> j\<rbrakk> \<Longrightarrow> basis_completion v ! i \<noteq> basis_completion v ! j
[PROOF STEP]
fix i j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < n; j < n; i \<noteq> j\<rbrakk> \<Longrightarrow> basis_completion v ! i \<noteq> basis_completion v ! j
[PROOF STEP]
assume i: "i < n" and j: "j < n" and ij: "i \<noteq> j"
[PROOF STATE]
proof (state)
this:
i < n
j < n
i \<noteq> j

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < n; j < n; i \<noteq> j\<rbrakk> \<Longrightarrow> basis_completion v ! i \<noteq> basis_completion v ! j
[PROOF STEP]
show "?b ! i \<noteq> ?b ! j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. basis_completion v ! i \<noteq> basis_completion v ! j
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. basis_completion v ! i = basis_completion v ! j \<Longrightarrow> False
[PROOF STEP]
assume id1: "?b ! i = ?b ! j"
[PROOF STATE]
proof (state)
this:
basis_completion v ! i = basis_completion v ! j

goal (1 subgoal):
 1. basis_completion v ! i = basis_completion v ! j \<Longrightarrow> False
[PROOF STEP]
hence id2: "\<And> l. ?b ! i $ l = ?b ! j $ l"
[PROOF STATE]
proof (prove)
using this:
basis_completion v ! i = basis_completion v ! j

goal (1 subgoal):
 1. \<And>l. basis_completion v ! i $ l = basis_completion v ! j $ l
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
basis_completion v ! i $ ?l2 = basis_completion v ! j $ ?l2

goal (1 subgoal):
 1. basis_completion v ! i = basis_completion v ! j \<Longrightarrow> False
[PROOF STEP]
have "i = j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i = j
[PROOF STEP]
proof (cases "i = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i = 0 \<Longrightarrow> i = j
 2. i \<noteq> 0 \<Longrightarrow> i = j
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
i = 0

goal (2 subgoals):
 1. i = 0 \<Longrightarrow> i = j
 2. i \<noteq> 0 \<Longrightarrow> i = j
[PROOF STEP]
hence biv: "?b ! i = v"
[PROOF STATE]
proof (prove)
using this:
i = 0

goal (1 subgoal):
 1. basis_completion v ! i = v
[PROOF STEP]
unfolding b
[PROOF STATE]
proof (prove)
using this:
i = 0

goal (1 subgoal):
 1. (v # map (unit_vec n) [0..<k] @ map (unit_vec n) [Suc k..<n]) ! i = v
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
basis_completion v ! i = v

goal (2 subgoals):
 1. i = 0 \<Longrightarrow> i = j
 2. i \<noteq> 0 \<Longrightarrow> i = j
[PROOF STEP]
from True ij
[PROOF STATE]
proof (chain)
picking this:
i = 0
i \<noteq> j
[PROOF STEP]
have bj: "?b ! j = unit_vec n (I (j - 1))" "Suc (j - 1) = j"
[PROOF STATE]
proof (prove)
using this:
i = 0
i \<noteq> j

goal (1 subgoal):
 1. basis_completion v ! j = unit_vec n (I (j - 1)) &&& Suc (j - 1) = j
[PROOF STEP]
unfolding bi[OF j]
[PROOF STATE]
proof (prove)
using this:
i = 0
i \<noteq> j

goal (1 subgoal):
 1. (if j = 0 then v else unit_vec n (I (j - 1))) = unit_vec n (I (j - 1)) &&& Suc (j - 1) = j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
basis_completion v ! j = unit_vec n (I (j - 1))
Suc (j - 1) = j

goal (2 subgoals):
 1. i = 0 \<Longrightarrow> i = j
 2. i \<noteq> 0 \<Longrightarrow> i = j
[PROOF STEP]
with id2[of k, unfolded biv bj] vk I[of "j - 1"] k j
[PROOF STATE]
proof (chain)
picking this:
v $ k = unit_vec n (I (j - 1)) $ k
v $ k \<noteq> (0::'a)
I (j - 1) \<noteq> k
Suc (j - 1) < n \<Longrightarrow> I (j - 1) < n
k < n
j < n
basis_completion v ! j = unit_vec n (I (j - 1))
Suc (j - 1) = j
[PROOF STEP]
have False
[PROOF STATE]
proof (prove)
using this:
v $ k = unit_vec n (I (j - 1)) $ k
v $ k \<noteq> (0::'a)
I (j - 1) \<noteq> k
Suc (j - 1) < n \<Longrightarrow> I (j - 1) < n
k < n
j < n
basis_completion v ! j = unit_vec n (I (j - 1))
Suc (j - 1) = j

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

goal (2 subgoals):
 1. i = 0 \<Longrightarrow> i = j
 2. i \<noteq> 0 \<Longrightarrow> i = j
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
False

goal (1 subgoal):
 1. i = j
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
i = j

goal (1 subgoal):
 1. i \<noteq> 0 \<Longrightarrow> i = j
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i \<noteq> 0 \<Longrightarrow> i = j
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
i \<noteq> 0

goal (1 subgoal):
 1. i \<noteq> 0 \<Longrightarrow> i = j
[PROOF STEP]
note i0 = this
[PROOF STATE]
proof (state)
this:
i \<noteq> 0

goal (1 subgoal):
 1. i \<noteq> 0 \<Longrightarrow> i = j
[PROOF STEP]
hence bi': "?b ! i = unit_vec n (I (i - 1))" "Suc (i - 1) = i"
[PROOF STATE]
proof (prove)
using this:
i \<noteq> 0

goal (1 subgoal):
 1. basis_completion v ! i = unit_vec n (I (i - 1)) &&& Suc (i - 1) = i
[PROOF STEP]
unfolding bi[OF i]
[PROOF STATE]
proof (prove)
using this:
i \<noteq> 0

goal (1 subgoal):
 1. (if i = 0 then v else unit_vec n (I (i - 1))) = unit_vec n (I (i - 1)) &&& Suc (i - 1) = i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
basis_completion v ! i = unit_vec n (I (i - 1))
Suc (i - 1) = i

goal (1 subgoal):
 1. i \<noteq> 0 \<Longrightarrow> i = j
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i = j
[PROOF STEP]
proof (cases "j = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. j = 0 \<Longrightarrow> i = j
 2. j \<noteq> 0 \<Longrightarrow> i = j
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
j = 0

goal (2 subgoals):
 1. j = 0 \<Longrightarrow> i = j
 2. j \<noteq> 0 \<Longrightarrow> i = j
[PROOF STEP]
hence bj: "?b ! j = v"
[PROOF STATE]
proof (prove)
using this:
j = 0

goal (1 subgoal):
 1. basis_completion v ! j = v
[PROOF STEP]
unfolding b
[PROOF STATE]
proof (prove)
using this:
j = 0

goal (1 subgoal):
 1. (v # map (unit_vec n) [0..<k] @ map (unit_vec n) [Suc k..<n]) ! j = v
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
basis_completion v ! j = v

goal (2 subgoals):
 1. j = 0 \<Longrightarrow> i = j
 2. j \<noteq> 0 \<Longrightarrow> i = j
[PROOF STEP]
from id2[of k, unfolded bi' bj] vk I[of "i - 1"] k i bi'
[PROOF STATE]
proof (chain)
picking this:
unit_vec n (I (i - 1)) $ k = v $ k
v $ k \<noteq> (0::'a)
I (i - 1) \<noteq> k
Suc (i - 1) < n \<Longrightarrow> I (i - 1) < n
k < n
i < n
basis_completion v ! i = unit_vec n (I (i - 1))
Suc (i - 1) = i
[PROOF STEP]
have False
[PROOF STATE]
proof (prove)
using this:
unit_vec n (I (i - 1)) $ k = v $ k
v $ k \<noteq> (0::'a)
I (i - 1) \<noteq> k
Suc (i - 1) < n \<Longrightarrow> I (i - 1) < n
k < n
i < n
basis_completion v ! i = unit_vec n (I (i - 1))
Suc (i - 1) = i

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

goal (2 subgoals):
 1. j = 0 \<Longrightarrow> i = j
 2. j \<noteq> 0 \<Longrightarrow> i = j
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
False

goal (1 subgoal):
 1. i = j
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
i = j

goal (1 subgoal):
 1. j \<noteq> 0 \<Longrightarrow> i = j
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. j \<noteq> 0 \<Longrightarrow> i = j
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
j \<noteq> 0

goal (1 subgoal):
 1. j \<noteq> 0 \<Longrightarrow> i = j
[PROOF STEP]
note j0 = this
[PROOF STATE]
proof (state)
this:
j \<noteq> 0

goal (1 subgoal):
 1. j \<noteq> 0 \<Longrightarrow> i = j
[PROOF STEP]
hence bj: "?b ! j = unit_vec n (I (j - 1))" "Suc (j - 1) = j"
[PROOF STATE]
proof (prove)
using this:
j \<noteq> 0

goal (1 subgoal):
 1. basis_completion v ! j = unit_vec n (I (j - 1)) &&& Suc (j - 1) = j
[PROOF STEP]
unfolding bi[OF j]
[PROOF STATE]
proof (prove)
using this:
j \<noteq> 0

goal (1 subgoal):
 1. (if j = 0 then v else unit_vec n (I (j - 1))) = unit_vec n (I (j - 1)) &&& Suc (j - 1) = j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
basis_completion v ! j = unit_vec n (I (j - 1))
Suc (j - 1) = j

goal (1 subgoal):
 1. j \<noteq> 0 \<Longrightarrow> i = j
[PROOF STEP]
have "1 = ?b ! i $ I (i - 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (1::'a) = basis_completion v ! i $ I (i - 1)
[PROOF STEP]
unfolding bi'
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (1::'a) = unit_vec n (I (i - 1)) $ I (i - 1)
[PROOF STEP]
using I[of "i - 1"] i i0
[PROOF STATE]
proof (prove)
using this:
I (i - 1) \<noteq> k
Suc (i - 1) < n \<Longrightarrow> I (i - 1) < n
i < n
i \<noteq> 0

goal (1 subgoal):
 1. (1::'a) = unit_vec n (I (i - 1)) $ I (i - 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(1::'a) = basis_completion v ! i $ I (i - 1)

goal (1 subgoal):
 1. j \<noteq> 0 \<Longrightarrow> i = j
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(1::'a) = basis_completion v ! i $ I (i - 1)

goal (1 subgoal):
 1. j \<noteq> 0 \<Longrightarrow> i = j
[PROOF STEP]
have "\<dots> = unit_vec n (I (j - 1)) $ I (i - 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. basis_completion v ! i $ I (i - 1) = unit_vec n (I (j - 1)) $ I (i - 1)
[PROOF STEP]
unfolding id1 bj
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unit_vec n (I (j - 1)) $ I (i - 1) = unit_vec n (I (j - 1)) $ I (i - 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
basis_completion v ! i $ I (i - 1) = unit_vec n (I (j - 1)) $ I (i - 1)

goal (1 subgoal):
 1. j \<noteq> 0 \<Longrightarrow> i = j
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
basis_completion v ! i $ I (i - 1) = unit_vec n (I (j - 1)) $ I (i - 1)

goal (1 subgoal):
 1. j \<noteq> 0 \<Longrightarrow> i = j
[PROOF STEP]
have "\<dots> = (if I (i - 1) = I (j - 1) then 1 else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unit_vec n (I (j - 1)) $ I (i - 1) = (if I (i - 1) = I (j - 1) then 1::'a else (0::'a))
[PROOF STEP]
using I[of "i - 1"] I[of "j - 1"] i0 j0 i j
[PROOF STATE]
proof (prove)
using this:
I (i - 1) \<noteq> k
Suc (i - 1) < n \<Longrightarrow> I (i - 1) < n
I (j - 1) \<noteq> k
Suc (j - 1) < n \<Longrightarrow> I (j - 1) < n
i \<noteq> 0
j \<noteq> 0
i < n
j < n

goal (1 subgoal):
 1. unit_vec n (I (j - 1)) $ I (i - 1) = (if I (i - 1) = I (j - 1) then 1::'a else (0::'a))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
unit_vec n (I (j - 1)) $ I (i - 1) = (if I (i - 1) = I (j - 1) then 1::'a else (0::'a))

goal (1 subgoal):
 1. j \<noteq> 0 \<Longrightarrow> i = j
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(1::'a) = (if I (i - 1) = I (j - 1) then 1::'a else (0::'a))
[PROOF STEP]
have "I (i - 1) = I (j - 1)"
[PROOF STATE]
proof (prove)
using this:
(1::'a) = (if I (i - 1) = I (j - 1) then 1::'a else (0::'a))

goal (1 subgoal):
 1. I (i - 1) = I (j - 1)
[PROOF STEP]
by (auto split: if_splits)
[PROOF STATE]
proof (state)
this:
I (i - 1) = I (j - 1)

goal (1 subgoal):
 1. j \<noteq> 0 \<Longrightarrow> i = j
[PROOF STEP]
with i0 j0
[PROOF STATE]
proof (chain)
picking this:
i \<noteq> 0
j \<noteq> 0
I (i - 1) = I (j - 1)
[PROOF STEP]
show "i = j"
[PROOF STATE]
proof (prove)
using this:
i \<noteq> 0
j \<noteq> 0
I (i - 1) = I (j - 1)

goal (1 subgoal):
 1. i = j
[PROOF STEP]
unfolding I_def
[PROOF STATE]
proof (prove)
using this:
i \<noteq> 0
j \<noteq> 0
(if i - 1 < k then i - 1 else Suc (i - 1)) = (if j - 1 < k then j - 1 else Suc (j - 1))

goal (1 subgoal):
 1. i = j
[PROOF STEP]
by (auto split: if_splits)
[PROOF STATE]
proof (state)
this:
i = j

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
i = j

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
i = j

goal (1 subgoal):
 1. basis_completion v ! i = basis_completion v ! j \<Longrightarrow> False
[PROOF STEP]
thus False
[PROOF STATE]
proof (prove)
using this:
i = j

goal (1 subgoal):
 1. False
[PROOF STEP]
using ij
[PROOF STATE]
proof (prove)
using this:
i = j
i \<noteq> j

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
basis_completion v ! i \<noteq> basis_completion v ! j

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
distinct (basis_completion v)

goal (3 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. lin_indpt (set (basis_completion v))
[PROOF STEP]
have "span (set ?b) \<subseteq> carrier_vec n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.span (set (basis_completion v)) \<subseteq> carrier_vec n
[PROOF STEP]
using carr
[PROOF STATE]
proof (prove)
using this:
set (basis_completion v) \<subseteq> carrier_vec n

goal (1 subgoal):
 1. local.span (set (basis_completion v)) \<subseteq> carrier_vec n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
local.span (set (basis_completion v)) \<subseteq> carrier_vec n

goal (3 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. lin_indpt (set (basis_completion v))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
local.span (set (basis_completion v)) \<subseteq> carrier_vec n

goal (3 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. lin_indpt (set (basis_completion v))
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
local.span (set (basis_completion v)) \<subseteq> carrier_vec n

goal (3 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. lin_indpt (set (basis_completion v))
[PROOF STEP]
fix w :: "'a vec"
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. lin_indpt (set (basis_completion v))
[PROOF STEP]
assume w: "w \<in> carrier_vec n"
[PROOF STATE]
proof (state)
this:
w \<in> carrier_vec n

goal (3 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. lin_indpt (set (basis_completion v))
[PROOF STEP]
define lookup where "lookup = (v,k) # [(unit_vec n i, i). i <- [0..<n], i \<noteq> k]"
[PROOF STATE]
proof (state)
this:
lookup = (v, k) # concat (map (\<lambda>i. if i \<noteq> k then [(unit_vec n i, i)] else []) [0..<n])

goal (3 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. lin_indpt (set (basis_completion v))
[PROOF STEP]
define a where "a = (\<lambda> vi. case map_of lookup vi of Some i \<Rightarrow> if i = k then w $ k / v $ k else
       w $ i - w $ k / v $ k * v $ i)"
[PROOF STATE]
proof (state)
this:
a = (\<lambda>vi. case map_of lookup vi of Some i \<Rightarrow> if i = k then w $ k / v $ k else w $ i - w $ k / v $ k * v $ i)

goal (3 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. lin_indpt (set (basis_completion v))
[PROOF STEP]
have "map fst lookup = ?b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map fst lookup = basis_completion v
[PROOF STEP]
unfolding b_all lookup_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map fst ((v, k) # concat (map (\<lambda>i. if i \<noteq> k then [(unit_vec n i, i)] else []) [0..<n])) = v # concat (map (\<lambda>i. if i \<noteq> k then [unit_vec n i] else []) [0..<n])
[PROOF STEP]
by (auto simp: map_concat o_def if_distrib, unfold list.simps fst_def prod.simps, simp)
[PROOF STATE]
proof (state)
this:
map fst lookup = basis_completion v

goal (3 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. lin_indpt (set (basis_completion v))
[PROOF STEP]
with dist
[PROOF STATE]
proof (chain)
picking this:
distinct (basis_completion v)
map fst lookup = basis_completion v
[PROOF STEP]
have dist: "distinct (map fst lookup)"
[PROOF STATE]
proof (prove)
using this:
distinct (basis_completion v)
map fst lookup = basis_completion v

goal (1 subgoal):
 1. distinct (map fst lookup)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
distinct (map fst lookup)

goal (3 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. lin_indpt (set (basis_completion v))
[PROOF STEP]
let ?w = "lincomb a (set ?b)"
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. lin_indpt (set (basis_completion v))
[PROOF STEP]
have "?w \<in> carrier_vec n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lincomb a (set (basis_completion v)) \<in> carrier_vec n
[PROOF STEP]
using carr
[PROOF STATE]
proof (prove)
using this:
set (basis_completion v) \<subseteq> carrier_vec n

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

goal (3 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. lin_indpt (set (basis_completion v))
[PROOF STEP]
with w
[PROOF STATE]
proof (chain)
picking this:
w \<in> carrier_vec n
lincomb a (set (basis_completion v)) \<in> carrier_vec n
[PROOF STEP]
have dim: "dim_vec w = n" "dim_vec ?w = n"
[PROOF STATE]
proof (prove)
using this:
w \<in> carrier_vec n
lincomb a (set (basis_completion v)) \<in> carrier_vec n

goal (1 subgoal):
 1. dim_vec w = n &&& dim_vec (lincomb a (set (basis_completion v))) = n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
dim_vec w = n
dim_vec (lincomb a (set (basis_completion v))) = n

goal (3 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. lin_indpt (set (basis_completion v))
[PROOF STEP]
have "w = ?w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. w = lincomb a (set (basis_completion v))
[PROOF STEP]
proof (rule eq_vecI; unfold dim)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i. i < n \<Longrightarrow> w $ i = lincomb a (set (basis_completion v)) $ i
 2. n = n
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i. i < n \<Longrightarrow> w $ i = lincomb a (set (basis_completion v)) $ i
 2. n = n
[PROOF STEP]
assume i: "i < n"
[PROOF STATE]
proof (state)
this:
i < n

goal (2 subgoals):
 1. \<And>i. i < n \<Longrightarrow> w $ i = lincomb a (set (basis_completion v)) $ i
 2. n = n
[PROOF STEP]
show "w $ i = ?w $ i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. w $ i = lincomb a (set (basis_completion v)) $ i
[PROOF STEP]
unfolding lincomb_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. w $ i = (\<Oplus>\<^bsub>V\<^esub>v\<in>set (basis_completion v). a v \<cdot>\<^sub>v v) $ i
[PROOF STEP]
proof (subst finsum_index[OF i _ carr])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (\<lambda>v. a v \<cdot>\<^sub>v v) \<in> set (basis_completion v) \<rightarrow> carrier_vec n
 2. w $ i = (\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i)
[PROOF STEP]
show "(\<lambda>v. a v \<cdot>\<^sub>v v) \<in> set ?b \<rightarrow> carrier_vec n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>v. a v \<cdot>\<^sub>v v) \<in> set (basis_completion v) \<rightarrow> carrier_vec n
[PROOF STEP]
using carr
[PROOF STATE]
proof (prove)
using this:
set (basis_completion v) \<subseteq> carrier_vec n

goal (1 subgoal):
 1. (\<lambda>v. a v \<cdot>\<^sub>v v) \<in> set (basis_completion v) \<rightarrow> carrier_vec n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>v. a v \<cdot>\<^sub>v v) \<in> set (basis_completion v) \<rightarrow> carrier_vec n

goal (1 subgoal):
 1. w $ i = (\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
(\<lambda>v. a v \<cdot>\<^sub>v v) \<in> set (basis_completion v) \<rightarrow> carrier_vec n

goal (1 subgoal):
 1. w $ i = (\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i)
[PROOF STEP]
fix x :: "'a vec" and j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. w $ i = (\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i)
[PROOF STEP]
assume "x = unit_vec n j" "j \<noteq> k" "j < n"
[PROOF STATE]
proof (state)
this:
x = unit_vec n j
j \<noteq> k
j < n

goal (1 subgoal):
 1. w $ i = (\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i)
[PROOF STEP]
hence "(x,j) \<in> set lookup"
[PROOF STATE]
proof (prove)
using this:
x = unit_vec n j
j \<noteq> k
j < n

goal (1 subgoal):
 1. (x, j) \<in> set lookup
[PROOF STEP]
unfolding lookup_def
[PROOF STATE]
proof (prove)
using this:
x = unit_vec n j
j \<noteq> k
j < n

goal (1 subgoal):
 1. (x, j) \<in> set ((v, k) # concat (map (\<lambda>i. if i \<noteq> k then [(unit_vec n i, i)] else []) [0..<n]))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(x, j) \<in> set lookup

goal (1 subgoal):
 1. w $ i = (\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i)
[PROOF STEP]
from map_of_is_SomeI[OF dist this]
[PROOF STATE]
proof (chain)
picking this:
map_of lookup x = Some j
[PROOF STEP]
have "a x = w $ j - w $ k / v $ k * v $ j"
[PROOF STATE]
proof (prove)
using this:
map_of lookup x = Some j

goal (1 subgoal):
 1. a x = w $ j - w $ k / v $ k * v $ j
[PROOF STEP]
unfolding a_def
[PROOF STATE]
proof (prove)
using this:
map_of lookup x = Some j

goal (1 subgoal):
 1. (case map_of lookup x of Some i \<Rightarrow> if i = k then w $ k / v $ k else w $ i - w $ k / v $ k * v $ i) = w $ j - w $ k / v $ k * v $ j
[PROOF STEP]
using \<open>j \<noteq> k\<close>
[PROOF STATE]
proof (prove)
using this:
map_of lookup x = Some j
j \<noteq> k

goal (1 subgoal):
 1. (case map_of lookup x of Some i \<Rightarrow> if i = k then w $ k / v $ k else w $ i - w $ k / v $ k * v $ i) = w $ j - w $ k / v $ k * v $ j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a x = w $ j - w $ k / v $ k * v $ j

goal (1 subgoal):
 1. w $ i = (\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>?x4 = unit_vec n ?j4; ?j4 \<noteq> k; ?j4 < n\<rbrakk> \<Longrightarrow> a ?x4 = w $ ?j4 - w $ k / v $ k * v $ ?j4

goal (1 subgoal):
 1. w $ i = (\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i)
[PROOF STEP]
note a = this
[PROOF STATE]
proof (state)
this:
\<lbrakk>?x4 = unit_vec n ?j4; ?j4 \<noteq> k; ?j4 < n\<rbrakk> \<Longrightarrow> a ?x4 = w $ ?j4 - w $ k / v $ k * v $ ?j4

goal (1 subgoal):
 1. w $ i = (\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i)
[PROOF STEP]
have "(\<Sum>x\<in>set ?b. (a x \<cdot>\<^sub>v x) $ i) = (a v \<cdot>\<^sub>v v) $ i + (\<Sum>x\<in>(set ?b) - {v}. (a x \<cdot>\<^sub>v x) $ i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i) = (a v \<cdot>\<^sub>v v) $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i)
[PROOF STEP]
by (rule sum.remove[OF finite_set], auto simp: b)
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i) = (a v \<cdot>\<^sub>v v) $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i)

goal (1 subgoal):
 1. w $ i = (\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i) = (a v \<cdot>\<^sub>v v) $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i)

goal (1 subgoal):
 1. w $ i = (\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i)
[PROOF STEP]
have "a v = w $ k / v $ k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a v = w $ k / v $ k
[PROOF STEP]
unfolding a_def lookup_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (case map_of ((v, k) # concat (map (\<lambda>i. if i \<noteq> k then [(unit_vec n i, i)] else []) [0..<n])) v of Some i \<Rightarrow> if i = k then w $ k / v $ k else w $ i - w $ k / v $ k * v $ i) = w $ k / v $ k
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a v = w $ k / v $ k

goal (1 subgoal):
 1. w $ i = (\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
a v = w $ k / v $ k

goal (1 subgoal):
 1. w $ i = (\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i)
[PROOF STEP]
have "(\<dots> \<cdot>\<^sub>v v) $ i = w $ k / v $ k * v $ i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (w $ k / v $ k \<cdot>\<^sub>v v) $ i = w $ k / v $ k * v $ i
[PROOF STEP]
using i v
[PROOF STATE]
proof (prove)
using this:
i < n
v \<in> carrier_vec n

goal (1 subgoal):
 1. (w $ k / v $ k \<cdot>\<^sub>v v) $ i = w $ k / v $ k * v $ i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(w $ k / v $ k \<cdot>\<^sub>v v) $ i = w $ k / v $ k * v $ i

goal (1 subgoal):
 1. w $ i = (\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i) = w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i)
[PROOF STEP]
have "(\<Sum>x\<in>set ?b. (a x \<cdot>\<^sub>v x) $ i) = w $ k / v $ k * v $ i + (\<Sum>x\<in>(set ?b) - {v}. (a x \<cdot>\<^sub>v x) $ i)"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i) = w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i)

goal (1 subgoal):
 1. (\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i) = w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i) = w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i)

goal (1 subgoal):
 1. w $ i = (\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i) = w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i)

goal (1 subgoal):
 1. w $ i = (\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i)
[PROOF STEP]
have "\<dots> = w $ i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
[PROOF STEP]
proof (cases "i = k")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i = k \<Longrightarrow> w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
 2. i \<noteq> k \<Longrightarrow> w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
i = k

goal (2 subgoals):
 1. i = k \<Longrightarrow> w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
 2. i \<noteq> k \<Longrightarrow> w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
[PROOF STEP]
hence "w $ k / v $ k * v $ i = w $ k"
[PROOF STATE]
proof (prove)
using this:
i = k

goal (1 subgoal):
 1. w $ k / v $ k * v $ i = w $ k
[PROOF STEP]
using vk
[PROOF STATE]
proof (prove)
using this:
i = k
v $ k \<noteq> (0::'a)

goal (1 subgoal):
 1. w $ k / v $ k * v $ i = w $ k
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
w $ k / v $ k * v $ i = w $ k

goal (2 subgoals):
 1. i = k \<Longrightarrow> w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
 2. i \<noteq> k \<Longrightarrow> w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
w $ k / v $ k * v $ i = w $ k

goal (2 subgoals):
 1. i = k \<Longrightarrow> w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
 2. i \<noteq> k \<Longrightarrow> w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
[PROOF STEP]
have "(\<Sum>x\<in>(set ?b) - {v}. (a x \<cdot>\<^sub>v x) $ i) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = (0::'a)
[PROOF STEP]
unfolding True
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ k) = (0::'a)
[PROOF STEP]
proof (rule sum.neutral, intro ballI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> set (basis_completion v) - {v} \<Longrightarrow> (a x \<cdot>\<^sub>v x) $ k = (0::'a)
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> set (basis_completion v) - {v} \<Longrightarrow> (a x \<cdot>\<^sub>v x) $ k = (0::'a)
[PROOF STEP]
assume "x \<in> set ?b - {v}"
[PROOF STATE]
proof (state)
this:
x \<in> set (basis_completion v) - {v}

goal (1 subgoal):
 1. \<And>x. x \<in> set (basis_completion v) - {v} \<Longrightarrow> (a x \<cdot>\<^sub>v x) $ k = (0::'a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> set (basis_completion v) - {v}
[PROOF STEP]
obtain j where x: "x = unit_vec n j" "j \<noteq> k" "j < n"
[PROOF STATE]
proof (prove)
using this:
x \<in> set (basis_completion v) - {v}

goal (1 subgoal):
 1. (\<And>j. \<lbrakk>x = unit_vec n j; j \<noteq> k; j < n\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using k
[PROOF STATE]
proof (prove)
using this:
x \<in> set (basis_completion v) - {v}
k < n

goal (1 subgoal):
 1. (\<And>j. \<lbrakk>x = unit_vec n j; j \<noteq> k; j < n\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding b
[PROOF STATE]
proof (prove)
using this:
x \<in> set (v # map (unit_vec n) [0..<k] @ map (unit_vec n) [Suc k..<n]) - {v}
k < n

goal (1 subgoal):
 1. (\<And>j. \<lbrakk>x = unit_vec n j; j \<noteq> k; j < n\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x = unit_vec n j
j \<noteq> k
j < n

goal (1 subgoal):
 1. \<And>x. x \<in> set (basis_completion v) - {v} \<Longrightarrow> (a x \<cdot>\<^sub>v x) $ k = (0::'a)
[PROOF STEP]
show "(a x \<cdot>\<^sub>v x) $ k = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a x \<cdot>\<^sub>v x) $ k = (0::'a)
[PROOF STEP]
unfolding a[OF x]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((w $ j - w $ k / v $ k * v $ j) \<cdot>\<^sub>v x) $ k = (0::'a)
[PROOF STEP]
unfolding x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((w $ j - w $ k / v $ k * v $ j) \<cdot>\<^sub>v unit_vec n j) $ k = (0::'a)
[PROOF STEP]
using x k
[PROOF STATE]
proof (prove)
using this:
x = unit_vec n j
j \<noteq> k
j < n
k < n

goal (1 subgoal):
 1. ((w $ j - w $ k / v $ k * v $ j) \<cdot>\<^sub>v unit_vec n j) $ k = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(a x \<cdot>\<^sub>v x) $ k = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = (0::'a)

goal (2 subgoals):
 1. i = k \<Longrightarrow> w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
 2. i \<noteq> k \<Longrightarrow> w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
w $ k / v $ k * v $ i = w $ k
(\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
w $ k / v $ k * v $ i = w $ k
(\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = (0::'a)

goal (1 subgoal):
 1. w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
[PROOF STEP]
unfolding True
[PROOF STATE]
proof (prove)
using this:
w $ k / v $ k * v $ k = w $ k
(\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ k) = (0::'a)

goal (1 subgoal):
 1. w $ k / v $ k * v $ k + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ k) = w $ k
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i

goal (1 subgoal):
 1. i \<noteq> k \<Longrightarrow> w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i \<noteq> k \<Longrightarrow> w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
i \<noteq> k

goal (1 subgoal):
 1. i \<noteq> k \<Longrightarrow> w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
[PROOF STEP]
let ?ui = "unit_vec n i :: 'a vec"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i \<noteq> k \<Longrightarrow> w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i \<noteq> k \<Longrightarrow> w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
[PROOF STEP]
assume "?ui = v"
[PROOF STATE]
proof (state)
this:
unit_vec n i = v

goal (1 subgoal):
 1. i \<noteq> k \<Longrightarrow> w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
[PROOF STEP]
from arg_cong[OF this, of "\<lambda> v. v $ k"] vk i k False
[PROOF STATE]
proof (chain)
picking this:
unit_vec n i $ k = v $ k
v $ k \<noteq> (0::'a)
i < n
k < n
i \<noteq> k
[PROOF STEP]
have False
[PROOF STATE]
proof (prove)
using this:
unit_vec n i $ k = v $ k
v $ k \<noteq> (0::'a)
i < n
k < n
i \<noteq> k

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

goal (1 subgoal):
 1. i \<noteq> k \<Longrightarrow> w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
unit_vec n i = v \<Longrightarrow> False

goal (1 subgoal):
 1. i \<noteq> k \<Longrightarrow> w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
[PROOF STEP]
hence diff: "?ui \<noteq> v"
[PROOF STATE]
proof (prove)
using this:
unit_vec n i = v \<Longrightarrow> False

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

goal (1 subgoal):
 1. i \<noteq> k \<Longrightarrow> w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
[PROOF STEP]
from a[OF refl False]
[PROOF STATE]
proof (chain)
picking this:
i < n \<Longrightarrow> a (unit_vec n i) = w $ i - w $ k / v $ k * v $ i
[PROOF STEP]
have ai: "(a ?ui \<cdot>\<^sub>v ?ui) $ i = w $ i - w $ k / v $ k * v $ i"
[PROOF STATE]
proof (prove)
using this:
i < n \<Longrightarrow> a (unit_vec n i) = w $ i - w $ k / v $ k * v $ i

goal (1 subgoal):
 1. (a (unit_vec n i) \<cdot>\<^sub>v unit_vec n i) $ i = w $ i - w $ k / v $ k * v $ i
[PROOF STEP]
using i
[PROOF STATE]
proof (prove)
using this:
i < n \<Longrightarrow> a (unit_vec n i) = w $ i - w $ k / v $ k * v $ i
i < n

goal (1 subgoal):
 1. (a (unit_vec n i) \<cdot>\<^sub>v unit_vec n i) $ i = w $ i - w $ k / v $ k * v $ i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(a (unit_vec n i) \<cdot>\<^sub>v unit_vec n i) $ i = w $ i - w $ k / v $ k * v $ i

goal (1 subgoal):
 1. i \<noteq> k \<Longrightarrow> w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
[PROOF STEP]
have "?ui \<in> set ?b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unit_vec n i \<in> set (basis_completion v)
[PROOF STEP]
unfolding b_all
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unit_vec n i \<in> set (v # concat (map (\<lambda>i. if i \<noteq> k then [unit_vec n i] else []) [0..<n]))
[PROOF STEP]
using False k i
[PROOF STATE]
proof (prove)
using this:
i \<noteq> k
k < n
i < n

goal (1 subgoal):
 1. unit_vec n i \<in> set (v # concat (map (\<lambda>i. if i \<noteq> k then [unit_vec n i] else []) [0..<n]))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
unit_vec n i \<in> set (basis_completion v)

goal (1 subgoal):
 1. i \<noteq> k \<Longrightarrow> w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
[PROOF STEP]
with diff
[PROOF STATE]
proof (chain)
picking this:
unit_vec n i \<noteq> v
unit_vec n i \<in> set (basis_completion v)
[PROOF STEP]
have mem: "unit_vec n i \<in> set ?b - {v}"
[PROOF STATE]
proof (prove)
using this:
unit_vec n i \<noteq> v
unit_vec n i \<in> set (basis_completion v)

goal (1 subgoal):
 1. unit_vec n i \<in> set (basis_completion v) - {v}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
unit_vec n i \<in> set (basis_completion v) - {v}

goal (1 subgoal):
 1. i \<noteq> k \<Longrightarrow> w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
[PROOF STEP]
have "w $ k / v $ k * v $ i + (\<Sum>x\<in>(set ?b) - {v}. (a x \<cdot>\<^sub>v x) $ i)
            = w $ i + (\<Sum>x\<in>(set ?b) - {v,?ui}. (a x \<cdot>\<^sub>v x) $ i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i + (\<Sum>x\<in>set (basis_completion v) - {v, unit_vec n i}. (a x \<cdot>\<^sub>v x) $ i)
[PROOF STEP]
by (subst sum.remove[OF _ mem], auto simp: ai intro!: sum.cong)
[PROOF STATE]
proof (state)
this:
w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i + (\<Sum>x\<in>set (basis_completion v) - {v, unit_vec n i}. (a x \<cdot>\<^sub>v x) $ i)

goal (1 subgoal):
 1. i \<noteq> k \<Longrightarrow> w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i + (\<Sum>x\<in>set (basis_completion v) - {v, unit_vec n i}. (a x \<cdot>\<^sub>v x) $ i)

goal (1 subgoal):
 1. i \<noteq> k \<Longrightarrow> w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
[PROOF STEP]
have "(\<Sum>x\<in>(set ?b) - {v,?ui}. (a x \<cdot>\<^sub>v x) $ i) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>set (basis_completion v) - {v, unit_vec n i}. (a x \<cdot>\<^sub>v x) $ i) = (0::'a)
[PROOF STEP]
by (rule sum.neutral, unfold b_all, insert i k, auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>set (basis_completion v) - {v, unit_vec n i}. (a x \<cdot>\<^sub>v x) $ i) = (0::'a)

goal (1 subgoal):
 1. i \<noteq> k \<Longrightarrow> w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i + (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i + (0::'a)

goal (1 subgoal):
 1. w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
w $ k / v $ k * v $ i + (\<Sum>x\<in>set (basis_completion v) - {v}. (a x \<cdot>\<^sub>v x) $ i) = w $ i

goal (1 subgoal):
 1. w $ i = (\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i) = w $ i
[PROOF STEP]
show "w $ i = (\<Sum>x\<in>set ?b. (a x \<cdot>\<^sub>v x) $ i)"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i) = w $ i

goal (1 subgoal):
 1. w $ i = (\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
w $ i = (\<Sum>x\<in>set (basis_completion v). (a x \<cdot>\<^sub>v x) $ i)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
w $ i = lincomb a (set (basis_completion v)) $ i

goal (1 subgoal):
 1. n = n
[PROOF STEP]
qed auto
[PROOF STATE]
proof (state)
this:
w = lincomb a (set (basis_completion v))

goal (3 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. lin_indpt (set (basis_completion v))
[PROOF STEP]
hence "w \<in> span (set ?b)"
[PROOF STATE]
proof (prove)
using this:
w = lincomb a (set (basis_completion v))

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

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

goal (3 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. lin_indpt (set (basis_completion v))
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?w4 \<in> carrier_vec n \<Longrightarrow> ?w4 \<in> local.span (set (basis_completion v))

goal (3 subgoals):
 1. basis (set (basis_completion v))
 2. local.span (set (basis_completion v)) = carrier_vec n
 3. lin_indpt (set (basis_completion v))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
local.span (set (basis_completion v)) \<subseteq> carrier_vec n
?w4 \<in> carrier_vec n \<Longrightarrow> ?w4 \<in> local.span (set (basis_completion v))
[PROOF STEP]
show span: "span (set ?b) = carrier_vec n"
[PROOF STATE]
proof (prove)
using this:
local.span (set (basis_completion v)) \<subseteq> carrier_vec n
?w4 \<in> carrier_vec n \<Longrightarrow> ?w4 \<in> local.span (set (basis_completion v))

goal (1 subgoal):
 1. local.span (set (basis_completion v)) = carrier_vec n
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
local.span (set (basis_completion v)) = carrier_vec n

goal (2 subgoals):
 1. basis (set (basis_completion v))
 2. lin_indpt (set (basis_completion v))
[PROOF STEP]
show "basis (set ?b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. basis (set (basis_completion v))
[PROOF STEP]
proof (rule dim_gen_is_basis[OF finite_set carr span])
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card (set (basis_completion v)) \<le> local.dim
[PROOF STEP]
have "card (set ?b) = dim"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (set (basis_completion v)) = local.dim
[PROOF STEP]
using dist len distinct_card
[PROOF STATE]
proof (prove)
using this:
distinct (basis_completion v)
length (basis_completion v) = n
distinct ?xs \<Longrightarrow> card (set ?xs) = length ?xs

goal (1 subgoal):
 1. card (set (basis_completion v)) = local.dim
[PROOF STEP]
unfolding dim_is_n
[PROOF STATE]
proof (prove)
using this:
distinct (basis_completion v)
length (basis_completion v) = n
distinct ?xs \<Longrightarrow> card (set ?xs) = length ?xs

goal (1 subgoal):
 1. card (set (basis_completion v)) = n
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
card (set (basis_completion v)) = local.dim

goal (1 subgoal):
 1. card (set (basis_completion v)) \<le> local.dim
[PROOF STEP]
thus "card (set ?b) \<le> dim"
[PROOF STATE]
proof (prove)
using this:
card (set (basis_completion v)) = local.dim

goal (1 subgoal):
 1. card (set (basis_completion v)) \<le> local.dim
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card (set (basis_completion v)) \<le> local.dim

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

goal (1 subgoal):
 1. lin_indpt (set (basis_completion v))
[PROOF STEP]
thus "\<not> lin_dep (set ?b)"
[PROOF STATE]
proof (prove)
using this:
basis (set (basis_completion v))

goal (1 subgoal):
 1. lin_indpt (set (basis_completion v))
[PROOF STEP]
unfolding basis_def
[PROOF STATE]
proof (prove)
using this:
lin_indpt (set (basis_completion v)) \<and> local.span (set (basis_completion v)) = carrier_vec n \<and> set (basis_completion v) \<subseteq> carrier_vec n

goal (1 subgoal):
 1. lin_indpt (set (basis_completion v))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
lin_indpt (set (basis_completion v))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma  mat_hom_inj: "map_mat hom A = map_mat hom B \<Longrightarrow> A = B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_mat hom A = map_mat hom B \<Longrightarrow> A = B
[PROOF STEP]
unfolding mat_eq_iff
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row (map_mat hom A) = dim_row (map_mat hom B) \<and> dim_col (map_mat hom A) = dim_col (map_mat hom B) \<and> (\<forall>i j. i < dim_row (map_mat hom B) \<longrightarrow> j < dim_col (map_mat hom B) \<longrightarrow> map_mat hom A $$ (i, j) = map_mat hom B $$ (i, j)) \<Longrightarrow> dim_row A = dim_row B \<and> dim_col A = dim_col B \<and> (\<forall>i j. i < dim_row B \<longrightarrow> j < dim_col B \<longrightarrow> A $$ (i, j) = B $$ (i, j))
[PROOF STEP]
by auto


[STATEMENT]
lemma toplevel_summands_lderivs_Star:
  "toplevel_summands (lderivs xs (Star r)) \<subseteq>
    {Star r} \<union> {Times (lderivs ys r) (Star r) | ys. \<exists>zs. ys \<noteq> [] \<and> zs @ ys = xs}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. toplevel_summands (lderivs xs (Star r)) \<subseteq> {Star r} \<union> {Times (lderivs ys r) (Star r) |ys. \<exists>zs. ys \<noteq> [] \<and> zs @ ys = xs}
[PROOF STEP]
by (cases "xs = []") (auto dest!: toplevel_summands_lderivs_Star_nonempty)