[STATEMENT]
lemma step_3_c_inner_result: assumes inv:
  "inv_upto jb A k"
  "inv_from uppert A k"
  "inv_at one_zero A k"
  "ev_block n A"
  and k: "k < n"
  and A: "A \<in> carrier_mat n n"
  and lbl: "(lb,l) \<in> set (identify_blocks A k)"
  and ib_block: "(i_begin,i_end) \<in> set (identify_blocks A k)"
  and il: "i_end \<noteq> l"
  and large: "l - lb \<ge> i_end - i_begin"
  and Alk: "A $$ (l,k) \<noteq> 0"
  shows "step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l,k)) l i_end (Suc i_end - i_begin) A =
    mat n n
     (\<lambda>(i, j). if (i, j) = (i_end, k) then 0
               else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l,k) * A $$ (l + i - i_end, j)
                    else A $$ (i, j))" (is "?L = ?R")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc i_end - i_begin) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc i_end - i_begin) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
let ?Alk = "A $$ (l,k)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc i_end - i_begin) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
let ?Aik = "A $$ (i_end,k)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc i_end - i_begin) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
define quot where "quot = ?Aik / ?Alk"
[PROOF STATE]
proof (state)
this:
quot = A $$ (i_end, k) / A $$ (l, k)

goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc i_end - i_begin) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
let ?idiff = "i_end - i_begin"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc i_end - i_begin) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
let ?m = "\<lambda> iter diff i j. if (i,j) = (i_end,k) then if diff = (Suc ?idiff) then ?Aik else 0
    else if i \<ge> i_begin + diff \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j)
    else if (i,j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc ?idiff} then quot
    else A $$ (i,j)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc i_end - i_begin) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
let ?mm = "\<lambda> iter diff i j. if (i,j) = (i_end,k) then 0
    else if i \<ge> i_begin + diff \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j)
    else if (i,j) = (i_end - Suc iter, l - iter) \<and> iter \<noteq> ?idiff then quot
    else A $$ (i,j)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc i_end - i_begin) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
let ?mat = "\<lambda> iter diff. mat n n (\<lambda> (i,j). ?m iter diff i j)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc i_end - i_begin) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
from identify_blocks[OF ib_block]
[PROOF STATE]
proof (chain)
picking this:
i_begin \<le> i_end \<and> i_end < k
[PROOF STEP]
have ib: "i_begin \<le> i_end" "i_end < k"
[PROOF STATE]
proof (prove)
using this:
i_begin \<le> i_end \<and> i_end < k

goal (1 subgoal):
 1. i_begin \<le> i_end &&& i_end < k
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i_begin \<le> i_end
i_end < k

goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc i_end - i_begin) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
from identify_blocks[OF lbl]
[PROOF STATE]
proof (chain)
picking this:
lb \<le> l \<and> l < k
[PROOF STEP]
have lb: "lb \<le> l" "l < k"
[PROOF STATE]
proof (prove)
using this:
lb \<le> l \<and> l < k

goal (1 subgoal):
 1. lb \<le> l &&& l < k
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
lb \<le> l
l < k

goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc i_end - i_begin) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
have mend: "?mat 0 (Suc ?idiff) = A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc (i_end - i_begin) = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc (i_end - i_begin) \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - 0, Suc l - 0) \<and> 0 \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) = A
[PROOF STEP]
by (rule eq_matI, insert A ib, auto)
[PROOF STATE]
proof (state)
this:
mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc (i_end - i_begin) = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc (i_end - i_begin) \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - 0, Suc l - 0) \<and> 0 \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) = A

goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc i_end - i_begin) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc (i_end - i_begin) = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc (i_end - i_begin) \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - 0, Suc l - 0) \<and> 0 \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) = A

goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc i_end - i_begin) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
fix ll ii diff iter
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc i_end - i_begin) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
assume "diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end" "diff \<noteq> 0 \<Longrightarrow> ll + iter = l" "diff + iter = Suc ?idiff"
[PROOF STATE]
proof (state)
this:
diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end
diff \<noteq> 0 \<Longrightarrow> ll + iter = l
diff + iter = Suc (i_end - i_begin)

goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc i_end - i_begin) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
hence "step_3_c_inner_loop quot ll ii diff (?mat iter diff) = ?R"
[PROOF STATE]
proof (prove)
using this:
diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end
diff \<noteq> 0 \<Longrightarrow> ll + iter = l
diff + iter = Suc (i_end - i_begin)

goal (1 subgoal):
 1. step_3_c_inner_loop quot ll ii diff (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
proof (induct diff arbitrary: ii ll iter)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>ii ll iter. \<lbrakk>0 \<noteq> 0 \<Longrightarrow> ii + iter = i_end; 0 \<noteq> 0 \<Longrightarrow> ll + iter = l; 0 + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii 0 (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if 0 = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + 0 \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
 2. \<And>diff ii ll iter. \<lbrakk>\<And>ii ll iter. \<lbrakk>diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; diff \<noteq> 0 \<Longrightarrow> ll + iter = l; diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii diff (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j)); Suc diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; Suc diff \<noteq> 0 \<Longrightarrow> ll + iter = l; Suc diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii (Suc diff) (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
0 \<noteq> 0 \<Longrightarrow> ii + iter = i_end
0 \<noteq> 0 \<Longrightarrow> ll + iter = l
0 + iter = Suc (i_end - i_begin)

goal (2 subgoals):
 1. \<And>ii ll iter. \<lbrakk>0 \<noteq> 0 \<Longrightarrow> ii + iter = i_end; 0 \<noteq> 0 \<Longrightarrow> ll + iter = l; 0 + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii 0 (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if 0 = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + 0 \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
 2. \<And>diff ii ll iter. \<lbrakk>\<And>ii ll iter. \<lbrakk>diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; diff \<noteq> 0 \<Longrightarrow> ll + iter = l; diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii diff (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j)); Suc diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; Suc diff \<noteq> 0 \<Longrightarrow> ll + iter = l; Suc diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii (Suc diff) (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
hence iter: "iter = Suc ?idiff"
[PROOF STATE]
proof (prove)
using this:
0 \<noteq> 0 \<Longrightarrow> ii + iter = i_end
0 \<noteq> 0 \<Longrightarrow> ll + iter = l
0 + iter = Suc (i_end - i_begin)

goal (1 subgoal):
 1. iter = Suc (i_end - i_begin)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
iter = Suc (i_end - i_begin)

goal (2 subgoals):
 1. \<And>ii ll iter. \<lbrakk>0 \<noteq> 0 \<Longrightarrow> ii + iter = i_end; 0 \<noteq> 0 \<Longrightarrow> ll + iter = l; 0 + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii 0 (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if 0 = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + 0 \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
 2. \<And>diff ii ll iter. \<lbrakk>\<And>ii ll iter. \<lbrakk>diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; diff \<noteq> 0 \<Longrightarrow> ll + iter = l; diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii diff (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j)); Suc diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; Suc diff \<noteq> 0 \<Longrightarrow> ll + iter = l; Suc diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii (Suc diff) (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
have "step_3_c_inner_loop quot ll ii 0 (?mat iter 0) = ?mat (Suc ?idiff) 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. step_3_c_inner_loop quot ll ii 0 (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if 0 = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + 0 \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if 0 = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + 0 \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc (i_end - i_begin), Suc l - Suc (i_end - i_begin)) \<and> Suc (i_end - i_begin) \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))
[PROOF STEP]
unfolding iter step_3_c_inner_loop.simps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if 0 = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + 0 \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc (i_end - i_begin), Suc l - Suc (i_end - i_begin)) \<and> Suc (i_end - i_begin) \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if 0 = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + 0 \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc (i_end - i_begin), Suc l - Suc (i_end - i_begin)) \<and> Suc (i_end - i_begin) \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
step_3_c_inner_loop quot ll ii 0 (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if 0 = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + 0 \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if 0 = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + 0 \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc (i_end - i_begin), Suc l - Suc (i_end - i_begin)) \<and> Suc (i_end - i_begin) \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))

goal (2 subgoals):
 1. \<And>ii ll iter. \<lbrakk>0 \<noteq> 0 \<Longrightarrow> ii + iter = i_end; 0 \<noteq> 0 \<Longrightarrow> ll + iter = l; 0 + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii 0 (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if 0 = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + 0 \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
 2. \<And>diff ii ll iter. \<lbrakk>\<And>ii ll iter. \<lbrakk>diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; diff \<noteq> 0 \<Longrightarrow> ll + iter = l; diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii diff (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j)); Suc diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; Suc diff \<noteq> 0 \<Longrightarrow> ll + iter = l; Suc diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii (Suc diff) (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
step_3_c_inner_loop quot ll ii 0 (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if 0 = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + 0 \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if 0 = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + 0 \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc (i_end - i_begin), Suc l - Suc (i_end - i_begin)) \<and> Suc (i_end - i_begin) \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))

goal (2 subgoals):
 1. \<And>ii ll iter. \<lbrakk>0 \<noteq> 0 \<Longrightarrow> ii + iter = i_end; 0 \<noteq> 0 \<Longrightarrow> ll + iter = l; 0 + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii 0 (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if 0 = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + 0 \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
 2. \<And>diff ii ll iter. \<lbrakk>\<And>ii ll iter. \<lbrakk>diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; diff \<noteq> 0 \<Longrightarrow> ll + iter = l; diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii diff (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j)); Suc diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; Suc diff \<noteq> 0 \<Longrightarrow> ll + iter = l; Suc diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii (Suc diff) (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
have "\<dots> = ?R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if 0 = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + 0 \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc (i_end - i_begin), Suc l - Suc (i_end - i_begin)) \<and> Suc (i_end - i_begin) \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
by (rule eq_matI, insert ib, auto simp: quot_def)
[PROOF STATE]
proof (state)
this:
mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if 0 = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + 0 \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc (i_end - i_begin), Suc l - Suc (i_end - i_begin)) \<and> Suc (i_end - i_begin) \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))

goal (2 subgoals):
 1. \<And>ii ll iter. \<lbrakk>0 \<noteq> 0 \<Longrightarrow> ii + iter = i_end; 0 \<noteq> 0 \<Longrightarrow> ll + iter = l; 0 + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii 0 (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if 0 = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + 0 \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
 2. \<And>diff ii ll iter. \<lbrakk>\<And>ii ll iter. \<lbrakk>diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; diff \<noteq> 0 \<Longrightarrow> ll + iter = l; diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii diff (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j)); Suc diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; Suc diff \<noteq> 0 \<Longrightarrow> ll + iter = l; Suc diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii (Suc diff) (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
step_3_c_inner_loop quot ll ii 0 (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if 0 = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + 0 \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
step_3_c_inner_loop quot ll ii 0 (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if 0 = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + 0 \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))

goal (1 subgoal):
 1. step_3_c_inner_loop quot ll ii 0 (mat n n (\<lambda>a. case a of (i, j) \<Rightarrow> if (i, j) = (i_end, k) then if 0 = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + 0 \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>a. case a of (i, j) \<Rightarrow> if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
step_3_c_inner_loop quot ll ii 0 (mat n n (\<lambda>a. case a of (i, j) \<Rightarrow> if (i, j) = (i_end, k) then if 0 = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + 0 \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>a. case a of (i, j) \<Rightarrow> if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))

goal (1 subgoal):
 1. \<And>diff ii ll iter. \<lbrakk>\<And>ii ll iter. \<lbrakk>diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; diff \<noteq> 0 \<Longrightarrow> ll + iter = l; diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii diff (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j)); Suc diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; Suc diff \<noteq> 0 \<Longrightarrow> ll + iter = l; Suc diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii (Suc diff) (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>diff ii ll iter. \<lbrakk>\<And>ii ll iter. \<lbrakk>diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; diff \<noteq> 0 \<Longrightarrow> ll + iter = l; diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii diff (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j)); Suc diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; Suc diff \<noteq> 0 \<Longrightarrow> ll + iter = l; Suc diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii (Suc diff) (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
case (Suc diff ii ll)
[PROOF STATE]
proof (state)
this:
\<lbrakk>diff \<noteq> 0 \<Longrightarrow> ?ii + ?iter = i_end; diff \<noteq> 0 \<Longrightarrow> ?ll + ?iter = l; diff + ?iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ?ll ?ii diff (mat n n (\<lambda>a. case a of (i, j) \<Rightarrow> if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - ?iter, Suc l - ?iter) \<and> ?iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>a. case a of (i, j) \<Rightarrow> if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
Suc diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end
Suc diff \<noteq> 0 \<Longrightarrow> ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)

goal (1 subgoal):
 1. \<And>diff ii ll iter. \<lbrakk>\<And>ii ll iter. \<lbrakk>diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; diff \<noteq> 0 \<Longrightarrow> ll + iter = l; diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii diff (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j)); Suc diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; Suc diff \<noteq> 0 \<Longrightarrow> ll + iter = l; Suc diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii (Suc diff) (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
note prems = Suc(2-)
[PROOF STATE]
proof (state)
this:
Suc diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end
Suc diff \<noteq> 0 \<Longrightarrow> ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)

goal (1 subgoal):
 1. \<And>diff ii ll iter. \<lbrakk>\<And>ii ll iter. \<lbrakk>diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; diff \<noteq> 0 \<Longrightarrow> ll + iter = l; diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii diff (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j)); Suc diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; Suc diff \<noteq> 0 \<Longrightarrow> ll + iter = l; Suc diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii (Suc diff) (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
let ?B = "?mat iter (Suc diff)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>diff ii ll iter. \<lbrakk>\<And>ii ll iter. \<lbrakk>diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; diff \<noteq> 0 \<Longrightarrow> ll + iter = l; diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii diff (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j)); Suc diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; Suc diff \<noteq> 0 \<Longrightarrow> ll + iter = l; Suc diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii (Suc diff) (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
have "step_3_c_inner_loop quot ll ii (Suc diff) ?B
      = step_3_c_inner_loop quot (ll - 1) (ii - 1) diff (add_col_sub_row quot ii ll ?B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. step_3_c_inner_loop quot ll ii (Suc diff) (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = step_3_c_inner_loop quot (ll - 1) (ii - 1) diff (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
step_3_c_inner_loop quot ll ii (Suc diff) (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = step_3_c_inner_loop quot (ll - 1) (ii - 1) diff (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))))

goal (1 subgoal):
 1. \<And>diff ii ll iter. \<lbrakk>\<And>ii ll iter. \<lbrakk>diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; diff \<noteq> 0 \<Longrightarrow> ll + iter = l; diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii diff (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j)); Suc diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; Suc diff \<noteq> 0 \<Longrightarrow> ll + iter = l; Suc diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii (Suc diff) (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
step_3_c_inner_loop quot ll ii (Suc diff) (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = step_3_c_inner_loop quot (ll - 1) (ii - 1) diff (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))))

goal (1 subgoal):
 1. \<And>diff ii ll iter. \<lbrakk>\<And>ii ll iter. \<lbrakk>diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; diff \<noteq> 0 \<Longrightarrow> ll + iter = l; diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii diff (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j)); Suc diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; Suc diff \<noteq> 0 \<Longrightarrow> ll + iter = l; Suc diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii (Suc diff) (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
have "add_col_sub_row quot ii ll ?B
        = ?mat (Suc iter) diff" (is "?C = ?D")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))
[PROOF STEP]
proof (rule eq_matI, unfold dim_row_mat dim_col_mat)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
fix i j
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
assume i: "i < n" and j: "j < n"
[PROOF STATE]
proof (state)
this:
i < n
j < n

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
have ll: "ll < n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ll < n
[PROOF STEP]
using prems lb k
[PROOF STATE]
proof (prove)
using this:
Suc diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end
Suc diff \<noteq> 0 \<Longrightarrow> ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
lb \<le> l
l < k
k < n

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

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
from prems ib k
[PROOF STATE]
proof (chain)
picking this:
Suc diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end
Suc diff \<noteq> 0 \<Longrightarrow> ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_begin \<le> i_end
i_end < k
k < n
[PROOF STEP]
have ii: "ii \<ge> i_begin" "ii < n" "ii < k" "ii \<le> i_end"
          and eqs: "ii + iter = i_end" "ll + iter = l" "Suc diff + iter = Suc ?idiff"
[PROOF STATE]
proof (prove)
using this:
Suc diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end
Suc diff \<noteq> 0 \<Longrightarrow> ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_begin \<le> i_end
i_end < k
k < n

goal (1 subgoal):
 1. ((i_begin \<le> ii &&& ii < n) &&& ii < k &&& ii \<le> i_end) &&& ii + iter = i_end &&& ll + iter = l &&& Suc diff + iter = Suc (i_end - i_begin)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
from eqs
[PROOF STATE]
proof (chain)
picking this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
[PROOF STEP]
have diff: "diff < Suc ?idiff"
[PROOF STATE]
proof (prove)
using this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)

goal (1 subgoal):
 1. diff < Suc (i_end - i_begin)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
diff < Suc (i_end - i_begin)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
from eqs lb \<open>k < n\<close>
[PROOF STATE]
proof (chain)
picking this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
lb \<le> l
l < k
k < n
[PROOF STEP]
have "ll < k" "l < n"
[PROOF STATE]
proof (prove)
using this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
lb \<le> l
l < k
k < n

goal (1 subgoal):
 1. ll < k &&& l < n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ll < k
l < n

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
note index = ib lb k i j ll il large ii this
[PROOF STATE]
proof (state)
this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
let ?Aij = "A $$ (i,j)"
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
have D: "?D $$ (i,j) = ?mm iter diff i j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = (if (i, j) = (i_end, k) then 0::'a else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, l - iter) \<and> iter \<noteq> i_end - i_begin then quot else A $$ (i, j))
[PROOF STEP]
using diff i j
[PROOF STATE]
proof (prove)
using this:
diff < Suc (i_end - i_begin)
i < n
j < n

goal (1 subgoal):
 1. mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = (if (i, j) = (i_end, k) then 0::'a else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, l - iter) \<and> iter \<noteq> i_end - i_begin then quot else A $$ (i, j))
[PROOF STEP]
by (auto split: if_splits)
[PROOF STATE]
proof (state)
this:
mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = (if (i, j) = (i_end, k) then 0::'a else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, l - iter) \<and> iter \<noteq> i_end - i_begin then quot else A $$ (i, j))

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
define B where "B = ?B"
[PROOF STATE]
proof (state)
this:
B = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
have BB: "\<And> i j. i < n \<Longrightarrow> j < n \<Longrightarrow> B $$ (i,j) = ?m iter (Suc diff) i j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> B $$ (i, j) = (if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))
[PROOF STEP]
unfolding B_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = (if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i < n; ?j < n\<rbrakk> \<Longrightarrow> B $$ (?i, ?j) = (if (?i, ?j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> ?i \<and> ?i \<le> i_end \<and> k < ?j then A $$ (?i, ?j) - quot * A $$ (l + ?i - i_end, ?j) else if (?i, ?j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (?i, ?j))

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
have B: "B $$ (i,j) = ?m iter (Suc diff) i j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B $$ (i, j) = (if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))
[PROOF STEP]
by (rule BB[OF i j])
[PROOF STATE]
proof (state)
this:
B $$ (i, j) = (if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
have C: "?C $$ (i, j) =
         (if i = ii \<and> j = ll then B $$ (i, j) + quot * B $$ (i, i) - quot * quot * B $$ (j, i) - quot * B $$ (j, j)
          else if i = ii \<and> j \<noteq> ll then B $$ (i, j) - quot * B $$ (ll, j)
          else if i \<noteq> ii \<and> j = ll then B $$ (i, j) + quot * B $$ (i, ii)
          else B $$ (i, j))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (if i = ii \<and> j = ll then B $$ (i, j) + quot * B $$ (i, i) - quot * quot * B $$ (j, i) - quot * B $$ (j, j) else if i = ii \<and> j \<noteq> ll then B $$ (i, j) - quot * B $$ (ll, j) else if i \<noteq> ii \<and> j = ll then B $$ (i, j) + quot * B $$ (i, ii) else B $$ (i, j))
[PROOF STEP]
unfolding B_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (if i = ii \<and> j = ll then mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) + quot * mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, i) - quot * quot * mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (j, i) - quot * mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (j, j) else if i = ii \<and> j \<noteq> ll then mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) - quot * mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (ll, j) else if i \<noteq> ii \<and> j = ll then mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) + quot * mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, ii) else mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j))
[PROOF STEP]
by (rule add_col_sub_index_row(1), insert i j ll, auto)
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (if i = ii \<and> j = ll then B $$ (i, j) + quot * B $$ (i, i) - quot * quot * B $$ (j, i) - quot * B $$ (j, j) else if i = ii \<and> j \<noteq> ll then B $$ (i, j) - quot * B $$ (ll, j) else if i \<noteq> ii \<and> j = ll then B $$ (i, j) + quot * B $$ (i, ii) else B $$ (i, j))

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
from inv_from_upto_at_all_ev_block[OF inv(1-4) _ \<open>k < n\<close>]
[PROOF STATE]
proof (chain)
picking this:
(\<And>i. \<lbrakk>i < n; one_zero A i k\<rbrakk> \<Longrightarrow> local.uppert A i k) \<Longrightarrow> local.inv_all local.uppert A
[PROOF STEP]
have invA: "inv_all uppert A"
[PROOF STATE]
proof (prove)
using this:
(\<And>i. \<lbrakk>i < n; one_zero A i k\<rbrakk> \<Longrightarrow> local.uppert A i k) \<Longrightarrow> local.inv_all local.uppert A

goal (1 subgoal):
 1. local.inv_all local.uppert A
[PROOF STEP]
unfolding one_zero_def uppert_def
[PROOF STATE]
proof (prove)
using this:
(\<And>i. \<lbrakk>i < n; (Suc i < k \<longrightarrow> A $$ (i, Suc i) = (1::'a) \<longrightarrow> A $$ (i, k) = (0::'a)) \<and> (k < i \<longrightarrow> A $$ (i, k) = (0::'a)) \<and> (i < k \<longrightarrow> A $$ (i, i) \<noteq> A $$ (k, k) \<longrightarrow> A $$ (i, k) = (0::'a))\<rbrakk> \<Longrightarrow> k < i \<longrightarrow> A $$ (i, k) = (0::'a)) \<Longrightarrow> local.inv_all (\<lambda>A i j. j < i \<longrightarrow> A $$ (i, j) = (0::'a)) A

goal (1 subgoal):
 1. local.inv_all (\<lambda>A i j. j < i \<longrightarrow> A $$ (i, j) = (0::'a)) A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
local.inv_all local.uppert A

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
note ut = inv_all_uppertD[OF invA]
[PROOF STATE]
proof (state)
this:
\<lbrakk>?j < ?i; ?i < n\<rbrakk> \<Longrightarrow> A $$ (?i, ?j) = (0::'a)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
note jb = inv_uptoD[OF inv(1), unfolded jb_def]
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i < n; ?j < n; ?j < k\<rbrakk> \<Longrightarrow> (Suc ?i = ?j \<longrightarrow> A $$ (?i, ?j) \<in> {0::'a, 1::'a}) \<and> (?i \<noteq> ?j \<longrightarrow> Suc ?i \<noteq> ?j \<or> A $$ (?i, ?i) \<noteq> A $$ (?j, ?j) \<longrightarrow> A $$ (?i, ?j) = (0::'a))

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
note oz = inv_atD[OF inv(3), unfolded one_zero_def]
[PROOF STATE]
proof (state)
this:
?i < n \<Longrightarrow> (Suc ?i < k \<longrightarrow> A $$ (?i, Suc ?i) = (1::'a) \<longrightarrow> A $$ (?i, k) = (0::'a)) \<and> (k < ?i \<longrightarrow> A $$ (?i, k) = (0::'a)) \<and> (?i < k \<longrightarrow> A $$ (?i, ?i) \<noteq> A $$ (k, k) \<longrightarrow> A $$ (?i, k) = (0::'a))

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
note evb = ev_blockD[OF inv(4)]
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i < n; ?j < n\<rbrakk> \<Longrightarrow> A $$ (?i, ?i) = A $$ (?j, ?j)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
note iblock = identify_blocksD[OF \<open>k < n\<close>]
[PROOF STATE]
proof (state)
this:
(?i, ?j) \<in> set (identify_blocks ?A k) \<Longrightarrow> ?i \<le> ?j
(?i, ?j) \<in> set (identify_blocks ?A k) \<Longrightarrow> ?j < k
\<lbrakk>(?i, ?j) \<in> set (identify_blocks ?A k); ?i \<le> ?l; ?l < ?j\<rbrakk> \<Longrightarrow> ?A $$ (?l, Suc ?l) = (1::?'b)
\<lbrakk>(?i, ?j) \<in> set (identify_blocks ?A k); Suc ?j \<noteq> k\<rbrakk> \<Longrightarrow> ?A $$ (?j, Suc ?j) \<noteq> (1::?'b)
\<lbrakk>(?i, ?j) \<in> set (identify_blocks ?A k); 0 < ?i\<rbrakk> \<Longrightarrow> ?A $$ (?i - 1, ?i - 1) \<noteq> ?A $$ (k, k) \<or> ?A $$ (?i - 1, ?i) \<noteq> (1::?'b)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
note ibe = iblock[OF ib_block]
[PROOF STATE]
proof (state)
this:
i_begin \<le> i_end
i_end < k
\<lbrakk>i_begin \<le> ?l; ?l < i_end\<rbrakk> \<Longrightarrow> A $$ (?l, Suc ?l) = (1::'a)
Suc i_end \<noteq> k \<Longrightarrow> A $$ (i_end, Suc i_end) \<noteq> (1::'a)
0 < i_begin \<Longrightarrow> A $$ (i_begin - 1, i_begin - 1) \<noteq> A $$ (k, k) \<or> A $$ (i_begin - 1, i_begin) \<noteq> (1::'a)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
let ?ev = "\<lambda> i. A $$ (i,i)"
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
fix i ib ie
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
assume "(ib,ie) \<in> set (identify_blocks A k)" and i: "ib \<le> i" "i < ie"
[PROOF STATE]
proof (state)
this:
(ib, ie) \<in> set (identify_blocks A k)
ib \<le> i
i < ie

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
note ibe = iblock[OF this(1)]
[PROOF STATE]
proof (state)
this:
ib \<le> ie
ie < k
\<lbrakk>ib \<le> ?l; ?l < ie\<rbrakk> \<Longrightarrow> A $$ (?l, Suc ?l) = (1::'a)
Suc ie \<noteq> k \<Longrightarrow> A $$ (ie, Suc ie) \<noteq> (1::'a)
0 < ib \<Longrightarrow> A $$ (ib - 1, ib - 1) \<noteq> A $$ (k, k) \<or> A $$ (ib - 1, ib) \<noteq> (1::'a)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
from ibe(3)[OF i]
[PROOF STATE]
proof (chain)
picking this:
A $$ (i, Suc i) = (1::'a)
[PROOF STEP]
have id: "A $$ (i, Suc i) = 1"
[PROOF STATE]
proof (prove)
using this:
A $$ (i, Suc i) = (1::'a)

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

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
from i ibe \<open>k < n\<close>
[PROOF STATE]
proof (chain)
picking this:
ib \<le> i
i < ie
ib \<le> ie
ie < k
\<lbrakk>ib \<le> ?l; ?l < ie\<rbrakk> \<Longrightarrow> A $$ (?l, Suc ?l) = (1::'a)
Suc ie \<noteq> k \<Longrightarrow> A $$ (ie, Suc ie) \<noteq> (1::'a)
0 < ib \<Longrightarrow> A $$ (ib - 1, ib - 1) \<noteq> A $$ (k, k) \<or> A $$ (ib - 1, ib) \<noteq> (1::'a)
k < n
[PROOF STEP]
have "i < n" "Suc i < k"
[PROOF STATE]
proof (prove)
using this:
ib \<le> i
i < ie
ib \<le> ie
ie < k
\<lbrakk>ib \<le> ?l; ?l < ie\<rbrakk> \<Longrightarrow> A $$ (?l, Suc ?l) = (1::'a)
Suc ie \<noteq> k \<Longrightarrow> A $$ (ie, Suc ie) \<noteq> (1::'a)
0 < ib \<Longrightarrow> A $$ (ib - 1, ib - 1) \<noteq> A $$ (k, k) \<or> A $$ (ib - 1, ib) \<noteq> (1::'a)
k < n

goal (1 subgoal):
 1. i < n &&& Suc i < k
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i < n
Suc i < k

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
with oz[OF this(1)] id
[PROOF STATE]
proof (chain)
picking this:
(Suc i < k \<longrightarrow> A $$ (i, Suc i) = (1::'a) \<longrightarrow> A $$ (i, k) = (0::'a)) \<and> (k < i \<longrightarrow> A $$ (i, k) = (0::'a)) \<and> (i < k \<longrightarrow> A $$ (i, i) \<noteq> A $$ (k, k) \<longrightarrow> A $$ (i, k) = (0::'a))
A $$ (i, Suc i) = (1::'a)
i < n
Suc i < k
[PROOF STEP]
have "A $$ (i,k) = 0"
[PROOF STATE]
proof (prove)
using this:
(Suc i < k \<longrightarrow> A $$ (i, Suc i) = (1::'a) \<longrightarrow> A $$ (i, k) = (0::'a)) \<and> (k < i \<longrightarrow> A $$ (i, k) = (0::'a)) \<and> (i < k \<longrightarrow> A $$ (i, i) \<noteq> A $$ (k, k) \<longrightarrow> A $$ (i, k) = (0::'a))
A $$ (i, Suc i) = (1::'a)
i < n
Suc i < k

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

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>(?ib2, ?ie2) \<in> set (identify_blocks A k); ?ib2 \<le> ?ia2; ?ia2 < ?ie2\<rbrakk> \<Longrightarrow> A $$ (?ia2, k) = (0::'a)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
note A_ik = this
[PROOF STATE]
proof (state)
this:
\<lbrakk>(?ib2, ?ie2) \<in> set (identify_blocks A k); ?ib2 \<le> ?ia2; ?ia2 < ?ie2\<rbrakk> \<Longrightarrow> A $$ (?ia2, k) = (0::'a)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
\<lbrakk>(?ib2, ?ie2) \<in> set (identify_blocks A k); ?ib2 \<le> ?ia2; ?ia2 < ?ie2\<rbrakk> \<Longrightarrow> A $$ (?ia2, k) = (0::'a)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
assume i: "i < n" and "\<not> (i \<ge> i_begin \<and> i \<le> i_end)"
[PROOF STATE]
proof (state)
this:
i < n
\<not> (i_begin \<le> i \<and> i \<le> i_end)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
hence choice: "i > i_end \<or> i < i_begin"
[PROOF STATE]
proof (prove)
using this:
i < n
\<not> (i_begin \<le> i \<and> i \<le> i_end)

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

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
note index = index i
[PROOF STATE]
proof (state)
this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i__ < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i < n

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
from index eqs choice
[PROOF STATE]
proof (chain)
picking this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i__ < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i < n
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_end < i \<or> i < i_begin
[PROOF STEP]
have "i \<noteq> ii"
[PROOF STATE]
proof (prove)
using this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i__ < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i < n
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_end < i \<or> i < i_begin

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

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
i \<noteq> ii

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
assume 0: "A $$ (i,ii) \<noteq> 0"
[PROOF STATE]
proof (state)
this:
A $$ (i, ii) \<noteq> (0::'a)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
from 0 ut[of ii, OF _ i] \<open>i \<noteq> ii\<close>
[PROOF STATE]
proof (chain)
picking this:
A $$ (i, ii) \<noteq> (0::'a)
ii < i \<Longrightarrow> A $$ (i, ii) = (0::'a)
i \<noteq> ii
[PROOF STEP]
have "i < ii"
[PROOF STATE]
proof (prove)
using this:
A $$ (i, ii) \<noteq> (0::'a)
ii < i \<Longrightarrow> A $$ (i, ii) = (0::'a)
i \<noteq> ii

goal (1 subgoal):
 1. i < ii
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
i < ii

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
from choice index eqs this
[PROOF STATE]
proof (chain)
picking this:
i_end < i \<or> i < i_begin
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i__ < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i < n
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i < ii
[PROOF STEP]
have "i < i_begin"
[PROOF STATE]
proof (prove)
using this:
i_end < i \<or> i < i_begin
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i__ < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i < n
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i < ii

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

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
with index
[PROOF STATE]
proof (chain)
picking this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i__ < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i < n
i < i_begin
[PROOF STEP]
have "i < k"
[PROOF STATE]
proof (prove)
using this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i__ < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i < n
i < i_begin

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

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
from jb[OF i \<open>ii < n\<close> \<open>ii < k\<close>] 0 \<open>i \<noteq> ii\<close>
[PROOF STATE]
proof (chain)
picking this:
(Suc i = ii \<longrightarrow> A $$ (i, ii) \<in> {0::'a, 1::'a}) \<and> (i \<noteq> ii \<longrightarrow> Suc i \<noteq> ii \<or> A $$ (i, i) \<noteq> A $$ (ii, ii) \<longrightarrow> A $$ (i, ii) = (0::'a))
A $$ (i, ii) \<noteq> (0::'a)
i \<noteq> ii
[PROOF STEP]
have *: "Suc i = ii" "A $$ (i,ii) = 1" "?ev i = ?ev ii"
[PROOF STATE]
proof (prove)
using this:
(Suc i = ii \<longrightarrow> A $$ (i, ii) \<in> {0::'a, 1::'a}) \<and> (i \<noteq> ii \<longrightarrow> Suc i \<noteq> ii \<or> A $$ (i, i) \<noteq> A $$ (ii, ii) \<longrightarrow> A $$ (i, ii) = (0::'a))
A $$ (i, ii) \<noteq> (0::'a)
i \<noteq> ii

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

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
with index \<open>i < i_begin\<close>
[PROOF STATE]
proof (chain)
picking this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i__ < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i < n
i < i_begin
Suc i = ii
A $$ (i, ii) = (1::'a)
A $$ (i, i) = A $$ (ii, ii)
[PROOF STEP]
have "ii = i_begin"
[PROOF STATE]
proof (prove)
using this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i__ < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i < n
i < i_begin
Suc i = ii
A $$ (i, ii) = (1::'a)
A $$ (i, i) = A $$ (ii, ii)

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

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
with evb[OF \<open>i < n\<close> \<open>k < n\<close>] ibe(5) *
[PROOF STATE]
proof (chain)
picking this:
A $$ (i, i) = A $$ (k, k)
0 < i_begin \<Longrightarrow> A $$ (i_begin - 1, i_begin - 1) \<noteq> A $$ (k, k) \<or> A $$ (i_begin - 1, i_begin) \<noteq> (1::'a)
Suc i = ii
A $$ (i, ii) = (1::'a)
A $$ (i, i) = A $$ (ii, ii)
ii = i_begin
[PROOF STEP]
have False
[PROOF STATE]
proof (prove)
using this:
A $$ (i, i) = A $$ (k, k)
0 < i_begin \<Longrightarrow> A $$ (i_begin - 1, i_begin - 1) \<noteq> A $$ (k, k) \<or> A $$ (i_begin - 1, i_begin) \<noteq> (1::'a)
Suc i = ii
A $$ (i, ii) = (1::'a)
A $$ (i, i) = A $$ (ii, ii)
ii = i_begin

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

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
A $$ (i, ii) \<noteq> (0::'a) \<Longrightarrow> False

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
hence Aii: "A $$ (i,ii) = 0"
[PROOF STATE]
proof (prove)
using this:
A $$ (i, ii) \<noteq> (0::'a) \<Longrightarrow> False

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

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
A $$ (i, ii) = (0::'a)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
fix j
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
assume j: "j < n"
[PROOF STATE]
proof (state)
this:
j < n

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
have B: "B $$ (i,j) = ?m iter (Suc diff) i j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B $$ (i, j) = (if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))
[PROOF STEP]
using i j
[PROOF STATE]
proof (prove)
using this:
i < n
j < n

goal (1 subgoal):
 1. B $$ (i, j) = (if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))
[PROOF STEP]
unfolding B_def
[PROOF STATE]
proof (prove)
using this:
i < n
j < n

goal (1 subgoal):
 1. mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = (if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
B $$ (i, j) = (if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
from choice
[PROOF STATE]
proof (chain)
picking this:
i_end < i \<or> i < i_begin
[PROOF STEP]
have id: "((i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc ?idiff}) = False"
[PROOF STATE]
proof (prove)
using this:
i_end < i \<or> i < i_begin

goal (1 subgoal):
 1. ((i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)}) = False
[PROOF STEP]
using ib index eqs
[PROOF STATE]
proof (prove)
using this:
i_end < i \<or> i < i_begin
i_begin \<le> i_end
i_end < k
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i__ < n
j__ < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i < n
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)

goal (1 subgoal):
 1. ((i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)}) = False
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
((i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)}) = False

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
have "B $$ (i,j) = A $$ (i,j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B $$ (i, j) = A $$ (i, j)
[PROOF STEP]
unfolding B id
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if False then quot else A $$ (i, j)) = A $$ (i, j)
[PROOF STEP]
using choice ib index
[PROOF STATE]
proof (prove)
using this:
i_end < i \<or> i < i_begin
i_begin \<le> i_end
i_end < k
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i__ < n
j__ < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i < n

goal (1 subgoal):
 1. (if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if False then quot else A $$ (i, j)) = A $$ (i, j)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B $$ (i, j) = A $$ (i, j)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?ja2 < n \<Longrightarrow> B $$ (i, ?ja2) = A $$ (i, ?ja2)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
note Aii this
[PROOF STATE]
proof (state)
this:
A $$ (i, ii) = (0::'a)
?ja2 < n \<Longrightarrow> B $$ (i, ?ja2) = A $$ (i, ?ja2)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>?ia5 < n; \<not> (i_begin \<le> ?ia5 \<and> ?ia5 \<le> i_end)\<rbrakk> \<Longrightarrow> A $$ (?ia5, ii) = (0::'a)
\<lbrakk>?ia5 < n; \<not> (i_begin \<le> ?ia5 \<and> ?ia5 \<le> i_end); ?ja2 < n\<rbrakk> \<Longrightarrow> B $$ (?ia5, ?ja2) = A $$ (?ia5, ?ja2)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
hence A_outside_ii: "\<And> i. i < n \<Longrightarrow> \<not> (i_begin \<le> i \<and> i \<le> i_end) \<Longrightarrow> A $$ (i, ii) = 0"
        and B_outside: "\<And> i j. i < n \<Longrightarrow> j < n \<Longrightarrow> \<not> (i_begin \<le> i \<and> i \<le> i_end) \<Longrightarrow> B $$ (i, j) = A $$ (i, j)"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?ia5 < n; \<not> (i_begin \<le> ?ia5 \<and> ?ia5 \<le> i_end)\<rbrakk> \<Longrightarrow> A $$ (?ia5, ii) = (0::'a)
\<lbrakk>?ia5 < n; \<not> (i_begin \<le> ?ia5 \<and> ?ia5 \<le> i_end); ?ja2 < n\<rbrakk> \<Longrightarrow> B $$ (?ia5, ?ja2) = A $$ (?ia5, ?ja2)

goal (1 subgoal):
 1. (\<And>i. \<lbrakk>i < n; \<not> (i_begin \<le> i \<and> i \<le> i_end)\<rbrakk> \<Longrightarrow> A $$ (i, ii) = (0::'a)) &&& (\<And>i j. \<lbrakk>i < n; j < n; \<not> (i_begin \<le> i \<and> i \<le> i_end)\<rbrakk> \<Longrightarrow> B $$ (i, j) = A $$ (i, j))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i < n; \<not> (i_begin \<le> ?i \<and> ?i \<le> i_end)\<rbrakk> \<Longrightarrow> A $$ (?i, ii) = (0::'a)
\<lbrakk>?i < n; ?j < n; \<not> (i_begin \<le> ?i \<and> ?i \<le> i_end)\<rbrakk> \<Longrightarrow> B $$ (?i, ?j) = A $$ (?i, ?j)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
from diff eqs
[PROOF STATE]
proof (chain)
picking this:
diff < Suc (i_end - i_begin)
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
[PROOF STEP]
have iter: "iter \<noteq> Suc ?idiff"
[PROOF STATE]
proof (prove)
using this:
diff < Suc (i_end - i_begin)
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)

goal (1 subgoal):
 1. iter \<noteq> Suc (i_end - i_begin)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
iter \<noteq> Suc (i_end - i_begin)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
iter \<noteq> Suc (i_end - i_begin)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
fix ib ie jb je
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
assume i: "(ib,ie) \<in> set (identify_blocks A k)" and
            j: "(jb,je) \<in> set (identify_blocks A k)" and lt: "ie < je"
[PROOF STATE]
proof (state)
this:
(ib, ie) \<in> set (identify_blocks A k)
(jb, je) \<in> set (identify_blocks A k)
ie < je

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
note i = iblock[OF i]
[PROOF STATE]
proof (state)
this:
ib \<le> ie
ie < k
\<lbrakk>ib \<le> ?l; ?l < ie\<rbrakk> \<Longrightarrow> A $$ (?l, Suc ?l) = (1::'a)
Suc ie \<noteq> k \<Longrightarrow> A $$ (ie, Suc ie) \<noteq> (1::'a)
0 < ib \<Longrightarrow> A $$ (ib - 1, ib - 1) \<noteq> A $$ (k, k) \<or> A $$ (ib - 1, ib) \<noteq> (1::'a)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
note j = iblock[OF j]
[PROOF STATE]
proof (state)
this:
jb \<le> je
je < k
\<lbrakk>jb \<le> ?l; ?l < je\<rbrakk> \<Longrightarrow> A $$ (?l, Suc ?l) = (1::'a)
Suc je \<noteq> k \<Longrightarrow> A $$ (je, Suc je) \<noteq> (1::'a)
0 < jb \<Longrightarrow> A $$ (jb - 1, jb - 1) \<noteq> A $$ (k, k) \<or> A $$ (jb - 1, jb) \<noteq> (1::'a)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
from i j lt
[PROOF STATE]
proof (chain)
picking this:
ib \<le> ie
ie < k
\<lbrakk>ib \<le> ?l; ?l < ie\<rbrakk> \<Longrightarrow> A $$ (?l, Suc ?l) = (1::'a)
Suc ie \<noteq> k \<Longrightarrow> A $$ (ie, Suc ie) \<noteq> (1::'a)
0 < ib \<Longrightarrow> A $$ (ib - 1, ib - 1) \<noteq> A $$ (k, k) \<or> A $$ (ib - 1, ib) \<noteq> (1::'a)
jb \<le> je
je < k
\<lbrakk>jb \<le> ?l; ?l < je\<rbrakk> \<Longrightarrow> A $$ (?l, Suc ?l) = (1::'a)
Suc je \<noteq> k \<Longrightarrow> A $$ (je, Suc je) \<noteq> (1::'a)
0 < jb \<Longrightarrow> A $$ (jb - 1, jb - 1) \<noteq> A $$ (k, k) \<or> A $$ (jb - 1, jb) \<noteq> (1::'a)
ie < je
[PROOF STEP]
have "Suc ie < k"
[PROOF STATE]
proof (prove)
using this:
ib \<le> ie
ie < k
\<lbrakk>ib \<le> ?l; ?l < ie\<rbrakk> \<Longrightarrow> A $$ (?l, Suc ?l) = (1::'a)
Suc ie \<noteq> k \<Longrightarrow> A $$ (ie, Suc ie) \<noteq> (1::'a)
0 < ib \<Longrightarrow> A $$ (ib - 1, ib - 1) \<noteq> A $$ (k, k) \<or> A $$ (ib - 1, ib) \<noteq> (1::'a)
jb \<le> je
je < k
\<lbrakk>jb \<le> ?l; ?l < je\<rbrakk> \<Longrightarrow> A $$ (?l, Suc ?l) = (1::'a)
Suc je \<noteq> k \<Longrightarrow> A $$ (je, Suc je) \<noteq> (1::'a)
0 < jb \<Longrightarrow> A $$ (jb - 1, jb - 1) \<noteq> A $$ (k, k) \<or> A $$ (jb - 1, jb) \<noteq> (1::'a)
ie < je

goal (1 subgoal):
 1. Suc ie < k
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Suc ie < k

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
with i
[PROOF STATE]
proof (chain)
picking this:
ib \<le> ie
ie < k
\<lbrakk>ib \<le> ?l; ?l < ie\<rbrakk> \<Longrightarrow> A $$ (?l, Suc ?l) = (1::'a)
Suc ie \<noteq> k \<Longrightarrow> A $$ (ie, Suc ie) \<noteq> (1::'a)
0 < ib \<Longrightarrow> A $$ (ib - 1, ib - 1) \<noteq> A $$ (k, k) \<or> A $$ (ib - 1, ib) \<noteq> (1::'a)
Suc ie < k
[PROOF STEP]
have Aie: "A $$ (ie, Suc ie) \<noteq> 1"
[PROOF STATE]
proof (prove)
using this:
ib \<le> ie
ie < k
\<lbrakk>ib \<le> ?l; ?l < ie\<rbrakk> \<Longrightarrow> A $$ (?l, Suc ?l) = (1::'a)
Suc ie \<noteq> k \<Longrightarrow> A $$ (ie, Suc ie) \<noteq> (1::'a)
0 < ib \<Longrightarrow> A $$ (ib - 1, ib - 1) \<noteq> A $$ (k, k) \<or> A $$ (ib - 1, ib) \<noteq> (1::'a)
Suc ie < k

goal (1 subgoal):
 1. A $$ (ie, Suc ie) \<noteq> (1::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A $$ (ie, Suc ie) \<noteq> (1::'a)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
have "ie < jb"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ie < jb
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> ie < jb \<Longrightarrow> False
[PROOF STEP]
assume "\<not> ie < jb"
[PROOF STATE]
proof (state)
this:
\<not> ie < jb

goal (1 subgoal):
 1. \<not> ie < jb \<Longrightarrow> False
[PROOF STEP]
hence "ie \<ge> jb"
[PROOF STATE]
proof (prove)
using this:
\<not> ie < jb

goal (1 subgoal):
 1. jb \<le> ie
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
jb \<le> ie

goal (1 subgoal):
 1. \<not> ie < jb \<Longrightarrow> False
[PROOF STEP]
from j(3)[OF this lt] Aie
[PROOF STATE]
proof (chain)
picking this:
A $$ (ie, Suc ie) = (1::'a)
A $$ (ie, Suc ie) \<noteq> (1::'a)
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
A $$ (ie, Suc ie) = (1::'a)
A $$ (ie, Suc ie) \<noteq> (1::'a)

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

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

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>(?ib2, ?ie2) \<in> set (identify_blocks A k); (?jb2, ?je2) \<in> set (identify_blocks A k); ?ie2 < ?je2\<rbrakk> \<Longrightarrow> ?ie2 < ?jb2

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
note block_bounds = this
[PROOF STATE]
proof (state)
this:
\<lbrakk>(?ib2, ?ie2) \<in> set (identify_blocks A k); (?jb2, ?je2) \<in> set (identify_blocks A k); ?ie2 < ?je2\<rbrakk> \<Longrightarrow> ?ie2 < ?jb2

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
\<lbrakk>(?ib2, ?ie2) \<in> set (identify_blocks A k); (?jb2, ?je2) \<in> set (identify_blocks A k); ?ie2 < ?je2\<rbrakk> \<Longrightarrow> ?ie2 < ?jb2

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
assume "i_end < l"
[PROOF STATE]
proof (state)
this:
i_end < l

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
from block_bounds[OF ib_block lbl this]
[PROOF STATE]
proof (chain)
picking this:
i_end < lb
[PROOF STEP]
have "i_end < lb"
[PROOF STATE]
proof (prove)
using this:
i_end < lb

goal (1 subgoal):
 1. i_end < lb
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
i_end < lb

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
i_end < l \<Longrightarrow> i_end < lb

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
note i_less_l = this
[PROOF STATE]
proof (state)
this:
i_end < l \<Longrightarrow> i_end < lb

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
i_end < l \<Longrightarrow> i_end < lb

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
assume "l < i_end"
[PROOF STATE]
proof (state)
this:
l < i_end

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
from block_bounds[OF lbl ib_block this]
[PROOF STATE]
proof (chain)
picking this:
l < i_begin
[PROOF STEP]
have "l < i_begin"
[PROOF STATE]
proof (prove)
using this:
l < i_begin

goal (1 subgoal):
 1. l < i_begin
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
l < i_begin

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
l < i_end \<Longrightarrow> l < i_begin

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
note l_less_i = this
[PROOF STATE]
proof (state)
this:
l < i_end \<Longrightarrow> l < i_begin

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
l < i_end \<Longrightarrow> l < i_begin

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
assume "i_end - iter = Suc l - iter"
[PROOF STATE]
proof (state)
this:
i_end - iter = Suc l - iter

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
with iter large eqs
[PROOF STATE]
proof (chain)
picking this:
iter \<noteq> Suc (i_end - i_begin)
i_end - i_begin \<le> l - lb
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_end - iter = Suc l - iter
[PROOF STEP]
have "i_end = Suc l"
[PROOF STATE]
proof (prove)
using this:
iter \<noteq> Suc (i_end - i_begin)
i_end - i_begin \<le> l - lb
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_end - iter = Suc l - iter

goal (1 subgoal):
 1. i_end = Suc l
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i_end = Suc l

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
with l_less_i
[PROOF STATE]
proof (chain)
picking this:
l < i_end \<Longrightarrow> l < i_begin
i_end = Suc l
[PROOF STEP]
have "l < i_begin"
[PROOF STATE]
proof (prove)
using this:
l < i_end \<Longrightarrow> l < i_begin
i_end = Suc l

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

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
with index \<open>i_end = Suc l\<close>
[PROOF STATE]
proof (chain)
picking this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_end = Suc l
l < i_begin
[PROOF STEP]
have "i_begin = i_end"
[PROOF STATE]
proof (prove)
using this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_end = Suc l
l < i_begin

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

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
i_end - iter = Suc l - iter \<Longrightarrow> i_begin = i_end

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
note block = this
[PROOF STATE]
proof (state)
this:
i_end - iter = Suc l - iter \<Longrightarrow> i_begin = i_end

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
have Alie: "A $$ (l, i_end) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A $$ (l, i_end) = (0::'a)
[PROOF STEP]
proof (cases "l < i_end")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. l < i_end \<Longrightarrow> A $$ (l, i_end) = (0::'a)
 2. \<not> l < i_end \<Longrightarrow> A $$ (l, i_end) = (0::'a)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
l < i_end

goal (2 subgoals):
 1. l < i_end \<Longrightarrow> A $$ (l, i_end) = (0::'a)
 2. \<not> l < i_end \<Longrightarrow> A $$ (l, i_end) = (0::'a)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
l < i_end

goal (2 subgoals):
 1. l < i_end \<Longrightarrow> A $$ (l, i_end) = (0::'a)
 2. \<not> l < i_end \<Longrightarrow> A $$ (l, i_end) = (0::'a)
[PROOF STEP]
assume nz: "A $$ (l, i_end) \<noteq> 0"
[PROOF STATE]
proof (state)
this:
A $$ (l, i_end) \<noteq> (0::'a)

goal (2 subgoals):
 1. l < i_end \<Longrightarrow> A $$ (l, i_end) = (0::'a)
 2. \<not> l < i_end \<Longrightarrow> A $$ (l, i_end) = (0::'a)
[PROOF STEP]
from l_less_i[OF True] index
[PROOF STATE]
proof (chain)
picking this:
l < i_begin
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
[PROOF STEP]
have "0 < i_begin" "l < i_begin" "i_end < n" "i_end < k"
[PROOF STATE]
proof (prove)
using this:
l < i_begin
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n

goal (1 subgoal):
 1. (0 < i_begin &&& l < i_begin) &&& i_end < n &&& i_end < k
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < i_begin
l < i_begin
i_end < n
i_end < k

goal (2 subgoals):
 1. l < i_end \<Longrightarrow> A $$ (l, i_end) = (0::'a)
 2. \<not> l < i_end \<Longrightarrow> A $$ (l, i_end) = (0::'a)
[PROOF STEP]
from jb[OF \<open>l < n\<close> this(3-4)] il nz
[PROOF STATE]
proof (chain)
picking this:
(Suc l = i_end \<longrightarrow> A $$ (l, i_end) \<in> {0::'a, 1::'a}) \<and> (l \<noteq> i_end \<longrightarrow> Suc l \<noteq> i_end \<or> A $$ (l, l) \<noteq> A $$ (i_end, i_end) \<longrightarrow> A $$ (l, i_end) = (0::'a))
i_end \<noteq> l
A $$ (l, i_end) \<noteq> (0::'a)
[PROOF STEP]
have "i_end = Suc l" "A $$ (l, Suc l) = 1"
[PROOF STATE]
proof (prove)
using this:
(Suc l = i_end \<longrightarrow> A $$ (l, i_end) \<in> {0::'a, 1::'a}) \<and> (l \<noteq> i_end \<longrightarrow> Suc l \<noteq> i_end \<or> A $$ (l, l) \<noteq> A $$ (i_end, i_end) \<longrightarrow> A $$ (l, i_end) = (0::'a))
i_end \<noteq> l
A $$ (l, i_end) \<noteq> (0::'a)

goal (1 subgoal):
 1. i_end = Suc l &&& A $$ (l, Suc l) = (1::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i_end = Suc l
A $$ (l, Suc l) = (1::'a)

goal (2 subgoals):
 1. l < i_end \<Longrightarrow> A $$ (l, i_end) = (0::'a)
 2. \<not> l < i_end \<Longrightarrow> A $$ (l, i_end) = (0::'a)
[PROOF STEP]
with iblock[OF lbl]
[PROOF STATE]
proof (chain)
picking this:
lb \<le> l
l < k
\<lbrakk>lb \<le> ?l; ?l < l\<rbrakk> \<Longrightarrow> A $$ (?l, Suc ?l) = (1::'a)
Suc l \<noteq> k \<Longrightarrow> A $$ (l, Suc l) \<noteq> (1::'a)
0 < lb \<Longrightarrow> A $$ (lb - 1, lb - 1) \<noteq> A $$ (k, k) \<or> A $$ (lb - 1, lb) \<noteq> (1::'a)
i_end = Suc l
A $$ (l, Suc l) = (1::'a)
[PROOF STEP]
have "k = Suc l"
[PROOF STATE]
proof (prove)
using this:
lb \<le> l
l < k
\<lbrakk>lb \<le> ?l; ?l < l\<rbrakk> \<Longrightarrow> A $$ (?l, Suc ?l) = (1::'a)
Suc l \<noteq> k \<Longrightarrow> A $$ (l, Suc l) \<noteq> (1::'a)
0 < lb \<Longrightarrow> A $$ (lb - 1, lb - 1) \<noteq> A $$ (k, k) \<or> A $$ (lb - 1, lb) \<noteq> (1::'a)
i_end = Suc l
A $$ (l, Suc l) = (1::'a)

goal (1 subgoal):
 1. k = Suc l
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
k = Suc l

goal (2 subgoals):
 1. l < i_end \<Longrightarrow> A $$ (l, i_end) = (0::'a)
 2. \<not> l < i_end \<Longrightarrow> A $$ (l, i_end) = (0::'a)
[PROOF STEP]
with \<open>i_end = Suc l\<close> \<open>i_end < k\<close>
[PROOF STATE]
proof (chain)
picking this:
i_end = Suc l
i_end < k
k = Suc l
[PROOF STEP]
have False
[PROOF STATE]
proof (prove)
using this:
i_end = Suc l
i_end < k
k = Suc l

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

goal (2 subgoals):
 1. l < i_end \<Longrightarrow> A $$ (l, i_end) = (0::'a)
 2. \<not> l < i_end \<Longrightarrow> A $$ (l, i_end) = (0::'a)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
A $$ (l, i_end) \<noteq> (0::'a) \<Longrightarrow> False

goal (2 subgoals):
 1. l < i_end \<Longrightarrow> A $$ (l, i_end) = (0::'a)
 2. \<not> l < i_end \<Longrightarrow> A $$ (l, i_end) = (0::'a)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
A $$ (l, i_end) \<noteq> (0::'a) \<Longrightarrow> False

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

goal (1 subgoal):
 1. \<not> l < i_end \<Longrightarrow> A $$ (l, i_end) = (0::'a)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> l < i_end \<Longrightarrow> A $$ (l, i_end) = (0::'a)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> l < i_end

goal (1 subgoal):
 1. \<not> l < i_end \<Longrightarrow> A $$ (l, i_end) = (0::'a)
[PROOF STEP]
with il
[PROOF STATE]
proof (chain)
picking this:
i_end \<noteq> l
\<not> l < i_end
[PROOF STEP]
have "i_end < l"
[PROOF STATE]
proof (prove)
using this:
i_end \<noteq> l
\<not> l < i_end

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

goal (1 subgoal):
 1. \<not> l < i_end \<Longrightarrow> A $$ (l, i_end) = (0::'a)
[PROOF STEP]
from ut[OF this \<open>l < n\<close>]
[PROOF STATE]
proof (chain)
picking this:
A $$ (l, i_end) = (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
A $$ (l, i_end) = (0::'a)

goal (1 subgoal):
 1. A $$ (l, i_end) = (0::'a)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
A $$ (l, i_end) = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
A $$ (l, i_end) = (0::'a)

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < n; j < n\<rbrakk> \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 3. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
show "?C $$ (i,j) = ?D $$ (i,j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
proof (cases "i \<ge> i_begin \<and> i \<le> i_end")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i_begin \<le> i \<and> i \<le> i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (i_begin \<le> i \<and> i \<le> i_end) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> (i_begin \<le> i \<and> i \<le> i_end)

goal (2 subgoals):
 1. i_begin \<le> i \<and> i \<le> i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (i_begin \<le> i \<and> i \<le> i_end) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
hence choice: "i > i_end \<or> i < i_begin"
[PROOF STATE]
proof (prove)
using this:
\<not> (i_begin \<le> i \<and> i \<le> i_end)

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

goal (2 subgoals):
 1. i_begin \<le> i \<and> i \<le> i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (i_begin \<le> i \<and> i \<le> i_end) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
from choice
[PROOF STATE]
proof (chain)
picking this:
i_end < i \<or> i < i_begin
[PROOF STEP]
have id: "((i, j) = (i_end - Suc iter, l - iter) \<and> iter \<noteq> ?idiff) = False"
[PROOF STATE]
proof (prove)
using this:
i_end < i \<or> i < i_begin

goal (1 subgoal):
 1. ((i, j) = (i_end - Suc iter, l - iter) \<and> iter \<noteq> i_end - i_begin) = False
[PROOF STEP]
using ib index eqs
[PROOF STATE]
proof (prove)
using this:
i_end < i \<or> i < i_begin
i_begin \<le> i_end
i_end < k
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)

goal (1 subgoal):
 1. ((i, j) = (i_end - Suc iter, l - iter) \<and> iter \<noteq> i_end - i_begin) = False
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
((i, j) = (i_end - Suc iter, l - iter) \<and> iter \<noteq> i_end - i_begin) = False

goal (2 subgoals):
 1. i_begin \<le> i \<and> i \<le> i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (i_begin \<le> i \<and> i \<le> i_end) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
have D: "?D $$ (i,j) = ?Aij"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
unfolding D id
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if (i, j) = (i_end, k) then 0::'a else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if False then quot else A $$ (i, j)) = A $$ (i, j)
[PROOF STEP]
using choice ib index
[PROOF STATE]
proof (prove)
using this:
i_end < i \<or> i < i_begin
i_begin \<le> i_end
i_end < k
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n

goal (1 subgoal):
 1. (if (i, j) = (i_end, k) then 0::'a else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if False then quot else A $$ (i, j)) = A $$ (i, j)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = A $$ (i, j)

goal (2 subgoals):
 1. i_begin \<le> i \<and> i \<le> i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (i_begin \<le> i \<and> i \<le> i_end) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
have B: "B $$ (i,j) = ?Aij"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B $$ (i, j) = A $$ (i, j)
[PROOF STEP]
unfolding B_outside[OF i j False]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A $$ (i, j) = A $$ (i, j)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
B $$ (i, j) = A $$ (i, j)

goal (2 subgoals):
 1. i_begin \<le> i \<and> i \<le> i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (i_begin \<le> i \<and> i \<le> i_end) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
from index eqs False
[PROOF STATE]
proof (chain)
picking this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
\<not> (i_begin \<le> i \<and> i \<le> i_end)
[PROOF STEP]
have "i \<noteq> ii"
[PROOF STATE]
proof (prove)
using this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
\<not> (i_begin \<le> i \<and> i \<le> i_end)

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

goal (2 subgoals):
 1. i_begin \<le> i \<and> i \<le> i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (i_begin \<le> i \<and> i \<le> i_end) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
have Bii: "B $$ (i, ii) = A $$ (i,ii)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B $$ (i, ii) = A $$ (i, ii)
[PROOF STEP]
unfolding B_outside[OF i \<open>ii < n\<close> False]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A $$ (i, ii) = A $$ (i, ii)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
B $$ (i, ii) = A $$ (i, ii)

goal (2 subgoals):
 1. i_begin \<le> i \<and> i \<le> i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (i_begin \<le> i \<and> i \<le> i_end) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
hence C: "?C $$ (i,j) = ?Aij"
[PROOF STATE]
proof (prove)
using this:
B $$ (i, ii) = A $$ (i, ii)

goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
unfolding C B Bii
[PROOF STATE]
proof (prove)
using this:
A $$ (i, ii) = A $$ (i, ii)

goal (1 subgoal):
 1. (if i = ii \<and> j = ll then A $$ (i, j) + quot * B $$ (i, i) - quot * quot * B $$ (j, i) - quot * B $$ (j, j) else if i = ii \<and> j \<noteq> ll then A $$ (i, j) - quot * B $$ (ll, j) else if i \<noteq> ii \<and> j = ll then A $$ (i, j) + quot * A $$ (i, ii) else A $$ (i, j)) = A $$ (i, j)
[PROOF STEP]
using \<open>i \<noteq> ii\<close> A_outside_ii[OF i False]
[PROOF STATE]
proof (prove)
using this:
A $$ (i, ii) = A $$ (i, ii)
i \<noteq> ii
A $$ (i, ii) = (0::'a)

goal (1 subgoal):
 1. (if i = ii \<and> j = ll then A $$ (i, j) + quot * B $$ (i, i) - quot * quot * B $$ (j, i) - quot * B $$ (j, j) else if i = ii \<and> j \<noteq> ll then A $$ (i, j) - quot * B $$ (ll, j) else if i \<noteq> ii \<and> j = ll then A $$ (i, j) + quot * A $$ (i, ii) else A $$ (i, j)) = A $$ (i, j)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)

goal (2 subgoals):
 1. i_begin \<le> i \<and> i \<le> i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (i_begin \<le> i \<and> i \<le> i_end) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
unfolding D C
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A $$ (i, j) = A $$ (i, j)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)

goal (1 subgoal):
 1. i_begin \<le> i \<and> i \<le> i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i_begin \<le> i \<and> i \<le> i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
i_begin \<le> i \<and> i \<le> i_end

goal (1 subgoal):
 1. i_begin \<le> i \<and> i \<le> i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
with index
[PROOF STATE]
proof (chain)
picking this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i \<and> i \<le> i_end
[PROOF STEP]
have "i_begin \<le> i" "i \<le> i_end" "i < k"
[PROOF STATE]
proof (prove)
using this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i \<and> i \<le> i_end

goal (1 subgoal):
 1. i_begin \<le> i &&& i \<le> i_end &&& i < k
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i_begin \<le> i
i \<le> i_end
i < k

goal (1 subgoal):
 1. i_begin \<le> i \<and> i \<le> i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
note index = index this
[PROOF STATE]
proof (state)
this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k

goal (1 subgoal):
 1. i_begin \<le> i \<and> i \<le> i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
proof (cases "j > k")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. k < j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> k < j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
k < j

goal (2 subgoals):
 1. k < j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> k < j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
note index = index this
[PROOF STATE]
proof (state)
this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
k < j

goal (2 subgoals):
 1. k < j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> k < j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
have D: "?D $$ (i,j) = (if i_begin + diff \<le> i then ?Aij - quot * A $$ (l + i - i_end, j) else ?Aij)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = (if i_begin + diff \<le> i then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
unfolding D
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if (i, j) = (i_end, k) then 0::'a else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, l - iter) \<and> iter \<noteq> i_end - i_begin then quot else A $$ (i, j)) = (if i_begin + diff \<le> i then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
using index
[PROOF STATE]
proof (prove)
using this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
k < j

goal (1 subgoal):
 1. (if (i, j) = (i_end, k) then 0::'a else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, l - iter) \<and> iter \<noteq> i_end - i_begin then quot else A $$ (i, j)) = (if i_begin + diff \<le> i then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = (if i_begin + diff \<le> i then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else A $$ (i, j))

goal (2 subgoals):
 1. k < j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> k < j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
have B: "B $$ (i,j) = (if i_begin + Suc diff \<le> i then ?Aij - quot * A $$ (l + i - i_end, j) else ?Aij)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B $$ (i, j) = (if i_begin + Suc diff \<le> i then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
unfolding B
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) = (if i_begin + Suc diff \<le> i then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
using index
[PROOF STATE]
proof (prove)
using this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
k < j

goal (1 subgoal):
 1. (if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) = (if i_begin + Suc diff \<le> i then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B $$ (i, j) = (if i_begin + Suc diff \<le> i then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else A $$ (i, j))

goal (2 subgoals):
 1. k < j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> k < j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
from index eqs
[PROOF STATE]
proof (chain)
picking this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
k < j
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
[PROOF STEP]
have "j > ll"
[PROOF STATE]
proof (prove)
using this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
k < j
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)

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

goal (2 subgoals):
 1. k < j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> k < j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
hence C: "?C $$ (i,j) = (if i = ii then B $$ (i, j) - quot * B $$ (ll, j) else B $$ (i, j))"
[PROOF STATE]
proof (prove)
using this:
ll < j

goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (if i = ii then B $$ (i, j) - quot * B $$ (ll, j) else B $$ (i, j))
[PROOF STEP]
unfolding C
[PROOF STATE]
proof (prove)
using this:
ll < j

goal (1 subgoal):
 1. (if i = ii \<and> j = ll then B $$ (i, j) + quot * B $$ (i, i) - quot * quot * B $$ (j, i) - quot * B $$ (j, j) else if i = ii \<and> j \<noteq> ll then B $$ (i, j) - quot * B $$ (ll, j) else if i \<noteq> ii \<and> j = ll then B $$ (i, j) + quot * B $$ (i, ii) else B $$ (i, j)) = (if i = ii then B $$ (i, j) - quot * B $$ (ll, j) else B $$ (i, j))
[PROOF STEP]
using index
[PROOF STATE]
proof (prove)
using this:
ll < j
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
k < j

goal (1 subgoal):
 1. (if i = ii \<and> j = ll then B $$ (i, j) + quot * B $$ (i, i) - quot * quot * B $$ (j, i) - quot * B $$ (j, j) else if i = ii \<and> j \<noteq> ll then B $$ (i, j) - quot * B $$ (ll, j) else if i \<noteq> ii \<and> j = ll then B $$ (i, j) + quot * B $$ (i, ii) else B $$ (i, j)) = (if i = ii then B $$ (i, j) - quot * B $$ (ll, j) else B $$ (i, j))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (if i = ii then B $$ (i, j) - quot * B $$ (ll, j) else B $$ (i, j))

goal (2 subgoals):
 1. k < j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> k < j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
proof (cases "i_begin + Suc diff \<le> i \<or> \<not> (i_begin + diff \<le> i)")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i

goal (2 subgoals):
 1. i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
from True eqs index
[PROOF STATE]
proof (chain)
picking this:
i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
k < j
[PROOF STEP]
have "i \<noteq> ii"
[PROOF STATE]
proof (prove)
using this:
i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
k < j

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

goal (2 subgoals):
 1. i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
from True
[PROOF STATE]
proof (chain)
picking this:
i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i
[PROOF STEP]
have "?D $$ (i,j) = B $$ (i,j)"
[PROOF STATE]
proof (prove)
using this:
i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i

goal (1 subgoal):
 1. mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = B $$ (i, j)
[PROOF STEP]
unfolding D B
[PROOF STATE]
proof (prove)
using this:
i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i

goal (1 subgoal):
 1. (if i_begin + diff \<le> i then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else A $$ (i, j)) = (if i_begin + Suc diff \<le> i then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = B $$ (i, j)

goal (2 subgoals):
 1. i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = B $$ (i, j)

goal (2 subgoals):
 1. i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
have "B $$ (i,j) = ?C $$ (i,j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B $$ (i, j) = add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j)
[PROOF STEP]
unfolding C
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B $$ (i, j) = (if i = ii then B $$ (i, j) - quot * B $$ (ll, j) else B $$ (i, j))
[PROOF STEP]
using \<open>i \<noteq> ii\<close>
[PROOF STATE]
proof (prove)
using this:
i \<noteq> ii

goal (1 subgoal):
 1. B $$ (i, j) = (if i = ii then B $$ (i, j) - quot * B $$ (ll, j) else B $$ (i, j))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B $$ (i, j) = add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j)

goal (2 subgoals):
 1. i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j)

goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)

goal (1 subgoal):
 1. \<not> (i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> (i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> (i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i)

goal (1 subgoal):
 1. \<not> (i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
hence i: "i = i_begin + diff"
[PROOF STATE]
proof (prove)
using this:
\<not> (i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i)

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

goal (1 subgoal):
 1. \<not> (i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
with eqs index
[PROOF STATE]
proof (chain)
picking this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
k < j
i = i_begin + diff
[PROOF STEP]
have ii: "ii = i"
[PROOF STATE]
proof (prove)
using this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
k < j
i = i_begin + diff

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

goal (1 subgoal):
 1. \<not> (i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
from index eqs i ii
[PROOF STATE]
proof (chain)
picking this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
k < j
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i = i_begin + diff
ii = i
[PROOF STEP]
have ll: "ll = l + i - i_end"
[PROOF STATE]
proof (prove)
using this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
k < j
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i = i_begin + diff
ii = i

goal (1 subgoal):
 1. ll = l + i - i_end
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ll = l + i - i_end

goal (1 subgoal):
 1. \<not> (i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
have not: "\<not> (i_begin + Suc diff \<le> ll \<and> ll \<le> i_end)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> (i_begin + Suc diff \<le> ll \<and> ll \<le> i_end)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i_begin + Suc diff \<le> ll \<and> ll \<le> i_end \<Longrightarrow> False
[PROOF STEP]
from eqs
[PROOF STATE]
proof (chain)
picking this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
[PROOF STEP]
have "ll \<le> l"
[PROOF STATE]
proof (prove)
using this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)

goal (1 subgoal):
 1. ll \<le> l
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ll \<le> l

goal (1 subgoal):
 1. i_begin + Suc diff \<le> ll \<and> ll \<le> i_end \<Longrightarrow> False
[PROOF STEP]
assume "i_begin + Suc diff \<le> ll \<and> ll \<le> i_end"
[PROOF STATE]
proof (state)
this:
i_begin + Suc diff \<le> ll \<and> ll \<le> i_end

goal (1 subgoal):
 1. i_begin + Suc diff \<le> ll \<and> ll \<le> i_end \<Longrightarrow> False
[PROOF STEP]
hence "i_begin < ll" "ll \<le> i_end"
[PROOF STATE]
proof (prove)
using this:
i_begin + Suc diff \<le> ll \<and> ll \<le> i_end

goal (1 subgoal):
 1. i_begin < ll &&& ll \<le> i_end
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i_begin < ll
ll \<le> i_end

goal (1 subgoal):
 1. i_begin + Suc diff \<le> ll \<and> ll \<le> i_end \<Longrightarrow> False
[PROOF STEP]
with \<open>ll \<le> l\<close>
[PROOF STATE]
proof (chain)
picking this:
ll \<le> l
i_begin < ll
ll \<le> i_end
[PROOF STEP]
have "i_begin < l"
[PROOF STATE]
proof (prove)
using this:
ll \<le> l
i_begin < ll
ll \<le> i_end

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

goal (1 subgoal):
 1. i_begin + Suc diff \<le> ll \<and> ll \<le> i_end \<Longrightarrow> False
[PROOF STEP]
with l_less_i
[PROOF STATE]
proof (chain)
picking this:
l < i_end \<Longrightarrow> l < i_begin
i_begin < l
[PROOF STEP]
have "\<not> l < i_end"
[PROOF STATE]
proof (prove)
using this:
l < i_end \<Longrightarrow> l < i_begin
i_begin < l

goal (1 subgoal):
 1. \<not> l < i_end
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<not> l < i_end

goal (1 subgoal):
 1. i_begin + Suc diff \<le> ll \<and> ll \<le> i_end \<Longrightarrow> False
[PROOF STEP]
hence "l \<ge> i_end"
[PROOF STATE]
proof (prove)
using this:
\<not> l < i_end

goal (1 subgoal):
 1. i_end \<le> l
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
i_end \<le> l

goal (1 subgoal):
 1. i_begin + Suc diff \<le> ll \<and> ll \<le> i_end \<Longrightarrow> False
[PROOF STEP]
with il i_less_l
[PROOF STATE]
proof (chain)
picking this:
i_end \<noteq> l
i_end < l \<Longrightarrow> i_end < lb
i_end \<le> l
[PROOF STEP]
have "i_end < lb"
[PROOF STATE]
proof (prove)
using this:
i_end \<noteq> l
i_end < l \<Longrightarrow> i_end < lb
i_end \<le> l

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

goal (1 subgoal):
 1. i_begin + Suc diff \<le> ll \<and> ll \<le> i_end \<Longrightarrow> False
[PROOF STEP]
from index large eqs
[PROOF STATE]
proof (chain)
picking this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
k < j
i_end - i_begin \<le> l - lb
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
[PROOF STEP]
have "lb \<le> ll"
[PROOF STATE]
proof (prove)
using this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
k < j
i_end - i_begin \<le> l - lb
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)

goal (1 subgoal):
 1. lb \<le> ll
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
lb \<le> ll

goal (1 subgoal):
 1. i_begin + Suc diff \<le> ll \<and> ll \<le> i_end \<Longrightarrow> False
[PROOF STEP]
with \<open>i_end < lb\<close>
[PROOF STATE]
proof (chain)
picking this:
i_end < lb
lb \<le> ll
[PROOF STEP]
have "i_end < ll"
[PROOF STATE]
proof (prove)
using this:
i_end < lb
lb \<le> ll

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

goal (1 subgoal):
 1. i_begin + Suc diff \<le> ll \<and> ll \<le> i_end \<Longrightarrow> False
[PROOF STEP]
with \<open>ll \<le> i_end\<close>
[PROOF STATE]
proof (chain)
picking this:
ll \<le> i_end
i_end < ll
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
ll \<le> i_end
i_end < ll

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<not> (i_begin + Suc diff \<le> ll \<and> ll \<le> i_end)

goal (1 subgoal):
 1. \<not> (i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
have D: "?D $$ (i,j) = ?Aij - quot * A $$ (ll, j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = A $$ (i, j) - quot * A $$ (ll, j)
[PROOF STEP]
unfolding D
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if i_begin + diff \<le> i then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else A $$ (i, j)) = A $$ (i, j) - quot * A $$ (ll, j)
[PROOF STEP]
unfolding i ll
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if i_begin + diff \<le> i_begin + diff then A $$ (i_begin + diff, j) - quot * A $$ (l + (i_begin + diff) - i_end, j) else A $$ (i_begin + diff, j)) = A $$ (i_begin + diff, j) - quot * A $$ (l + (i_begin + diff) - i_end, j)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = A $$ (i, j) - quot * A $$ (ll, j)

goal (1 subgoal):
 1. \<not> (i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
have C: "?C $$ (i,j) = ?Aij - quot * B $$ (ll, j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j) - quot * B $$ (ll, j)
[PROOF STEP]
unfolding C B
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if i = ii then (if i_begin + Suc diff \<le> i then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else A $$ (i, j)) - quot * B $$ (ll, j) else if i_begin + Suc diff \<le> i then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else A $$ (i, j)) = A $$ (i, j) - quot * B $$ (ll, j)
[PROOF STEP]
unfolding ii i
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if i_begin + diff = i_begin + diff then (if i_begin + Suc diff \<le> i_begin + diff then A $$ (i_begin + diff, j) - quot * A $$ (l + (i_begin + diff) - i_end, j) else A $$ (i_begin + diff, j)) - quot * B $$ (ll, j) else if i_begin + Suc diff \<le> i_begin + diff then A $$ (i_begin + diff, j) - quot * A $$ (l + (i_begin + diff) - i_end, j) else A $$ (i_begin + diff, j)) = A $$ (i_begin + diff, j) - quot * B $$ (ll, j)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j) - quot * B $$ (ll, j)

goal (1 subgoal):
 1. \<not> (i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
have B: "B $$ (ll, j) = A $$ (ll, j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B $$ (ll, j) = A $$ (ll, j)
[PROOF STEP]
unfolding BB[OF \<open>ll < n\<close> j]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if (ll, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> ll \<and> ll \<le> i_end \<and> k < j then A $$ (ll, j) - quot * A $$ (l + ll - i_end, j) else if (ll, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (ll, j)) = A $$ (ll, j)
[PROOF STEP]
using index not
[PROOF STATE]
proof (prove)
using this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
k < j
\<not> (i_begin + Suc diff \<le> ll \<and> ll \<le> i_end)

goal (1 subgoal):
 1. (if (ll, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> ll \<and> ll \<le> i_end \<and> k < j then A $$ (ll, j) - quot * A $$ (l + ll - i_end, j) else if (ll, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (ll, j)) = A $$ (ll, j)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B $$ (ll, j) = A $$ (ll, j)

goal (1 subgoal):
 1. \<not> (i_begin + Suc diff \<le> i \<or> \<not> i_begin + diff \<le> i) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
unfolding C D B
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A $$ (i, j) - quot * A $$ (ll, j) = A $$ (i, j) - quot * A $$ (ll, j)
[PROOF STEP]
unfolding ii i
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A $$ (i_begin + diff, j) - quot * A $$ (ll, j) = A $$ (i_begin + diff, j) - quot * A $$ (ll, j)
[PROOF STEP]
by (simp split: if_splits)
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)

goal (1 subgoal):
 1. \<not> k < j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> k < j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> k < j

goal (1 subgoal):
 1. \<not> k < j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
hence "j < k \<or> j = k"
[PROOF STATE]
proof (prove)
using this:
\<not> k < j

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

goal (1 subgoal):
 1. \<not> k < j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
j < k \<or> j = k

goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. j < k \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. j = k \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
assume jk: "j = k"
[PROOF STATE]
proof (state)
this:
j = k

goal (2 subgoals):
 1. j < k \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. j = k \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
hence "j \<noteq> Suc l - Suc iter"
[PROOF STATE]
proof (prove)
using this:
j = k

goal (1 subgoal):
 1. j \<noteq> Suc l - Suc iter
[PROOF STEP]
using index
[PROOF STATE]
proof (prove)
using this:
j = k
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k

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

goal (2 subgoals):
 1. j < k \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. j = k \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
hence "?D $$ (i,j) = (if i = i_end then 0 else ?Aij)"
[PROOF STATE]
proof (prove)
using this:
j \<noteq> Suc l - Suc iter

goal (1 subgoal):
 1. mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = (if i = i_end then 0::'a else A $$ (i, j))
[PROOF STEP]
unfolding D
[PROOF STATE]
proof (prove)
using this:
j \<noteq> Suc l - Suc iter

goal (1 subgoal):
 1. (if (i, j) = (i_end, k) then 0::'a else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, l - iter) \<and> iter \<noteq> i_end - i_begin then quot else A $$ (i, j)) = (if i = i_end then 0::'a else A $$ (i, j))
[PROOF STEP]
using jk
[PROOF STATE]
proof (prove)
using this:
j \<noteq> Suc l - Suc iter
j = k

goal (1 subgoal):
 1. (if (i, j) = (i_end, k) then 0::'a else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, l - iter) \<and> iter \<noteq> i_end - i_begin then quot else A $$ (i, j)) = (if i = i_end then 0::'a else A $$ (i, j))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = (if i = i_end then 0::'a else A $$ (i, j))

goal (2 subgoals):
 1. j < k \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. j = k \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = (if i = i_end then 0::'a else A $$ (i, j))

goal (2 subgoals):
 1. j < k \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. j = k \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
have "\<dots> = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if i = i_end then 0::'a else A $$ (i, j)) = (0::'a)
[PROOF STEP]
using A_ik[OF ib_block \<open>i_begin \<le> i\<close>] \<open>i \<le> i_end\<close>
[PROOF STATE]
proof (prove)
using this:
i < i_end \<Longrightarrow> A $$ (i, k) = (0::'a)
i \<le> i_end

goal (1 subgoal):
 1. (if i = i_end then 0::'a else A $$ (i, j)) = (0::'a)
[PROOF STEP]
unfolding jk
[PROOF STATE]
proof (prove)
using this:
i < i_end \<Longrightarrow> A $$ (i, k) = (0::'a)
i \<le> i_end

goal (1 subgoal):
 1. (if i = i_end then 0::'a else A $$ (i, k)) = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(if i = i_end then 0::'a else A $$ (i, j)) = (0::'a)

goal (2 subgoals):
 1. j < k \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. j = k \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = (0::'a)
[PROOF STEP]
have D: "?D $$ (i,j) = 0"
[PROOF STATE]
proof (prove)
using this:
mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = (0::'a)

goal (1 subgoal):
 1. mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = (0::'a)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = (0::'a)

goal (2 subgoals):
 1. j < k \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. j = k \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
from jk index
[PROOF STATE]
proof (chain)
picking this:
j = k
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
[PROOF STEP]
have "j \<noteq> ll"
[PROOF STATE]
proof (prove)
using this:
j = k
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k

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

goal (2 subgoals):
 1. j < k \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. j = k \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
hence C: "?C $$ (i,j) = (if i = ii then B $$ (i, j) - quot * B $$ (ll, j) else B $$ (i, j))"
[PROOF STATE]
proof (prove)
using this:
j \<noteq> ll

goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (if i = ii then B $$ (i, j) - quot * B $$ (ll, j) else B $$ (i, j))
[PROOF STEP]
unfolding C
[PROOF STATE]
proof (prove)
using this:
j \<noteq> ll

goal (1 subgoal):
 1. (if i = ii \<and> j = ll then B $$ (i, j) + quot * B $$ (i, i) - quot * quot * B $$ (j, i) - quot * B $$ (j, j) else if i = ii \<and> j \<noteq> ll then B $$ (i, j) - quot * B $$ (ll, j) else if i \<noteq> ii \<and> j = ll then B $$ (i, j) + quot * B $$ (i, ii) else B $$ (i, j)) = (if i = ii then B $$ (i, j) - quot * B $$ (ll, j) else B $$ (i, j))
[PROOF STEP]
unfolding jk
[PROOF STATE]
proof (prove)
using this:
k \<noteq> ll

goal (1 subgoal):
 1. (if i = ii \<and> k = ll then B $$ (i, k) + quot * B $$ (i, i) - quot * quot * B $$ (k, i) - quot * B $$ (k, k) else if i = ii \<and> k \<noteq> ll then B $$ (i, k) - quot * B $$ (ll, k) else if i \<noteq> ii \<and> k = ll then B $$ (i, k) + quot * B $$ (i, ii) else B $$ (i, k)) = (if i = ii then B $$ (i, k) - quot * B $$ (ll, k) else B $$ (i, k))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (if i = ii then B $$ (i, j) - quot * B $$ (ll, j) else B $$ (i, j))

goal (2 subgoals):
 1. j < k \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. j = k \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
have C: "?C $$ (i,j) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
proof (cases "i = i_end")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i = i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
 2. i \<noteq> i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
i \<noteq> i_end

goal (2 subgoals):
 1. i = i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
 2. i \<noteq> i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
with index ii jk
[PROOF STATE]
proof (chain)
picking this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
j = k
i \<noteq> i_end
[PROOF STEP]
have i: "i_begin \<le> i" "i < i_end"
[PROOF STATE]
proof (prove)
using this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
j = k
i \<noteq> i_end

goal (1 subgoal):
 1. i_begin \<le> i &&& i < i_end
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i_begin \<le> i
i < i_end

goal (2 subgoals):
 1. i = i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
 2. i \<noteq> i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
from A_ik[OF ib_block this]
[PROOF STATE]
proof (chain)
picking this:
A $$ (i, k) = (0::'a)
[PROOF STEP]
have Aij: "A $$ (i,j) = 0"
[PROOF STATE]
proof (prove)
using this:
A $$ (i, k) = (0::'a)

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

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

goal (2 subgoals):
 1. i = i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
 2. i \<noteq> i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
from index i jk
[PROOF STATE]
proof (chain)
picking this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
i_begin \<le> i
i < i_end
j = k
[PROOF STEP]
have "\<not> ((i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc ?idiff})"
[PROOF STATE]
proof (prove)
using this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
i_begin \<le> i
i < i_end
j = k

goal (1 subgoal):
 1. \<not> ((i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<not> ((i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)})

goal (2 subgoals):
 1. i = i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
 2. i \<noteq> i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
hence Bij: "B $$ (i,j) = 0"
[PROOF STATE]
proof (prove)
using this:
\<not> ((i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)})

goal (1 subgoal):
 1. B $$ (i, j) = (0::'a)
[PROOF STEP]
unfolding B Aij
[PROOF STATE]
proof (prove)
using this:
\<not> ((i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)})

goal (1 subgoal):
 1. (if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then (0::'a) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else (0::'a)) = (0::'a)
[PROOF STEP]
using i jk
[PROOF STATE]
proof (prove)
using this:
\<not> ((i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)})
i_begin \<le> i
i < i_end
j = k

goal (1 subgoal):
 1. (if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then (0::'a) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else (0::'a)) = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B $$ (i, j) = (0::'a)

goal (2 subgoals):
 1. i = i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
 2. i \<noteq> i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
hence C: "?C $$ (i,j) = (if i = ii then - quot * B $$ (ll,j) else 0)"
[PROOF STATE]
proof (prove)
using this:
B $$ (i, j) = (0::'a)

goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (if i = ii then - quot * B $$ (ll, j) else (0::'a))
[PROOF STEP]
unfolding C
[PROOF STATE]
proof (prove)
using this:
B $$ (i, j) = (0::'a)

goal (1 subgoal):
 1. (if i = ii then B $$ (i, j) - quot * B $$ (ll, j) else B $$ (i, j)) = (if i = ii then - quot * B $$ (ll, j) else (0::'a))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (if i = ii then - quot * B $$ (ll, j) else (0::'a))

goal (2 subgoals):
 1. i = i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
 2. i \<noteq> i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
let ?l = "l - iter"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i = i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
 2. i \<noteq> i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
from index eqs
[PROOF STATE]
proof (chain)
picking this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
[PROOF STEP]
have ll: "ll = ?l"
[PROOF STATE]
proof (prove)
using this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)

goal (1 subgoal):
 1. ll = l - iter
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ll = l - iter

goal (2 subgoals):
 1. i = i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
 2. i \<noteq> i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
show "?C $$ (i,j) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
proof (cases "i = ii")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i = ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
 2. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
i = ii

goal (2 subgoals):
 1. i = ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
 2. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
with index eqs i
[PROOF STATE]
proof (chain)
picking this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_begin \<le> i
i < i_end
i = ii
[PROOF STEP]
have l: "lb \<le> ?l" "?l < l" and diff: "Suc diff \<noteq> Suc ?idiff"
[PROOF STATE]
proof (prove)
using this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_begin \<le> i
i < i_end
i = ii

goal (1 subgoal):
 1. (lb \<le> l - iter &&& l - iter < l) &&& Suc diff \<noteq> Suc (i_end - i_begin)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
lb \<le> l - iter
l - iter < l
Suc diff \<noteq> Suc (i_end - i_begin)

goal (2 subgoals):
 1. i = ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
 2. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
from A_ik[OF lbl l]
[PROOF STATE]
proof (chain)
picking this:
A $$ (l - iter, k) = (0::'a)
[PROOF STEP]
have Alj: "A $$ (ll,j) = 0"
[PROOF STATE]
proof (prove)
using this:
A $$ (l - iter, k) = (0::'a)

goal (1 subgoal):
 1. A $$ (ll, j) = (0::'a)
[PROOF STEP]
unfolding jk ll
[PROOF STATE]
proof (prove)
using this:
A $$ (l - iter, k) = (0::'a)

goal (1 subgoal):
 1. A $$ (l - iter, k) = (0::'a)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
A $$ (ll, j) = (0::'a)

goal (2 subgoals):
 1. i = ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
 2. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
from index l jk eqs
[PROOF STATE]
proof (chain)
picking this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
lb \<le> l - iter
l - iter < l
j = k
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
[PROOF STEP]
have "\<not> ((ll, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc ?idiff})"
[PROOF STATE]
proof (prove)
using this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
lb \<le> l - iter
l - iter < l
j = k
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)

goal (1 subgoal):
 1. \<not> ((ll, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<not> ((ll, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)})

goal (2 subgoals):
 1. i = ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
 2. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
hence Bij: "B $$ (ll,j) = 0"
[PROOF STATE]
proof (prove)
using this:
\<not> ((ll, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)})

goal (1 subgoal):
 1. B $$ (ll, j) = (0::'a)
[PROOF STEP]
unfolding BB[OF \<open>ll < n\<close> j] Alj
[PROOF STATE]
proof (prove)
using this:
\<not> ((ll, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)})

goal (1 subgoal):
 1. (if (ll, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> ll \<and> ll \<le> i_end \<and> k < j then (0::'a) - quot * A $$ (l + ll - i_end, j) else if (ll, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else (0::'a)) = (0::'a)
[PROOF STEP]
using l jk diff
[PROOF STATE]
proof (prove)
using this:
\<not> ((ll, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)})
lb \<le> l - iter
l - iter < l
j = k
Suc diff \<noteq> Suc (i_end - i_begin)

goal (1 subgoal):
 1. (if (ll, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> ll \<and> ll \<le> i_end \<and> k < j then (0::'a) - quot * A $$ (l + ll - i_end, j) else if (ll, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else (0::'a)) = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B $$ (ll, j) = (0::'a)

goal (2 subgoals):
 1. i = ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
 2. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
B $$ (ll, j) = (0::'a)

goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
unfolding C
[PROOF STATE]
proof (prove)
using this:
B $$ (ll, j) = (0::'a)

goal (1 subgoal):
 1. (if i = ii then - quot * B $$ (ll, j) else (0::'a)) = (0::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)

goal (1 subgoal):
 1. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
i \<noteq> ii

goal (1 subgoal):
 1. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
i \<noteq> ii

goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
unfolding C
[PROOF STATE]
proof (prove)
using this:
i \<noteq> ii

goal (1 subgoal):
 1. (if i = ii then - quot * B $$ (ll, j) else (0::'a)) = (0::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)

goal (1 subgoal):
 1. i = i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i = i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
i = i_end

goal (1 subgoal):
 1. i = i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
note i = this
[PROOF STATE]
proof (state)
this:
i = i_end

goal (1 subgoal):
 1. i = i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
hence Bij: "B $$ (i,j) = (if diff = ?idiff then A $$ (i_end, k) else 0)"
[PROOF STATE]
proof (prove)
using this:
i = i_end

goal (1 subgoal):
 1. B $$ (i, j) = (if diff = i_end - i_begin then A $$ (i_end, k) else (0::'a))
[PROOF STEP]
unfolding B
[PROOF STATE]
proof (prove)
using this:
i = i_end

goal (1 subgoal):
 1. (if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) = (if diff = i_end - i_begin then A $$ (i_end, k) else (0::'a))
[PROOF STEP]
unfolding jk
[PROOF STATE]
proof (prove)
using this:
i = i_end

goal (1 subgoal):
 1. (if (i, k) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < k then A $$ (i, k) - quot * A $$ (l + i - i_end, k) else if (i, k) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, k)) = (if diff = i_end - i_begin then A $$ (i_end, k) else (0::'a))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B $$ (i, j) = (if diff = i_end - i_begin then A $$ (i_end, k) else (0::'a))

goal (1 subgoal):
 1. i = i_end \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
proof (cases "i = ii")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i = ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
 2. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
i = ii

goal (2 subgoals):
 1. i = ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
 2. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
with i eqs
[PROOF STATE]
proof (chain)
picking this:
i = i_end
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i = ii
[PROOF STEP]
have "diff = ?idiff" "ll = l" "iter = 0"
[PROOF STATE]
proof (prove)
using this:
i = i_end
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i = ii

goal (1 subgoal):
 1. diff = i_end - i_begin &&& ll = l &&& iter = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
diff = i_end - i_begin
ll = l
iter = 0

goal (2 subgoals):
 1. i = ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
 2. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
hence B: "B $$ (i,j) = A $$ (i_end,k)"
[PROOF STATE]
proof (prove)
using this:
diff = i_end - i_begin
ll = l
iter = 0

goal (1 subgoal):
 1. B $$ (i, j) = A $$ (i_end, k)
[PROOF STEP]
unfolding Bij
[PROOF STATE]
proof (prove)
using this:
diff = i_end - i_begin
ll = l
iter = 0

goal (1 subgoal):
 1. (if diff = i_end - i_begin then A $$ (i_end, k) else (0::'a)) = A $$ (i_end, k)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B $$ (i, j) = A $$ (i_end, k)

goal (2 subgoals):
 1. i = ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
 2. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
have C: "?C $$ (i,j) = A $$ (i_end,k) - quot * B $$ (l, k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i_end, k) - quot * B $$ (l, k)
[PROOF STEP]
unfolding C B
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if i = ii then A $$ (i_end, k) - quot * B $$ (ll, j) else A $$ (i_end, k)) = A $$ (i_end, k) - quot * B $$ (l, k)
[PROOF STEP]
unfolding True \<open>ll =l\<close> jk
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if ii = ii then A $$ (i_end, k) - quot * B $$ (l, k) else A $$ (i_end, k)) = A $$ (i_end, k) - quot * B $$ (l, k)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i_end, k) - quot * B $$ (l, k)

goal (2 subgoals):
 1. i = ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
 2. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i_end, k) - quot * B $$ (l, k)

goal (2 subgoals):
 1. i = ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
 2. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
have "B $$ (l,k) = A $$ (l,k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B $$ (l, k) = A $$ (l, k)
[PROOF STEP]
unfolding BB[OF \<open>l < n\<close> \<open>k < n\<close>]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if (l, k) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> l \<and> l \<le> i_end \<and> k < k then A $$ (l, k) - quot * A $$ (l + l - i_end, k) else if (l, k) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (l, k)) = A $$ (l, k)
[PROOF STEP]
using il \<open>iter = 0\<close>
[PROOF STATE]
proof (prove)
using this:
i_end \<noteq> l
iter = 0

goal (1 subgoal):
 1. (if (l, k) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> l \<and> l \<le> i_end \<and> k < k then A $$ (l, k) - quot * A $$ (l + l - i_end, k) else if (l, k) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (l, k)) = A $$ (l, k)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B $$ (l, k) = A $$ (l, k)

goal (2 subgoals):
 1. i = ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
 2. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
B $$ (l, k) = A $$ (l, k)

goal (2 subgoals):
 1. i = ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
 2. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
have "A $$ (i_end,k) - quot * \<dots> = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A $$ (i_end, k) - quot * A $$ (l, k) = (0::'a)
[PROOF STEP]
unfolding quot_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A $$ (i_end, k) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l, k) = (0::'a)
[PROOF STEP]
using Alk
[PROOF STATE]
proof (prove)
using this:
A $$ (l, k) \<noteq> (0::'a)

goal (1 subgoal):
 1. A $$ (i_end, k) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l, k) = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A $$ (i_end, k) - quot * A $$ (l, k) = (0::'a)

goal (2 subgoals):
 1. i = ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
 2. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
add_col_sub_row quot ii ll (mat n n (\<lambda>a. case a of (i, j) \<Rightarrow> if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
add_col_sub_row quot ii ll (mat n n (\<lambda>a. case a of (i, j) \<Rightarrow> if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)

goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)

goal (1 subgoal):
 1. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
i \<noteq> ii

goal (1 subgoal):
 1. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
with i eqs
[PROOF STATE]
proof (chain)
picking this:
i = i_end
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i \<noteq> ii
[PROOF STEP]
have "diff \<noteq> ?idiff"
[PROOF STATE]
proof (prove)
using this:
i = i_end
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i \<noteq> ii

goal (1 subgoal):
 1. diff \<noteq> i_end - i_begin
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
diff \<noteq> i_end - i_begin

goal (1 subgoal):
 1. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
diff \<noteq> i_end - i_begin

goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
unfolding C Bij
[PROOF STATE]
proof (prove)
using this:
diff \<noteq> i_end - i_begin

goal (1 subgoal):
 1. (if i = ii then (if diff = i_end - i_begin then A $$ (i_end, k) else (0::'a)) - quot * B $$ (ll, j) else if diff = i_end - i_begin then A $$ (i_end, k) else (0::'a)) = (0::'a)
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
diff \<noteq> i_end - i_begin
i \<noteq> ii

goal (1 subgoal):
 1. (if i = ii then (if diff = i_end - i_begin then A $$ (i_end, k) else (0::'a)) - quot * B $$ (ll, j) else if diff = i_end - i_begin then A $$ (i_end, k) else (0::'a)) = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)

goal (2 subgoals):
 1. j < k \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. j = k \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
unfolding C D
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0::'a) = (0::'a)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)

goal (1 subgoal):
 1. j < k \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. j < k \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
assume jk: "j < k"
[PROOF STATE]
proof (state)
this:
j < k

goal (1 subgoal):
 1. j < k \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
from eqs il
[PROOF STATE]
proof (chain)
picking this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_end \<noteq> l
[PROOF STEP]
have "ii \<noteq> ll"
[PROOF STATE]
proof (prove)
using this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_end \<noteq> l

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

goal (1 subgoal):
 1. j < k \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
proof (cases "diff = 0 \<or> (i,j) \<noteq> (ii - 1,ll)")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll)) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> (diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll))

goal (2 subgoals):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll)) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
with eqs
[PROOF STATE]
proof (chain)
picking this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
\<not> (diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll))
[PROOF STEP]
have **: "i = i_end - Suc iter" "j = l - iter" "iter \<noteq> ?idiff"
                  and *: "diff \<noteq> 0" "i = ii - 1" "j = ll" "ii \<noteq> 0" "i \<noteq> ii"
[PROOF STATE]
proof (prove)
using this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
\<not> (diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll))

goal (1 subgoal):
 1. (i = i_end - Suc iter &&& j = l - iter &&& iter \<noteq> i_end - i_begin) &&& (diff \<noteq> 0 &&& i = ii - 1) &&& j = ll &&& ii \<noteq> 0 &&& i \<noteq> ii
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i = i_end - Suc iter
j = l - iter
iter \<noteq> i_end - i_begin
diff \<noteq> 0
i = ii - 1
j = ll
ii \<noteq> 0
i \<noteq> ii

goal (2 subgoals):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll)) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
hence D: "?D $$ (i,j) = quot"
[PROOF STATE]
proof (prove)
using this:
i = i_end - Suc iter
j = l - iter
iter \<noteq> i_end - i_begin
diff \<noteq> 0
i = ii - 1
j = ll
ii \<noteq> 0
i \<noteq> ii

goal (1 subgoal):
 1. mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = quot
[PROOF STEP]
unfolding D
[PROOF STATE]
proof (prove)
using this:
i = i_end - Suc iter
j = l - iter
iter \<noteq> i_end - i_begin
diff \<noteq> 0
i = ii - 1
j = ll
ii \<noteq> 0
i \<noteq> ii

goal (1 subgoal):
 1. (if (i, j) = (i_end, k) then 0::'a else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, l - iter) \<and> iter \<noteq> i_end - i_begin then quot else A $$ (i, j)) = quot
[PROOF STEP]
using jk index
[PROOF STATE]
proof (prove)
using this:
i = i_end - Suc iter
j = l - iter
iter \<noteq> i_end - i_begin
diff \<noteq> 0
i = ii - 1
j = ll
ii \<noteq> 0
i \<noteq> ii
j < k
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k

goal (1 subgoal):
 1. (if (i, j) = (i_end, k) then 0::'a else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, l - iter) \<and> iter \<noteq> i_end - i_begin then quot else A $$ (i, j)) = quot
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = quot

goal (2 subgoals):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll)) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
from * index eqs False jk
[PROOF STATE]
proof (chain)
picking this:
diff \<noteq> 0
i = ii - 1
j = ll
ii \<noteq> 0
i \<noteq> ii
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
\<not> (diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll))
j < k
[PROOF STEP]
have i: "ii = Suc i" "i < i_end"
[PROOF STATE]
proof (prove)
using this:
diff \<noteq> 0
i = ii - 1
j = ll
ii \<noteq> 0
i \<noteq> ii
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
\<not> (diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll))
j < k

goal (1 subgoal):
 1. ii = Suc i &&& i < i_end
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ii = Suc i
i < i_end

goal (2 subgoals):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll)) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
from iblock(3)[OF ib_block \<open>i_begin \<le> i\<close> \<open>i < i_end\<close>]
[PROOF STATE]
proof (chain)
picking this:
A $$ (i, Suc i) = (1::'a)
[PROOF STEP]
have Ai: "A $$ (i, ii) = 1"
[PROOF STATE]
proof (prove)
using this:
A $$ (i, Suc i) = (1::'a)

goal (1 subgoal):
 1. A $$ (i, ii) = (1::'a)
[PROOF STEP]
unfolding i
[PROOF STATE]
proof (prove)
using this:
A $$ (i, Suc i) = (1::'a)

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

goal (2 subgoals):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll)) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
have "ii < k" "i \<noteq> i_end - iter"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ii < k &&& i \<noteq> i_end - iter
[PROOF STEP]
using index * ** eqs
[PROOF STATE]
proof (prove)
using this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
diff \<noteq> 0
i = ii - 1
j = ll
ii \<noteq> 0
i \<noteq> ii
i = i_end - Suc iter
j = l - iter
iter \<noteq> i_end - i_begin
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)

goal (1 subgoal):
 1. ii < k &&& i \<noteq> i_end - iter
[PROOF STEP]
by (blast, force)
[PROOF STATE]
proof (state)
this:
ii < k
i \<noteq> i_end - iter

goal (2 subgoals):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll)) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
hence Bi: "B $$ (i,ii) = 1"
[PROOF STATE]
proof (prove)
using this:
ii < k
i \<noteq> i_end - iter

goal (1 subgoal):
 1. B $$ (i, ii) = (1::'a)
[PROOF STEP]
unfolding BB[OF \<open>i < n\<close> \<open>ii < n\<close>] Ai
[PROOF STATE]
proof (prove)
using this:
ii < k
i \<noteq> i_end - iter

goal (1 subgoal):
 1. (if (i, ii) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < ii then (1::'a) - quot * A $$ (l + i - i_end, ii) else if (i, ii) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else (1::'a)) = (1::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B $$ (i, ii) = (1::'a)

goal (2 subgoals):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll)) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
have "B $$ (i,ll) = A $$ (i,ll)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B $$ (i, ll) = A $$ (i, ll)
[PROOF STEP]
unfolding BB[OF \<open>i < n\<close> \<open>ll < n\<close>]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if (i, ll) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < ll then A $$ (i, ll) - quot * A $$ (l + i - i_end, ll) else if (i, ll) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, ll)) = A $$ (i, ll)
[PROOF STEP]
using \<open>i \<noteq> i_end - iter\<close> \<open>ll < k\<close>
[PROOF STATE]
proof (prove)
using this:
i \<noteq> i_end - iter
ll < k

goal (1 subgoal):
 1. (if (i, ll) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < ll then A $$ (i, ll) - quot * A $$ (l + i - i_end, ll) else if (i, ll) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, ll)) = A $$ (i, ll)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B $$ (i, ll) = A $$ (i, ll)

goal (2 subgoals):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll)) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
B $$ (i, ll) = A $$ (i, ll)

goal (2 subgoals):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll)) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
have "A $$ (i,ll) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A $$ (i, ll) = (0::'a)
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. A $$ (i, ll) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
assume nz: "A $$ (i,ll) \<noteq> 0"
[PROOF STATE]
proof (state)
this:
A $$ (i, ll) \<noteq> (0::'a)

goal (1 subgoal):
 1. A $$ (i, ll) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
from i eqs il
[PROOF STATE]
proof (chain)
picking this:
ii = Suc i
i < i_end
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_end \<noteq> l
[PROOF STEP]
have neq: "Suc i \<noteq> ll"
[PROOF STATE]
proof (prove)
using this:
ii = Suc i
i < i_end
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_end \<noteq> l

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

goal (1 subgoal):
 1. A $$ (i, ll) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
from jb[OF \<open>i < n\<close> \<open>ll < n\<close> \<open>ll < k\<close>] nz neq
[PROOF STATE]
proof (chain)
picking this:
(Suc i = ll \<longrightarrow> A $$ (i, ll) \<in> {0::'a, 1::'a}) \<and> (i \<noteq> ll \<longrightarrow> Suc i \<noteq> ll \<or> A $$ (i, i) \<noteq> A $$ (ll, ll) \<longrightarrow> A $$ (i, ll) = (0::'a))
A $$ (i, ll) \<noteq> (0::'a)
Suc i \<noteq> ll
[PROOF STEP]
have "i = ll"
[PROOF STATE]
proof (prove)
using this:
(Suc i = ll \<longrightarrow> A $$ (i, ll) \<in> {0::'a, 1::'a}) \<and> (i \<noteq> ll \<longrightarrow> Suc i \<noteq> ll \<or> A $$ (i, i) \<noteq> A $$ (ll, ll) \<longrightarrow> A $$ (i, ll) = (0::'a))
A $$ (i, ll) \<noteq> (0::'a)
Suc i \<noteq> ll

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

goal (1 subgoal):
 1. A $$ (i, ll) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
with i
[PROOF STATE]
proof (chain)
picking this:
ii = Suc i
i < i_end
i = ll
[PROOF STEP]
have "ii = Suc ll"
[PROOF STATE]
proof (prove)
using this:
ii = Suc i
i < i_end
i = ll

goal (1 subgoal):
 1. ii = Suc ll
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
ii = Suc ll

goal (1 subgoal):
 1. A $$ (i, ll) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
hence "i_end - iter = Suc l - iter"
[PROOF STATE]
proof (prove)
using this:
ii = Suc ll

goal (1 subgoal):
 1. i_end - iter = Suc l - iter
[PROOF STEP]
using eqs
[PROOF STATE]
proof (prove)
using this:
ii = Suc ll
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)

goal (1 subgoal):
 1. i_end - iter = Suc l - iter
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i_end - iter = Suc l - iter

goal (1 subgoal):
 1. A $$ (i, ll) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
from block[OF this]
[PROOF STATE]
proof (chain)
picking this:
i_begin = i_end
[PROOF STEP]
have "i_begin = i_end"
[PROOF STATE]
proof (prove)
using this:
i_begin = i_end

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

goal (1 subgoal):
 1. A $$ (i, ll) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
with large ib lb index
[PROOF STATE]
proof (chain)
picking this:
i_end - i_begin \<le> l - lb
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
i_begin = i_end
[PROOF STEP]
have "i = ii"
[PROOF STATE]
proof (prove)
using this:
i_end - i_begin \<le> l - lb
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
i_begin = i_end

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

goal (1 subgoal):
 1. A $$ (i, ll) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
with *
[PROOF STATE]
proof (chain)
picking this:
diff \<noteq> 0
i = ii - 1
j = ll
ii \<noteq> 0
i \<noteq> ii
i = ii
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
diff \<noteq> 0
i = ii - 1
j = ll
ii \<noteq> 0
i \<noteq> ii
i = ii

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
A $$ (i, ll) = (0::'a)

goal (2 subgoals):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll)) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
B $$ (i, ll) = (0::'a)
[PROOF STEP]
have C: "?C $$ (i,j) = quot"
[PROOF STATE]
proof (prove)
using this:
B $$ (i, ll) = (0::'a)

goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = quot
[PROOF STEP]
unfolding C
[PROOF STATE]
proof (prove)
using this:
B $$ (i, ll) = (0::'a)

goal (1 subgoal):
 1. (if i = ii \<and> j = ll then B $$ (i, j) + quot * B $$ (i, i) - quot * quot * B $$ (j, i) - quot * B $$ (j, j) else if i = ii \<and> j \<noteq> ll then B $$ (i, j) - quot * B $$ (ll, j) else if i \<noteq> ii \<and> j = ll then B $$ (i, j) + quot * B $$ (i, ii) else B $$ (i, j)) = quot
[PROOF STEP]
using * Bi
[PROOF STATE]
proof (prove)
using this:
B $$ (i, ll) = (0::'a)
diff \<noteq> 0
i = ii - 1
j = ll
ii \<noteq> 0
i \<noteq> ii
B $$ (i, ii) = (1::'a)

goal (1 subgoal):
 1. (if i = ii \<and> j = ll then B $$ (i, j) + quot * B $$ (i, i) - quot * quot * B $$ (j, i) - quot * B $$ (j, j) else if i = ii \<and> j \<noteq> ll then B $$ (i, j) - quot * B $$ (ll, j) else if i \<noteq> ii \<and> j = ll then B $$ (i, j) + quot * B $$ (i, ii) else B $$ (i, j)) = quot
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = quot

goal (2 subgoals):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
 2. \<not> (diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll)) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
unfolding C D
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. quot = quot
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)

goal (1 subgoal):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll)

goal (1 subgoal):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
with eqs
[PROOF STATE]
proof (chain)
picking this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll)
[PROOF STEP]
have "\<not> ((i, j) = (i_end - Suc iter, l - iter) \<and> iter \<noteq> ?idiff)"
                  and not: "\<not> (i = ii - 1 \<and> j = ll \<and> iter \<noteq> ?idiff)"
[PROOF STATE]
proof (prove)
using this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll)

goal (1 subgoal):
 1. \<not> ((i, j) = (i_end - Suc iter, l - iter) \<and> iter \<noteq> i_end - i_begin) &&& \<not> (i = ii - 1 \<and> j = ll \<and> iter \<noteq> i_end - i_begin)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<not> ((i, j) = (i_end - Suc iter, l - iter) \<and> iter \<noteq> i_end - i_begin)
\<not> (i = ii - 1 \<and> j = ll \<and> iter \<noteq> i_end - i_begin)

goal (1 subgoal):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
from this(1)
[PROOF STATE]
proof (chain)
picking this:
\<not> ((i, j) = (i_end - Suc iter, l - iter) \<and> iter \<noteq> i_end - i_begin)
[PROOF STEP]
have D: "?D $$ (i,j) = ?Aij"
[PROOF STATE]
proof (prove)
using this:
\<not> ((i, j) = (i_end - Suc iter, l - iter) \<and> iter \<noteq> i_end - i_begin)

goal (1 subgoal):
 1. mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
unfolding D
[PROOF STATE]
proof (prove)
using this:
\<not> ((i, j) = (i_end - Suc iter, l - iter) \<and> iter \<noteq> i_end - i_begin)

goal (1 subgoal):
 1. (if (i, j) = (i_end, k) then 0::'a else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, l - iter) \<and> iter \<noteq> i_end - i_begin then quot else A $$ (i, j)) = A $$ (i, j)
[PROOF STEP]
using jk index
[PROOF STATE]
proof (prove)
using this:
\<not> ((i, j) = (i_end - Suc iter, l - iter) \<and> iter \<noteq> i_end - i_begin)
j < k
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k

goal (1 subgoal):
 1. (if (i, j) = (i_end, k) then 0::'a else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, l - iter) \<and> iter \<noteq> i_end - i_begin then quot else A $$ (i, j)) = A $$ (i, j)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = A $$ (i, j)

goal (1 subgoal):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j) = A $$ (i, j)

goal (1 subgoal):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. diff = 0 \<or> (i__, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i__, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i__, j)
[PROOF STEP]
assume "i < n"
[PROOF STATE]
proof (state)
this:
i < n

goal (1 subgoal):
 1. diff = 0 \<or> (i__, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i__, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i__, j)
[PROOF STEP]
with index
[PROOF STATE]
proof (chain)
picking this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i__ < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i__
i__ \<le> i_end
i__ < k
i < n
[PROOF STEP]
have id: "((i,i) = (i_end,k)) = False" "(i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < i) = False"
[PROOF STATE]
proof (prove)
using this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i__ < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i__
i__ \<le> i_end
i__ < k
i < n

goal (1 subgoal):
 1. ((i, i) = (i_end, k)) = False &&& (i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < i) = False
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
((i, i) = (i_end, k)) = False
(i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < i) = False

goal (1 subgoal):
 1. diff = 0 \<or> (i__, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i__, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i__, j)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
((i, i) = (i_end, k)) = False
(i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < i) = False

goal (1 subgoal):
 1. diff = 0 \<or> (i__, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i__, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i__, j)
[PROOF STEP]
assume *: "(i, i) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc ?idiff}"
[PROOF STATE]
proof (state)
this:
(i, i) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)}

goal (1 subgoal):
 1. diff = 0 \<or> (i__, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i__, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i__, j)
[PROOF STEP]
hence "i_end - iter = Suc l - iter"
[PROOF STATE]
proof (prove)
using this:
(i, i) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)}

goal (1 subgoal):
 1. i_end - iter = Suc l - iter
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i_end - iter = Suc l - iter

goal (1 subgoal):
 1. diff = 0 \<or> (i__, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i__, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i__, j)
[PROOF STEP]
from block[OF this] * index large eqs
[PROOF STATE]
proof (chain)
picking this:
i_begin = i_end
(i, i) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)}
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i__ < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i__
i__ \<le> i_end
i__ < k
i_end - i_begin \<le> l - lb
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
[PROOF STEP]
have False
[PROOF STATE]
proof (prove)
using this:
i_begin = i_end
(i, i) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)}
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i__ < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i__
i__ \<le> i_end
i__ < k
i_end - i_begin \<le> l - lb
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)

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

goal (1 subgoal):
 1. diff = 0 \<or> (i__, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i__, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i__, j)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
(i, i) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} \<Longrightarrow> False

goal (1 subgoal):
 1. diff = 0 \<or> (i__, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i__, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i__, j)
[PROOF STEP]
hence "B $$ (i,i) = ?ev i"
[PROOF STATE]
proof (prove)
using this:
(i, i) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} \<Longrightarrow> False

goal (1 subgoal):
 1. B $$ (i, i) = A $$ (i, i)
[PROOF STEP]
unfolding BB[OF \<open>i < n\<close> \<open>i < n\<close>] id if_False
[PROOF STATE]
proof (prove)
using this:
(i, i) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} \<Longrightarrow> False

goal (1 subgoal):
 1. (if (i, i) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, i)) = A $$ (i, i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B $$ (i, i) = A $$ (i, i)

goal (1 subgoal):
 1. diff = 0 \<or> (i__, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i__, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i__, j)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?ia2 < n \<Longrightarrow> B $$ (?ia2, ?ia2) = A $$ (?ia2, ?ia2)

goal (1 subgoal):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
note Bdiag = this
[PROOF STATE]
proof (state)
this:
?ia2 < n \<Longrightarrow> B $$ (?ia2, ?ia2) = A $$ (?ia2, ?ia2)

goal (1 subgoal):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
from eqs
[PROOF STATE]
proof (chain)
picking this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
[PROOF STEP]
have ii: "ii = i_end - iter" "Suc l - iter = Suc ll"
[PROOF STATE]
proof (prove)
using this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)

goal (1 subgoal):
 1. ii = i_end - iter &&& Suc l - iter = Suc ll
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ii = i_end - iter
Suc l - iter = Suc ll

goal (1 subgoal):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
have B: "B $$ (i,j) =
                  (if (i, j) = (ii, Suc ll) \<and> iter \<noteq> 0 then quot else A $$ (i, j))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B $$ (i, j) = (if (i, j) = (ii, Suc ll) \<and> iter \<noteq> 0 then quot else A $$ (i, j))
[PROOF STEP]
unfolding B
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) = (if (i, j) = (ii, Suc ll) \<and> iter \<noteq> 0 then quot else A $$ (i, j))
[PROOF STEP]
using ii jk iter
[PROOF STATE]
proof (prove)
using this:
ii = i_end - iter
Suc l - iter = Suc ll
j < k
iter \<noteq> Suc (i_end - i_begin)

goal (1 subgoal):
 1. (if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) = (if (i, j) = (ii, Suc ll) \<and> iter \<noteq> 0 then quot else A $$ (i, j))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B $$ (i, j) = (if (i, j) = (ii, Suc ll) \<and> iter \<noteq> 0 then quot else A $$ (i, j))

goal (1 subgoal):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
have ll_i: "ll \<noteq> i_end - iter"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ll \<noteq> i_end - iter
[PROOF STEP]
using \<open>ii \<noteq> ll\<close> eqs
[PROOF STATE]
proof (prove)
using this:
ii \<noteq> ll
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)

goal (1 subgoal):
 1. ll \<noteq> i_end - iter
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ll \<noteq> i_end - iter

goal (1 subgoal):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
have "B $$ (ll,ii) = A $$ (ll,ii)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B $$ (ll, ii) = A $$ (ll, ii)
[PROOF STEP]
unfolding BB[OF \<open>ll < n\<close> \<open>ii < n\<close>]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if (ll, ii) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> ll \<and> ll \<le> i_end \<and> k < ii then A $$ (ll, ii) - quot * A $$ (l + ll - i_end, ii) else if (ll, ii) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (ll, ii)) = A $$ (ll, ii)
[PROOF STEP]
using \<open>ii < k\<close> ll_i
[PROOF STATE]
proof (prove)
using this:
ii < k
ll \<noteq> i_end - iter

goal (1 subgoal):
 1. (if (ll, ii) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> ll \<and> ll \<le> i_end \<and> k < ii then A $$ (ll, ii) - quot * A $$ (l + ll - i_end, ii) else if (ll, ii) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (ll, ii)) = A $$ (ll, ii)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B $$ (ll, ii) = A $$ (ll, ii)

goal (1 subgoal):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
B $$ (ll, ii) = A $$ (ll, ii)

goal (1 subgoal):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
have "\<dots> = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A $$ (ll, ii) = (0::'a)
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. A $$ (ll, ii) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
assume nz: "A $$ (ll,ii) \<noteq> 0"
[PROOF STATE]
proof (state)
this:
A $$ (ll, ii) \<noteq> (0::'a)

goal (1 subgoal):
 1. A $$ (ll, ii) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
with jb[OF \<open>ll < n\<close> \<open>ii < n\<close> \<open>ii < k\<close>] \<open>ii \<noteq> ll\<close>
[PROOF STATE]
proof (chain)
picking this:
(Suc ll = ii \<longrightarrow> A $$ (ll, ii) \<in> {0::'a, 1::'a}) \<and> (ll \<noteq> ii \<longrightarrow> Suc ll \<noteq> ii \<or> A $$ (ll, ll) \<noteq> A $$ (ii, ii) \<longrightarrow> A $$ (ll, ii) = (0::'a))
ii \<noteq> ll
A $$ (ll, ii) \<noteq> (0::'a)
[PROOF STEP]
have "Suc ll = ii"
[PROOF STATE]
proof (prove)
using this:
(Suc ll = ii \<longrightarrow> A $$ (ll, ii) \<in> {0::'a, 1::'a}) \<and> (ll \<noteq> ii \<longrightarrow> Suc ll \<noteq> ii \<or> A $$ (ll, ll) \<noteq> A $$ (ii, ii) \<longrightarrow> A $$ (ll, ii) = (0::'a))
ii \<noteq> ll
A $$ (ll, ii) \<noteq> (0::'a)

goal (1 subgoal):
 1. Suc ll = ii
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Suc ll = ii

goal (1 subgoal):
 1. A $$ (ll, ii) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
with eqs
[PROOF STATE]
proof (chain)
picking this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
Suc ll = ii
[PROOF STEP]
have "i_end - iter = Suc l - iter"
[PROOF STATE]
proof (prove)
using this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
Suc ll = ii

goal (1 subgoal):
 1. i_end - iter = Suc l - iter
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i_end - iter = Suc l - iter

goal (1 subgoal):
 1. A $$ (ll, ii) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
from block[OF this] index eqs
[PROOF STATE]
proof (chain)
picking this:
i_begin = i_end
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
[PROOF STEP]
have "iter = 0"
[PROOF STATE]
proof (prove)
using this:
i_begin = i_end
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)

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

goal (1 subgoal):
 1. A $$ (ll, ii) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
with ii
[PROOF STATE]
proof (chain)
picking this:
ii = i_end - iter
Suc l - iter = Suc ll
iter = 0
[PROOF STEP]
have "ll = l" "ii = i_end"
[PROOF STATE]
proof (prove)
using this:
ii = i_end - iter
Suc l - iter = Suc ll
iter = 0

goal (1 subgoal):
 1. ll = l &&& ii = i_end
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ll = l
ii = i_end

goal (1 subgoal):
 1. A $$ (ll, ii) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
with Alie nz
[PROOF STATE]
proof (chain)
picking this:
A $$ (l, i_end) = (0::'a)
A $$ (ll, ii) \<noteq> (0::'a)
ll = l
ii = i_end
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
A $$ (l, i_end) = (0::'a)
A $$ (ll, ii) \<noteq> (0::'a)
ll = l
ii = i_end

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
A $$ (ll, ii) = (0::'a)

goal (1 subgoal):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
B $$ (ll, ii) = (0::'a)
[PROOF STEP]
have Bli: "B $$ (ll,ii) = 0"
[PROOF STATE]
proof (prove)
using this:
B $$ (ll, ii) = (0::'a)

goal (1 subgoal):
 1. B $$ (ll, ii) = (0::'a)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
B $$ (ll, ii) = (0::'a)

goal (1 subgoal):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
have C: "?C $$ (i,j) = ?Aij"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
proof (cases "i = j")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i = j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
 2. i \<noteq> j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
i = j

goal (2 subgoals):
 1. i = j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
 2. i \<noteq> j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
unfolding C
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if i = ii \<and> j = ll then B $$ (i, j) + quot * B $$ (i, i) - quot * quot * B $$ (j, i) - quot * B $$ (j, j) else if i = ii \<and> j \<noteq> ll then B $$ (i, j) - quot * B $$ (ll, j) else if i \<noteq> ii \<and> j = ll then B $$ (i, j) + quot * B $$ (i, ii) else B $$ (i, j)) = A $$ (i, j)
[PROOF STEP]
unfolding Bdiag[OF \<open>j < n\<close>] True
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if j = ii \<and> j = ll then A $$ (j, j) + quot * A $$ (j, j) - quot * quot * A $$ (j, j) - quot * A $$ (j, j) else if j = ii \<and> j \<noteq> ll then A $$ (j, j) - quot * B $$ (ll, j) else if j \<noteq> ii \<and> j = ll then A $$ (j, j) + quot * B $$ (j, ii) else A $$ (j, j)) = A $$ (j, j)
[PROOF STEP]
using \<open>ii \<noteq> ll\<close> Bli
[PROOF STATE]
proof (prove)
using this:
ii \<noteq> ll
B $$ (ll, ii) = (0::'a)

goal (1 subgoal):
 1. (if j = ii \<and> j = ll then A $$ (j, j) + quot * A $$ (j, j) - quot * quot * A $$ (j, j) - quot * A $$ (j, j) else if j = ii \<and> j \<noteq> ll then A $$ (j, j) - quot * B $$ (ll, j) else if j \<noteq> ii \<and> j = ll then A $$ (j, j) + quot * B $$ (j, ii) else A $$ (j, j)) = A $$ (j, j)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)

goal (1 subgoal):
 1. i \<noteq> j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i \<noteq> j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
i \<noteq> j

goal (1 subgoal):
 1. i \<noteq> j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
from lb eqs index large
[PROOF STATE]
proof (chain)
picking this:
lb \<le> l
l < k
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
i_end - i_begin \<le> l - lb
[PROOF STEP]
have "lb \<le> ll" "ll \<le> l"
[PROOF STATE]
proof (prove)
using this:
lb \<le> l
l < k
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
i_end - i_begin \<le> l - lb

goal (1 subgoal):
 1. lb \<le> ll &&& ll \<le> l
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
lb \<le> ll
ll \<le> l

goal (1 subgoal):
 1. i \<noteq> j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
note C = C[unfolded Bdiag[OF \<open>i < n\<close>] Bdiag[OF \<open>j < n\<close>]]
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (if i = ii \<and> j = ll then B $$ (i, j) + quot * A $$ (i, i) - quot * quot * B $$ (j, i) - quot * A $$ (j, j) else if i = ii \<and> j \<noteq> ll then B $$ (i, j) - quot * B $$ (ll, j) else if i \<noteq> ii \<and> j = ll then B $$ (i, j) + quot * B $$ (i, ii) else B $$ (i, j))

goal (1 subgoal):
 1. i \<noteq> j \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
proof (cases "(i, j) = (ii, Suc ll) \<and> iter \<noteq> 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (i, j) = (ii, Suc ll) \<and> iter \<noteq> 0 \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
 2. \<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
(i, j) = (ii, Suc ll) \<and> iter \<noteq> 0

goal (2 subgoals):
 1. (i, j) = (ii, Suc ll) \<and> iter \<noteq> 0 \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
 2. \<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
hence *: "i = ii" "j = Suc ll" "iter \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
(i, j) = (ii, Suc ll) \<and> iter \<noteq> 0

goal (1 subgoal):
 1. i = ii &&& j = Suc ll &&& iter \<noteq> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i = ii
j = Suc ll
iter \<noteq> 0

goal (2 subgoals):
 1. (i, j) = (ii, Suc ll) \<and> iter \<noteq> 0 \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
 2. \<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
from * eqs index
[PROOF STATE]
proof (chain)
picking this:
i = ii
j = Suc ll
iter \<noteq> 0
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
[PROOF STEP]
have "ll < l" "Suc ll < k" "Suc ll < n"
[PROOF STATE]
proof (prove)
using this:
i = ii
j = Suc ll
iter \<noteq> 0
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k

goal (1 subgoal):
 1. ll < l &&& Suc ll < k &&& Suc ll < n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ll < l
Suc ll < k
Suc ll < n

goal (2 subgoals):
 1. (i, j) = (ii, Suc ll) \<and> iter \<noteq> 0 \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
 2. \<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
have B: "B $$ (i,j) = quot"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B $$ (i, j) = quot
[PROOF STEP]
unfolding B
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if (i, j) = (ii, Suc ll) \<and> iter \<noteq> 0 then quot else A $$ (i, j)) = quot
[PROOF STEP]
using *
[PROOF STATE]
proof (prove)
using this:
i = ii
j = Suc ll
iter \<noteq> 0

goal (1 subgoal):
 1. (if (i, j) = (ii, Suc ll) \<and> iter \<noteq> 0 then quot else A $$ (i, j)) = quot
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B $$ (i, j) = quot

goal (2 subgoals):
 1. (i, j) = (ii, Suc ll) \<and> iter \<noteq> 0 \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
 2. \<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
have "\<not> ((ll, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc ?idiff})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> ((ll, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)})
[PROOF STEP]
using * index eqs
[PROOF STATE]
proof (prove)
using this:
i = ii
j = Suc ll
iter \<noteq> 0
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)

goal (1 subgoal):
 1. \<not> ((ll, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<not> ((ll, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)})

goal (2 subgoals):
 1. (i, j) = (ii, Suc ll) \<and> iter \<noteq> 0 \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
 2. \<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
hence B': "B $$ (ll, j) = A $$ (ll, j)"
[PROOF STATE]
proof (prove)
using this:
\<not> ((ll, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)})

goal (1 subgoal):
 1. B $$ (ll, j) = A $$ (ll, j)
[PROOF STEP]
unfolding BB[OF \<open>ll < n\<close> \<open>j < n\<close>]
[PROOF STATE]
proof (prove)
using this:
\<not> ((ll, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)})

goal (1 subgoal):
 1. (if (ll, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> ll \<and> ll \<le> i_end \<and> k < j then A $$ (ll, j) - quot * A $$ (l + ll - i_end, j) else if (ll, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (ll, j)) = A $$ (ll, j)
[PROOF STEP]
using jk
[PROOF STATE]
proof (prove)
using this:
\<not> ((ll, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)})
j < k

goal (1 subgoal):
 1. (if (ll, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> ll \<and> ll \<le> i_end \<and> k < j then A $$ (ll, j) - quot * A $$ (l + ll - i_end, j) else if (ll, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (ll, j)) = A $$ (ll, j)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B $$ (ll, j) = A $$ (ll, j)

goal (2 subgoals):
 1. (i, j) = (ii, Suc ll) \<and> iter \<noteq> 0 \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
 2. \<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
have "?C $$ (i,j) = quot - quot * A $$ (ll, Suc ll)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = quot - quot * A $$ (ll, Suc ll)
[PROOF STEP]
unfolding C B
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if i = ii \<and> j = ll then quot + quot * A $$ (i, i) - quot * quot * B $$ (j, i) - quot * A $$ (j, j) else if i = ii \<and> j \<noteq> ll then quot - quot * B $$ (ll, j) else if i \<noteq> ii \<and> j = ll then quot + quot * B $$ (i, ii) else quot) = quot - quot * A $$ (ll, Suc ll)
[PROOF STEP]
using * B'
[PROOF STATE]
proof (prove)
using this:
i = ii
j = Suc ll
iter \<noteq> 0
B $$ (ll, j) = A $$ (ll, j)

goal (1 subgoal):
 1. (if i = ii \<and> j = ll then quot + quot * A $$ (i, i) - quot * quot * B $$ (j, i) - quot * A $$ (j, j) else if i = ii \<and> j \<noteq> ll then quot - quot * B $$ (ll, j) else if i \<noteq> ii \<and> j = ll then quot + quot * B $$ (i, ii) else quot) = quot - quot * A $$ (ll, Suc ll)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = quot - quot * A $$ (ll, Suc ll)

goal (2 subgoals):
 1. (i, j) = (ii, Suc ll) \<and> iter \<noteq> 0 \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
 2. \<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
with iblock(3)[OF lbl \<open>lb \<le> ll\<close> \<open>ll < l\<close>]
[PROOF STATE]
proof (chain)
picking this:
A $$ (ll, Suc ll) = (1::'a)
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = quot - quot * A $$ (ll, Suc ll)
[PROOF STEP]
have C: "?C $$ (i,j) = 0"
[PROOF STATE]
proof (prove)
using this:
A $$ (ll, Suc ll) = (1::'a)
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = quot - quot * A $$ (ll, Suc ll)

goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)

goal (2 subgoals):
 1. (i, j) = (ii, Suc ll) \<and> iter \<noteq> 0 \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
 2. \<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = (0::'a)

goal (2 subgoals):
 1. (i, j) = (ii, Suc ll) \<and> iter \<noteq> 0 \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
 2. \<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
assume "A $$ (ii, Suc ll) \<noteq> 0"
[PROOF STATE]
proof (state)
this:
A $$ (ii, Suc ll) \<noteq> (0::'a)

goal (2 subgoals):
 1. (i, j) = (ii, Suc ll) \<and> iter \<noteq> 0 \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
 2. \<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
with jb[OF \<open>ii < n\<close> \<open>Suc ll < n\<close> \<open>Suc ll < k\<close>] \<open>ii \<noteq> ll\<close>
[PROOF STATE]
proof (chain)
picking this:
(Suc ii = Suc ll \<longrightarrow> A $$ (ii, Suc ll) \<in> {0::'a, 1::'a}) \<and> (ii \<noteq> Suc ll \<longrightarrow> Suc ii \<noteq> Suc ll \<or> A $$ (ii, ii) \<noteq> A $$ (Suc ll, Suc ll) \<longrightarrow> A $$ (ii, Suc ll) = (0::'a))
ii \<noteq> ll
A $$ (ii, Suc ll) \<noteq> (0::'a)
[PROOF STEP]
have "ii = Suc ll"
[PROOF STATE]
proof (prove)
using this:
(Suc ii = Suc ll \<longrightarrow> A $$ (ii, Suc ll) \<in> {0::'a, 1::'a}) \<and> (ii \<noteq> Suc ll \<longrightarrow> Suc ii \<noteq> Suc ll \<or> A $$ (ii, ii) \<noteq> A $$ (Suc ll, Suc ll) \<longrightarrow> A $$ (ii, Suc ll) = (0::'a))
ii \<noteq> ll
A $$ (ii, Suc ll) \<noteq> (0::'a)

goal (1 subgoal):
 1. ii = Suc ll
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ii = Suc ll

goal (2 subgoals):
 1. (i, j) = (ii, Suc ll) \<and> iter \<noteq> 0 \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
 2. \<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
with eqs
[PROOF STATE]
proof (chain)
picking this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
ii = Suc ll
[PROOF STEP]
have "i_end - iter = Suc l - iter"
[PROOF STATE]
proof (prove)
using this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
ii = Suc ll

goal (1 subgoal):
 1. i_end - iter = Suc l - iter
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i_end - iter = Suc l - iter

goal (2 subgoals):
 1. (i, j) = (ii, Suc ll) \<and> iter \<noteq> 0 \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
 2. \<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
from block[OF this] \<open>iter \<noteq> 0\<close> \<open>iter \<noteq> Suc ?idiff\<close> eqs large
[PROOF STATE]
proof (chain)
picking this:
i_begin = i_end
iter \<noteq> 0
iter \<noteq> Suc (i_end - i_begin)
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_end - i_begin \<le> l - lb
[PROOF STEP]
have False
[PROOF STATE]
proof (prove)
using this:
i_begin = i_end
iter \<noteq> 0
iter \<noteq> Suc (i_end - i_begin)
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_end - i_begin \<le> l - lb

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

goal (2 subgoals):
 1. (i, j) = (ii, Suc ll) \<and> iter \<noteq> 0 \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
 2. \<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
A $$ (ii, Suc ll) \<noteq> (0::'a) \<Longrightarrow> False

goal (2 subgoals):
 1. (i, j) = (ii, Suc ll) \<and> iter \<noteq> 0 \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
 2. \<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
hence "A $$ (ii,Suc ll) = 0"
[PROOF STATE]
proof (prove)
using this:
A $$ (ii, Suc ll) \<noteq> (0::'a) \<Longrightarrow> False

goal (1 subgoal):
 1. A $$ (ii, Suc ll) = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A $$ (ii, Suc ll) = (0::'a)

goal (2 subgoals):
 1. (i, j) = (ii, Suc ll) \<and> iter \<noteq> 0 \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
 2. \<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
A $$ (ii, Suc ll) = (0::'a)

goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
unfolding C
[PROOF STATE]
proof (prove)
using this:
A $$ (ii, Suc ll) = (0::'a)

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

goal (1 subgoal):
 1. (0::'a) = A $$ (ii, Suc ll)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)

goal (1 subgoal):
 1. \<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0)

goal (1 subgoal):
 1. \<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
hence B: "B $$ (i,j) = ?Aij"
[PROOF STATE]
proof (prove)
using this:
\<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0)

goal (1 subgoal):
 1. B $$ (i, j) = A $$ (i, j)
[PROOF STEP]
unfolding B
[PROOF STATE]
proof (prove)
using this:
\<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0)

goal (1 subgoal):
 1. (if (i, j) = (ii, Suc ll) \<and> iter \<noteq> 0 then quot else A $$ (i, j)) = A $$ (i, j)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B $$ (i, j) = A $$ (i, j)

goal (1 subgoal):
 1. \<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
from eqs index
[PROOF STATE]
proof (chain)
picking this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
[PROOF STEP]
have "lb \<le> ll" "ll \<le> l"
[PROOF STATE]
proof (prove)
using this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k

goal (1 subgoal):
 1. lb \<le> ll &&& ll \<le> l
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
lb \<le> ll
ll \<le> l

goal (1 subgoal):
 1. \<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
note index = index this ll_i
[PROOF STATE]
proof (state)
this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
lb \<le> ll
ll \<le> l
ll \<noteq> i_end - iter

goal (1 subgoal):
 1. \<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
from evb[of ll k] index
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>ll < n; k < n\<rbrakk> \<Longrightarrow> A $$ (ll, ll) = A $$ (k, k)
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
lb \<le> ll
ll \<le> l
ll \<noteq> i_end - iter
[PROOF STEP]
have evl: "?ev ll = ?ev k"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>ll < n; k < n\<rbrakk> \<Longrightarrow> A $$ (ll, ll) = A $$ (k, k)
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
lb \<le> ll
ll \<le> l
ll \<noteq> i_end - iter

goal (1 subgoal):
 1. A $$ (ll, ll) = A $$ (k, k)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A $$ (ll, ll) = A $$ (k, k)

goal (1 subgoal):
 1. \<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
from evb[of i k] index
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>i < n; k < n\<rbrakk> \<Longrightarrow> A $$ (i, i) = A $$ (k, k)
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
lb \<le> ll
ll \<le> l
ll \<noteq> i_end - iter
[PROOF STEP]
have evi: "?ev i = ?ev k"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>i < n; k < n\<rbrakk> \<Longrightarrow> A $$ (i, i) = A $$ (k, k)
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
lb \<le> ll
ll \<le> l
ll \<noteq> i_end - iter

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

goal (1 subgoal):
 1. \<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
from not
[PROOF STATE]
proof (chain)
picking this:
\<not> (i = ii - 1 \<and> j = ll \<and> iter \<noteq> i_end - i_begin)
[PROOF STEP]
have not: "i \<noteq> ii - 1 \<or> j \<noteq> ll \<or> iter = ?idiff"
[PROOF STATE]
proof (prove)
using this:
\<not> (i = ii - 1 \<and> j = ll \<and> iter \<noteq> i_end - i_begin)

goal (1 subgoal):
 1. i \<noteq> ii - 1 \<or> j \<noteq> ll \<or> iter = i_end - i_begin
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i \<noteq> ii - 1 \<or> j \<noteq> ll \<or> iter = i_end - i_begin

goal (1 subgoal):
 1. \<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
from False
[PROOF STATE]
proof (chain)
picking this:
\<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0)
[PROOF STEP]
have not2: "i \<noteq> ii \<or> j \<noteq> Suc ll \<or> iter = 0"
[PROOF STATE]
proof (prove)
using this:
\<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0)

goal (1 subgoal):
 1. i \<noteq> ii \<or> j \<noteq> Suc ll \<or> iter = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i \<noteq> ii \<or> j \<noteq> Suc ll \<or> iter = 0

goal (1 subgoal):
 1. \<not> ((i, j) = (ii, Suc ll) \<and> iter \<noteq> 0) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
proof (cases "i = ii")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i = ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
 2. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
i = ii

goal (2 subgoals):
 1. i = ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
 2. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
let ?diff = "if j = ll then 0 else - quot * A $$ (ll, j)"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i = ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
 2. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
have Bli: "B $$ (ll, i) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B $$ (ll, i) = (0::'a)
[PROOF STEP]
using True Bli
[PROOF STATE]
proof (prove)
using this:
i = ii
B $$ (ll, ii) = (0::'a)

goal (1 subgoal):
 1. B $$ (ll, i) = (0::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
B $$ (ll, i) = (0::'a)

goal (2 subgoals):
 1. i = ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
 2. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
have Blj: "B $$ (ll, j) = A $$ (ll,j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B $$ (ll, j) = A $$ (ll, j)
[PROOF STEP]
unfolding BB[OF \<open>ll < n\<close> \<open>j < n\<close>]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if (ll, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> ll \<and> ll \<le> i_end \<and> k < j then A $$ (ll, j) - quot * A $$ (l + ll - i_end, j) else if (ll, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (ll, j)) = A $$ (ll, j)
[PROOF STEP]
using index jk
[PROOF STATE]
proof (prove)
using this:
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
lb \<le> ll
ll \<le> l
ll \<noteq> i_end - iter
j < k

goal (1 subgoal):
 1. (if (ll, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> ll \<and> ll \<le> i_end \<and> k < j then A $$ (ll, j) - quot * A $$ (l + ll - i_end, j) else if (ll, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (ll, j)) = A $$ (ll, j)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B $$ (ll, j) = A $$ (ll, j)

goal (2 subgoals):
 1. i = ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
 2. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
from True
[PROOF STATE]
proof (chain)
picking this:
i = ii
[PROOF STEP]
have C: "?C $$ (i,j) = ?Aij + ?diff"
[PROOF STATE]
proof (prove)
using this:
i = ii

goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j) + (if j = ll then 0::'a else - quot * A $$ (ll, j))
[PROOF STEP]
unfolding C B evi
[PROOF STATE]
proof (prove)
using this:
i = ii

goal (1 subgoal):
 1. (if i = ii \<and> j = ll then A $$ (i, j) + quot * A $$ (k, k) - quot * quot * B $$ (j, i) - quot * A $$ (j, j) else if i = ii \<and> j \<noteq> ll then A $$ (i, j) - quot * B $$ (ll, j) else if i \<noteq> ii \<and> j = ll then A $$ (i, j) + quot * B $$ (i, ii) else A $$ (i, j)) = A $$ (i, j) + (if j = ll then 0::'a else - quot * A $$ (ll, j))
[PROOF STEP]
using Bli Blj evl
[PROOF STATE]
proof (prove)
using this:
i = ii
B $$ (ll, i) = (0::'a)
B $$ (ll, j) = A $$ (ll, j)
A $$ (ll, ll) = A $$ (k, k)

goal (1 subgoal):
 1. (if i = ii \<and> j = ll then A $$ (i, j) + quot * A $$ (k, k) - quot * quot * B $$ (j, i) - quot * A $$ (j, j) else if i = ii \<and> j \<noteq> ll then A $$ (i, j) - quot * B $$ (ll, j) else if i \<noteq> ii \<and> j = ll then A $$ (i, j) + quot * B $$ (i, ii) else A $$ (i, j)) = A $$ (i, j) + (if j = ll then 0::'a else - quot * A $$ (ll, j))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j) + (if j = ll then 0::'a else - quot * A $$ (ll, j))

goal (2 subgoals):
 1. i = ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
 2. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j) + (if j = ll then 0::'a else - quot * A $$ (ll, j))

goal (2 subgoals):
 1. i = ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
 2. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
have "?diff = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if j = ll then 0::'a else - quot * A $$ (ll, j)) = (0::'a)
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (if j = ll then 0::'a else - quot * A $$ (ll, j)) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
assume "?diff \<noteq> 0"
[PROOF STATE]
proof (state)
this:
(if j = ll then 0::'a else - quot * A $$ (ll, j)) \<noteq> (0::'a)

goal (1 subgoal):
 1. (if j = ll then 0::'a else - quot * A $$ (ll, j)) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
hence jl: "j \<noteq> ll" and Alj: "A $$ (ll,j) \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
(if j = ll then 0::'a else - quot * A $$ (ll, j)) \<noteq> (0::'a)

goal (1 subgoal):
 1. j \<noteq> ll &&& A $$ (ll, j) \<noteq> (0::'a)
[PROOF STEP]
by (auto split: if_splits)
[PROOF STATE]
proof (state)
this:
j \<noteq> ll
A $$ (ll, j) \<noteq> (0::'a)

goal (1 subgoal):
 1. (if j = ll then 0::'a else - quot * A $$ (ll, j)) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
with jb[OF \<open>ll < n\<close> \<open>j < n\<close> jk]
[PROOF STATE]
proof (chain)
picking this:
(Suc ll = j \<longrightarrow> A $$ (ll, j) \<in> {0::'a, 1::'a}) \<and> (ll \<noteq> j \<longrightarrow> Suc ll \<noteq> j \<or> A $$ (ll, ll) \<noteq> A $$ (j, j) \<longrightarrow> A $$ (ll, j) = (0::'a))
j \<noteq> ll
A $$ (ll, j) \<noteq> (0::'a)
[PROOF STEP]
have "j = Suc ll" "?ev ll = ?ev j"
[PROOF STATE]
proof (prove)
using this:
(Suc ll = j \<longrightarrow> A $$ (ll, j) \<in> {0::'a, 1::'a}) \<and> (ll \<noteq> j \<longrightarrow> Suc ll \<noteq> j \<or> A $$ (ll, ll) \<noteq> A $$ (j, j) \<longrightarrow> A $$ (ll, j) = (0::'a))
j \<noteq> ll
A $$ (ll, j) \<noteq> (0::'a)

goal (1 subgoal):
 1. j = Suc ll &&& A $$ (ll, ll) = A $$ (j, j)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j = Suc ll
A $$ (ll, ll) = A $$ (j, j)

goal (1 subgoal):
 1. (if j = ll then 0::'a else - quot * A $$ (ll, j)) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
with not2 True
[PROOF STATE]
proof (chain)
picking this:
i \<noteq> ii \<or> j \<noteq> Suc ll \<or> iter = 0
i = ii
j = Suc ll
A $$ (ll, ll) = A $$ (j, j)
[PROOF STEP]
have "iter = 0"
[PROOF STATE]
proof (prove)
using this:
i \<noteq> ii \<or> j \<noteq> Suc ll \<or> iter = 0
i = ii
j = Suc ll
A $$ (ll, ll) = A $$ (j, j)

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

goal (1 subgoal):
 1. (if j = ll then 0::'a else - quot * A $$ (ll, j)) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
with eqs index jk
[PROOF STATE]
proof (chain)
picking this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
lb \<le> ll
ll \<le> l
ll \<noteq> i_end - iter
j < k
iter = 0
[PROOF STEP]
have id: "A $$ (ll, j) = A $$ (l, Suc l)" and
                          "j = Suc l" "Suc l < k" "ll = l"
[PROOF STATE]
proof (prove)
using this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
lb \<le> ll
ll \<le> l
ll \<noteq> i_end - iter
j < k
iter = 0

goal (1 subgoal):
 1. A $$ (ll, j) = A $$ (l, Suc l) &&& j = Suc l &&& Suc l < k &&& ll = l
[PROOF STEP]
unfolding \<open>j = Suc ll\<close>
[PROOF STATE]
proof (prove)
using this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
Suc ll < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
lb \<le> ll
ll \<le> l
ll \<noteq> i_end - iter
Suc ll < k
iter = 0

goal (1 subgoal):
 1. A $$ (ll, Suc ll) = A $$ (l, Suc l) &&& Suc ll = Suc l &&& Suc l < k &&& ll = l
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A $$ (ll, j) = A $$ (l, Suc l)
j = Suc l
Suc l < k
ll = l

goal (1 subgoal):
 1. (if j = ll then 0::'a else - quot * A $$ (ll, j)) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
from iblock[OF lbl] \<open>Suc l < k\<close>
[PROOF STATE]
proof (chain)
picking this:
lb \<le> l
l < k
\<lbrakk>lb \<le> ?l; ?l < l\<rbrakk> \<Longrightarrow> A $$ (?l, Suc ?l) = (1::'a)
Suc l \<noteq> k \<Longrightarrow> A $$ (l, Suc l) \<noteq> (1::'a)
0 < lb \<Longrightarrow> A $$ (lb - 1, lb - 1) \<noteq> A $$ (k, k) \<or> A $$ (lb - 1, lb) \<noteq> (1::'a)
Suc l < k
[PROOF STEP]
have "A $$ (l, Suc l) \<noteq> 1"
[PROOF STATE]
proof (prove)
using this:
lb \<le> l
l < k
\<lbrakk>lb \<le> ?l; ?l < l\<rbrakk> \<Longrightarrow> A $$ (?l, Suc ?l) = (1::'a)
Suc l \<noteq> k \<Longrightarrow> A $$ (l, Suc l) \<noteq> (1::'a)
0 < lb \<Longrightarrow> A $$ (lb - 1, lb - 1) \<noteq> A $$ (k, k) \<or> A $$ (lb - 1, lb) \<noteq> (1::'a)
Suc l < k

goal (1 subgoal):
 1. A $$ (l, Suc l) \<noteq> (1::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A $$ (l, Suc l) \<noteq> (1::'a)

goal (1 subgoal):
 1. (if j = ll then 0::'a else - quot * A $$ (ll, j)) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
from jb[OF \<open>l < n\<close> \<open>j < n\<close> jk] Alj this
[PROOF STATE]
proof (chain)
picking this:
(Suc l = j \<longrightarrow> A $$ (l, j) \<in> {0::'a, 1::'a}) \<and> (l \<noteq> j \<longrightarrow> Suc l \<noteq> j \<or> A $$ (l, l) \<noteq> A $$ (j, j) \<longrightarrow> A $$ (l, j) = (0::'a))
A $$ (ll, j) \<noteq> (0::'a)
A $$ (l, Suc l) \<noteq> (1::'a)
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
(Suc l = j \<longrightarrow> A $$ (l, j) \<in> {0::'a, 1::'a}) \<and> (l \<noteq> j \<longrightarrow> Suc l \<noteq> j \<or> A $$ (l, l) \<noteq> A $$ (j, j) \<longrightarrow> A $$ (l, j) = (0::'a))
A $$ (ll, j) \<noteq> (0::'a)
A $$ (l, Suc l) \<noteq> (1::'a)

goal (1 subgoal):
 1. False
[PROOF STEP]
unfolding \<open>j = Suc l\<close> \<open>ll = l\<close>
[PROOF STATE]
proof (prove)
using this:
(Suc l = Suc l \<longrightarrow> A $$ (l, Suc l) \<in> {0::'a, 1::'a}) \<and> (l \<noteq> Suc l \<longrightarrow> Suc l \<noteq> Suc l \<or> A $$ (l, l) \<noteq> A $$ (Suc l, Suc l) \<longrightarrow> A $$ (l, Suc l) = (0::'a))
A $$ (l, Suc l) \<noteq> (0::'a)
A $$ (l, Suc l) \<noteq> (1::'a)

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(if j = ll then 0::'a else - quot * A $$ (ll, j)) = (0::'a)

goal (2 subgoals):
 1. i = ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
 2. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
add_col_sub_row quot ii ll (mat n n (\<lambda>a. case a of (i, j) \<Rightarrow> if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j) + (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
add_col_sub_row quot ii ll (mat n n (\<lambda>a. case a of (i, j) \<Rightarrow> if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j) + (0::'a)

goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)

goal (1 subgoal):
 1. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
i \<noteq> ii

goal (1 subgoal):
 1. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
let ?diff = "if j = ll then quot * B $$ (i, ii) else 0"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
from False
[PROOF STATE]
proof (chain)
picking this:
i \<noteq> ii
[PROOF STEP]
have C: "?C $$ (i,j) = ?Aij + ?diff"
[PROOF STATE]
proof (prove)
using this:
i \<noteq> ii

goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j) + (if j = ll then quot * B $$ (i, ii) else (0::'a))
[PROOF STEP]
unfolding C B
[PROOF STATE]
proof (prove)
using this:
i \<noteq> ii

goal (1 subgoal):
 1. (if i = ii \<and> j = ll then A $$ (i, j) + quot * A $$ (i, i) - quot * quot * B $$ (j, i) - quot * A $$ (j, j) else if i = ii \<and> j \<noteq> ll then A $$ (i, j) - quot * B $$ (ll, j) else if i \<noteq> ii \<and> j = ll then A $$ (i, j) + quot * B $$ (i, ii) else A $$ (i, j)) = A $$ (i, j) + (if j = ll then quot * B $$ (i, ii) else (0::'a))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j) + (if j = ll then quot * B $$ (i, ii) else (0::'a))

goal (1 subgoal):
 1. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j) + (if j = ll then quot * B $$ (i, ii) else (0::'a))

goal (1 subgoal):
 1. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
have "?diff = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if j = ll then quot * B $$ (i, ii) else (0::'a)) = (0::'a)
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (if j = ll then quot * B $$ (i, ii) else (0::'a)) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
assume "?diff \<noteq> 0"
[PROOF STATE]
proof (state)
this:
(if j = ll then quot * B $$ (i, ii) else (0::'a)) \<noteq> (0::'a)

goal (1 subgoal):
 1. (if j = ll then quot * B $$ (i, ii) else (0::'a)) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
hence j: "j = ll" and Bi: "B $$ (i, ii) \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
(if j = ll then quot * B $$ (i, ii) else (0::'a)) \<noteq> (0::'a)

goal (1 subgoal):
 1. j = ll &&& B $$ (i, ii) \<noteq> (0::'a)
[PROOF STEP]
by (auto split: if_splits)
[PROOF STATE]
proof (state)
this:
j = ll
B $$ (i, ii) \<noteq> (0::'a)

goal (1 subgoal):
 1. (if j = ll then quot * B $$ (i, ii) else (0::'a)) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
from eqs
[PROOF STATE]
proof (chain)
picking this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
[PROOF STEP]
have ii: "i_end - iter = ii"
[PROOF STATE]
proof (prove)
using this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)

goal (1 subgoal):
 1. i_end - iter = ii
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i_end - iter = ii

goal (1 subgoal):
 1. (if j = ll then quot * B $$ (i, ii) else (0::'a)) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
have Bii: "B $$ (i,ii) = A $$ (i, ii)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B $$ (i, ii) = A $$ (i, ii)
[PROOF STEP]
unfolding BB[OF \<open>i < n\<close> \<open>ii < n\<close>]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if (i, ii) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < ii then A $$ (i, ii) - quot * A $$ (l + i - i_end, ii) else if (i, ii) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, ii)) = A $$ (i, ii)
[PROOF STEP]
using \<open>ii < k\<close> iter ii False
[PROOF STATE]
proof (prove)
using this:
ii < k
iter \<noteq> Suc (i_end - i_begin)
i_end - iter = ii
i \<noteq> ii

goal (1 subgoal):
 1. (if (i, ii) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < ii then A $$ (i, ii) - quot * A $$ (l + i - i_end, ii) else if (i, ii) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, ii)) = A $$ (i, ii)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B $$ (i, ii) = A $$ (i, ii)

goal (1 subgoal):
 1. (if j = ll then quot * B $$ (i, ii) else (0::'a)) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
from Bi Bii
[PROOF STATE]
proof (chain)
picking this:
B $$ (i, ii) \<noteq> (0::'a)
B $$ (i, ii) = A $$ (i, ii)
[PROOF STEP]
have Ai: "A $$ (i,ii) \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
B $$ (i, ii) \<noteq> (0::'a)
B $$ (i, ii) = A $$ (i, ii)

goal (1 subgoal):
 1. A $$ (i, ii) \<noteq> (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A $$ (i, ii) \<noteq> (0::'a)

goal (1 subgoal):
 1. (if j = ll then quot * B $$ (i, ii) else (0::'a)) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
from jb[OF \<open>i < n\<close> \<open>ii < n\<close> \<open>ii < k\<close>] False Ai
[PROOF STATE]
proof (chain)
picking this:
(Suc i = ii \<longrightarrow> A $$ (i, ii) \<in> {0::'a, 1::'a}) \<and> (i \<noteq> ii \<longrightarrow> Suc i \<noteq> ii \<or> A $$ (i, i) \<noteq> A $$ (ii, ii) \<longrightarrow> A $$ (i, ii) = (0::'a))
i \<noteq> ii
A $$ (i, ii) \<noteq> (0::'a)
[PROOF STEP]
have ii: "ii = Suc i"
                          and Ai: "A $$ (i,ii) = 1"
[PROOF STATE]
proof (prove)
using this:
(Suc i = ii \<longrightarrow> A $$ (i, ii) \<in> {0::'a, 1::'a}) \<and> (i \<noteq> ii \<longrightarrow> Suc i \<noteq> ii \<or> A $$ (i, i) \<noteq> A $$ (ii, ii) \<longrightarrow> A $$ (i, ii) = (0::'a))
i \<noteq> ii
A $$ (i, ii) \<noteq> (0::'a)

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

goal (1 subgoal):
 1. (if j = ll then quot * B $$ (i, ii) else (0::'a)) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
from not ii j
[PROOF STATE]
proof (chain)
picking this:
i \<noteq> ii - 1 \<or> j \<noteq> ll \<or> iter = i_end - i_begin
ii = Suc i
j = ll
[PROOF STEP]
have iter: "iter = ?idiff"
[PROOF STATE]
proof (prove)
using this:
i \<noteq> ii - 1 \<or> j \<noteq> ll \<or> iter = i_end - i_begin
ii = Suc i
j = ll

goal (1 subgoal):
 1. iter = i_end - i_begin
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
iter = i_end - i_begin

goal (1 subgoal):
 1. (if j = ll then quot * B $$ (i, ii) else (0::'a)) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
with eqs index
[PROOF STATE]
proof (chain)
picking this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
lb \<le> ll
ll \<le> l
ll \<noteq> i_end - iter
iter = i_end - i_begin
[PROOF STEP]
have "ii = i_begin"
[PROOF STATE]
proof (prove)
using this:
ii + iter = i_end
ll + iter = l
Suc diff + iter = Suc (i_end - i_begin)
i_begin \<le> i_end
i_end < k
lb \<le> l
l < k
k < n
i < n
j < n
ll < n
i_end \<noteq> l
i_end - i_begin \<le> l - lb
i_begin \<le> ii
ii < n
ii < k
ii \<le> i_end
ll < k
l < n
i_begin \<le> i
i \<le> i_end
i < k
lb \<le> ll
ll \<le> l
ll \<noteq> i_end - iter
iter = i_end - i_begin

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

goal (1 subgoal):
 1. (if j = ll then quot * B $$ (i, ii) else (0::'a)) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
with ii \<open>i \<ge> i_begin\<close>
[PROOF STATE]
proof (chain)
picking this:
ii = Suc i
i_begin \<le> i
ii = i_begin
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
ii = Suc i
i_begin \<le> i
ii = i_begin

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(if j = ll then quot * B $$ (i, ii) else (0::'a)) = (0::'a)

goal (1 subgoal):
 1. i \<noteq> ii \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
add_col_sub_row quot ii ll (mat n n (\<lambda>a. case a of (i, j) \<Rightarrow> if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j) + (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
add_col_sub_row quot ii ll (mat n n (\<lambda>a. case a of (i, j) \<Rightarrow> if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j) + (0::'a)

goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = A $$ (i, j)

goal (1 subgoal):
 1. diff = 0 \<or> (i, j) \<noteq> (ii - 1, ll) \<Longrightarrow> add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)
[PROOF STEP]
unfolding D C
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A $$ (i, j) = A $$ (i, j)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) $$ (i, j) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)) $$ (i, j)

goal (2 subgoals):
 1. dim_row (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
 2. dim_col (add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))) = n
[PROOF STEP]
qed auto
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))

goal (1 subgoal):
 1. \<And>diff ii ll iter. \<lbrakk>\<And>ii ll iter. \<lbrakk>diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; diff \<noteq> 0 \<Longrightarrow> ll + iter = l; diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii diff (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j)); Suc diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; Suc diff \<noteq> 0 \<Longrightarrow> ll + iter = l; Suc diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii (Suc diff) (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
add_col_sub_row quot ii ll (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))

goal (1 subgoal):
 1. \<And>diff ii ll iter. \<lbrakk>\<And>ii ll iter. \<lbrakk>diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; diff \<noteq> 0 \<Longrightarrow> ll + iter = l; diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii diff (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j)); Suc diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; Suc diff \<noteq> 0 \<Longrightarrow> ll + iter = l; Suc diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii (Suc diff) (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
have "step_3_c_inner_loop quot (ll - 1) (ii - 1) diff \<dots> = ?R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. step_3_c_inner_loop quot (ll - 1) (ii - 1) diff (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
by (rule Suc(1), insert prems large, auto)
[PROOF STATE]
proof (state)
this:
step_3_c_inner_loop quot (ll - 1) (ii - 1) diff (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - Suc iter, Suc l - Suc iter) \<and> Suc iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))

goal (1 subgoal):
 1. \<And>diff ii ll iter. \<lbrakk>\<And>ii ll iter. \<lbrakk>diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; diff \<noteq> 0 \<Longrightarrow> ll + iter = l; diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii diff (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j)); Suc diff \<noteq> 0 \<Longrightarrow> ii + iter = i_end; Suc diff \<noteq> 0 \<Longrightarrow> ll + iter = l; Suc diff + iter = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ll ii (Suc diff) (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
step_3_c_inner_loop quot ll ii (Suc diff) (mat n n (\<lambda>a. case a of (i, j) \<Rightarrow> if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
step_3_c_inner_loop quot ll ii (Suc diff) (mat n n (\<lambda>a. case a of (i, j) \<Rightarrow> if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))

goal (1 subgoal):
 1. step_3_c_inner_loop quot ll ii (Suc diff) (mat n n (\<lambda>a. case a of (i, j) \<Rightarrow> if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>a. case a of (i, j) \<Rightarrow> if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
step_3_c_inner_loop quot ll ii (Suc diff) (mat n n (\<lambda>a. case a of (i, j) \<Rightarrow> if (i, j) = (i_end, k) then if Suc diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>a. case a of (i, j) \<Rightarrow> if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
step_3_c_inner_loop quot ll ii diff (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if diff = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + diff \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - iter, Suc l - iter) \<and> iter \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))

goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc i_end - i_begin) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>?diff2 \<noteq> 0 \<Longrightarrow> ?ii2 + ?iter2 = i_end; ?diff2 \<noteq> 0 \<Longrightarrow> ?ll2 + ?iter2 = l; ?diff2 + ?iter2 = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot ?ll2 ?ii2 ?diff2 (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if ?diff2 = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + ?diff2 \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - ?iter2, Suc l - ?iter2) \<and> ?iter2 \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))

goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc i_end - i_begin) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
note main = this[of "Suc ?idiff" i_end 0 l]
[PROOF STATE]
proof (state)
this:
\<lbrakk>Suc (i_end - i_begin) \<noteq> 0 \<Longrightarrow> i_end + 0 = i_end; Suc (i_end - i_begin) \<noteq> 0 \<Longrightarrow> l + 0 = l; Suc (i_end - i_begin) + 0 = Suc (i_end - i_begin)\<rbrakk> \<Longrightarrow> step_3_c_inner_loop quot l i_end (Suc (i_end - i_begin)) (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc (i_end - i_begin) = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc (i_end - i_begin) \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - 0, Suc l - 0) \<and> 0 \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))

goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc i_end - i_begin) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
from ib
[PROOF STATE]
proof (chain)
picking this:
i_begin \<le> i_end
i_end < k
[PROOF STEP]
have suc: "Suc i_end - i_begin = Suc ?idiff"
[PROOF STATE]
proof (prove)
using this:
i_begin \<le> i_end
i_end < k

goal (1 subgoal):
 1. Suc i_end - i_begin = Suc (i_end - i_begin)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Suc i_end - i_begin = Suc (i_end - i_begin)

goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc i_end - i_begin) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
have "step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc ?idiff) A
    = step_3_c_inner_loop quot l i_end (Suc ?idiff) (?mat 0 (Suc ?idiff))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc (i_end - i_begin)) A = step_3_c_inner_loop quot l i_end (Suc (i_end - i_begin)) (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc (i_end - i_begin) = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc (i_end - i_begin) \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - 0, Suc l - 0) \<and> 0 \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))
[PROOF STEP]
unfolding mend
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc (i_end - i_begin)) A = step_3_c_inner_loop quot l i_end (Suc (i_end - i_begin)) A
[PROOF STEP]
unfolding quot_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc (i_end - i_begin)) A = step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc (i_end - i_begin)) A
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc (i_end - i_begin)) A = step_3_c_inner_loop quot l i_end (Suc (i_end - i_begin)) (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc (i_end - i_begin) = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc (i_end - i_begin) \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - 0, Suc l - 0) \<and> 0 \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))

goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc i_end - i_begin) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc (i_end - i_begin)) A = step_3_c_inner_loop quot l i_end (Suc (i_end - i_begin)) (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc (i_end - i_begin) = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc (i_end - i_begin) \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - 0, Suc l - 0) \<and> 0 \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j)))

goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc i_end - i_begin) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
have "\<dots> = ?R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. step_3_c_inner_loop quot l i_end (Suc (i_end - i_begin)) (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc (i_end - i_begin) = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc (i_end - i_begin) \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - 0, Suc l - 0) \<and> 0 \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
by (rule main, auto)
[PROOF STATE]
proof (state)
this:
step_3_c_inner_loop quot l i_end (Suc (i_end - i_begin)) (mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then if Suc (i_end - i_begin) = Suc (i_end - i_begin) then A $$ (i_end, k) else (0::'a) else if i_begin + Suc (i_end - i_begin) \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - quot * A $$ (l + i - i_end, j) else if (i, j) = (i_end - 0, Suc l - 0) \<and> 0 \<notin> {0, Suc (i_end - i_begin)} then quot else A $$ (i, j))) = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))

goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc i_end - i_begin) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc (i_end - i_begin)) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc (i_end - i_begin)) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))

goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc i_end - i_begin) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
unfolding suc
[PROOF STATE]
proof (prove)
using this:
step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc (i_end - i_begin)) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))

goal (1 subgoal):
 1. step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc (i_end - i_begin)) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
step_3_c_inner_loop (A $$ (i_end, k) / A $$ (l, k)) l i_end (Suc i_end - i_begin) A = mat n n (\<lambda>(i, j). if (i, j) = (i_end, k) then 0::'a else if i_begin \<le> i \<and> i \<le> i_end \<and> k < j then A $$ (i, j) - A $$ (i_end, k) / A $$ (l, k) * A $$ (l + i - i_end, j) else A $$ (i, j))

goal:
No subgoals!
[PROOF STEP]
qed