[STATEMENT]
lemma eventually_finite:
  fixes x :: ereal
  assumes "\<bar>x\<bar> \<noteq> \<infinity>" "(f \<longlongrightarrow> x) F"
  shows "eventually (\<lambda>x. \<bar>f x\<bar> \<noteq> \<infinity>) F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. \<bar>f x\<bar> \<noteq> \<infinity>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. \<bar>f x\<bar> \<noteq> \<infinity>
[PROOF STEP]
have "(f \<longlongrightarrow> ereal (real_of_ereal x)) F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f \<longlongrightarrow> ereal (real_of_ereal x)) F
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<bar>x\<bar> \<noteq> \<infinity>
(f \<longlongrightarrow> x) F

goal (1 subgoal):
 1. (f \<longlongrightarrow> ereal (real_of_ereal x)) F
[PROOF STEP]
by (cases x) auto
[PROOF STATE]
proof (state)
this:
(f \<longlongrightarrow> ereal (real_of_ereal x)) F

goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. \<bar>f x\<bar> \<noteq> \<infinity>
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(f \<longlongrightarrow> ereal (real_of_ereal x)) F
[PROOF STEP]
have "eventually (\<lambda>x. f x \<in> ereal ` UNIV) F"
[PROOF STATE]
proof (prove)
using this:
(f \<longlongrightarrow> ereal (real_of_ereal x)) F

goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. f x \<in> range ereal
[PROOF STEP]
by (rule topological_tendstoD) (auto intro: open_ereal)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in F. f x \<in> range ereal

goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. \<bar>f x\<bar> \<noteq> \<infinity>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in F. f x \<in> range ereal

goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. \<bar>f x\<bar> \<noteq> \<infinity>
[PROOF STEP]
have "(\<lambda>x. f x \<in> ereal ` UNIV) = (\<lambda>x. \<bar>f x\<bar> \<noteq> \<infinity>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. f x \<in> range ereal) = (\<lambda>x. \<bar>f x\<bar> \<noteq> \<infinity>)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>x. f x \<in> range ereal) = (\<lambda>x. \<bar>f x\<bar> \<noteq> \<infinity>)

goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. \<bar>f x\<bar> \<noteq> \<infinity>
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<forall>\<^sub>F x in F. \<bar>f x\<bar> \<noteq> \<infinity>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in F. \<bar>f x\<bar> \<noteq> \<infinity>

goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. \<bar>f x\<bar> \<noteq> \<infinity>
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in F. \<bar>f x\<bar> \<noteq> \<infinity>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma finite_eint_bounded:
  assumes le_fin: "\<And>y. y \<in> A \<Longrightarrow> eint m \<le> y \<and> y \<le> eint n"
  shows "finite A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite A
[PROOF STEP]
proof (rule finite_subset)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. A \<subseteq> ?B
 2. finite ?B
[PROOF STEP]
show "finite (eint ` {m..n})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (eint ` {m..n})
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
finite (eint ` {m..n})

goal (1 subgoal):
 1. A \<subseteq> eint ` {m..n}
[PROOF STEP]
have "A \<subseteq> {eint m..eint n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<subseteq> {eint m..eint n}
[PROOF STEP]
using le_fin
[PROOF STATE]
proof (prove)
using this:
?y \<in> A \<Longrightarrow> eint m \<le> ?y \<and> ?y \<le> eint n

goal (1 subgoal):
 1. A \<subseteq> {eint m..eint n}
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
A \<subseteq> {eint m..eint n}

goal (1 subgoal):
 1. A \<subseteq> eint ` {m..n}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
A \<subseteq> {eint m..eint n}

goal (1 subgoal):
 1. A \<subseteq> eint ` {m..n}
[PROOF STEP]
have "\<dots> \<subseteq> eint ` {m..n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {eint m..eint n} \<subseteq> eint ` {m..n}
[PROOF STEP]
apply (rule subsetI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> {eint m..eint n} \<Longrightarrow> x \<in> eint ` {m..n}
[PROOF STEP]
subgoal for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> {eint m..eint n} \<Longrightarrow> x \<in> eint ` {m..n}
[PROOF STEP]
by (cases x) auto
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
{eint m..eint n} \<subseteq> eint ` {m..n}

goal (1 subgoal):
 1. A \<subseteq> eint ` {m..n}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
A \<subseteq> eint ` {m..n}
[PROOF STEP]
show "A \<subseteq> eint ` {m..n}"
[PROOF STATE]
proof (prove)
using this:
A \<subseteq> eint ` {m..n}

goal (1 subgoal):
 1. A \<subseteq> eint ` {m..n}
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
A \<subseteq> eint ` {m..n}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma gauss_jordan_main_code[code]:
  "gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in
    if i < nr \<and> j < nc then let aij = A $$ (i,j) in if aij = 0 then
      (case [ i' . i' <- [Suc i ..< nr],  A $$ (i',j) \<noteq> 0]
        of [] \<Rightarrow> gauss_jordan_main A B i (Suc j)
         | (i' # _) \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j)
      else if aij = 1 then let v = (\<lambda> i. A $$ (i,j)) in
        gauss_jordan_main
        (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j)
      else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B;
        v = (\<lambda> i. A' $$ (i,j)) in gauss_jordan_main
        (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j)
    else (A,B))" (is "?l = ?r")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))
[PROOF STEP]
note simps = gauss_jordan_main.simps[of A B i j] Let_def
[PROOF STATE]
proof (state)
this:
gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij in gauss_jordan_main (multrow i iaij A) (multrow i iaij B) i j else (A, B))
Let ?s ?f \<equiv> ?f ?s

goal (1 subgoal):
 1. gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))
[PROOF STEP]
let ?nr = "dim_row A"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))
[PROOF STEP]
let ?nc = "dim_col A"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))
[PROOF STEP]
let ?A' = "multrow i (inverse (A $$ (i,j))) A"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))
[PROOF STEP]
let ?B' = "multrow i (inverse (A $$ (i,j))) B"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))
[PROOF STEP]
proof (cases "i < ?nr \<and> j < ?nc \<and> A $$ (i,j) \<noteq> 0 \<and> A $$ (i,j) \<noteq> 1")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i < dim_row A \<and> j < dim_col A \<and> A $$ (i, j) \<noteq> (0::'a) \<and> A $$ (i, j) \<noteq> (1::'a) \<Longrightarrow> gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))
 2. \<not> (i < dim_row A \<and> j < dim_col A \<and> A $$ (i, j) \<noteq> (0::'a) \<and> A $$ (i, j) \<noteq> (1::'a)) \<Longrightarrow> gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> (i < dim_row A \<and> j < dim_col A \<and> A $$ (i, j) \<noteq> (0::'a) \<and> A $$ (i, j) \<noteq> (1::'a))

goal (2 subgoals):
 1. i < dim_row A \<and> j < dim_col A \<and> A $$ (i, j) \<noteq> (0::'a) \<and> A $$ (i, j) \<noteq> (1::'a) \<Longrightarrow> gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))
 2. \<not> (i < dim_row A \<and> j < dim_col A \<and> A $$ (i, j) \<noteq> (0::'a) \<and> A $$ (i, j) \<noteq> (1::'a)) \<Longrightarrow> gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> (i < dim_row A \<and> j < dim_col A \<and> A $$ (i, j) \<noteq> (0::'a) \<and> A $$ (i, j) \<noteq> (1::'a))

goal (1 subgoal):
 1. gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))
[PROOF STEP]
unfolding simps
[PROOF STATE]
proof (prove)
using this:
\<not> (i < dim_row A \<and> j < dim_col A \<and> A $$ (i, j) \<noteq> (0::'a) \<and> A $$ (i, j) \<noteq> (1::'a))

goal (1 subgoal):
 1. (if i < dim_row A \<and> j < dim_col A then if A $$ (i, j) = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<dim_row A]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if A $$ (i, j) = (1::'a) then gauss_jordan_main (eliminate_entries (\<lambda>i. A $$ (i, j)) A i j) (eliminate_entries (\<lambda>i. A $$ (i, j)) B i j) (Suc i) (Suc j) else gauss_jordan_main (multrow i (inverse (A $$ (i, j))) A) (multrow i (inverse (A $$ (i, j))) B) i j else (A, B)) = (if i < dim_row A \<and> j < dim_col A then if A $$ (i, j) = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<dim_row A]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if A $$ (i, j) = (1::'a) then gauss_jordan_main (eliminate_entries (\<lambda>i. A $$ (i, j)) A i j) (eliminate_entries (\<lambda>i. A $$ (i, j)) B i j) (Suc i) (Suc j) else gauss_jordan_main (eliminate_entries (\<lambda>ia. multrow i (inverse (A $$ (i, j))) A $$ (ia, j)) (multrow i (inverse (A $$ (i, j))) A) i j) (eliminate_entries (\<lambda>ia. multrow i (inverse (A $$ (i, j))) A $$ (ia, j)) (multrow i (inverse (A $$ (i, j))) B) i j) (Suc i) (Suc j) else (A, B))
[PROOF STEP]
by (auto split: if_splits)
[PROOF STATE]
proof (state)
this:
gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))

goal (1 subgoal):
 1. i < dim_row A \<and> j < dim_col A \<and> A $$ (i, j) \<noteq> (0::'a) \<and> A $$ (i, j) \<noteq> (1::'a) \<Longrightarrow> gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i < dim_row A \<and> j < dim_col A \<and> A $$ (i, j) \<noteq> (0::'a) \<and> A $$ (i, j) \<noteq> (1::'a) \<Longrightarrow> gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
i < dim_row A \<and> j < dim_col A \<and> A $$ (i, j) \<noteq> (0::'a) \<and> A $$ (i, j) \<noteq> (1::'a)

goal (1 subgoal):
 1. i < dim_row A \<and> j < dim_col A \<and> A $$ (i, j) \<noteq> (0::'a) \<and> A $$ (i, j) \<noteq> (1::'a) \<Longrightarrow> gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))
[PROOF STEP]
from True
[PROOF STATE]
proof (chain)
picking this:
i < dim_row A \<and> j < dim_col A \<and> A $$ (i, j) \<noteq> (0::'a) \<and> A $$ (i, j) \<noteq> (1::'a)
[PROOF STEP]
have id: "?A' $$ (i,j) = 1"
[PROOF STATE]
proof (prove)
using this:
i < dim_row A \<and> j < dim_col A \<and> A $$ (i, j) \<noteq> (0::'a) \<and> A $$ (i, j) \<noteq> (1::'a)

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

goal (1 subgoal):
 1. i < dim_row A \<and> j < dim_col A \<and> A $$ (i, j) \<noteq> (0::'a) \<and> A $$ (i, j) \<noteq> (1::'a) \<Longrightarrow> gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))
[PROOF STEP]
from True
[PROOF STATE]
proof (chain)
picking this:
i < dim_row A \<and> j < dim_col A \<and> A $$ (i, j) \<noteq> (0::'a) \<and> A $$ (i, j) \<noteq> (1::'a)
[PROOF STEP]
have "?l = gauss_jordan_main ?A' ?B' i j"
[PROOF STATE]
proof (prove)
using this:
i < dim_row A \<and> j < dim_col A \<and> A $$ (i, j) \<noteq> (0::'a) \<and> A $$ (i, j) \<noteq> (1::'a)

goal (1 subgoal):
 1. gauss_jordan_main A B i j = gauss_jordan_main (multrow i (inverse (A $$ (i, j))) A) (multrow i (inverse (A $$ (i, j))) B) i j
[PROOF STEP]
unfolding simps
[PROOF STATE]
proof (prove)
using this:
i < dim_row A \<and> j < dim_col A \<and> A $$ (i, j) \<noteq> (0::'a) \<and> A $$ (i, j) \<noteq> (1::'a)

goal (1 subgoal):
 1. (if i < dim_row A \<and> j < dim_col A then if A $$ (i, j) = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<dim_row A]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if A $$ (i, j) = (1::'a) then gauss_jordan_main (eliminate_entries (\<lambda>i. A $$ (i, j)) A i j) (eliminate_entries (\<lambda>i. A $$ (i, j)) B i j) (Suc i) (Suc j) else gauss_jordan_main (multrow i (inverse (A $$ (i, j))) A) (multrow i (inverse (A $$ (i, j))) B) i j else (A, B)) = gauss_jordan_main (multrow i (inverse (A $$ (i, j))) A) (multrow i (inverse (A $$ (i, j))) B) i j
[PROOF STEP]
by (simp add: Let_def)
[PROOF STATE]
proof (state)
this:
gauss_jordan_main A B i j = gauss_jordan_main (multrow i (inverse (A $$ (i, j))) A) (multrow i (inverse (A $$ (i, j))) B) i j

goal (1 subgoal):
 1. i < dim_row A \<and> j < dim_col A \<and> A $$ (i, j) \<noteq> (0::'a) \<and> A $$ (i, j) \<noteq> (1::'a) \<Longrightarrow> gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
gauss_jordan_main A B i j = gauss_jordan_main (multrow i (inverse (A $$ (i, j))) A) (multrow i (inverse (A $$ (i, j))) B) i j

goal (1 subgoal):
 1. i < dim_row A \<and> j < dim_col A \<and> A $$ (i, j) \<noteq> (0::'a) \<and> A $$ (i, j) \<noteq> (1::'a) \<Longrightarrow> gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))
[PROOF STEP]
have "\<dots> = ?r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gauss_jordan_main (multrow i (inverse (A $$ (i, j))) A) (multrow i (inverse (A $$ (i, j))) B) i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))
[PROOF STEP]
unfolding Let_def gauss_jordan_main.simps[of ?A' ?B' i j] id
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if i < dim_row (multrow i (inverse (A $$ (i, j))) A) \<and> j < dim_col (multrow i (inverse (A $$ (i, j))) A) then if (1::'a) = (0::'a) then case concat (map (\<lambda>i'. if multrow i (inverse (A $$ (i, j))) A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<dim_row (multrow i (inverse (A $$ (i, j))) A)]) of [] \<Rightarrow> gauss_jordan_main (multrow i (inverse (A $$ (i, j))) A) (multrow i (inverse (A $$ (i, j))) B) i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' (multrow i (inverse (A $$ (i, j))) A)) (swaprows i i' (multrow i (inverse (A $$ (i, j))) B)) i j else if (1::'a) = (1::'a) then gauss_jordan_main (eliminate_entries (\<lambda>ia. multrow i (inverse (A $$ (i, j))) A $$ (ia, j)) (multrow i (inverse (A $$ (i, j))) A) i j) (eliminate_entries (\<lambda>ia. multrow i (inverse (A $$ (i, j))) A $$ (ia, j)) (multrow i (inverse (A $$ (i, j))) B) i j) (Suc i) (Suc j) else gauss_jordan_main (multrow i (inverse (1::'a)) (multrow i (inverse (A $$ (i, j))) A)) (multrow i (inverse (1::'a)) (multrow i (inverse (A $$ (i, j))) B)) i j else (multrow i (inverse (A $$ (i, j))) A, multrow i (inverse (A $$ (i, j))) B)) = (if i < dim_row A \<and> j < dim_col A then if A $$ (i, j) = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<dim_row A]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if A $$ (i, j) = (1::'a) then gauss_jordan_main (eliminate_entries (\<lambda>i. A $$ (i, j)) A i j) (eliminate_entries (\<lambda>i. A $$ (i, j)) B i j) (Suc i) (Suc j) else gauss_jordan_main (eliminate_entries (\<lambda>ia. multrow i (inverse (A $$ (i, j))) A $$ (ia, j)) (multrow i (inverse (A $$ (i, j))) A) i j) (eliminate_entries (\<lambda>ia. multrow i (inverse (A $$ (i, j))) A $$ (ia, j)) (multrow i (inverse (A $$ (i, j))) B) i j) (Suc i) (Suc j) else (A, B))
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
i < dim_row A \<and> j < dim_col A \<and> A $$ (i, j) \<noteq> (0::'a) \<and> A $$ (i, j) \<noteq> (1::'a)

goal (1 subgoal):
 1. (if i < dim_row (multrow i (inverse (A $$ (i, j))) A) \<and> j < dim_col (multrow i (inverse (A $$ (i, j))) A) then if (1::'a) = (0::'a) then case concat (map (\<lambda>i'. if multrow i (inverse (A $$ (i, j))) A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<dim_row (multrow i (inverse (A $$ (i, j))) A)]) of [] \<Rightarrow> gauss_jordan_main (multrow i (inverse (A $$ (i, j))) A) (multrow i (inverse (A $$ (i, j))) B) i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' (multrow i (inverse (A $$ (i, j))) A)) (swaprows i i' (multrow i (inverse (A $$ (i, j))) B)) i j else if (1::'a) = (1::'a) then gauss_jordan_main (eliminate_entries (\<lambda>ia. multrow i (inverse (A $$ (i, j))) A $$ (ia, j)) (multrow i (inverse (A $$ (i, j))) A) i j) (eliminate_entries (\<lambda>ia. multrow i (inverse (A $$ (i, j))) A $$ (ia, j)) (multrow i (inverse (A $$ (i, j))) B) i j) (Suc i) (Suc j) else gauss_jordan_main (multrow i (inverse (1::'a)) (multrow i (inverse (A $$ (i, j))) A)) (multrow i (inverse (1::'a)) (multrow i (inverse (A $$ (i, j))) B)) i j else (multrow i (inverse (A $$ (i, j))) A, multrow i (inverse (A $$ (i, j))) B)) = (if i < dim_row A \<and> j < dim_col A then if A $$ (i, j) = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<dim_row A]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if A $$ (i, j) = (1::'a) then gauss_jordan_main (eliminate_entries (\<lambda>i. A $$ (i, j)) A i j) (eliminate_entries (\<lambda>i. A $$ (i, j)) B i j) (Suc i) (Suc j) else gauss_jordan_main (eliminate_entries (\<lambda>ia. multrow i (inverse (A $$ (i, j))) A $$ (ia, j)) (multrow i (inverse (A $$ (i, j))) A) i j) (eliminate_entries (\<lambda>ia. multrow i (inverse (A $$ (i, j))) A $$ (ia, j)) (multrow i (inverse (A $$ (i, j))) B) i j) (Suc i) (Suc j) else (A, B))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
gauss_jordan_main (multrow i (inverse (A $$ (i, j))) A) (multrow i (inverse (A $$ (i, j))) B) i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))

goal (1 subgoal):
 1. i < dim_row A \<and> j < dim_col A \<and> A $$ (i, j) \<noteq> (0::'a) \<and> A $$ (i, j) \<noteq> (1::'a) \<Longrightarrow> gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))

goal (1 subgoal):
 1. gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
gauss_jordan_main A B i j = (let nr = dim_row A; nc = dim_col A in if i < nr \<and> j < nc then let aij = A $$ (i, j) in if aij = (0::'a) then case concat (map (\<lambda>i'. if A $$ (i', j) \<noteq> (0::'a) then [i'] else []) [Suc i..<nr]) of [] \<Rightarrow> gauss_jordan_main A B i (Suc j) | i' # x \<Rightarrow> gauss_jordan_main (swaprows i i' A) (swaprows i i' B) i j else if aij = (1::'a) then let v = \<lambda>i. A $$ (i, j) in gauss_jordan_main (eliminate_entries v A i j) (eliminate_entries v B i j) (Suc i) (Suc j) else let iaij = inverse aij; A' = multrow i iaij A; B' = multrow i iaij B; v = \<lambda>i. A' $$ (i, j) in gauss_jordan_main (eliminate_entries v A' i j) (eliminate_entries v B' i j) (Suc i) (Suc j) else (A, B))

goal:
No subgoals!
[PROOF STEP]
qed