[STATEMENT]
lemma step_3_main_inv: "A \<in> carrier_mat n n
  \<Longrightarrow> k > 0
  \<Longrightarrow> inv_all uppert A
  \<Longrightarrow> ev_block n A
  \<Longrightarrow> inv_upto jb A k
  \<Longrightarrow> inv_all jb (step_3_main n k A) \<and> same_diag A (step_3_main n k A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A \<in> carrier_mat n n; 0 < k; local.inv_all local.uppert A; local.ev_block n A; inv_upto local.jb A k\<rbrakk> \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
proof (induct k A taking: n rule: step_3_main.induct)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>k A. \<lbrakk>\<And>x xa xb xaa. \<lbrakk>\<not> n \<le> k; x = step_3_a (k - 1) k A; xa = identify_blocks x k; xb = filter (\<lambda>block. x $$ (snd block, k) \<noteq> (0::'a)) xa; xaa = (if xb = [] then x else let (l_start, l) = find_largest_block (hd xb) (tl xb); xa = x $$ (l, k); C = step_3_c xa l k xb x; D = mult_col_div_row (inverse xa) k C; E = swap_cols_rows_block (Suc l) k D in E); xaa \<in> carrier_mat n n; 0 < Suc k; local.inv_all local.uppert xaa; local.ev_block n xaa; inv_upto local.jb xaa (Suc k)\<rbrakk> \<Longrightarrow> local.inv_all local.jb (step_3_main n (Suc k) xaa) \<and> local.same_diag xaa (step_3_main n (Suc k) xaa); A \<in> carrier_mat n n; 0 < k; local.inv_all local.uppert A; local.ev_block n A; inv_upto local.jb A k\<rbrakk> \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
case (1 k A)
[PROOF STATE]
proof (state)
this:
\<lbrakk>\<not> n \<le> k; ?x = step_3_a (k - 1) k A; ?xa = identify_blocks ?x k; ?xb = filter (\<lambda>block. ?x $$ (snd block, k) \<noteq> (0::'a)) ?xa; ?xaa = (if ?xb = [] then ?x else let (l_start, l) = find_largest_block (hd ?xb) (tl ?xb); x = ?x $$ (l, k); C = step_3_c x l k ?xb ?x; D = mult_col_div_row (inverse x) k C; E = swap_cols_rows_block (Suc l) k D in E); ?xaa \<in> carrier_mat n n; 0 < Suc k; local.inv_all local.uppert ?xaa; local.ev_block n ?xaa; inv_upto local.jb ?xaa (Suc k)\<rbrakk> \<Longrightarrow> local.inv_all local.jb (step_3_main n (Suc k) ?xaa) \<and> local.same_diag ?xaa (step_3_main n (Suc k) ?xaa)
A \<in> carrier_mat n n
0 < k
local.inv_all local.uppert A
local.ev_block n A
inv_upto local.jb A k

goal (1 subgoal):
 1. \<And>k A. \<lbrakk>\<And>x xa xb xaa. \<lbrakk>\<not> n \<le> k; x = step_3_a (k - 1) k A; xa = identify_blocks x k; xb = filter (\<lambda>block. x $$ (snd block, k) \<noteq> (0::'a)) xa; xaa = (if xb = [] then x else let (l_start, l) = find_largest_block (hd xb) (tl xb); xa = x $$ (l, k); C = step_3_c xa l k xb x; D = mult_col_div_row (inverse xa) k C; E = swap_cols_rows_block (Suc l) k D in E); xaa \<in> carrier_mat n n; 0 < Suc k; local.inv_all local.uppert xaa; local.ev_block n xaa; inv_upto local.jb xaa (Suc k)\<rbrakk> \<Longrightarrow> local.inv_all local.jb (step_3_main n (Suc k) xaa) \<and> local.same_diag xaa (step_3_main n (Suc k) xaa); A \<in> carrier_mat n n; 0 < k; local.inv_all local.uppert A; local.ev_block n A; inv_upto local.jb A k\<rbrakk> \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
from 1(2-)
[PROOF STATE]
proof (chain)
picking this:
A \<in> carrier_mat n n
0 < k
local.inv_all local.uppert A
local.ev_block n A
inv_upto local.jb A k
[PROOF STEP]
have A: "A \<in> carrier_mat n n" and k: "k > 0" and
    inv: "inv_all uppert A" "ev_block n A" "inv_upto jb A k"
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n n
0 < k
local.inv_all local.uppert A
local.ev_block n A
inv_upto local.jb A k

goal (1 subgoal):
 1. A \<in> carrier_mat n n &&& 0 < k &&& local.inv_all local.uppert A &&& local.ev_block n A &&& inv_upto local.jb A k
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A \<in> carrier_mat n n
0 < k
local.inv_all local.uppert A
local.ev_block n A
inv_upto local.jb A k

goal (1 subgoal):
 1. \<And>k A. \<lbrakk>\<And>x xa xb xaa. \<lbrakk>\<not> n \<le> k; x = step_3_a (k - 1) k A; xa = identify_blocks x k; xb = filter (\<lambda>block. x $$ (snd block, k) \<noteq> (0::'a)) xa; xaa = (if xb = [] then x else let (l_start, l) = find_largest_block (hd xb) (tl xb); xa = x $$ (l, k); C = step_3_c xa l k xb x; D = mult_col_div_row (inverse xa) k C; E = swap_cols_rows_block (Suc l) k D in E); xaa \<in> carrier_mat n n; 0 < Suc k; local.inv_all local.uppert xaa; local.ev_block n xaa; inv_upto local.jb xaa (Suc k)\<rbrakk> \<Longrightarrow> local.inv_all local.jb (step_3_main n (Suc k) xaa) \<and> local.same_diag xaa (step_3_main n (Suc k) xaa); A \<in> carrier_mat n n; 0 < k; local.inv_all local.uppert A; local.ev_block n A; inv_upto local.jb A k\<rbrakk> \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
note [simp] = step_3_main.simps[of n k A]
[PROOF STATE]
proof (state)
this:
step_3_main n k A = (if n \<le> k then A else let B = step_3_a (k - 1) k A; all_blocks = identify_blocks B k; blocks = filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) all_blocks in Let (if blocks = [] then B else let (l_start, l) = find_largest_block (hd blocks) (tl blocks); x = B $$ (l, k); C = step_3_c x l k blocks B; D = mult_col_div_row (inverse x) k C; E = swap_cols_rows_block (Suc l) k D in E) (step_3_main n (Suc k)))

goal (1 subgoal):
 1. \<And>k A. \<lbrakk>\<And>x xa xb xaa. \<lbrakk>\<not> n \<le> k; x = step_3_a (k - 1) k A; xa = identify_blocks x k; xb = filter (\<lambda>block. x $$ (snd block, k) \<noteq> (0::'a)) xa; xaa = (if xb = [] then x else let (l_start, l) = find_largest_block (hd xb) (tl xb); xa = x $$ (l, k); C = step_3_c xa l k xb x; D = mult_col_div_row (inverse xa) k C; E = swap_cols_rows_block (Suc l) k D in E); xaa \<in> carrier_mat n n; 0 < Suc k; local.inv_all local.uppert xaa; local.ev_block n xaa; inv_upto local.jb xaa (Suc k)\<rbrakk> \<Longrightarrow> local.inv_all local.jb (step_3_main n (Suc k) xaa) \<and> local.same_diag xaa (step_3_main n (Suc k) xaa); A \<in> carrier_mat n n; 0 < k; local.inv_all local.uppert A; local.ev_block n A; inv_upto local.jb A k\<rbrakk> \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
proof (cases "k \<ge> n")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
 2. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
n \<le> k

goal (2 subgoals):
 1. n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
 2. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
n \<le> k

goal (1 subgoal):
 1. local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
using inv_uptoD[OF inv(3)]
[PROOF STATE]
proof (prove)
using this:
n \<le> k
\<lbrakk>?i < n; ?j < n; ?j < k\<rbrakk> \<Longrightarrow> local.jb A ?i ?j

goal (1 subgoal):
 1. local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
by (intro conjI inv_allI, auto)
[PROOF STATE]
proof (state)
this:
local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)

goal (1 subgoal):
 1. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> n \<le> k

goal (1 subgoal):
 1. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
hence kn: "k < n"
[PROOF STATE]
proof (prove)
using this:
\<not> n \<le> k

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

goal (1 subgoal):
 1. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
obtain B where B: "B = step_3_a (k - 1) k A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>B. B = step_3_a (k - 1) k A \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B = step_3_a (k - 1) k A

goal (1 subgoal):
 1. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
note IH = 1(1)[OF False B]
[PROOF STATE]
proof (state)
this:
\<lbrakk>?xa = identify_blocks B k; ?xb = filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) ?xa; ?xaa = (if ?xb = [] then B else let (l_start, l) = find_largest_block (hd ?xb) (tl ?xb); x = B $$ (l, k); C = step_3_c x l k ?xb B; D = mult_col_div_row (inverse x) k C; E = swap_cols_rows_block (Suc l) k D in E); ?xaa \<in> carrier_mat n n; 0 < Suc k; local.inv_all local.uppert ?xaa; local.ev_block n ?xaa; inv_upto local.jb ?xaa (Suc k)\<rbrakk> \<Longrightarrow> local.inv_all local.jb (step_3_main n (Suc k) ?xaa) \<and> local.same_diag ?xaa (step_3_main n (Suc k) ?xaa)

goal (1 subgoal):
 1. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
from A
[PROOF STATE]
proof (chain)
picking this:
A \<in> carrier_mat n n
[PROOF STEP]
have Bn: "B \<in> carrier_mat n n"
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n n

goal (1 subgoal):
 1. B \<in> carrier_mat n n
[PROOF STEP]
unfolding B carrier_mat_def
[PROOF STATE]
proof (prove)
using this:
A \<in> {m. dim_row m = n \<and> dim_col m = n}

goal (1 subgoal):
 1. step_3_a (k - 1) k A \<in> {m. dim_row m = n \<and> dim_col m = n}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
B \<in> carrier_mat n n

goal (1 subgoal):
 1. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
from k
[PROOF STATE]
proof (chain)
picking this:
0 < k
[PROOF STEP]
have "k - 1 < k"
[PROOF STATE]
proof (prove)
using this:
0 < k

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

goal (1 subgoal):
 1. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
k - 1 < k

goal (1 subgoal):
 1. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
assume "i < k"
[PROOF STATE]
proof (state)
this:
i < k

goal (1 subgoal):
 1. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
with ev_blockD[OF inv(2) _ \<open>k < n\<close>, of i] \<open>k < n\<close>
[PROOF STATE]
proof (chain)
picking this:
i < n \<Longrightarrow> A $$ (i, i) = A $$ (k, k)
k < n
i < k
[PROOF STEP]
have "A $$ (i,i) = A $$ (k,k)"
[PROOF STATE]
proof (prove)
using this:
i < n \<Longrightarrow> A $$ (i, i) = A $$ (k, k)
k < n
i < k

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> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?i2 < k \<Longrightarrow> A $$ (?i2, ?i2) = A $$ (k, k)

goal (1 subgoal):
 1. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
hence "inv_from_bot (\<lambda>A i. one_zero A i k) A (k - 1)"
[PROOF STATE]
proof (prove)
using this:
?i2 < k \<Longrightarrow> A $$ (?i2, ?i2) = A $$ (k, k)

goal (1 subgoal):
 1. inv_from_bot (\<lambda>A i. one_zero A i k) A (k - 1)
[PROOF STEP]
using inv_all_uppertD[OF inv(1), of k]
[PROOF STATE]
proof (prove)
using this:
?i2 < k \<Longrightarrow> A $$ (?i2, ?i2) = A $$ (k, k)
\<lbrakk>k < ?i; ?i < n\<rbrakk> \<Longrightarrow> A $$ (?i, k) = (0::'a)

goal (1 subgoal):
 1. inv_from_bot (\<lambda>A i. one_zero A i k) A (k - 1)
[PROOF STEP]
unfolding inv_from_bot_def one_zero_def
[PROOF STATE]
proof (prove)
using this:
?i2 < k \<Longrightarrow> A $$ (?i2, ?i2) = A $$ (k, k)
\<lbrakk>k < ?i; ?i < n\<rbrakk> \<Longrightarrow> A $$ (?i, k) = (0::'a)

goal (1 subgoal):
 1. \<forall>i\<ge>k - 1. 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))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
inv_from_bot (\<lambda>A i. one_zero A i k) A (k - 1)

goal (1 subgoal):
 1. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
from step_3_a_inv[OF A \<open>k - 1 < k\<close> \<open>k < n\<close> inv(3) inv_all_imp_inv_from[OF inv(1)]
      this inv(2)] same_diag_ev_block[OF  _ inv(2)]
[PROOF STATE]
proof (chain)
picking this:
inv_from local.uppert (step_3_a (k - 1) k A) k \<and> inv_upto local.jb (step_3_a (k - 1) k A) k \<and> inv_at one_zero (step_3_a (k - 1) k A) k \<and> local.same_diag A (step_3_a (k - 1) k A)
local.same_diag A ?B \<Longrightarrow> local.ev_block n ?B
[PROOF STEP]
have inv: "inv_from uppert B k" "ev_block n B" "inv_upto jb B k"
      "inv_at one_zero B k" and sd: "same_diag A B"
[PROOF STATE]
proof (prove)
using this:
inv_from local.uppert (step_3_a (k - 1) k A) k \<and> inv_upto local.jb (step_3_a (k - 1) k A) k \<and> inv_at one_zero (step_3_a (k - 1) k A) k \<and> local.same_diag A (step_3_a (k - 1) k A)
local.same_diag A ?B \<Longrightarrow> local.ev_block n ?B

goal (1 subgoal):
 1. ((inv_from local.uppert B k &&& local.ev_block n B) &&& inv_upto local.jb B k &&& inv_at one_zero B k) &&& local.same_diag A B
[PROOF STEP]
unfolding B
[PROOF STATE]
proof (prove)
using this:
inv_from local.uppert (step_3_a (k - 1) k A) k \<and> inv_upto local.jb (step_3_a (k - 1) k A) k \<and> inv_at one_zero (step_3_a (k - 1) k A) k \<and> local.same_diag A (step_3_a (k - 1) k A)
local.same_diag A ?B \<Longrightarrow> local.ev_block n ?B

goal (1 subgoal):
 1. ((inv_from local.uppert (step_3_a (k - 1) k A) k &&& local.ev_block n (step_3_a (k - 1) k A)) &&& inv_upto local.jb (step_3_a (k - 1) k A) k &&& inv_at one_zero (step_3_a (k - 1) k A) k) &&& local.same_diag A (step_3_a (k - 1) k A)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
inv_from local.uppert B k
local.ev_block n B
inv_upto local.jb B k
inv_at one_zero B k
local.same_diag A B

goal (1 subgoal):
 1. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
note evb = ev_blockD[OF inv(2)]
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i < n; ?j < n\<rbrakk> \<Longrightarrow> B $$ (?i, ?i) = B $$ (?j, ?j)

goal (1 subgoal):
 1. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
obtain all_blocks where ab: "all_blocks = identify_blocks B k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>all_blocks. all_blocks = identify_blocks B k \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
all_blocks = identify_blocks B k

goal (1 subgoal):
 1. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
obtain blocks where blocks: "blocks = filter (\<lambda> block. B $$ (snd block, k) \<noteq> 0) all_blocks"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>blocks. blocks = filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) all_blocks \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
blocks = filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) all_blocks

goal (1 subgoal):
 1. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
obtain F where F: "F = (if blocks = [] then B
       else let (l_begin,l) = find_largest_block (hd blocks) (tl blocks); x = B $$ (l, k); C = step_3_c x l k blocks B;
            D = mult_col_div_row (inverse x) k C; E = swap_cols_rows_block (Suc l) k D
        in E)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>F. F = (if blocks = [] then B else let (l_begin, l) = find_largest_block (hd blocks) (tl blocks); x = B $$ (l, k); C = step_3_c x l k blocks B; D = mult_col_div_row (inverse x) k C; E = swap_cols_rows_block (Suc l) k D in E) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
F = (if blocks = [] then B else let (l_begin, l) = find_largest_block (hd blocks) (tl blocks); x = B $$ (l, k); C = step_3_c x l k blocks B; D = mult_col_div_row (inverse x) k C; E = swap_cols_rows_block (Suc l) k D in E)

goal (1 subgoal):
 1. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
note IH = IH[OF ab blocks F]
[PROOF STATE]
proof (state)
this:
\<lbrakk>F \<in> carrier_mat n n; 0 < Suc k; local.inv_all local.uppert F; local.ev_block n F; inv_upto local.jb F (Suc k)\<rbrakk> \<Longrightarrow> local.inv_all local.jb (step_3_main n (Suc k) F) \<and> local.same_diag F (step_3_main n (Suc k) F)

goal (1 subgoal):
 1. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
have Fn: "F \<in> carrier_mat n n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. F \<in> carrier_mat n n
[PROOF STEP]
unfolding F Let_def carrier_mat_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if blocks = [] then B else case find_largest_block (hd blocks) (tl blocks) of (l_begin, l) \<Rightarrow> swap_cols_rows_block (Suc l) k (mult_col_div_row (inverse (B $$ (l, k))) k (step_3_c (B $$ (l, k)) l k blocks B))) \<in> {m. dim_row m = n \<and> dim_col m = n}
[PROOF STEP]
using Bn
[PROOF STATE]
proof (prove)
using this:
B \<in> carrier_mat n n

goal (1 subgoal):
 1. (if blocks = [] then B else case find_largest_block (hd blocks) (tl blocks) of (l_begin, l) \<Rightarrow> swap_cols_rows_block (Suc l) k (mult_col_div_row (inverse (B $$ (l, k))) k (step_3_c (B $$ (l, k)) l k blocks B))) \<in> {m. dim_row m = n \<and> dim_col m = n}
[PROOF STEP]
by (simp split: prod.splits)
[PROOF STATE]
proof (state)
this:
F \<in> carrier_mat n n

goal (1 subgoal):
 1. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
have inv: "inv_all uppert F \<and> same_diag A F \<and> inv_upto jb F (Suc k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
proof (cases "blocks = []")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. blocks = [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
 2. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
blocks = []

goal (2 subgoals):
 1. blocks = [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
 2. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
hence F: "F = B"
[PROOF STATE]
proof (prove)
using this:
blocks = []

goal (1 subgoal):
 1. F = B
[PROOF STEP]
unfolding F
[PROOF STATE]
proof (prove)
using this:
blocks = []

goal (1 subgoal):
 1. (if blocks = [] then B else let (l_begin, l) = find_largest_block (hd blocks) (tl blocks); x = B $$ (l, k); C = step_3_c x l k blocks B; D = mult_col_div_row (inverse x) k C; E = swap_cols_rows_block (Suc l) k D in E) = B
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
F = B

goal (2 subgoals):
 1. blocks = [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
 2. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
have lo: "inv_at (lower_one k) B k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inv_at (lower_one k) B k
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> lower_one k B i k
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> lower_one k B i k
[PROOF STEP]
assume i: "i < n"
[PROOF STATE]
proof (state)
this:
i < n

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> lower_one k B i k
[PROOF STEP]
note lower_one_def[simp]
[PROOF STATE]
proof (state)
this:
lower_one ?k ?A ?i ?j = (?j = ?k \<longrightarrow> ?A $$ (?i, ?j) = (0::'a) \<or> ?i = ?j \<or> ?A $$ (?i, ?j) = (1::'a) \<and> ?j = Suc ?i \<and> ?A $$ (?i, ?i) = ?A $$ (?j, ?j))

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> lower_one k B i k
[PROOF STEP]
show "lower_one k B i k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lower_one k B i k
[PROOF STEP]
proof (cases "B $$ (i,k) = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. B $$ (i, k) = (0::'a) \<Longrightarrow> lower_one k B i k
 2. B $$ (i, k) \<noteq> (0::'a) \<Longrightarrow> lower_one k B i k
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
B $$ (i, k) \<noteq> (0::'a)

goal (2 subgoals):
 1. B $$ (i, k) = (0::'a) \<Longrightarrow> lower_one k B i k
 2. B $$ (i, k) \<noteq> (0::'a) \<Longrightarrow> lower_one k B i k
[PROOF STEP]
note nz = this
[PROOF STATE]
proof (state)
this:
B $$ (i, k) \<noteq> (0::'a)

goal (2 subgoals):
 1. B $$ (i, k) = (0::'a) \<Longrightarrow> lower_one k B i k
 2. B $$ (i, k) \<noteq> (0::'a) \<Longrightarrow> lower_one k B i k
[PROOF STEP]
note oz = inv_atD[OF inv(4) i, unfolded one_zero_def]
[PROOF STATE]
proof (state)
this:
(Suc i < k \<longrightarrow> B $$ (i, Suc i) = (1::'a) \<longrightarrow> B $$ (i, k) = (0::'a)) \<and> (k < i \<longrightarrow> B $$ (i, k) = (0::'a)) \<and> (i < k \<longrightarrow> B $$ (i, i) \<noteq> B $$ (k, k) \<longrightarrow> B $$ (i, k) = (0::'a))

goal (2 subgoals):
 1. B $$ (i, k) = (0::'a) \<Longrightarrow> lower_one k B i k
 2. B $$ (i, k) \<noteq> (0::'a) \<Longrightarrow> lower_one k B i k
[PROOF STEP]
from nz oz
[PROOF STATE]
proof (chain)
picking this:
B $$ (i, k) \<noteq> (0::'a)
(Suc i < k \<longrightarrow> B $$ (i, Suc i) = (1::'a) \<longrightarrow> B $$ (i, k) = (0::'a)) \<and> (k < i \<longrightarrow> B $$ (i, k) = (0::'a)) \<and> (i < k \<longrightarrow> B $$ (i, i) \<noteq> B $$ (k, k) \<longrightarrow> B $$ (i, k) = (0::'a))
[PROOF STEP]
have "i \<le> k"
[PROOF STATE]
proof (prove)
using this:
B $$ (i, k) \<noteq> (0::'a)
(Suc i < k \<longrightarrow> B $$ (i, Suc i) = (1::'a) \<longrightarrow> B $$ (i, k) = (0::'a)) \<and> (k < i \<longrightarrow> B $$ (i, k) = (0::'a)) \<and> (i < k \<longrightarrow> B $$ (i, i) \<noteq> B $$ (k, k) \<longrightarrow> B $$ (i, k) = (0::'a))

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

goal (2 subgoals):
 1. B $$ (i, k) = (0::'a) \<Longrightarrow> lower_one k B i k
 2. B $$ (i, k) \<noteq> (0::'a) \<Longrightarrow> lower_one k B i k
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lower_one k B i k
[PROOF STEP]
proof (cases "i = k")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i = k \<Longrightarrow> lower_one k B i k
 2. i \<noteq> k \<Longrightarrow> lower_one k B i k
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
i \<noteq> k

goal (2 subgoals):
 1. i = k \<Longrightarrow> lower_one k B i k
 2. i \<noteq> k \<Longrightarrow> lower_one k B i k
[PROOF STEP]
with \<open>i \<le> k\<close>
[PROOF STATE]
proof (chain)
picking this:
i \<le> k
i \<noteq> k
[PROOF STEP]
have "i < k"
[PROOF STATE]
proof (prove)
using this:
i \<le> k
i \<noteq> k

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

goal (2 subgoals):
 1. i = k \<Longrightarrow> lower_one k B i k
 2. i \<noteq> k \<Longrightarrow> lower_one k B i k
[PROOF STEP]
with nz oz
[PROOF STATE]
proof (chain)
picking this:
B $$ (i, k) \<noteq> (0::'a)
(Suc i < k \<longrightarrow> B $$ (i, Suc i) = (1::'a) \<longrightarrow> B $$ (i, k) = (0::'a)) \<and> (k < i \<longrightarrow> B $$ (i, k) = (0::'a)) \<and> (i < k \<longrightarrow> B $$ (i, i) \<noteq> B $$ (k, k) \<longrightarrow> B $$ (i, k) = (0::'a))
i < k
[PROOF STEP]
have ev: "B $$ (i,i) = B $$ (k,k)"
[PROOF STATE]
proof (prove)
using this:
B $$ (i, k) \<noteq> (0::'a)
(Suc i < k \<longrightarrow> B $$ (i, Suc i) = (1::'a) \<longrightarrow> B $$ (i, k) = (0::'a)) \<and> (k < i \<longrightarrow> B $$ (i, k) = (0::'a)) \<and> (i < k \<longrightarrow> B $$ (i, i) \<noteq> B $$ (k, k) \<longrightarrow> B $$ (i, k) = (0::'a))
i < k

goal (1 subgoal):
 1. B $$ (i, i) = B $$ (k, k)
[PROOF STEP]
unfolding diff_ev_def
[PROOF STATE]
proof (prove)
using this:
B $$ (i, k) \<noteq> (0::'a)
(Suc i < k \<longrightarrow> B $$ (i, Suc i) = (1::'a) \<longrightarrow> B $$ (i, k) = (0::'a)) \<and> (k < i \<longrightarrow> B $$ (i, k) = (0::'a)) \<and> (i < k \<longrightarrow> B $$ (i, i) \<noteq> B $$ (k, k) \<longrightarrow> B $$ (i, k) = (0::'a))
i < k

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

goal (2 subgoals):
 1. i = k \<Longrightarrow> lower_one k B i k
 2. i \<noteq> k \<Longrightarrow> lower_one k B i k
[PROOF STEP]
have "(identify_block B i, i) \<in> set all_blocks"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (identify_block B i, i) \<in> set all_blocks
[PROOF STEP]
unfolding ab
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (identify_block B i, i) \<in> set (identify_blocks B k)
[PROOF STEP]
proof (rule identify_blocks_rev[OF _ \<open>k < n\<close>])
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. B $$ (i, Suc i) = (0::'a) \<and> Suc i < k \<or> Suc i = k
[PROOF STEP]
show "B $$ (i, Suc i) = 0 \<and> Suc i < k \<or> Suc i = k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B $$ (i, Suc i) = (0::'a) \<and> Suc i < k \<or> Suc i = k
[PROOF STEP]
proof (cases "Suc i = k")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Suc i = k \<Longrightarrow> B $$ (i, Suc i) = (0::'a) \<and> Suc i < k \<or> Suc i = k
 2. Suc i \<noteq> k \<Longrightarrow> B $$ (i, Suc i) = (0::'a) \<and> Suc i < k \<or> Suc i = k
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
Suc i \<noteq> k

goal (2 subgoals):
 1. Suc i = k \<Longrightarrow> B $$ (i, Suc i) = (0::'a) \<and> Suc i < k \<or> Suc i = k
 2. Suc i \<noteq> k \<Longrightarrow> B $$ (i, Suc i) = (0::'a) \<and> Suc i < k \<or> Suc i = k
[PROOF STEP]
with \<open>i < k\<close> \<open>k < n\<close>
[PROOF STATE]
proof (chain)
picking this:
i < k
k < n
Suc i \<noteq> k
[PROOF STEP]
have "Suc i < k" "Suc i < n"
[PROOF STATE]
proof (prove)
using this:
i < k
k < n
Suc i \<noteq> k

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

goal (2 subgoals):
 1. Suc i = k \<Longrightarrow> B $$ (i, Suc i) = (0::'a) \<and> Suc i < k \<or> Suc i = k
 2. Suc i \<noteq> k \<Longrightarrow> B $$ (i, Suc i) = (0::'a) \<and> Suc i < k \<or> Suc i = k
[PROOF STEP]
with nz oz
[PROOF STATE]
proof (chain)
picking this:
B $$ (i, k) \<noteq> (0::'a)
(Suc i < k \<longrightarrow> B $$ (i, Suc i) = (1::'a) \<longrightarrow> B $$ (i, k) = (0::'a)) \<and> (k < i \<longrightarrow> B $$ (i, k) = (0::'a)) \<and> (i < k \<longrightarrow> B $$ (i, i) \<noteq> B $$ (k, k) \<longrightarrow> B $$ (i, k) = (0::'a))
Suc i < k
Suc i < n
[PROOF STEP]
have "B $$ (i, Suc i) \<noteq> 1"
[PROOF STATE]
proof (prove)
using this:
B $$ (i, k) \<noteq> (0::'a)
(Suc i < k \<longrightarrow> B $$ (i, Suc i) = (1::'a) \<longrightarrow> B $$ (i, k) = (0::'a)) \<and> (k < i \<longrightarrow> B $$ (i, k) = (0::'a)) \<and> (i < k \<longrightarrow> B $$ (i, i) \<noteq> B $$ (k, k) \<longrightarrow> B $$ (i, k) = (0::'a))
Suc i < k
Suc i < n

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

goal (2 subgoals):
 1. Suc i = k \<Longrightarrow> B $$ (i, Suc i) = (0::'a) \<and> Suc i < k \<or> Suc i = k
 2. Suc i \<noteq> k \<Longrightarrow> B $$ (i, Suc i) = (0::'a) \<and> Suc i < k \<or> Suc i = k
[PROOF STEP]
with inv_uptoD[OF inv(3) \<open>i < n\<close> \<open>Suc i < n\<close> \<open>Suc i < k\<close>, unfolded jb_def]
[PROOF STATE]
proof (chain)
picking this:
(Suc i = Suc i \<longrightarrow> B $$ (i, Suc i) \<in> {0::'a, 1::'a}) \<and> (i \<noteq> Suc i \<longrightarrow> Suc i \<noteq> Suc i \<or> B $$ (i, i) \<noteq> B $$ (Suc i, Suc i) \<longrightarrow> B $$ (i, Suc i) = (0::'a))
B $$ (i, Suc i) \<noteq> (1::'a)
[PROOF STEP]
have "B $$ (i, Suc i) = 0"
[PROOF STATE]
proof (prove)
using this:
(Suc i = Suc i \<longrightarrow> B $$ (i, Suc i) \<in> {0::'a, 1::'a}) \<and> (i \<noteq> Suc i \<longrightarrow> Suc i \<noteq> Suc i \<or> B $$ (i, i) \<noteq> B $$ (Suc i, Suc i) \<longrightarrow> B $$ (i, Suc i) = (0::'a))
B $$ (i, Suc i) \<noteq> (1::'a)

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

goal (2 subgoals):
 1. Suc i = k \<Longrightarrow> B $$ (i, Suc i) = (0::'a) \<and> Suc i < k \<or> Suc i = k
 2. Suc i \<noteq> k \<Longrightarrow> B $$ (i, Suc i) = (0::'a) \<and> Suc i < k \<or> Suc i = k
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
B $$ (i, Suc i) = (0::'a)

goal (1 subgoal):
 1. B $$ (i, Suc i) = (0::'a) \<and> Suc i < k \<or> Suc i = k
[PROOF STEP]
using \<open>Suc i < k\<close>
[PROOF STATE]
proof (prove)
using this:
B $$ (i, Suc i) = (0::'a)
Suc i < k

goal (1 subgoal):
 1. B $$ (i, Suc i) = (0::'a) \<and> Suc i < k \<or> Suc i = k
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
B $$ (i, Suc i) = (0::'a) \<and> Suc i < k \<or> Suc i = k

goal (1 subgoal):
 1. Suc i = k \<Longrightarrow> B $$ (i, Suc i) = (0::'a) \<and> Suc i < k \<or> Suc i = k
[PROOF STEP]
qed simp
[PROOF STATE]
proof (state)
this:
B $$ (i, Suc i) = (0::'a) \<and> Suc i < k \<or> Suc i = k

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(identify_block B i, i) \<in> set all_blocks

goal (2 subgoals):
 1. i = k \<Longrightarrow> lower_one k B i k
 2. i \<noteq> k \<Longrightarrow> lower_one k B i k
[PROOF STEP]
with arg_cong[OF \<open>blocks = []\<close>[unfolded blocks], of set]
[PROOF STATE]
proof (chain)
picking this:
set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) all_blocks) = set []
(identify_block B i, i) \<in> set all_blocks
[PROOF STEP]
have "B $$ (i,k) = 0"
[PROOF STATE]
proof (prove)
using this:
set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) all_blocks) = set []
(identify_block B i, i) \<in> set all_blocks

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

goal (2 subgoals):
 1. i = k \<Longrightarrow> lower_one k B i k
 2. i \<noteq> k \<Longrightarrow> lower_one k B i k
[PROOF STEP]
with nz
[PROOF STATE]
proof (chain)
picking this:
B $$ (i, k) \<noteq> (0::'a)
B $$ (i, k) = (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
B $$ (i, k) \<noteq> (0::'a)
B $$ (i, k) = (0::'a)

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

goal (1 subgoal):
 1. i = k \<Longrightarrow> lower_one k B i k
[PROOF STEP]
qed auto
[PROOF STATE]
proof (state)
this:
lower_one k B i k

goal (1 subgoal):
 1. B $$ (i, k) = (0::'a) \<Longrightarrow> lower_one k B i k
[PROOF STEP]
qed auto
[PROOF STATE]
proof (state)
this:
lower_one k B i k

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
inv_at (lower_one k) B k

goal (2 subgoals):
 1. blocks = [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
 2. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
have inv_jb: "inv_upto jb B (Suc k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inv_upto local.jb B (Suc k)
[PROOF STEP]
proof (rule inv_upto_Suc[OF inv(3)])
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> local.jb B i k
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> local.jb B i k
[PROOF STEP]
assume "i < n"
[PROOF STATE]
proof (state)
this:
i < n

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> local.jb B i k
[PROOF STEP]
from inv_atD[OF lo \<open>i < n\<close>, unfolded lower_one_def]
[PROOF STATE]
proof (chain)
picking this:
k = k \<longrightarrow> B $$ (i, k) = (0::'a) \<or> i = k \<or> B $$ (i, k) = (1::'a) \<and> k = Suc i \<and> B $$ (i, i) = B $$ (k, k)
[PROOF STEP]
show "jb B i k"
[PROOF STATE]
proof (prove)
using this:
k = k \<longrightarrow> B $$ (i, k) = (0::'a) \<or> i = k \<or> B $$ (i, k) = (1::'a) \<and> k = Suc i \<and> B $$ (i, i) = B $$ (k, k)

goal (1 subgoal):
 1. local.jb B i k
[PROOF STEP]
unfolding jb_def
[PROOF STATE]
proof (prove)
using this:
k = k \<longrightarrow> B $$ (i, k) = (0::'a) \<or> i = k \<or> B $$ (i, k) = (1::'a) \<and> k = Suc i \<and> B $$ (i, i) = B $$ (k, k)

goal (1 subgoal):
 1. (Suc i = k \<longrightarrow> B $$ (i, k) \<in> {0::'a, 1::'a}) \<and> (i \<noteq> k \<longrightarrow> Suc i \<noteq> k \<or> B $$ (i, i) \<noteq> B $$ (k, k) \<longrightarrow> B $$ (i, k) = (0::'a))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
local.jb B i k

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
inv_upto local.jb B (Suc k)

goal (2 subgoals):
 1. blocks = [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
 2. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
from inv_from_upto_at_all_ev_block[OF inv(3,1) lo inv(2) _ \<open>k < n\<close>] lower_one_diff_uppert
[PROOF STATE]
proof (chain)
picking this:
(\<And>i. \<lbrakk>i < n; lower_one k B i k\<rbrakk> \<Longrightarrow> local.uppert B i k) \<Longrightarrow> local.inv_all local.uppert B
\<lbrakk>?i < n; lower_one ?k ?B ?i ?k\<rbrakk> \<Longrightarrow> local.diff_ev ?B ?i ?k \<and> local.uppert ?B ?i ?k
[PROOF STEP]
have "inv_all uppert B"
[PROOF STATE]
proof (prove)
using this:
(\<And>i. \<lbrakk>i < n; lower_one k B i k\<rbrakk> \<Longrightarrow> local.uppert B i k) \<Longrightarrow> local.inv_all local.uppert B
\<lbrakk>?i < n; lower_one ?k ?B ?i ?k\<rbrakk> \<Longrightarrow> local.diff_ev ?B ?i ?k \<and> local.uppert ?B ?i ?k

goal (1 subgoal):
 1. local.inv_all local.uppert B
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
local.inv_all local.uppert B

goal (2 subgoals):
 1. blocks = [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
 2. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
with inv inv_jb sd
[PROOF STATE]
proof (chain)
picking this:
inv_from local.uppert B k
local.ev_block n B
inv_upto local.jb B k
inv_at one_zero B k
inv_upto local.jb B (Suc k)
local.same_diag A B
local.inv_all local.uppert B
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
inv_from local.uppert B k
local.ev_block n B
inv_upto local.jb B k
inv_at one_zero B k
inv_upto local.jb B (Suc k)
local.same_diag A B
local.inv_all local.uppert B

goal (1 subgoal):
 1. local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
unfolding F
[PROOF STATE]
proof (prove)
using this:
inv_from local.uppert B k
local.ev_block n B
inv_upto local.jb B k
inv_at one_zero B k
inv_upto local.jb B (Suc k)
local.same_diag A B
local.inv_all local.uppert B

goal (1 subgoal):
 1. local.inv_all local.uppert B \<and> local.same_diag A B \<and> inv_upto local.jb B (Suc k)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
blocks \<noteq> []

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
obtain l_start l where l: "find_largest_block (hd blocks) (tl blocks) = (l_start, l)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>l_start l. find_largest_block (hd blocks) (tl blocks) = (l_start, l) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
find_largest_block (hd blocks) (tl blocks) = (l_start, l)

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
obtain x where x: "x = B $$ (l,k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>x. x = B $$ (l, k) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
x = B $$ (l, k)

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
obtain C where C: "C = step_3_c x l k blocks B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>C. C = step_3_c x l k blocks B \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
C = step_3_c x l k blocks B

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
obtain D where D: "D = mult_col_div_row (inverse x) k C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>D. D = mult_col_div_row (inverse x) k C \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
D = mult_col_div_row (inverse x) k C

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
obtain E where E: "E = swap_cols_rows_block (Suc l) k D"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>E. E = swap_cols_rows_block (Suc l) k D \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
E = swap_cols_rows_block (Suc l) k D

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
from find_largest_block[OF False l]
[PROOF STATE]
proof (chain)
picking this:
(l_start, l) \<in> set blocks
(?i_begin, ?i_end) \<in> set blocks \<Longrightarrow> ?i_end - ?i_begin \<le> l - l_start
[PROOF STEP]
have lb: "(l_start,l) \<in> set blocks"
        and llarge: "\<And> i_begin i_end. (i_begin,i_end) \<in> set blocks \<Longrightarrow> l - l_start \<ge> i_end - i_begin"
[PROOF STATE]
proof (prove)
using this:
(l_start, l) \<in> set blocks
(?i_begin, ?i_end) \<in> set blocks \<Longrightarrow> ?i_end - ?i_begin \<le> l - l_start

goal (1 subgoal):
 1. (l_start, l) \<in> set blocks &&& (\<And>i_begin i_end. (i_begin, i_end) \<in> set blocks \<Longrightarrow> i_end - i_begin \<le> l - l_start)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(l_start, l) \<in> set blocks
(?i_begin, ?i_end) \<in> set blocks \<Longrightarrow> ?i_end - ?i_begin \<le> l - l_start

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
from lb
[PROOF STATE]
proof (chain)
picking this:
(l_start, l) \<in> set blocks
[PROOF STEP]
have x0: "x \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
(l_start, l) \<in> set blocks

goal (1 subgoal):
 1. x \<noteq> (0::'a)
[PROOF STEP]
unfolding blocks x
[PROOF STATE]
proof (prove)
using this:
(l_start, l) \<in> set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) all_blocks)

goal (1 subgoal):
 1. B $$ (l, k) \<noteq> (0::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
x \<noteq> (0::'a)

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
x \<noteq> (0::'a)

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
fix i_start i_end
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
assume "(i_start,i_end) \<in> set blocks"
[PROOF STATE]
proof (state)
this:
(i_start, i_end) \<in> set blocks

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
hence "(i_start,i_end) \<in> set (identify_blocks B k)"
[PROOF STATE]
proof (prove)
using this:
(i_start, i_end) \<in> set blocks

goal (1 subgoal):
 1. (i_start, i_end) \<in> set (identify_blocks B k)
[PROOF STEP]
unfolding blocks ab
[PROOF STATE]
proof (prove)
using this:
(i_start, i_end) \<in> set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k))

goal (1 subgoal):
 1. (i_start, i_end) \<in> set (identify_blocks B k)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(i_start, i_end) \<in> set (identify_blocks B k)

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
with identify_blocks[OF this]
[PROOF STATE]
proof (chain)
picking this:
i_start \<le> i_end \<and> i_end < k
(i_start, i_end) \<in> set (identify_blocks B k)
[PROOF STEP]
have "i_end < k" "(i_start,i_end) \<in> set (identify_blocks B k)"
[PROOF STATE]
proof (prove)
using this:
i_start \<le> i_end \<and> i_end < k
(i_start, i_end) \<in> set (identify_blocks B k)

goal (1 subgoal):
 1. i_end < k &&& (i_start, i_end) \<in> set (identify_blocks B k)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i_end < k
(i_start, i_end) \<in> set (identify_blocks B k)

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
(?i_start2, ?i_end2) \<in> set blocks \<Longrightarrow> ?i_end2 < k
(?i_start2, ?i_end2) \<in> set blocks \<Longrightarrow> (?i_start2, ?i_end2) \<in> set (identify_blocks B k)

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
note block_bound = this
[PROOF STATE]
proof (state)
this:
(?i_start2, ?i_end2) \<in> set blocks \<Longrightarrow> ?i_end2 < k
(?i_start2, ?i_end2) \<in> set blocks \<Longrightarrow> (?i_start2, ?i_end2) \<in> set (identify_blocks B k)

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
from block_bound[OF lb]
[PROOF STATE]
proof (chain)
picking this:
l < k
(l_start, l) \<in> set (identify_blocks B k)
[PROOF STEP]
have lk: "l < k" and lblock: "(l_start, l) \<in> set (identify_blocks B k)"
[PROOF STATE]
proof (prove)
using this:
l < k
(l_start, l) \<in> set (identify_blocks B k)

goal (1 subgoal):
 1. l < k &&& (l_start, l) \<in> set (identify_blocks B k)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
l < k
(l_start, l) \<in> set (identify_blocks B k)

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
from lk \<open>k < n\<close>
[PROOF STATE]
proof (chain)
picking this:
l < k
k < n
[PROOF STEP]
have ln: "l < n"
[PROOF STATE]
proof (prove)
using this:
l < k
k < n

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

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
from evb[OF \<open>l < n\<close> \<open>k < n\<close>]
[PROOF STATE]
proof (chain)
picking this:
B $$ (l, l) = B $$ (k, k)
[PROOF STEP]
have Bll: "B $$ (l,l) = B $$ (k,k)"
[PROOF STATE]
proof (prove)
using this:
B $$ (l, l) = B $$ (k, k)

goal (1 subgoal):
 1. B $$ (l, l) = B $$ (k, k)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
B $$ (l, l) = B $$ (k, k)

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
from False
[PROOF STATE]
proof (chain)
picking this:
blocks \<noteq> []
[PROOF STEP]
have F: "F = E"
[PROOF STATE]
proof (prove)
using this:
blocks \<noteq> []

goal (1 subgoal):
 1. F = E
[PROOF STEP]
unfolding E D C x F l Let_def
[PROOF STATE]
proof (prove)
using this:
blocks \<noteq> []

goal (1 subgoal):
 1. (if blocks = [] then B else case (l_start, l) of (l_begin, l) \<Rightarrow> swap_cols_rows_block (Suc l) k (mult_col_div_row (inverse (B $$ (l, k))) k (step_3_c (B $$ (l, k)) l k blocks B))) = swap_cols_rows_block (Suc l) k (mult_col_div_row (inverse (B $$ (l, k))) k (step_3_c (B $$ (l, k)) l k blocks B))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
F = E

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
from Bn
[PROOF STATE]
proof (chain)
picking this:
B \<in> carrier_mat n n
[PROOF STEP]
have Cn: "C \<in> carrier_mat n n"
[PROOF STATE]
proof (prove)
using this:
B \<in> carrier_mat n n

goal (1 subgoal):
 1. C \<in> carrier_mat n n
[PROOF STEP]
unfolding C carrier_mat_def
[PROOF STATE]
proof (prove)
using this:
B \<in> {m. dim_row m = n \<and> dim_col m = n}

goal (1 subgoal):
 1. step_3_c x l k blocks B \<in> {m. dim_row m = n \<and> dim_col m = n}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
C \<in> carrier_mat n n

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
C \<in> carrier_mat n n

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
fix be
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
assume nmem: "be \<notin> snd ` set blocks" and belk: "be \<notin> {l, k}" and be: "be < n"
[PROOF STATE]
proof (state)
this:
be \<notin> snd ` set blocks
be \<notin> {l, k}
be < n

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
have "B $$ (be, k) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B $$ (be, k) = (0::'a)
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. B $$ (be, k) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
assume nz: "\<not> ?thesis"
[PROOF STATE]
proof (state)
this:
B $$ (be, k) \<noteq> (0::'a)

goal (1 subgoal):
 1. B $$ (be, k) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
note oz = inv_atD[OF inv(4) be, unfolded one_zero_def]
[PROOF STATE]
proof (state)
this:
(Suc be < k \<longrightarrow> B $$ (be, Suc be) = (1::'a) \<longrightarrow> B $$ (be, k) = (0::'a)) \<and> (k < be \<longrightarrow> B $$ (be, k) = (0::'a)) \<and> (be < k \<longrightarrow> B $$ (be, be) \<noteq> B $$ (k, k) \<longrightarrow> B $$ (be, k) = (0::'a))

goal (1 subgoal):
 1. B $$ (be, k) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
from belk oz be nz
[PROOF STATE]
proof (chain)
picking this:
be \<notin> {l, k}
(Suc be < k \<longrightarrow> B $$ (be, Suc be) = (1::'a) \<longrightarrow> B $$ (be, k) = (0::'a)) \<and> (k < be \<longrightarrow> B $$ (be, k) = (0::'a)) \<and> (be < k \<longrightarrow> B $$ (be, be) \<noteq> B $$ (k, k) \<longrightarrow> B $$ (be, k) = (0::'a))
be < n
B $$ (be, k) \<noteq> (0::'a)
[PROOF STEP]
have "be < k"
[PROOF STATE]
proof (prove)
using this:
be \<notin> {l, k}
(Suc be < k \<longrightarrow> B $$ (be, Suc be) = (1::'a) \<longrightarrow> B $$ (be, k) = (0::'a)) \<and> (k < be \<longrightarrow> B $$ (be, k) = (0::'a)) \<and> (be < k \<longrightarrow> B $$ (be, be) \<noteq> B $$ (k, k) \<longrightarrow> B $$ (be, k) = (0::'a))
be < n
B $$ (be, k) \<noteq> (0::'a)

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

goal (1 subgoal):
 1. B $$ (be, k) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
obtain bb where ib: "identify_block B be = bb"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>bb. identify_block B be = bb \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
identify_block B be = bb

goal (1 subgoal):
 1. B $$ (be, k) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
note ib_inv = identify_block[OF ib]
[PROOF STATE]
proof (state)
this:
bb \<le> be
bb = 0 \<or> B $$ (bb - 1, bb) \<noteq> (1::'a)
\<lbrakk>bb \<le> ?k; ?k < be\<rbrakk> \<Longrightarrow> B $$ (?k, Suc ?k) = (1::'a)

goal (1 subgoal):
 1. B $$ (be, k) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
have "B $$ (be, Suc be) = 0 \<and> Suc be < k \<or> Suc be = k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B $$ (be, Suc be) = (0::'a) \<and> Suc be < k \<or> Suc be = k
[PROOF STEP]
proof (cases "Suc be = k")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Suc be = k \<Longrightarrow> B $$ (be, Suc be) = (0::'a) \<and> Suc be < k \<or> Suc be = k
 2. Suc be \<noteq> k \<Longrightarrow> B $$ (be, Suc be) = (0::'a) \<and> Suc be < k \<or> Suc be = k
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
Suc be \<noteq> k

goal (2 subgoals):
 1. Suc be = k \<Longrightarrow> B $$ (be, Suc be) = (0::'a) \<and> Suc be < k \<or> Suc be = k
 2. Suc be \<noteq> k \<Longrightarrow> B $$ (be, Suc be) = (0::'a) \<and> Suc be < k \<or> Suc be = k
[PROOF STEP]
with \<open>be < k\<close>
[PROOF STATE]
proof (chain)
picking this:
be < k
Suc be \<noteq> k
[PROOF STEP]
have sbek: "Suc be < k"
[PROOF STATE]
proof (prove)
using this:
be < k
Suc be \<noteq> k

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

goal (2 subgoals):
 1. Suc be = k \<Longrightarrow> B $$ (be, Suc be) = (0::'a) \<and> Suc be < k \<or> Suc be = k
 2. Suc be \<noteq> k \<Longrightarrow> B $$ (be, Suc be) = (0::'a) \<and> Suc be < k \<or> Suc be = k
[PROOF STEP]
from inv_uptoD[OF inv(3) \<open>be < n\<close> _ sbek] sbek kn
[PROOF STATE]
proof (chain)
picking this:
Suc be < n \<Longrightarrow> local.jb B be (Suc be)
Suc be < k
k < n
[PROOF STEP]
have "jb B be (Suc be)"
[PROOF STATE]
proof (prove)
using this:
Suc be < n \<Longrightarrow> local.jb B be (Suc be)
Suc be < k
k < n

goal (1 subgoal):
 1. local.jb B be (Suc be)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
local.jb B be (Suc be)

goal (2 subgoals):
 1. Suc be = k \<Longrightarrow> B $$ (be, Suc be) = (0::'a) \<and> Suc be < k \<or> Suc be = k
 2. Suc be \<noteq> k \<Longrightarrow> B $$ (be, Suc be) = (0::'a) \<and> Suc be < k \<or> Suc be = k
[PROOF STEP]
from this[unfolded jb_def]
[PROOF STATE]
proof (chain)
picking this:
(Suc be = Suc be \<longrightarrow> B $$ (be, Suc be) \<in> {0::'a, 1::'a}) \<and> (be \<noteq> Suc be \<longrightarrow> Suc be \<noteq> Suc be \<or> B $$ (be, be) \<noteq> B $$ (Suc be, Suc be) \<longrightarrow> B $$ (be, Suc be) = (0::'a))
[PROOF STEP]
have 01: "B $$ (be, Suc be) \<in> {0,1}"
[PROOF STATE]
proof (prove)
using this:
(Suc be = Suc be \<longrightarrow> B $$ (be, Suc be) \<in> {0::'a, 1::'a}) \<and> (be \<noteq> Suc be \<longrightarrow> Suc be \<noteq> Suc be \<or> B $$ (be, be) \<noteq> B $$ (Suc be, Suc be) \<longrightarrow> B $$ (be, Suc be) = (0::'a))

goal (1 subgoal):
 1. B $$ (be, Suc be) \<in> {0::'a, 1::'a}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B $$ (be, Suc be) \<in> {0::'a, 1::'a}

goal (2 subgoals):
 1. Suc be = k \<Longrightarrow> B $$ (be, Suc be) = (0::'a) \<and> Suc be < k \<or> Suc be = k
 2. Suc be \<noteq> k \<Longrightarrow> B $$ (be, Suc be) = (0::'a) \<and> Suc be < k \<or> Suc be = k
[PROOF STEP]
from 01 oz sbek nz
[PROOF STATE]
proof (chain)
picking this:
B $$ (be, Suc be) \<in> {0::'a, 1::'a}
(Suc be < k \<longrightarrow> B $$ (be, Suc be) = (1::'a) \<longrightarrow> B $$ (be, k) = (0::'a)) \<and> (k < be \<longrightarrow> B $$ (be, k) = (0::'a)) \<and> (be < k \<longrightarrow> B $$ (be, be) \<noteq> B $$ (k, k) \<longrightarrow> B $$ (be, k) = (0::'a))
Suc be < k
B $$ (be, k) \<noteq> (0::'a)
[PROOF STEP]
have "B $$ (be, Suc be) = 0"
[PROOF STATE]
proof (prove)
using this:
B $$ (be, Suc be) \<in> {0::'a, 1::'a}
(Suc be < k \<longrightarrow> B $$ (be, Suc be) = (1::'a) \<longrightarrow> B $$ (be, k) = (0::'a)) \<and> (k < be \<longrightarrow> B $$ (be, k) = (0::'a)) \<and> (be < k \<longrightarrow> B $$ (be, be) \<noteq> B $$ (k, k) \<longrightarrow> B $$ (be, k) = (0::'a))
Suc be < k
B $$ (be, k) \<noteq> (0::'a)

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

goal (2 subgoals):
 1. Suc be = k \<Longrightarrow> B $$ (be, Suc be) = (0::'a) \<and> Suc be < k \<or> Suc be = k
 2. Suc be \<noteq> k \<Longrightarrow> B $$ (be, Suc be) = (0::'a) \<and> Suc be < k \<or> Suc be = k
[PROOF STEP]
with sbek
[PROOF STATE]
proof (chain)
picking this:
Suc be < k
B $$ (be, Suc be) = (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Suc be < k
B $$ (be, Suc be) = (0::'a)

goal (1 subgoal):
 1. B $$ (be, Suc be) = (0::'a) \<and> Suc be < k \<or> Suc be = k
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B $$ (be, Suc be) = (0::'a) \<and> Suc be < k \<or> Suc be = k

goal (1 subgoal):
 1. Suc be = k \<Longrightarrow> B $$ (be, Suc be) = (0::'a) \<and> Suc be < k \<or> Suc be = k
[PROOF STEP]
qed auto
[PROOF STATE]
proof (state)
this:
B $$ (be, Suc be) = (0::'a) \<and> Suc be < k \<or> Suc be = k

goal (1 subgoal):
 1. B $$ (be, k) \<noteq> (0::'a) \<Longrightarrow> False
[PROOF STEP]
from identify_blocks_rev[OF this kn]
             nz nmem
[PROOF STATE]
proof (chain)
picking this:
(identify_block B be, be) \<in> set (identify_blocks B k)
B $$ (be, k) \<noteq> (0::'a)
be \<notin> snd ` set blocks
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
(identify_block B be, be) \<in> set (identify_blocks B k)
B $$ (be, k) \<noteq> (0::'a)
be \<notin> snd ` set blocks

goal (1 subgoal):
 1. False
[PROOF STEP]
unfolding ab blocks
[PROOF STATE]
proof (prove)
using this:
(identify_block B be, be) \<in> set (identify_blocks B k)
B $$ (be, k) \<noteq> (0::'a)
be \<notin> snd ` set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k))

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
B $$ (be, k) = (0::'a)

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>?be2 \<notin> snd ` set blocks; ?be2 \<notin> {l, k}; ?be2 < n\<rbrakk> \<Longrightarrow> B $$ (?be2, k) = (0::'a)

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
note inv3 = step_3_c_inv[OF Bn \<open>k < n\<close> lblock inv(3,1,4,2) _ this llarge x x0, of blocks, folded C,
        unfolded ab blocks]
[PROOF STATE]
proof (state)
this:
\<lbrakk>set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)) \<subseteq> set (identify_blocks B k); \<And>be. \<lbrakk>be \<notin> snd ` set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)); be \<notin> {l, k}; be < n\<rbrakk> \<Longrightarrow> be \<notin> snd ` set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)); \<And>be. \<lbrakk>be \<notin> snd ` set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)); be \<notin> {l, k}; be < n\<rbrakk> \<Longrightarrow> be \<notin> {l, k}; \<And>be. \<lbrakk>be \<notin> snd ` set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)); be \<notin> {l, k}; be < n\<rbrakk> \<Longrightarrow> be < n; \<And>bb be. (bb, be) \<in> set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)) \<Longrightarrow> (bb, be) \<in> set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k))\<rbrakk> \<Longrightarrow> local.inv_all local.uppert C \<and> local.same_diag B C \<and> same_upto k B C \<and> inv_at (single_non_zero l k x) C k

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
from inv3
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)) \<subseteq> set (identify_blocks B k); \<And>be. \<lbrakk>be \<notin> snd ` set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)); be \<notin> {l, k}; be < n\<rbrakk> \<Longrightarrow> be \<notin> snd ` set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)); \<And>be. \<lbrakk>be \<notin> snd ` set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)); be \<notin> {l, k}; be < n\<rbrakk> \<Longrightarrow> be \<notin> {l, k}; \<And>be. \<lbrakk>be \<notin> snd ` set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)); be \<notin> {l, k}; be < n\<rbrakk> \<Longrightarrow> be < n; \<And>bb be. (bb, be) \<in> set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)) \<Longrightarrow> (bb, be) \<in> set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k))\<rbrakk> \<Longrightarrow> local.inv_all local.uppert C \<and> local.same_diag B C \<and> same_upto k B C \<and> inv_at (single_non_zero l k x) C k
[PROOF STEP]
have sdC: "same_diag B C" and suC: "same_upto k B C"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)) \<subseteq> set (identify_blocks B k); \<And>be. \<lbrakk>be \<notin> snd ` set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)); be \<notin> {l, k}; be < n\<rbrakk> \<Longrightarrow> be \<notin> snd ` set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)); \<And>be. \<lbrakk>be \<notin> snd ` set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)); be \<notin> {l, k}; be < n\<rbrakk> \<Longrightarrow> be \<notin> {l, k}; \<And>be. \<lbrakk>be \<notin> snd ` set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)); be \<notin> {l, k}; be < n\<rbrakk> \<Longrightarrow> be < n; \<And>bb be. (bb, be) \<in> set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)) \<Longrightarrow> (bb, be) \<in> set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k))\<rbrakk> \<Longrightarrow> local.inv_all local.uppert C \<and> local.same_diag B C \<and> same_upto k B C \<and> inv_at (single_non_zero l k x) C k

goal (1 subgoal):
 1. local.same_diag B C &&& same_upto k B C
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
local.same_diag B C
same_upto k B C

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
note sd = same_diag_trans[OF sd sdC]
[PROOF STATE]
proof (state)
this:
local.same_diag A C

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
from Bll sdC ln \<open>k < n\<close>
[PROOF STATE]
proof (chain)
picking this:
B $$ (l, l) = B $$ (k, k)
local.same_diag B C
l < n
k < n
[PROOF STEP]
have Cll: "C $$ (l,l) = C $$ (k,k)"
[PROOF STATE]
proof (prove)
using this:
B $$ (l, l) = B $$ (k, k)
local.same_diag B C
l < n
k < n

goal (1 subgoal):
 1. C $$ (l, l) = C $$ (k, k)
[PROOF STEP]
unfolding same_diag_def
[PROOF STATE]
proof (prove)
using this:
B $$ (l, l) = B $$ (k, k)
\<forall>i<n. B $$ (i, i) = C $$ (i, i)
l < n
k < n

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

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
from same_diag_ev_block[OF sdC inv(2)] same_upto_inv_upto_jb[OF suC inv(3)] inv3
[PROOF STATE]
proof (chain)
picking this:
local.ev_block n C
inv_upto local.jb C k
\<lbrakk>set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)) \<subseteq> set (identify_blocks B k); \<And>be. \<lbrakk>be \<notin> snd ` set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)); be \<notin> {l, k}; be < n\<rbrakk> \<Longrightarrow> be \<notin> snd ` set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)); \<And>be. \<lbrakk>be \<notin> snd ` set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)); be \<notin> {l, k}; be < n\<rbrakk> \<Longrightarrow> be \<notin> {l, k}; \<And>be. \<lbrakk>be \<notin> snd ` set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)); be \<notin> {l, k}; be < n\<rbrakk> \<Longrightarrow> be < n; \<And>bb be. (bb, be) \<in> set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)) \<Longrightarrow> (bb, be) \<in> set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k))\<rbrakk> \<Longrightarrow> local.inv_all local.uppert C \<and> local.same_diag B C \<and> same_upto k B C \<and> inv_at (single_non_zero l k x) C k
[PROOF STEP]
have inv: "inv_all uppert C" "ev_block n C"
        "inv_upto jb C k" "inv_at (single_non_zero l k x) C k"
[PROOF STATE]
proof (prove)
using this:
local.ev_block n C
inv_upto local.jb C k
\<lbrakk>set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)) \<subseteq> set (identify_blocks B k); \<And>be. \<lbrakk>be \<notin> snd ` set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)); be \<notin> {l, k}; be < n\<rbrakk> \<Longrightarrow> be \<notin> snd ` set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)); \<And>be. \<lbrakk>be \<notin> snd ` set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)); be \<notin> {l, k}; be < n\<rbrakk> \<Longrightarrow> be \<notin> {l, k}; \<And>be. \<lbrakk>be \<notin> snd ` set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)); be \<notin> {l, k}; be < n\<rbrakk> \<Longrightarrow> be < n; \<And>bb be. (bb, be) \<in> set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k)) \<Longrightarrow> (bb, be) \<in> set (filter (\<lambda>block. B $$ (snd block, k) \<noteq> (0::'a)) (identify_blocks B k))\<rbrakk> \<Longrightarrow> local.inv_all local.uppert C \<and> local.same_diag B C \<and> same_upto k B C \<and> inv_at (single_non_zero l k x) C k

goal (1 subgoal):
 1. (local.inv_all local.uppert C &&& local.ev_block n C) &&& inv_upto local.jb C k &&& inv_at (single_non_zero l k x) C k
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
local.inv_all local.uppert C
local.ev_block n C
inv_upto local.jb C k
inv_at (single_non_zero l k x) C k

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
from x0
[PROOF STATE]
proof (chain)
picking this:
x \<noteq> (0::'a)
[PROOF STEP]
have "inverse x \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
x \<noteq> (0::'a)

goal (1 subgoal):
 1. inverse x \<noteq> (0::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
inverse x \<noteq> (0::'a)

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
from Cn
[PROOF STATE]
proof (chain)
picking this:
C \<in> carrier_mat n n
[PROOF STEP]
have Dn: "D \<in> carrier_mat n n"
[PROOF STATE]
proof (prove)
using this:
C \<in> carrier_mat n n

goal (1 subgoal):
 1. D \<in> carrier_mat n n
[PROOF STEP]
unfolding D carrier_mat_def
[PROOF STATE]
proof (prove)
using this:
C \<in> {m. dim_row m = n \<and> dim_col m = n}

goal (1 subgoal):
 1. mult_col_div_row (inverse x) k C \<in> {m. dim_row m = n \<and> dim_col m = n}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
D \<in> carrier_mat n n

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
D \<in> carrier_mat n n

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
fix i j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
assume i: "i < n" and j: "j < n"
[PROOF STATE]
proof (state)
this:
i < n
j < n

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
with Cn
[PROOF STATE]
proof (chain)
picking this:
C \<in> carrier_mat n n
i < n
j < n
[PROOF STEP]
have dC: "i < dim_row C" "i < dim_col C" "j < dim_row C" "j < dim_col C"
[PROOF STATE]
proof (prove)
using this:
C \<in> carrier_mat n n
i < n
j < n

goal (1 subgoal):
 1. (i < dim_row C &&& i < dim_col C) &&& j < dim_row C &&& j < dim_col C
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i < dim_row C
i < dim_col C
j < dim_row C
j < dim_col C

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
let ?c = "C $$ (i,j)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
let ?x = "inverse x"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
have "D $$ (i,j) = (if i = l \<and> j = k then 1 else if i = k \<and> j \<noteq> k then x * ?c else ?c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. D $$ (i, j) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
unfolding D
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mult_col_div_row (inverse x) k C $$ (i, j) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
proof (subst mult_col_div_index_row[OF dC \<open>inverse x \<noteq> 0\<close>], unfold inverse_inverse_eq)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
note at = inv_atD[OF inv(4) \<open>i < n\<close>, unfolded single_non_zero_def]
[PROOF STATE]
proof (state)
this:
(i \<notin> {k, l} \<longrightarrow> C $$ (i, k) = (0::'a)) \<and> C $$ (l, k) = x

goal (1 subgoal):
 1. (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
show "(if i = k \<and> j \<noteq> i then x * ?c
            else if j = k \<and> j \<noteq> i then ?x * ?c else ?c) =
            (if i = l \<and> j = k then 1 else if i = k \<and> j \<noteq> k then x * ?c else ?c)" (is "?l = ?r")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
proof (cases "(i,j) = (l,k)")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (i, j) = (l, k) \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
 2. (i, j) \<noteq> (l, k) \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
(i, j) = (l, k)

goal (2 subgoals):
 1. (i, j) = (l, k) \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
 2. (i, j) \<noteq> (l, k) \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
with lk
[PROOF STATE]
proof (chain)
picking this:
l < k
(i, j) = (l, k)
[PROOF STEP]
have "?l = ?x * ?c"
[PROOF STATE]
proof (prove)
using this:
l < k
(i, j) = (l, k)

goal (1 subgoal):
 1. (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = inverse x * C $$ (i, j)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = inverse x * C $$ (i, j)

goal (2 subgoals):
 1. (i, j) = (l, k) \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
 2. (i, j) \<noteq> (l, k) \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = inverse x * C $$ (i, j)

goal (2 subgoals):
 1. (i, j) = (l, k) \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
 2. (i, j) \<noteq> (l, k) \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
have "\<dots> = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inverse x * C $$ (i, j) = (1::'a)
[PROOF STEP]
using at True \<open>inverse x \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
using this:
(i \<notin> {k, l} \<longrightarrow> C $$ (i, k) = (0::'a)) \<and> C $$ (l, k) = x
(i, j) = (l, k)
inverse x \<noteq> (0::'a)

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

goal (2 subgoals):
 1. (i, j) = (l, k) \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
 2. (i, j) \<noteq> (l, k) \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (1::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (1::'a)

goal (1 subgoal):
 1. (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
(if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (1::'a)
(i, j) = (l, k)

goal (1 subgoal):
 1. (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))

goal (1 subgoal):
 1. (i, j) \<noteq> (l, k) \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (i, j) \<noteq> (l, k) \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
(i, j) \<noteq> (l, k)

goal (1 subgoal):
 1. (i, j) \<noteq> (l, k) \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
note neq = this
[PROOF STATE]
proof (state)
this:
(i, j) \<noteq> (l, k)

goal (1 subgoal):
 1. (i, j) \<noteq> (l, k) \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
have "?l = (if i = k \<and> j \<noteq> k then x * ?c else ?c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
proof (cases "i = k \<and> j \<noteq> k \<or> j = k \<and> i \<noteq> k")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i = k \<and> j \<noteq> k \<or> j = k \<and> i \<noteq> k \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
 2. \<not> (i = k \<and> j \<noteq> k \<or> j = k \<and> i \<noteq> k) \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
i = k \<and> j \<noteq> k \<or> j = k \<and> i \<noteq> k

goal (2 subgoals):
 1. i = k \<and> j \<noteq> k \<or> j = k \<and> i \<noteq> k \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
 2. \<not> (i = k \<and> j \<noteq> k \<or> j = k \<and> i \<noteq> k) \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
i = k \<and> j \<noteq> k \<or> j = k \<and> i \<noteq> k

goal (1 subgoal):
 1. (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i = k \<and> j \<noteq> k \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
 2. j = k \<and> i \<noteq> k \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
assume *: "i = k \<and> j \<noteq> k"
[PROOF STATE]
proof (state)
this:
i = k \<and> j \<noteq> k

goal (2 subgoals):
 1. i = k \<and> j \<noteq> k \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
 2. j = k \<and> i \<noteq> k \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
hence l: "?l = x * ?c"
[PROOF STATE]
proof (prove)
using this:
i = k \<and> j \<noteq> k

goal (1 subgoal):
 1. (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = x * C $$ (i, j)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = x * C $$ (i, j)

goal (2 subgoals):
 1. i = k \<and> j \<noteq> k \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
 2. j = k \<and> i \<noteq> k \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
using * neq
[PROOF STATE]
proof (prove)
using this:
i = k \<and> j \<noteq> k
(i, j) \<noteq> (l, k)

goal (1 subgoal):
 1. (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
unfolding l
[PROOF STATE]
proof (prove)
using this:
i = k \<and> j \<noteq> k
(i, j) \<noteq> (l, k)

goal (1 subgoal):
 1. x * C $$ (i, j) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))

goal (1 subgoal):
 1. j = k \<and> i \<noteq> k \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. j = k \<and> i \<noteq> k \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
assume *: "j = k \<and> i \<noteq> k"
[PROOF STATE]
proof (state)
this:
j = k \<and> i \<noteq> k

goal (1 subgoal):
 1. j = k \<and> i \<noteq> k \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
hence "?l = ?x * ?c"
[PROOF STATE]
proof (prove)
using this:
j = k \<and> i \<noteq> k

goal (1 subgoal):
 1. (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = inverse x * C $$ (i, j)
[PROOF STEP]
using lk
[PROOF STATE]
proof (prove)
using this:
j = k \<and> i \<noteq> k
l < k

goal (1 subgoal):
 1. (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = inverse x * C $$ (i, j)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = inverse x * C $$ (i, j)

goal (1 subgoal):
 1. j = k \<and> i \<noteq> k \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
from * neq
[PROOF STATE]
proof (chain)
picking this:
j = k \<and> i \<noteq> k
(i, j) \<noteq> (l, k)
[PROOF STEP]
have "i \<noteq> l" and **: "\<not> (i = k \<and> j \<noteq> k)"
[PROOF STATE]
proof (prove)
using this:
j = k \<and> i \<noteq> k
(i, j) \<noteq> (l, k)

goal (1 subgoal):
 1. i \<noteq> l &&& \<not> (i = k \<and> j \<noteq> k)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i \<noteq> l
\<not> (i = k \<and> j \<noteq> k)

goal (1 subgoal):
 1. j = k \<and> i \<noteq> k \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
from at \<open>i \<noteq> l\<close> *
[PROOF STATE]
proof (chain)
picking this:
(i \<notin> {k, l} \<longrightarrow> C $$ (i, k) = (0::'a)) \<and> C $$ (l, k) = x
i \<noteq> l
j = k \<and> i \<noteq> k
[PROOF STEP]
have "?c = 0"
[PROOF STATE]
proof (prove)
using this:
(i \<notin> {k, l} \<longrightarrow> C $$ (i, k) = (0::'a)) \<and> C $$ (l, k) = x
i \<noteq> l
j = k \<and> i \<noteq> k

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

goal (1 subgoal):
 1. j = k \<and> i \<noteq> k \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
with \<open>?l = ?x * ?c\<close> **
[PROOF STATE]
proof (chain)
picking this:
(if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = inverse x * C $$ (i, j)
\<not> (i = k \<and> j \<noteq> k)
C $$ (i, j) = (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = inverse x * C $$ (i, j)
\<not> (i = k \<and> j \<noteq> k)
C $$ (i, j) = (0::'a)

goal (1 subgoal):
 1. (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))

goal (1 subgoal):
 1. \<not> (i = k \<and> j \<noteq> k \<or> j = k \<and> i \<noteq> k) \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
qed auto
[PROOF STATE]
proof (state)
this:
(if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))

goal (1 subgoal):
 1. (i, j) \<noteq> (l, k) \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))

goal (1 subgoal):
 1. (i, j) \<noteq> (l, k) \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
have "\<dots> = ?r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
(i, j) \<noteq> (l, k)

goal (1 subgoal):
 1. (if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))

goal (1 subgoal):
 1. (i, j) \<noteq> (l, k) \<Longrightarrow> (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))

goal (1 subgoal):
 1. (if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(if i = k \<and> j \<noteq> i then x * C $$ (i, j) else if j = k \<and> j \<noteq> i then inverse x * C $$ (i, j) else C $$ (i, j)) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
D $$ (i, j) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i2 < n; ?j2 < n\<rbrakk> \<Longrightarrow> D $$ (?i2, ?j2) = (if ?i2 = l \<and> ?j2 = k then 1::'a else if ?i2 = k \<and> ?j2 \<noteq> k then x * C $$ (?i2, ?j2) else C $$ (?i2, ?j2))

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
note D = this
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i2 < n; ?j2 < n\<rbrakk> \<Longrightarrow> D $$ (?i2, ?j2) = (if ?i2 = l \<and> ?j2 = k then 1::'a else if ?i2 = k \<and> ?j2 \<noteq> k then x * C $$ (?i2, ?j2) else C $$ (?i2, ?j2))

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
have sD[simp]: "\<And> i. i < n \<Longrightarrow> D $$ (i,i) = C $$ (i,i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> D $$ (i, i) = C $$ (i, i)
[PROOF STEP]
using lk
[PROOF STATE]
proof (prove)
using this:
l < k

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> D $$ (i, i) = C $$ (i, i)
[PROOF STEP]
by (auto simp: D)
[PROOF STATE]
proof (state)
this:
?i < n \<Longrightarrow> D $$ (?i, ?i) = C $$ (?i, ?i)

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
from \<open>C $$ (l,l) = C $$ (k,k)\<close> \<open>l < n\<close> \<open>k < n\<close>
[PROOF STATE]
proof (chain)
picking this:
C $$ (l, l) = C $$ (k, k)
l < n
k < n
[PROOF STEP]
have Dll: "D $$ (l,l) = D $$ (k,k)"
[PROOF STATE]
proof (prove)
using this:
C $$ (l, l) = C $$ (k, k)
l < n
k < n

goal (1 subgoal):
 1. D $$ (l, l) = D $$ (k, k)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
D $$ (l, l) = D $$ (k, k)

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
have sdD: "same_diag C D"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.same_diag C D
[PROOF STEP]
unfolding same_diag_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i<n. C $$ (i, i) = D $$ (i, i)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
local.same_diag C D

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
note sd = same_diag_trans[OF sd sdD]
[PROOF STATE]
proof (state)
this:
local.same_diag A D

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
from same_diag_ev_block[OF sdD inv(2)]
[PROOF STATE]
proof (chain)
picking this:
local.ev_block n D
[PROOF STEP]
have invD: "ev_block n D"
[PROOF STATE]
proof (prove)
using this:
local.ev_block n D

goal (1 subgoal):
 1. local.ev_block n D
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
local.ev_block n D

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
note inv = inv_uptoD[OF inv(3), unfolded jb_def] inv_all_uppertD[OF inv(1)]
        inv_atD[OF inv(4), unfolded single_non_zero_def]
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i < n; ?j < n; ?j < k\<rbrakk> \<Longrightarrow> (Suc ?i = ?j \<longrightarrow> C $$ (?i, ?j) \<in> {0::'a, 1::'a}) \<and> (?i \<noteq> ?j \<longrightarrow> Suc ?i \<noteq> ?j \<or> C $$ (?i, ?i) \<noteq> C $$ (?j, ?j) \<longrightarrow> C $$ (?i, ?j) = (0::'a))
\<lbrakk>?j < ?i; ?i < n\<rbrakk> \<Longrightarrow> C $$ (?i, ?j) = (0::'a)
?i < n \<Longrightarrow> (?i \<notin> {k, l} \<longrightarrow> C $$ (?i, k) = (0::'a)) \<and> C $$ (l, k) = x

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i < n; ?j < n; ?j < k\<rbrakk> \<Longrightarrow> (Suc ?i = ?j \<longrightarrow> C $$ (?i, ?j) \<in> {0::'a, 1::'a}) \<and> (?i \<noteq> ?j \<longrightarrow> Suc ?i \<noteq> ?j \<or> C $$ (?i, ?i) \<noteq> C $$ (?j, ?j) \<longrightarrow> C $$ (?i, ?j) = (0::'a))
\<lbrakk>?j < ?i; ?i < n\<rbrakk> \<Longrightarrow> C $$ (?i, ?j) = (0::'a)
?i < n \<Longrightarrow> (?i \<notin> {k, l} \<longrightarrow> C $$ (?i, k) = (0::'a)) \<and> C $$ (l, k) = x

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
have "inv_all uppert D"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.inv_all local.uppert D
[PROOF STEP]
by (intro inv_allI, insert inv(2) lk, auto simp: uppert_def D)
[PROOF STATE]
proof (state)
this:
local.inv_all local.uppert D

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
local.inv_all local.uppert D

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
have suD: "same_upto k C D"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. same_upto k C D
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i' j'. \<lbrakk>i' < n; j' < k\<rbrakk> \<Longrightarrow> C $$ (i', j') = D $$ (i', j')
[PROOF STEP]
fix i j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i' j'. \<lbrakk>i' < n; j' < k\<rbrakk> \<Longrightarrow> C $$ (i', j') = D $$ (i', j')
[PROOF STEP]
assume i: "i < n" and j: "j < k"
[PROOF STATE]
proof (state)
this:
i < n
j < k

goal (1 subgoal):
 1. \<And>i' j'. \<lbrakk>i' < n; j' < k\<rbrakk> \<Longrightarrow> C $$ (i', j') = D $$ (i', j')
[PROOF STEP]
with kn
[PROOF STATE]
proof (chain)
picking this:
k < n
i < n
j < k
[PROOF STEP]
have jn: "j < n"
[PROOF STATE]
proof (prove)
using this:
k < n
i < n
j < k

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

goal (1 subgoal):
 1. \<And>i' j'. \<lbrakk>i' < n; j' < k\<rbrakk> \<Longrightarrow> C $$ (i', j') = D $$ (i', j')
[PROOF STEP]
show "C $$ (i, j) = D $$ (i, j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. C $$ (i, j) = D $$ (i, j)
[PROOF STEP]
unfolding D[OF i jn]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. C $$ (i, j) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
using j k
           inv(1)[OF i jn j] i j
[PROOF STATE]
proof (prove)
using this:
j < k
0 < k
(Suc i = j \<longrightarrow> C $$ (i, j) \<in> {0::'a, 1::'a}) \<and> (i \<noteq> j \<longrightarrow> Suc i \<noteq> j \<or> C $$ (i, i) \<noteq> C $$ (j, j) \<longrightarrow> C $$ (i, j) = (0::'a))
i < n
j < k

goal (1 subgoal):
 1. C $$ (i, j) = (if i = l \<and> j = k then 1::'a else if i = k \<and> j \<noteq> k then x * C $$ (i, j) else C $$ (i, j))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
C $$ (i, j) = D $$ (i, j)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
same_upto k C D

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
from same_upto_inv_upto_jb[OF suD \<open>inv_upto jb C k\<close>]
[PROOF STATE]
proof (chain)
picking this:
inv_upto local.jb D k
[PROOF STEP]
have "inv_upto jb D k"
[PROOF STATE]
proof (prove)
using this:
inv_upto local.jb D k

goal (1 subgoal):
 1. inv_upto local.jb D k
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
inv_upto local.jb D k

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
inv_upto local.jb D k

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
let ?single_one = "single_one l k"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
have "inv_at ?single_one D k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inv_at (single_one l k) D k
[PROOF STEP]
by (intro inv_atI, insert inv(3) D[OF _ \<open>k < n\<close>] ln, auto simp: single_one_def)
[PROOF STATE]
proof (state)
this:
inv_at (single_one l k) D k

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>?i < n; ?j < n; ?j < k\<rbrakk> \<Longrightarrow> (Suc ?i = ?j \<longrightarrow> C $$ (?i, ?j) \<in> {0::'a, 1::'a}) \<and> (?i \<noteq> ?j \<longrightarrow> Suc ?i \<noteq> ?j \<or> C $$ (?i, ?i) \<noteq> C $$ (?j, ?j) \<longrightarrow> C $$ (?i, ?j) = (0::'a))
\<lbrakk>?j < ?i; ?i < n\<rbrakk> \<Longrightarrow> C $$ (?i, ?j) = (0::'a)
?i < n \<Longrightarrow> (?i \<notin> {k, l} \<longrightarrow> C $$ (?i, k) = (0::'a)) \<and> C $$ (l, k) = x
local.inv_all local.uppert D
inv_upto local.jb D k
inv_at (single_one l k) D k
[PROOF STEP]
have inv: "inv_all uppert D" "ev_block n D"
        "inv_upto jb D k" "inv_at ?single_one D k"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?i < n; ?j < n; ?j < k\<rbrakk> \<Longrightarrow> (Suc ?i = ?j \<longrightarrow> C $$ (?i, ?j) \<in> {0::'a, 1::'a}) \<and> (?i \<noteq> ?j \<longrightarrow> Suc ?i \<noteq> ?j \<or> C $$ (?i, ?i) \<noteq> C $$ (?j, ?j) \<longrightarrow> C $$ (?i, ?j) = (0::'a))
\<lbrakk>?j < ?i; ?i < n\<rbrakk> \<Longrightarrow> C $$ (?i, ?j) = (0::'a)
?i < n \<Longrightarrow> (?i \<notin> {k, l} \<longrightarrow> C $$ (?i, k) = (0::'a)) \<and> C $$ (l, k) = x
local.inv_all local.uppert D
inv_upto local.jb D k
inv_at (single_one l k) D k

goal (1 subgoal):
 1. (local.inv_all local.uppert D &&& local.ev_block n D) &&& inv_upto local.jb D k &&& inv_at (single_one l k) D k
[PROOF STEP]
using invD
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?i < n; ?j < n; ?j < k\<rbrakk> \<Longrightarrow> (Suc ?i = ?j \<longrightarrow> C $$ (?i, ?j) \<in> {0::'a, 1::'a}) \<and> (?i \<noteq> ?j \<longrightarrow> Suc ?i \<noteq> ?j \<or> C $$ (?i, ?i) \<noteq> C $$ (?j, ?j) \<longrightarrow> C $$ (?i, ?j) = (0::'a))
\<lbrakk>?j < ?i; ?i < n\<rbrakk> \<Longrightarrow> C $$ (?i, ?j) = (0::'a)
?i < n \<Longrightarrow> (?i \<notin> {k, l} \<longrightarrow> C $$ (?i, k) = (0::'a)) \<and> C $$ (l, k) = x
local.inv_all local.uppert D
inv_upto local.jb D k
inv_at (single_one l k) D k
local.ev_block n D

goal (1 subgoal):
 1. (local.inv_all local.uppert D &&& local.ev_block n D) &&& inv_upto local.jb D k &&& inv_at (single_one l k) D k
[PROOF STEP]
by blast+
[PROOF STATE]
proof (state)
this:
local.inv_all local.uppert D
local.ev_block n D
inv_upto local.jb D k
inv_at (single_one l k) D k

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
note inv = inv_uptoD[OF inv(3), unfolded jb_def]
        inv_all_uppertD[OF inv(1)]
        inv_atD[OF inv(4), unfolded single_one_def]
        ev_blockD[OF inv(2)]
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i < n; ?j < n; ?j < k\<rbrakk> \<Longrightarrow> (Suc ?i = ?j \<longrightarrow> D $$ (?i, ?j) \<in> {0::'a, 1::'a}) \<and> (?i \<noteq> ?j \<longrightarrow> Suc ?i \<noteq> ?j \<or> D $$ (?i, ?i) \<noteq> D $$ (?j, ?j) \<longrightarrow> D $$ (?i, ?j) = (0::'a))
\<lbrakk>?j < ?i; ?i < n\<rbrakk> \<Longrightarrow> D $$ (?i, ?j) = (0::'a)
?i < n \<Longrightarrow> (?i \<notin> {k, l} \<longrightarrow> D $$ (?i, k) = (0::'a)) \<and> D $$ (l, k) = (1::'a)
\<lbrakk>?i < n; ?j < n\<rbrakk> \<Longrightarrow> D $$ (?i, ?i) = D $$ (?j, ?j)

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
from suC suD
[PROOF STATE]
proof (chain)
picking this:
same_upto k B C
same_upto k C D
[PROOF STEP]
have suD: "same_upto k B D"
[PROOF STATE]
proof (prove)
using this:
same_upto k B C
same_upto k C D

goal (1 subgoal):
 1. same_upto k B D
[PROOF STEP]
unfolding same_upto_def
[PROOF STATE]
proof (prove)
using this:
\<forall>i' j'. i' < n \<longrightarrow> j' < k \<longrightarrow> B $$ (i', j') = C $$ (i', j')
\<forall>i' j'. i' < n \<longrightarrow> j' < k \<longrightarrow> C $$ (i', j') = D $$ (i', j')

goal (1 subgoal):
 1. \<forall>i' j'. i' < n \<longrightarrow> j' < k \<longrightarrow> B $$ (i', j') = D $$ (i', j')
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
same_upto k B D

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
let ?I = "\<lambda> j. if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
let ?I' = "\<lambda> j. if j = Suc l then k else j - 1"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
fix i j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
assume i: "i < n" and j: "j < n"
[PROOF STATE]
proof (state)
this:
i < n
j < n

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
with Dn lk \<open>k < n\<close>
[PROOF STATE]
proof (chain)
picking this:
D \<in> carrier_mat n n
l < k
k < n
i < n
j < n
[PROOF STEP]
have dims: "i < dim_row D" "i < dim_col D" "j < dim_row D" "j < dim_col D"
          "Suc l \<le> k" "k < dim_row D" "k < dim_col D"
[PROOF STATE]
proof (prove)
using this:
D \<in> carrier_mat n n
l < k
k < n
i < n
j < n

goal (1 subgoal):
 1. (i < dim_row D &&& i < dim_col D &&& j < dim_row D) &&& (j < dim_col D &&& Suc l \<le> k) &&& k < dim_row D &&& k < dim_col D
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i < dim_row D
i < dim_col D
j < dim_row D
j < dim_col D
Suc l \<le> k
k < dim_row D
k < dim_col D

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
have "E $$ (i,j) = D $$ (?I i, ?I j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. E $$ (i, j) = D $$ (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i, if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j)
[PROOF STEP]
unfolding E
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. swap_cols_rows_block (Suc l) k D $$ (i, j) = D $$ (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i, if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j)
[PROOF STEP]
by (rule subst swap_cols_rows_block_index[OF dims])
[PROOF STATE]
proof (state)
this:
E $$ (i, j) = D $$ (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i, if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j)

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i2 < n; ?j2 < n\<rbrakk> \<Longrightarrow> E $$ (?i2, ?j2) = D $$ (if ?i2 = Suc l then k else if Suc l < ?i2 \<and> ?i2 \<le> k then ?i2 - 1 else ?i2, if ?j2 = Suc l then k else if Suc l < ?j2 \<and> ?j2 \<le> k then ?j2 - 1 else ?j2)

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
note E = this
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i2 < n; ?j2 < n\<rbrakk> \<Longrightarrow> E $$ (?i2, ?j2) = D $$ (if ?i2 = Suc l then k else if Suc l < ?i2 \<and> ?i2 \<le> k then ?i2 - 1 else ?i2, if ?j2 = Suc l then k else if Suc l < ?j2 \<and> ?j2 \<le> k then ?j2 - 1 else ?j2)

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i2 < n; ?j2 < n\<rbrakk> \<Longrightarrow> E $$ (?i2, ?j2) = D $$ (if ?i2 = Suc l then k else if Suc l < ?i2 \<and> ?i2 \<le> k then ?i2 - 1 else ?i2, if ?j2 = Suc l then k else if Suc l < ?j2 \<and> ?j2 \<le> k then ?j2 - 1 else ?j2)

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
assume i: "i < n"
[PROOF STATE]
proof (state)
this:
i < n

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
from \<open>l < k\<close>
[PROOF STATE]
proof (chain)
picking this:
l < k
[PROOF STEP]
have "l \<le> Suc l" "Suc l \<le> k"
[PROOF STATE]
proof (prove)
using this:
l < k

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

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
have "E $$ (i,i) = D $$ (i,i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. E $$ (i, i) = D $$ (i, i)
[PROOF STEP]
unfolding E[OF i i]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. D $$ (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i, if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) = D $$ (i, i)
[PROOF STEP]
by (rule inv(4), insert i \<open>k < n\<close>, auto)
[PROOF STATE]
proof (state)
this:
E $$ (i, i) = D $$ (i, i)

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?i2 < n \<Longrightarrow> E $$ (?i2, ?i2) = D $$ (?i2, ?i2)

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
note Ed = this
[PROOF STATE]
proof (state)
this:
?i2 < n \<Longrightarrow> E $$ (?i2, ?i2) = D $$ (?i2, ?i2)

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
from Ed
[PROOF STATE]
proof (chain)
picking this:
?i2 < n \<Longrightarrow> E $$ (?i2, ?i2) = D $$ (?i2, ?i2)
[PROOF STEP]
have ed: "same_diag D E"
[PROOF STATE]
proof (prove)
using this:
?i2 < n \<Longrightarrow> E $$ (?i2, ?i2) = D $$ (?i2, ?i2)

goal (1 subgoal):
 1. local.same_diag D E
[PROOF STEP]
unfolding same_diag_def
[PROOF STATE]
proof (prove)
using this:
?i2 < n \<Longrightarrow> E $$ (?i2, ?i2) = D $$ (?i2, ?i2)

goal (1 subgoal):
 1. \<forall>i<n. D $$ (i, i) = E $$ (i, i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
local.same_diag D E

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
note sd = same_diag_trans[OF sd ed]
[PROOF STATE]
proof (state)
this:
local.same_diag A E

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
have "ev_block n E"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.ev_block n E
[PROOF STEP]
using same_diag_ev_block[OF ed \<open>ev_block n D\<close>]
[PROOF STATE]
proof (prove)
using this:
local.ev_block n E

goal (1 subgoal):
 1. local.ev_block n E
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
local.ev_block n E

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
local.ev_block n E

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
have Eut: "inv_all uppert E"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.inv_all local.uppert E
[PROOF STEP]
proof (intro inv_allI, unfold uppert_def, intro impI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < n; j < n; j < i\<rbrakk> \<Longrightarrow> E $$ (i, j) = (0::'a)
[PROOF STEP]
fix i j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < n; j < n; j < i\<rbrakk> \<Longrightarrow> E $$ (i, j) = (0::'a)
[PROOF STEP]
assume i: "i < n" and j: "j < n" and ji: "j < i"
[PROOF STATE]
proof (state)
this:
i < n
j < n
j < i

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < n; j < n; j < i\<rbrakk> \<Longrightarrow> E $$ (i, j) = (0::'a)
[PROOF STEP]
have "?I i < n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) < n
[PROOF STEP]
using i \<open>k < n\<close>
[PROOF STATE]
proof (prove)
using this:
i < n
k < n

goal (1 subgoal):
 1. (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) < n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) < n

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < n; j < n; j < i\<rbrakk> \<Longrightarrow> E $$ (i, j) = (0::'a)
[PROOF STEP]
show "E $$ (i,j) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. E $$ (i, j) = (0::'a)
[PROOF STEP]
proof (cases "?I j < ?I i")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) < (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) \<Longrightarrow> E $$ (i, j) = (0::'a)
 2. \<not> (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) < (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) \<Longrightarrow> E $$ (i, j) = (0::'a)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
(if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) < (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i)

goal (2 subgoals):
 1. (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) < (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) \<Longrightarrow> E $$ (i, j) = (0::'a)
 2. \<not> (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) < (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) \<Longrightarrow> E $$ (i, j) = (0::'a)
[PROOF STEP]
from inv(2)[OF this \<open>?I i < n\<close>]
[PROOF STATE]
proof (chain)
picking this:
D $$ (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i, if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) = (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
D $$ (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i, if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) = (0::'a)

goal (1 subgoal):
 1. E $$ (i, j) = (0::'a)
[PROOF STEP]
unfolding E[OF i j]
[PROOF STATE]
proof (prove)
using this:
D $$ (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i, if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) = (0::'a)

goal (1 subgoal):
 1. D $$ (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i, if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) = (0::'a)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
E $$ (i, j) = (0::'a)

goal (1 subgoal):
 1. \<not> (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) < (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) \<Longrightarrow> E $$ (i, j) = (0::'a)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) < (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) \<Longrightarrow> E $$ (i, j) = (0::'a)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) < (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i)

goal (1 subgoal):
 1. \<not> (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) < (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) \<Longrightarrow> E $$ (i, j) = (0::'a)
[PROOF STEP]
have "?I i \<noteq> ?I j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) \<noteq> (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j)
[PROOF STEP]
using ji lk
[PROOF STATE]
proof (prove)
using this:
j < i
l < k

goal (1 subgoal):
 1. (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) \<noteq> (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j)
[PROOF STEP]
by (auto split: if_splits)
[PROOF STATE]
proof (state)
this:
(if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) \<noteq> (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j)

goal (1 subgoal):
 1. \<not> (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) < (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) \<Longrightarrow> E $$ (i, j) = (0::'a)
[PROOF STEP]
with False
[PROOF STATE]
proof (chain)
picking this:
\<not> (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) < (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i)
(if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) \<noteq> (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j)
[PROOF STEP]
have ij: "?I i < ?I j"
[PROOF STATE]
proof (prove)
using this:
\<not> (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) < (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i)
(if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) \<noteq> (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j)

goal (1 subgoal):
 1. (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) < (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) < (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j)

goal (1 subgoal):
 1. \<not> (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) < (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) \<Longrightarrow> E $$ (i, j) = (0::'a)
[PROOF STEP]
from ij ji
[PROOF STATE]
proof (chain)
picking this:
(if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) < (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j)
j < i
[PROOF STEP]
have jl: "j = Suc l"
[PROOF STATE]
proof (prove)
using this:
(if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) < (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j)
j < i

goal (1 subgoal):
 1. j = Suc l
[PROOF STEP]
using lk
[PROOF STATE]
proof (prove)
using this:
(if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) < (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j)
j < i
l < k

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

goal (1 subgoal):
 1. \<not> (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) < (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) \<Longrightarrow> E $$ (i, j) = (0::'a)
[PROOF STEP]
with ji ij
[PROOF STATE]
proof (chain)
picking this:
j < i
(if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) < (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j)
j = Suc l
[PROOF STEP]
have il: "i > Suc l" "i \<le> k"
[PROOF STATE]
proof (prove)
using this:
j < i
(if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) < (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j)
j = Suc l

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

goal (1 subgoal):
 1. \<not> (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) < (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) \<Longrightarrow> E $$ (i, j) = (0::'a)
[PROOF STEP]
from jl il
[PROOF STATE]
proof (chain)
picking this:
j = Suc l
Suc l < i
i \<le> k
[PROOF STEP]
have Eij: "E $$ (i,j) = D $$ (i-1,k)"
[PROOF STATE]
proof (prove)
using this:
j = Suc l
Suc l < i
i \<le> k

goal (1 subgoal):
 1. E $$ (i, j) = D $$ (i - 1, k)
[PROOF STEP]
unfolding E[OF i j]
[PROOF STATE]
proof (prove)
using this:
j = Suc l
Suc l < i
i \<le> k

goal (1 subgoal):
 1. D $$ (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i, if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) = D $$ (i - 1, k)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
E $$ (i, j) = D $$ (i - 1, k)

goal (1 subgoal):
 1. \<not> (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) < (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) \<Longrightarrow> E $$ (i, j) = (0::'a)
[PROOF STEP]
have "i - 1 < n" "i - 1 \<notin> {k, l}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i - 1 < n &&& i - 1 \<notin> {k, l}
[PROOF STEP]
using i il
[PROOF STATE]
proof (prove)
using this:
i < n
Suc l < i
i \<le> k

goal (1 subgoal):
 1. i - 1 < n &&& i - 1 \<notin> {k, l}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i - 1 < n
i - 1 \<notin> {k, l}

goal (1 subgoal):
 1. \<not> (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) < (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) \<Longrightarrow> E $$ (i, j) = (0::'a)
[PROOF STEP]
with inv(3)[of "i-1"]
[PROOF STATE]
proof (chain)
picking this:
i - 1 < n \<Longrightarrow> (i - 1 \<notin> {k, l} \<longrightarrow> D $$ (i - 1, k) = (0::'a)) \<and> D $$ (l, k) = (1::'a)
i - 1 < n
i - 1 \<notin> {k, l}
[PROOF STEP]
have D: "D $$ (i-1,k) = 0"
[PROOF STATE]
proof (prove)
using this:
i - 1 < n \<Longrightarrow> (i - 1 \<notin> {k, l} \<longrightarrow> D $$ (i - 1, k) = (0::'a)) \<and> D $$ (l, k) = (1::'a)
i - 1 < n
i - 1 \<notin> {k, l}

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

goal (1 subgoal):
 1. \<not> (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) < (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i) \<Longrightarrow> E $$ (i, j) = (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. E $$ (i, j) = (0::'a)
[PROOF STEP]
unfolding Eij D
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0::'a) = (0::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
E $$ (i, j) = (0::'a)

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
local.inv_all local.uppert E

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
local.inv_all local.uppert E

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
from same_diag_trans[OF \<open>same_diag B C\<close> \<open>same_diag C D\<close>]
[PROOF STATE]
proof (chain)
picking this:
local.same_diag B D
[PROOF STEP]
have "same_diag B D"
[PROOF STATE]
proof (prove)
using this:
local.same_diag B D

goal (1 subgoal):
 1. local.same_diag B D
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
local.same_diag B D

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
from identify_blocks_cong[OF \<open>k < n\<close> this suD]
[PROOF STATE]
proof (chain)
picking this:
identify_blocks B k = identify_blocks D k
[PROOF STEP]
have idb: "identify_blocks B k = identify_blocks D k"
[PROOF STATE]
proof (prove)
using this:
identify_blocks B k = identify_blocks D k

goal (1 subgoal):
 1. identify_blocks B k = identify_blocks D k
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
identify_blocks B k = identify_blocks D k

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
have "inv_upto jb E (Suc k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inv_upto local.jb E (Suc k)
[PROOF STEP]
proof (intro inv_uptoI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < n; j < n; j < Suc k\<rbrakk> \<Longrightarrow> local.jb E i j
[PROOF STEP]
fix i j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < n; j < n; j < Suc k\<rbrakk> \<Longrightarrow> local.jb E i j
[PROOF STEP]
assume i: "i < n" and j: "j < n" and "j < Suc k"
[PROOF STATE]
proof (state)
this:
i < n
j < n
j < Suc k

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < n; j < n; j < Suc k\<rbrakk> \<Longrightarrow> local.jb E i j
[PROOF STEP]
hence jk: "j \<le> k"
[PROOF STATE]
proof (prove)
using this:
i < n
j < n
j < Suc k

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

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < n; j < n; j < Suc k\<rbrakk> \<Longrightarrow> local.jb E i j
[PROOF STEP]
show "jb E i j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.jb E i j
[PROOF STEP]
proof (cases "E $$ (i,j) = 0 \<or> j = i")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. E $$ (i, j) = (0::'a) \<or> j = i \<Longrightarrow> local.jb E i j
 2. \<not> (E $$ (i, j) = (0::'a) \<or> j = i) \<Longrightarrow> local.jb E i j
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
E $$ (i, j) = (0::'a) \<or> j = i

goal (2 subgoals):
 1. E $$ (i, j) = (0::'a) \<or> j = i \<Longrightarrow> local.jb E i j
 2. \<not> (E $$ (i, j) = (0::'a) \<or> j = i) \<Longrightarrow> local.jb E i j
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
E $$ (i, j) = (0::'a) \<or> j = i

goal (1 subgoal):
 1. local.jb E i j
[PROOF STEP]
unfolding jb_def
[PROOF STATE]
proof (prove)
using this:
E $$ (i, j) = (0::'a) \<or> j = i

goal (1 subgoal):
 1. (Suc i = j \<longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a}) \<and> (i \<noteq> j \<longrightarrow> Suc i \<noteq> j \<or> E $$ (i, i) \<noteq> E $$ (j, j) \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
local.jb E i j

goal (1 subgoal):
 1. \<not> (E $$ (i, j) = (0::'a) \<or> j = i) \<Longrightarrow> local.jb E i j
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> (E $$ (i, j) = (0::'a) \<or> j = i) \<Longrightarrow> local.jb E i j
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> (E $$ (i, j) = (0::'a) \<or> j = i)

goal (1 subgoal):
 1. \<not> (E $$ (i, j) = (0::'a) \<or> j = i) \<Longrightarrow> local.jb E i j
[PROOF STEP]
note enz = this
[PROOF STATE]
proof (state)
this:
\<not> (E $$ (i, j) = (0::'a) \<or> j = i)

goal (1 subgoal):
 1. \<not> (E $$ (i, j) = (0::'a) \<or> j = i) \<Longrightarrow> local.jb E i j
[PROOF STEP]
from inv(4)[OF i j]
[PROOF STATE]
proof (chain)
picking this:
D $$ (i, i) = D $$ (j, j)
[PROOF STEP]
have same_ev: "D $$ (i,i) = D $$ (j,j)"
[PROOF STATE]
proof (prove)
using this:
D $$ (i, i) = D $$ (j, j)

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

goal (1 subgoal):
 1. \<not> (E $$ (i, j) = (0::'a) \<or> j = i) \<Longrightarrow> local.jb E i j
[PROOF STEP]
note inv2 = inv_all_uppertD[OF Eut _ i, of j]
[PROOF STATE]
proof (state)
this:
j < i \<Longrightarrow> E $$ (i, j) = (0::'a)

goal (1 subgoal):
 1. \<not> (E $$ (i, j) = (0::'a) \<or> j = i) \<Longrightarrow> local.jb E i j
[PROOF STEP]
from False inv2
[PROOF STATE]
proof (chain)
picking this:
\<not> (E $$ (i, j) = (0::'a) \<or> j = i)
j < i \<Longrightarrow> E $$ (i, j) = (0::'a)
[PROOF STEP]
have "\<not> j < i"
[PROOF STATE]
proof (prove)
using this:
\<not> (E $$ (i, j) = (0::'a) \<or> j = i)
j < i \<Longrightarrow> E $$ (i, j) = (0::'a)

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

goal (1 subgoal):
 1. \<not> (E $$ (i, j) = (0::'a) \<or> j = i) \<Longrightarrow> local.jb E i j
[PROOF STEP]
with False
[PROOF STATE]
proof (chain)
picking this:
\<not> (E $$ (i, j) = (0::'a) \<or> j = i)
\<not> j < i
[PROOF STEP]
have ji: "j > i"
[PROOF STATE]
proof (prove)
using this:
\<not> (E $$ (i, j) = (0::'a) \<or> j = i)
\<not> j < i

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

goal (1 subgoal):
 1. \<not> (E $$ (i, j) = (0::'a) \<or> j = i) \<Longrightarrow> local.jb E i j
[PROOF STEP]
have "E $$ (i,j) \<in> {0,1} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i,j) = 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
proof (cases "j \<le> l")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. j \<le> l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
 2. \<not> j \<le> l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
j \<le> l

goal (2 subgoals):
 1. j \<le> l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
 2. \<not> j \<le> l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
note jl = this
[PROOF STATE]
proof (state)
this:
j \<le> l

goal (2 subgoals):
 1. j \<le> l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
 2. \<not> j \<le> l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
with ji lk
[PROOF STATE]
proof (chain)
picking this:
i < j
l < k
j \<le> l
[PROOF STEP]
have il: "i \<le> l" and jk: "j < k"
[PROOF STATE]
proof (prove)
using this:
i < j
l < k
j \<le> l

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

goal (2 subgoals):
 1. j \<le> l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
 2. \<not> j \<le> l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
have id: "E $$ (i,j) = D $$ (i,j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. E $$ (i, j) = D $$ (i, j)
[PROOF STEP]
unfolding E[OF i j]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. D $$ (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i, if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) = D $$ (i, j)
[PROOF STEP]
using jl il
[PROOF STATE]
proof (prove)
using this:
j \<le> l
i \<le> l

goal (1 subgoal):
 1. D $$ (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i, if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) = D $$ (i, j)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
E $$ (i, j) = D $$ (i, j)

goal (2 subgoals):
 1. j \<le> l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
 2. \<not> j \<le> l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
from inv(1)[OF i j jk] ji
[PROOF STATE]
proof (chain)
picking this:
(Suc i = j \<longrightarrow> D $$ (i, j) \<in> {0::'a, 1::'a}) \<and> (i \<noteq> j \<longrightarrow> Suc i \<noteq> j \<or> D $$ (i, i) \<noteq> D $$ (j, j) \<longrightarrow> D $$ (i, j) = (0::'a))
i < j
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(Suc i = j \<longrightarrow> D $$ (i, j) \<in> {0::'a, 1::'a}) \<and> (i \<noteq> j \<longrightarrow> Suc i \<noteq> j \<or> D $$ (i, i) \<noteq> D $$ (j, j) \<longrightarrow> D $$ (i, j) = (0::'a))
i < j

goal (1 subgoal):
 1. E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
unfolding id
[PROOF STATE]
proof (prove)
using this:
(Suc i = j \<longrightarrow> D $$ (i, j) \<in> {0::'a, 1::'a}) \<and> (i \<noteq> j \<longrightarrow> Suc i \<noteq> j \<or> D $$ (i, i) \<noteq> D $$ (j, j) \<longrightarrow> D $$ (i, j) = (0::'a))
i < j

goal (1 subgoal):
 1. D $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> D $$ (i, j) = (0::'a))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))

goal (1 subgoal):
 1. \<not> j \<le> l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> j \<le> l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> j \<le> l

goal (1 subgoal):
 1. \<not> j \<le> l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
note jl = this
[PROOF STATE]
proof (state)
this:
\<not> j \<le> l

goal (1 subgoal):
 1. \<not> j \<le> l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
proof (cases "j = Suc l")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. j = Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
 2. j \<noteq> Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
j = Suc l

goal (2 subgoals):
 1. j = Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
 2. j \<noteq> Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
note jl = this
[PROOF STATE]
proof (state)
this:
j = Suc l

goal (2 subgoals):
 1. j = Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
 2. j \<noteq> Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
with ji lk
[PROOF STATE]
proof (chain)
picking this:
i < j
l < k
j = Suc l
[PROOF STEP]
have il: "i \<le> l" "i \<noteq> k"
[PROOF STATE]
proof (prove)
using this:
i < j
l < k
j = Suc l

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

goal (2 subgoals):
 1. j = Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
 2. j \<noteq> Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
have id: "E $$ (i,j) = D $$ (i,k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. E $$ (i, j) = D $$ (i, k)
[PROOF STEP]
unfolding E[OF i j]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. D $$ (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i, if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) = D $$ (i, k)
[PROOF STEP]
using jl il
[PROOF STATE]
proof (prove)
using this:
j = Suc l
i \<le> l
i \<noteq> k

goal (1 subgoal):
 1. D $$ (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i, if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) = D $$ (i, k)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
E $$ (i, j) = D $$ (i, k)

goal (2 subgoals):
 1. j = Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
 2. j \<noteq> Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
from inv(3)[OF i] jl il
[PROOF STATE]
proof (chain)
picking this:
(i \<notin> {k, l} \<longrightarrow> D $$ (i, k) = (0::'a)) \<and> D $$ (l, k) = (1::'a)
j = Suc l
i \<le> l
i \<noteq> k
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(i \<notin> {k, l} \<longrightarrow> D $$ (i, k) = (0::'a)) \<and> D $$ (l, k) = (1::'a)
j = Suc l
i \<le> l
i \<noteq> k

goal (1 subgoal):
 1. E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
unfolding id
[PROOF STATE]
proof (prove)
using this:
(i \<notin> {k, l} \<longrightarrow> D $$ (i, k) = (0::'a)) \<and> D $$ (l, k) = (1::'a)
j = Suc l
i \<le> l
i \<noteq> k

goal (1 subgoal):
 1. D $$ (i, k) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> D $$ (i, k) = (0::'a))
[PROOF STEP]
by (cases "i = l", auto)
[PROOF STATE]
proof (state)
this:
E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))

goal (1 subgoal):
 1. j \<noteq> Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. j \<noteq> Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
j \<noteq> Suc l

goal (1 subgoal):
 1. j \<noteq> Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
with jl jk kn
[PROOF STATE]
proof (chain)
picking this:
\<not> j \<le> l
j \<le> k
k < n
j \<noteq> Suc l
[PROOF STEP]
have jl: "j > Suc l" and jk: "j - 1 < k" and jn: "j - 1 < n"
[PROOF STATE]
proof (prove)
using this:
\<not> j \<le> l
j \<le> k
k < n
j \<noteq> Suc l

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

goal (1 subgoal):
 1. j \<noteq> Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
with jk
[PROOF STATE]
proof (chain)
picking this:
j - 1 < k
Suc l < j
j - 1 < k
j - 1 < n
[PROOF STEP]
have id: "?I j = j - 1"
[PROOF STATE]
proof (prove)
using this:
j - 1 < k
Suc l < j
j - 1 < k
j - 1 < n

goal (1 subgoal):
 1. (if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) = j - 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) = j - 1

goal (1 subgoal):
 1. j \<noteq> Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
note jb = inv(1)[OF _ jn jk]
[PROOF STATE]
proof (state)
this:
?i < n \<Longrightarrow> (Suc ?i = j - 1 \<longrightarrow> D $$ (?i, j - 1) \<in> {0::'a, 1::'a}) \<and> (?i \<noteq> j - 1 \<longrightarrow> Suc ?i \<noteq> j - 1 \<or> D $$ (?i, ?i) \<noteq> D $$ (j - 1, j - 1) \<longrightarrow> D $$ (?i, j - 1) = (0::'a))

goal (1 subgoal):
 1. j \<noteq> Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
proof (cases "i < Suc l")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i < Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
 2. \<not> i < Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
i < Suc l

goal (2 subgoals):
 1. i < Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
 2. \<not> i < Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
note il = this
[PROOF STATE]
proof (state)
this:
i < Suc l

goal (2 subgoals):
 1. i < Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
 2. \<not> i < Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
with id
[PROOF STATE]
proof (chain)
picking this:
(if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) = j - 1
i < Suc l
[PROOF STEP]
have id: "E $$ (i,j) = D $$ (i,j - 1)"
[PROOF STATE]
proof (prove)
using this:
(if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) = j - 1
i < Suc l

goal (1 subgoal):
 1. E $$ (i, j) = D $$ (i, j - 1)
[PROOF STEP]
unfolding E[OF i j]
[PROOF STATE]
proof (prove)
using this:
(if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) = j - 1
i < Suc l

goal (1 subgoal):
 1. D $$ (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i, if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) = D $$ (i, j - 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
E $$ (i, j) = D $$ (i, j - 1)

goal (2 subgoals):
 1. i < Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
 2. \<not> i < Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
proof (cases "i = j - 2")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i = j - 2 \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
 2. i \<noteq> j - 2 \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
i \<noteq> j - 2

goal (2 subgoals):
 1. i = j - 2 \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
 2. i \<noteq> j - 2 \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
i \<noteq> j - 2

goal (1 subgoal):
 1. E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
unfolding id
[PROOF STATE]
proof (prove)
using this:
i \<noteq> j - 2

goal (1 subgoal):
 1. D $$ (i, j - 1) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> D $$ (i, j - 1) = (0::'a))
[PROOF STEP]
using jb[OF i] il jl
[PROOF STATE]
proof (prove)
using this:
i \<noteq> j - 2
(Suc i = j - 1 \<longrightarrow> D $$ (i, j - 1) \<in> {0::'a, 1::'a}) \<and> (i \<noteq> j - 1 \<longrightarrow> Suc i \<noteq> j - 1 \<or> D $$ (i, i) \<noteq> D $$ (j - 1, j - 1) \<longrightarrow> D $$ (i, j - 1) = (0::'a))
i < Suc l
Suc l < j

goal (1 subgoal):
 1. D $$ (i, j - 1) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> D $$ (i, j - 1) = (0::'a))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))

goal (1 subgoal):
 1. i = j - 2 \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i = j - 2 \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
i = j - 2

goal (1 subgoal):
 1. i = j - 2 \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
with il jl
[PROOF STATE]
proof (chain)
picking this:
i < Suc l
Suc l < j
i = j - 2
[PROOF STEP]
have *: "j = Suc (Suc l)" "i = l"
[PROOF STATE]
proof (prove)
using this:
i < Suc l
Suc l < j
i = j - 2

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

goal (1 subgoal):
 1. i = j - 2 \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
with id
[PROOF STATE]
proof (chain)
picking this:
E $$ (i, j) = D $$ (i, j - 1)
j = Suc (Suc l)
i = l
[PROOF STEP]
have id: "E $$ (i,j) = D $$ (l,Suc l)"
[PROOF STATE]
proof (prove)
using this:
E $$ (i, j) = D $$ (i, j - 1)
j = Suc (Suc l)
i = l

goal (1 subgoal):
 1. E $$ (i, j) = D $$ (l, Suc l)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
E $$ (i, j) = D $$ (l, Suc l)

goal (1 subgoal):
 1. i = j - 2 \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
from * jl jk
[PROOF STATE]
proof (chain)
picking this:
j = Suc (Suc l)
i = l
Suc l < j
j - 1 < k
[PROOF STEP]
have neq: "Suc l \<noteq> k"
[PROOF STATE]
proof (prove)
using this:
j = Suc (Suc l)
i = l
Suc l < j
j - 1 < k

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

goal (1 subgoal):
 1. i = j - 2 \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
from lblock[unfolded idb]
[PROOF STATE]
proof (chain)
picking this:
(l_start, l) \<in> set (identify_blocks D k)
[PROOF STEP]
have "(l_start, l) \<in> set (identify_blocks D k)"
[PROOF STATE]
proof (prove)
using this:
(l_start, l) \<in> set (identify_blocks D k)

goal (1 subgoal):
 1. (l_start, l) \<in> set (identify_blocks D k)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(l_start, l) \<in> set (identify_blocks D k)

goal (1 subgoal):
 1. i = j - 2 \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
from this[unfolded identify_blocks_iff[OF kn]] neq
[PROOF STATE]
proof (chain)
picking this:
(l_start, l) \<in> {(i, j) |i j. i \<le> j \<and> j < k \<and> (\<forall>l\<ge>i. l < j \<longrightarrow> D $$ (l, Suc l) = (1::'a)) \<and> (Suc j \<noteq> k \<longrightarrow> D $$ (j, Suc j) \<noteq> (1::'a)) \<and> (0 < i \<longrightarrow> D $$ (i - 1, i) \<noteq> (1::'a))}
Suc l \<noteq> k
[PROOF STEP]
have "D $$ (l, Suc l) \<noteq> 1"
[PROOF STATE]
proof (prove)
using this:
(l_start, l) \<in> {(i, j) |i j. i \<le> j \<and> j < k \<and> (\<forall>l\<ge>i. l < j \<longrightarrow> D $$ (l, Suc l) = (1::'a)) \<and> (Suc j \<noteq> k \<longrightarrow> D $$ (j, Suc j) \<noteq> (1::'a)) \<and> (0 < i \<longrightarrow> D $$ (i - 1, i) \<noteq> (1::'a))}
Suc l \<noteq> k

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

goal (1 subgoal):
 1. i = j - 2 \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
with jb[OF i] il jl ji *
[PROOF STATE]
proof (chain)
picking this:
(Suc i = j - 1 \<longrightarrow> D $$ (i, j - 1) \<in> {0::'a, 1::'a}) \<and> (i \<noteq> j - 1 \<longrightarrow> Suc i \<noteq> j - 1 \<or> D $$ (i, i) \<noteq> D $$ (j - 1, j - 1) \<longrightarrow> D $$ (i, j - 1) = (0::'a))
i < Suc l
Suc l < j
i < j
j = Suc (Suc l)
i = l
D $$ (l, Suc l) \<noteq> (1::'a)
[PROOF STEP]
have "D $$ (l, Suc l) = 0"
[PROOF STATE]
proof (prove)
using this:
(Suc i = j - 1 \<longrightarrow> D $$ (i, j - 1) \<in> {0::'a, 1::'a}) \<and> (i \<noteq> j - 1 \<longrightarrow> Suc i \<noteq> j - 1 \<or> D $$ (i, i) \<noteq> D $$ (j - 1, j - 1) \<longrightarrow> D $$ (i, j - 1) = (0::'a))
i < Suc l
Suc l < j
i < j
j = Suc (Suc l)
i = l
D $$ (l, Suc l) \<noteq> (1::'a)

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

goal (1 subgoal):
 1. i = j - 2 \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
D $$ (l, Suc l) = (0::'a)

goal (1 subgoal):
 1. E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
unfolding id
[PROOF STATE]
proof (prove)
using this:
D $$ (l, Suc l) = (0::'a)

goal (1 subgoal):
 1. D $$ (l, Suc l) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> D $$ (l, Suc l) = (0::'a))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))

goal (1 subgoal):
 1. \<not> i < Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> i < Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> i < Suc l

goal (1 subgoal):
 1. \<not> i < Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
note il = this
[PROOF STATE]
proof (state)
this:
\<not> i < Suc l

goal (1 subgoal):
 1. \<not> i < Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
proof (cases "i = Suc l")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i = Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
 2. i \<noteq> Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
i = Suc l

goal (2 subgoals):
 1. i = Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
 2. i \<noteq> Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
with id
[PROOF STATE]
proof (chain)
picking this:
(if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) = j - 1
i = Suc l
[PROOF STEP]
have id: "E $$ (i,j) = D $$ (k,j - 1)"
[PROOF STATE]
proof (prove)
using this:
(if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) = j - 1
i = Suc l

goal (1 subgoal):
 1. E $$ (i, j) = D $$ (k, j - 1)
[PROOF STEP]
unfolding E[OF i j]
[PROOF STATE]
proof (prove)
using this:
(if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) = j - 1
i = Suc l

goal (1 subgoal):
 1. D $$ (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i, if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) = D $$ (k, j - 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
E $$ (i, j) = D $$ (k, j - 1)

goal (2 subgoals):
 1. i = Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
 2. i \<noteq> Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
from inv(2)[OF jk kn]
[PROOF STATE]
proof (chain)
picking this:
D $$ (k, j - 1) = (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
D $$ (k, j - 1) = (0::'a)

goal (1 subgoal):
 1. E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
unfolding id
[PROOF STATE]
proof (prove)
using this:
D $$ (k, j - 1) = (0::'a)

goal (1 subgoal):
 1. D $$ (k, j - 1) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> D $$ (k, j - 1) = (0::'a))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))

goal (1 subgoal):
 1. i \<noteq> Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i \<noteq> Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
i \<noteq> Suc l

goal (1 subgoal):
 1. i \<noteq> Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
with il jl ji jk kn
[PROOF STATE]
proof (chain)
picking this:
\<not> i < Suc l
Suc l < j
i < j
j - 1 < k
k < n
i \<noteq> Suc l
[PROOF STEP]
have il: "i > Suc l" and ik: "i < k" and i_n: "i - 1 < n"
[PROOF STATE]
proof (prove)
using this:
\<not> i < Suc l
Suc l < j
i < j
j - 1 < k
k < n
i \<noteq> Suc l

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

goal (1 subgoal):
 1. i \<noteq> Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
with id
[PROOF STATE]
proof (chain)
picking this:
(if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) = j - 1
Suc l < i
i < k
i - 1 < n
[PROOF STEP]
have id: "E $$ (i,j) = D $$ (i - 1, j - 1)"
[PROOF STATE]
proof (prove)
using this:
(if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) = j - 1
Suc l < i
i < k
i - 1 < n

goal (1 subgoal):
 1. E $$ (i, j) = D $$ (i - 1, j - 1)
[PROOF STEP]
unfolding E[OF i j]
[PROOF STATE]
proof (prove)
using this:
(if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) = j - 1
Suc l < i
i < k
i - 1 < n

goal (1 subgoal):
 1. D $$ (if i = Suc l then k else if Suc l < i \<and> i \<le> k then i - 1 else i, if j = Suc l then k else if Suc l < j \<and> j \<le> k then j - 1 else j) = D $$ (i - 1, j - 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
E $$ (i, j) = D $$ (i - 1, j - 1)

goal (1 subgoal):
 1. i \<noteq> Suc l \<Longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
unfolding id
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. D $$ (i - 1, j - 1) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> D $$ (i - 1, j - 1) = (0::'a))
[PROOF STEP]
using jb[OF i_n] il jl ji
[PROOF STATE]
proof (prove)
using this:
(Suc (i - 1) = j - 1 \<longrightarrow> D $$ (i - 1, j - 1) \<in> {0::'a, 1::'a}) \<and> (i - 1 \<noteq> j - 1 \<longrightarrow> Suc (i - 1) \<noteq> j - 1 \<or> D $$ (i - 1, i - 1) \<noteq> D $$ (j - 1, j - 1) \<longrightarrow> D $$ (i - 1, j - 1) = (0::'a))
Suc l < i
Suc l < j
i < j

goal (1 subgoal):
 1. D $$ (i - 1, j - 1) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> D $$ (i - 1, j - 1) = (0::'a))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))

goal (1 subgoal):
 1. \<not> (E $$ (i, j) = (0::'a) \<or> j = i) \<Longrightarrow> local.jb E i j
[PROOF STEP]
thus "jb E i j"
[PROOF STATE]
proof (prove)
using this:
E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))

goal (1 subgoal):
 1. local.jb E i j
[PROOF STEP]
unfolding jb_def Ed[OF i] Ed[OF j] same_ev
[PROOF STATE]
proof (prove)
using this:
E $$ (i, j) \<in> {0::'a, 1::'a} \<and> (j \<noteq> Suc i \<longrightarrow> E $$ (i, j) = (0::'a))

goal (1 subgoal):
 1. (Suc i = j \<longrightarrow> E $$ (i, j) \<in> {0::'a, 1::'a}) \<and> (i \<noteq> j \<longrightarrow> Suc i \<noteq> j \<or> D $$ (j, j) \<noteq> D $$ (j, j) \<longrightarrow> E $$ (i, j) = (0::'a))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
local.jb E i j

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
local.jb E i j

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
inv_upto local.jb E (Suc k)

goal (1 subgoal):
 1. blocks \<noteq> [] \<Longrightarrow> local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
local.ev_block n E
local.inv_all local.uppert E
inv_upto local.jb E (Suc k)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
local.ev_block n E
local.inv_all local.uppert E
inv_upto local.jb E (Suc k)

goal (1 subgoal):
 1. local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
using sd
[PROOF STATE]
proof (prove)
using this:
local.ev_block n E
local.inv_all local.uppert E
inv_upto local.jb E (Suc k)
local.same_diag A E

goal (1 subgoal):
 1. local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
[PROOF STEP]
unfolding F
[PROOF STATE]
proof (prove)
using this:
local.ev_block n E
local.inv_all local.uppert E
inv_upto local.jb E (Suc k)
local.same_diag A E

goal (1 subgoal):
 1. local.inv_all local.uppert E \<and> local.same_diag A E \<and> inv_upto local.jb E (Suc k)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)

goal (1 subgoal):
 1. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
hence inv: "inv_all uppert F" "ev_block n F" "inv_upto jb F (Suc k)"
      and sd: "same_diag A F"
[PROOF STATE]
proof (prove)
using this:
local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)

goal (1 subgoal):
 1. (local.inv_all local.uppert F &&& local.ev_block n F &&& inv_upto local.jb F (Suc k)) &&& local.same_diag A F
[PROOF STEP]
using same_diag_ev_block[OF _ \<open>ev_block n A\<close>]
[PROOF STATE]
proof (prove)
using this:
local.inv_all local.uppert F \<and> local.same_diag A F \<and> inv_upto local.jb F (Suc k)
local.same_diag A ?B \<Longrightarrow> local.ev_block n ?B

goal (1 subgoal):
 1. (local.inv_all local.uppert F &&& local.ev_block n F &&& inv_upto local.jb F (Suc k)) &&& local.same_diag A F
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
local.inv_all local.uppert F
local.ev_block n F
inv_upto local.jb F (Suc k)
local.same_diag A F

goal (1 subgoal):
 1. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
have "0 < Suc k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < Suc k
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 < Suc k

goal (1 subgoal):
 1. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
note IH = IH[OF Fn this inv(1-3)]
[PROOF STATE]
proof (state)
this:
local.inv_all local.jb (step_3_main n (Suc k) F) \<and> local.same_diag F (step_3_main n (Suc k) F)

goal (1 subgoal):
 1. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
have id: "step_3_main n k A = step_3_main n (Suc k) F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. step_3_main n k A = step_3_main n (Suc k) F
[PROOF STEP]
using kn
[PROOF STATE]
proof (prove)
using this:
k < n

goal (1 subgoal):
 1. step_3_main n k A = step_3_main n (Suc k) F
[PROOF STEP]
by (simp add: F Let_def blocks ab B)
[PROOF STATE]
proof (state)
this:
step_3_main n k A = step_3_main n (Suc k) F

goal (1 subgoal):
 1. \<not> n \<le> k \<Longrightarrow> local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
from same_diag_trans[OF sd] IH
[PROOF STATE]
proof (chain)
picking this:
local.same_diag F ?C \<Longrightarrow> local.same_diag A ?C
local.inv_all local.jb (step_3_main n (Suc k) F) \<and> local.same_diag F (step_3_main n (Suc k) F)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
local.same_diag F ?C \<Longrightarrow> local.same_diag A ?C
local.inv_all local.jb (step_3_main n (Suc k) F) \<and> local.same_diag F (step_3_main n (Suc k) F)

goal (1 subgoal):
 1. local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)
[PROOF STEP]
unfolding id
[PROOF STATE]
proof (prove)
using this:
local.same_diag F ?C \<Longrightarrow> local.same_diag A ?C
local.inv_all local.jb (step_3_main n (Suc k) F) \<and> local.same_diag F (step_3_main n (Suc k) F)

goal (1 subgoal):
 1. local.inv_all local.jb (step_3_main n (Suc k) F) \<and> local.same_diag A (step_3_main n (Suc k) F)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
local.inv_all local.jb (step_3_main n k A) \<and> local.same_diag A (step_3_main n k A)

goal:
No subgoals!
[PROOF STEP]
qed