[STATEMENT]
lemma echelon_echelon_form_column_k:
  fixes A::"'a::{bezout_domain}^'cols::{mod_type}^'rows::{mod_type}" and k bezout
  defines i:"i \<equiv> (if \<forall>m. is_zero_row_upt_k m k A then 0
  else to_nat ((GREATEST n. \<not> is_zero_row_upt_k n k A)) + 1)"
  defines B: "B \<equiv> fst ((echelon_form_of_column_k bezout) (A,i) k)"
  assumes ib: "is_bezout_ext bezout" and e: "echelon_form_upt_k A k" and k: "k<ncols A"
  shows "echelon_form_upt_k B (Suc k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. echelon_form_upt_k B (Suc k)
[PROOF STEP]
unfolding echelon_form_upt_k_def echelon_form_of_column_k_def Let_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>i. is_zero_row_upt_k i (Suc k) B \<longrightarrow> \<not> (\<exists>j>i. \<not> is_zero_row_upt_k j (Suc k) B)) \<and> (\<forall>i j. i < j \<and> \<not> is_zero_row_upt_k i (Suc k) B \<and> \<not> is_zero_row_upt_k j (Suc k) B \<longrightarrow> (LEAST n. B $ i $ n \<noteq> (0::'a)) < (LEAST n. B $ j $ n \<noteq> (0::'a)))
[PROOF STEP]
proof auto
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i j. \<lbrakk>is_zero_row_upt_k i (Suc k) B; i < j\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) B
 2. \<And>i j. \<lbrakk>i < j; \<not> is_zero_row_upt_k i (Suc k) B; \<not> is_zero_row_upt_k j (Suc k) B\<rbrakk> \<Longrightarrow> (LEAST n. B $ i $ n \<noteq> (0::'a)) < (LEAST n. B $ j $ n \<noteq> (0::'a))
[PROOF STEP]
fix a b
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i j. \<lbrakk>is_zero_row_upt_k i (Suc k) B; i < j\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) B
 2. \<And>i j. \<lbrakk>i < j; \<not> is_zero_row_upt_k i (Suc k) B; \<not> is_zero_row_upt_k j (Suc k) B\<rbrakk> \<Longrightarrow> (LEAST n. B $ i $ n \<noteq> (0::'a)) < (LEAST n. B $ j $ n \<noteq> (0::'a))
[PROOF STEP]
let ?B2="(fst (if \<forall>m\<ge>from_nat i. A $ m $ from_nat k = 0 then (A, i)
    else if \<forall>m>from_nat i. A $ m $ from_nat k = 0 then (A, i + 1)
    else (bezout_iterate
    (interchange_rows A (from_nat i) (LEAST n. A $ n $ from_nat k \<noteq> 0 \<and> from_nat i \<le> n))
    (nrows A - 1) (from_nat i) (from_nat k) bezout, i + 1)))"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i j. \<lbrakk>is_zero_row_upt_k i (Suc k) B; i < j\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) B
 2. \<And>i j. \<lbrakk>i < j; \<not> is_zero_row_upt_k i (Suc k) B; \<not> is_zero_row_upt_k j (Suc k) B\<rbrakk> \<Longrightarrow> (LEAST n. B $ i $ n \<noteq> (0::'a)) < (LEAST n. B $ j $ n \<noteq> (0::'a))
[PROOF STEP]
show "is_zero_row_upt_k a (Suc k) B \<Longrightarrow> a < b \<Longrightarrow> is_zero_row_upt_k b (Suc k) B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>is_zero_row_upt_k a (Suc k) B; a < b\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) B
[PROOF STEP]
proof (unfold B echelon_form_of_column_k_def Let_def fst_conv snd_conv, auto)
[PROOF STATE]
proof (state)
goal (5 subgoals):
 1. \<lbrakk>is_zero_row_upt_k a (Suc k) A; a < b; \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 2. \<lbrakk>is_zero_row_upt_k a (Suc k) A; a < b; \<forall>m>mod_type_class.from_nat (nrows A). A $ m $ mod_type_class.from_nat k = (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 3. \<And>m. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 4. \<And>m. \<lbrakk>is_zero_row_upt_k a (Suc k) A; a < b; mod_type_class.from_nat (nrows A) < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 5. \<And>m ma. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout)
[PROOF STEP]
assume 1: "is_zero_row_upt_k a (Suc k) A" and 2: "a < b"
      and 3: "\<forall>m\<ge>from_nat i. A $ m $ from_nat k = 0"
[PROOF STATE]
proof (state)
this:
is_zero_row_upt_k a (Suc k) A
a < b
\<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a)

goal (5 subgoals):
 1. \<lbrakk>is_zero_row_upt_k a (Suc k) A; a < b; \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 2. \<lbrakk>is_zero_row_upt_k a (Suc k) A; a < b; \<forall>m>mod_type_class.from_nat (nrows A). A $ m $ mod_type_class.from_nat k = (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 3. \<And>m. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 4. \<And>m. \<lbrakk>is_zero_row_upt_k a (Suc k) A; a < b; mod_type_class.from_nat (nrows A) < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 5. \<And>m ma. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout)
[PROOF STEP]
show "is_zero_row_upt_k b (Suc k) A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_zero_row_upt_k b (Suc k) A
[PROOF STEP]
by (rule condition1_part1[OF e 1 2 3[unfolded i]])
[PROOF STATE]
proof (state)
this:
is_zero_row_upt_k b (Suc k) A

goal (4 subgoals):
 1. \<lbrakk>is_zero_row_upt_k a (Suc k) A; a < b; \<forall>m>mod_type_class.from_nat (nrows A). A $ m $ mod_type_class.from_nat k = (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 2. \<And>m. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 3. \<And>m. \<lbrakk>is_zero_row_upt_k a (Suc k) A; a < b; mod_type_class.from_nat (nrows A) < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 4. \<And>m ma. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. \<lbrakk>is_zero_row_upt_k a (Suc k) A; a < b; \<forall>m>mod_type_class.from_nat (nrows A). A $ m $ mod_type_class.from_nat k = (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 2. \<And>m. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 3. \<And>m. \<lbrakk>is_zero_row_upt_k a (Suc k) A; a < b; mod_type_class.from_nat (nrows A) < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 4. \<And>m ma. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout)
[PROOF STEP]
assume 1: "is_zero_row_upt_k a (Suc k) A" and 2: "a < b"
      and 3: "i = nrows A " and 4: "\<forall>m>from_nat (nrows A). A $ m $ from_nat k = 0"
[PROOF STATE]
proof (state)
this:
is_zero_row_upt_k a (Suc k) A
a < b
i = nrows A
\<forall>m>mod_type_class.from_nat (nrows A). A $ m $ mod_type_class.from_nat k = (0::'a)

goal (4 subgoals):
 1. \<lbrakk>is_zero_row_upt_k a (Suc k) A; a < b; \<forall>m>mod_type_class.from_nat (nrows A). A $ m $ mod_type_class.from_nat k = (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 2. \<And>m. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 3. \<And>m. \<lbrakk>is_zero_row_upt_k a (Suc k) A; a < b; mod_type_class.from_nat (nrows A) < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 4. \<And>m ma. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout)
[PROOF STEP]
show "is_zero_row_upt_k b (Suc k) A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_zero_row_upt_k b (Suc k) A
[PROOF STEP]
by (rule condition1_part2[OF e 1 2 3[unfolded i] 4])
[PROOF STATE]
proof (state)
this:
is_zero_row_upt_k b (Suc k) A

goal (3 subgoals):
 1. \<And>m. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 2. \<And>m. \<lbrakk>is_zero_row_upt_k a (Suc k) A; a < b; mod_type_class.from_nat (nrows A) < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 3. \<And>m ma. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>m. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 2. \<And>m. \<lbrakk>is_zero_row_upt_k a (Suc k) A; a < b; mod_type_class.from_nat (nrows A) < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 3. \<And>m ma. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout)
[PROOF STEP]
fix m
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>m. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 2. \<And>m. \<lbrakk>is_zero_row_upt_k a (Suc k) A; a < b; mod_type_class.from_nat (nrows A) < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 3. \<And>m ma. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout)
[PROOF STEP]
assume 1: "is_zero_row_upt_k a (Suc k) ?B2"
      and 2: "a < b" and 3: "\<forall>m>from_nat i. A $ m $ from_nat k = 0"
      and 4: "i \<noteq> nrows A" and 5: "from_nat i \<le> m"
      and 6: "A $ m $ from_nat k \<noteq> 0"
[PROOF STATE]
proof (state)
this:
is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1)))
a < b
\<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a)
i \<noteq> nrows A
mod_type_class.from_nat i \<le> m
A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)

goal (3 subgoals):
 1. \<And>m. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 2. \<And>m. \<lbrakk>is_zero_row_upt_k a (Suc k) A; a < b; mod_type_class.from_nat (nrows A) < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 3. \<And>m ma. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout)
[PROOF STEP]
show "is_zero_row_upt_k b (Suc k) A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_zero_row_upt_k b (Suc k) A
[PROOF STEP]
using condition1_part3[OF e ib _ 2 _ _ _ 6]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>is_zero_row_upt_k a (Suc k) (fst (echelon_form_of_column_k bezout (A, if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) k)); \<forall>m>mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1). A $ m $ mod_type_class.from_nat k = (0::'a); (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) \<noteq> nrows A; mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) \<le> m\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A

goal (1 subgoal):
 1. is_zero_row_upt_k b (Suc k) A
[PROOF STEP]
using 1 3 4 5
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>is_zero_row_upt_k a (Suc k) (fst (echelon_form_of_column_k bezout (A, if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) k)); \<forall>m>mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1). A $ m $ mod_type_class.from_nat k = (0::'a); (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) \<noteq> nrows A; mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) \<le> m\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1)))
\<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a)
i \<noteq> nrows A
mod_type_class.from_nat i \<le> m

goal (1 subgoal):
 1. is_zero_row_upt_k b (Suc k) A
[PROOF STEP]
unfolding i echelon_form_of_column_k_def Let_def fst_conv snd_conv
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>is_zero_row_upt_k a (Suc k) (fst (case (A, if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) of (A, i) \<Rightarrow> if (\<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a)) \<or> i = nrows A then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); \<forall>m>mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1). A $ m $ mod_type_class.from_nat k = (0::'a); (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) \<noteq> nrows A; mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) \<le> m\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1). A $ m $ mod_type_class.from_nat k = (0::'a) then (A, if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) else if \<forall>m>mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1). A $ m $ mod_type_class.from_nat k = (0::'a) then (A, (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1)) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) \<le> n)) (nrows A - 1) (mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1)) (mod_type_class.from_nat k) bezout, (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) + 1)))
\<forall>m>mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1). A $ m $ mod_type_class.from_nat k = (0::'a)
(if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) \<noteq> nrows A
mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) \<le> m

goal (1 subgoal):
 1. is_zero_row_upt_k b (Suc k) A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
is_zero_row_upt_k b (Suc k) A

goal (2 subgoals):
 1. \<And>m. \<lbrakk>is_zero_row_upt_k a (Suc k) A; a < b; mod_type_class.from_nat (nrows A) < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 2. \<And>m ma. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>m. \<lbrakk>is_zero_row_upt_k a (Suc k) A; a < b; mod_type_class.from_nat (nrows A) < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 2. \<And>m ma. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout)
[PROOF STEP]
fix m::'c
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>m. \<lbrakk>is_zero_row_upt_k a (Suc k) A; a < b; mod_type_class.from_nat (nrows A) < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 2. \<And>m ma. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout)
[PROOF STEP]
assume 1: "is_zero_row_upt_k a (Suc k) A" and 2: "i = nrows A"
[PROOF STATE]
proof (state)
this:
is_zero_row_upt_k a (Suc k) A
i = nrows A

goal (2 subgoals):
 1. \<And>m. \<lbrakk>is_zero_row_upt_k a (Suc k) A; a < b; mod_type_class.from_nat (nrows A) < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) A
 2. \<And>m ma. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout)
[PROOF STEP]
show "is_zero_row_upt_k b (Suc k) A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_zero_row_upt_k b (Suc k) A
[PROOF STEP]
by (rule condition1_part4[OF e 1 2[unfolded i]])
[PROOF STATE]
proof (state)
this:
is_zero_row_upt_k b (Suc k) A

goal (1 subgoal):
 1. \<And>m ma. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>m ma. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout)
[PROOF STEP]
let ?B2="(fst (if \<forall>m\<ge>from_nat i. A $ m $ from_nat k = 0 then (A, i)
      else if \<forall>m>from_nat i. A $ m $ from_nat k = 0 then (A, i + 1)
      else (bezout_iterate
      (interchange_rows A (from_nat i)
      (LEAST n. A $ n $ from_nat k \<noteq> 0 \<and> from_nat i \<le> n))
      (nrows A - 1) (from_nat i) (from_nat k) bezout,
      i + 1)))"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>m ma. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout)
[PROOF STEP]
fix m
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>m ma. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout)
[PROOF STEP]
assume 1: "is_zero_row_upt_k a (Suc k) ?B2"
      and 2: "a < b"
      and 3: "from_nat i < m"
      and 4: "A $ m $ from_nat k \<noteq> 0"
      and 5: "i \<noteq> nrows A"
[PROOF STATE]
proof (state)
this:
is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1)))
a < b
mod_type_class.from_nat i < m
A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)
i \<noteq> nrows A

goal (1 subgoal):
 1. \<And>m ma. \<lbrakk>is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); a < b; mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout)
[PROOF STEP]
show "is_zero_row_upt_k b (Suc k)
      (bezout_iterate
      (interchange_rows A (from_nat i) (LEAST n. A $ n $ from_nat k \<noteq> 0 \<and> from_nat i \<le> n))
      (nrows A - Suc 0) (from_nat i) (from_nat k) bezout)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout)
[PROOF STEP]
using condition1_part5[OF ib e _ 2 _ 4 _ k]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>is_zero_row_upt_k a (Suc k) (fst (echelon_form_of_column_k bezout (A, if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) k)); mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) < m; (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) \<noteq> nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1)) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1)) (mod_type_class.from_nat k) bezout)

goal (1 subgoal):
 1. is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout)
[PROOF STEP]
using 1 3 5
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>is_zero_row_upt_k a (Suc k) (fst (echelon_form_of_column_k bezout (A, if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) k)); mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) < m; (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) \<noteq> nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1)) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1)) (mod_type_class.from_nat k) bezout)
is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1)))
mod_type_class.from_nat i < m
i \<noteq> nrows A

goal (1 subgoal):
 1. is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout)
[PROOF STEP]
unfolding i echelon_form_of_column_k_def Let_def fst_conv snd_conv
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>is_zero_row_upt_k a (Suc k) (fst (case (A, if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) of (A, i) \<Rightarrow> if (\<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a)) \<or> i = nrows A then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1))); mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) < m; (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) \<noteq> nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1)) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1)) (mod_type_class.from_nat k) bezout)
is_zero_row_upt_k a (Suc k) (fst (if \<forall>m\<ge>mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1). A $ m $ mod_type_class.from_nat k = (0::'a) then (A, if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) else if \<forall>m>mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1). A $ m $ mod_type_class.from_nat k = (0::'a) then (A, (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1)) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) \<le> n)) (nrows A - 1) (mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1)) (mod_type_class.from_nat k) bezout, (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) + 1)))
mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) < m
(if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) \<noteq> nrows A

goal (1 subgoal):
 1. is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1)) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1)) (mod_type_class.from_nat k) bezout)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<lbrakk>is_zero_row_upt_k a (Suc k) B; a < b\<rbrakk> \<Longrightarrow> is_zero_row_upt_k b (Suc k) B

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < j; \<not> is_zero_row_upt_k i (Suc k) B; \<not> is_zero_row_upt_k j (Suc k) B\<rbrakk> \<Longrightarrow> (LEAST n. B $ i $ n \<noteq> (0::'a)) < (LEAST n. B $ j $ n \<noteq> (0::'a))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < j; \<not> is_zero_row_upt_k i (Suc k) B; \<not> is_zero_row_upt_k j (Suc k) B\<rbrakk> \<Longrightarrow> (LEAST n. B $ i $ n \<noteq> (0::'a)) < (LEAST n. B $ j $ n \<noteq> (0::'a))
[PROOF STEP]
fix a b
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < j; \<not> is_zero_row_upt_k i (Suc k) B; \<not> is_zero_row_upt_k j (Suc k) B\<rbrakk> \<Longrightarrow> (LEAST n. B $ i $ n \<noteq> (0::'a)) < (LEAST n. B $ j $ n \<noteq> (0::'a))
[PROOF STEP]
assume ab: "a < b" and not_zero_aB: "\<not> is_zero_row_upt_k a (Suc k) B"
    and not_zero_bB: "\<not> is_zero_row_upt_k b (Suc k) B"
[PROOF STATE]
proof (state)
this:
a < b
\<not> is_zero_row_upt_k a (Suc k) B
\<not> is_zero_row_upt_k b (Suc k) B

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < j; \<not> is_zero_row_upt_k i (Suc k) B; \<not> is_zero_row_upt_k j (Suc k) B\<rbrakk> \<Longrightarrow> (LEAST n. B $ i $ n \<noteq> (0::'a)) < (LEAST n. B $ j $ n \<noteq> (0::'a))
[PROOF STEP]
show "(LEAST n. B $ a $ n \<noteq> 0) < (LEAST n. B $ b $ n \<noteq> 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (LEAST n. B $ a $ n \<noteq> (0::'a)) < (LEAST n. B $ b $ n \<noteq> (0::'a))
[PROOF STEP]
proof (unfold B echelon_form_of_column_k_def Let_def fst_conv snd_conv, auto)
[PROOF STATE]
proof (state)
goal (5 subgoals):
 1. \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 2. \<lbrakk>\<forall>m>mod_type_class.from_nat (nrows A). A $ m $ mod_type_class.from_nat k = (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 3. \<And>m. \<lbrakk>\<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 4. \<And>m. \<lbrakk>mod_type_class.from_nat (nrows A) < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 5. \<And>m ma. \<lbrakk>mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ a $ n \<noteq> (0::'a)) < (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ b $ n \<noteq> (0::'a))
[PROOF STEP]
assume all_zero: "\<forall>m\<ge>from_nat i. A $ m $ from_nat k = 0"
[PROOF STATE]
proof (state)
this:
\<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a)

goal (5 subgoals):
 1. \<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 2. \<lbrakk>\<forall>m>mod_type_class.from_nat (nrows A). A $ m $ mod_type_class.from_nat k = (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 3. \<And>m. \<lbrakk>\<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 4. \<And>m. \<lbrakk>mod_type_class.from_nat (nrows A) < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 5. \<And>m ma. \<lbrakk>mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ a $ n \<noteq> (0::'a)) < (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ b $ n \<noteq> (0::'a))
[PROOF STEP]
show "(LEAST n. A $ a $ n \<noteq> 0) < (LEAST n. A $ b $ n \<noteq> 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
[PROOF STEP]
using condition2_part1[OF e ab] not_zero_aB not_zero_bB all_zero
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> is_zero_row_upt_k a (Suc k) (fst (echelon_form_of_column_k ?bezout (A, if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) k)); \<not> is_zero_row_upt_k b (Suc k) (fst (echelon_form_of_column_k ?bezout (A, if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) k)); \<forall>m\<ge>mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1). A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
\<not> is_zero_row_upt_k a (Suc k) B
\<not> is_zero_row_upt_k b (Suc k) B
\<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a)

goal (1 subgoal):
 1. (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
[PROOF STEP]
unfolding B i
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> is_zero_row_upt_k a (Suc k) (fst (echelon_form_of_column_k ?bezout (A, if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) k)); \<not> is_zero_row_upt_k b (Suc k) (fst (echelon_form_of_column_k ?bezout (A, if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) k)); \<forall>m\<ge>mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1). A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
\<not> is_zero_row_upt_k a (Suc k) (fst (echelon_form_of_column_k bezout (A, if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) k))
\<not> is_zero_row_upt_k b (Suc k) (fst (echelon_form_of_column_k bezout (A, if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) k))
\<forall>m\<ge>mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1). A $ m $ mod_type_class.from_nat k = (0::'a)

goal (1 subgoal):
 1. (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))

goal (4 subgoals):
 1. \<lbrakk>\<forall>m>mod_type_class.from_nat (nrows A). A $ m $ mod_type_class.from_nat k = (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 2. \<And>m. \<lbrakk>\<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 3. \<And>m. \<lbrakk>mod_type_class.from_nat (nrows A) < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 4. \<And>m ma. \<lbrakk>mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ a $ n \<noteq> (0::'a)) < (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ b $ n \<noteq> (0::'a))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. \<lbrakk>\<forall>m>mod_type_class.from_nat (nrows A). A $ m $ mod_type_class.from_nat k = (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 2. \<And>m. \<lbrakk>\<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 3. \<And>m. \<lbrakk>mod_type_class.from_nat (nrows A) < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 4. \<And>m ma. \<lbrakk>mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ a $ n \<noteq> (0::'a)) < (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ b $ n \<noteq> (0::'a))
[PROOF STEP]
assume 1: "\<forall>m>from_nat (nrows A). A $ m $ from_nat k = 0" and 2: "i = nrows A"
[PROOF STATE]
proof (state)
this:
\<forall>m>mod_type_class.from_nat (nrows A). A $ m $ mod_type_class.from_nat k = (0::'a)
i = nrows A

goal (4 subgoals):
 1. \<lbrakk>\<forall>m>mod_type_class.from_nat (nrows A). A $ m $ mod_type_class.from_nat k = (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 2. \<And>m. \<lbrakk>\<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 3. \<And>m. \<lbrakk>mod_type_class.from_nat (nrows A) < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 4. \<And>m ma. \<lbrakk>mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ a $ n \<noteq> (0::'a)) < (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ b $ n \<noteq> (0::'a))
[PROOF STEP]
show "(LEAST n. A $ a $ n \<noteq> 0) < (LEAST n. A $ b $ n \<noteq> 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
[PROOF STEP]
using condition2_part2[OF e ab 1] 2
[PROOF STATE]
proof (prove)
using this:
(if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) = nrows A \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
i = nrows A

goal (1 subgoal):
 1. (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
[PROOF STEP]
unfolding i
[PROOF STATE]
proof (prove)
using this:
(if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) = nrows A \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
(if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) = nrows A

goal (1 subgoal):
 1. (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))

goal (3 subgoals):
 1. \<And>m. \<lbrakk>\<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 2. \<And>m. \<lbrakk>mod_type_class.from_nat (nrows A) < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 3. \<And>m ma. \<lbrakk>mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ a $ n \<noteq> (0::'a)) < (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ b $ n \<noteq> (0::'a))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>m. \<lbrakk>\<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 2. \<And>m. \<lbrakk>mod_type_class.from_nat (nrows A) < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 3. \<And>m ma. \<lbrakk>mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ a $ n \<noteq> (0::'a)) < (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ b $ n \<noteq> (0::'a))
[PROOF STEP]
fix ma
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>m. \<lbrakk>\<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 2. \<And>m. \<lbrakk>mod_type_class.from_nat (nrows A) < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 3. \<And>m ma. \<lbrakk>mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ a $ n \<noteq> (0::'a)) < (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ b $ n \<noteq> (0::'a))
[PROOF STEP]
assume 1: "\<forall>m>from_nat i. A $ m $ from_nat k = 0"
      and 2: "from_nat i \<le> ma" and 3: "A $ ma $ from_nat k \<noteq> 0"
[PROOF STATE]
proof (state)
this:
\<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a)
mod_type_class.from_nat i \<le> ma
A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)

goal (3 subgoals):
 1. \<And>m. \<lbrakk>\<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 2. \<And>m. \<lbrakk>mod_type_class.from_nat (nrows A) < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 3. \<And>m ma. \<lbrakk>mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ a $ n \<noteq> (0::'a)) < (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ b $ n \<noteq> (0::'a))
[PROOF STEP]
show "(LEAST n. A $ a $ n \<noteq> 0) < (LEAST n. A $ b $ n \<noteq> 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
[PROOF STEP]
using condition2_part3[OF e k ab _ _ _ _ 3]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> is_zero_row_upt_k a (Suc k) (fst (echelon_form_of_column_k ?bezout (A, if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) k)); \<not> is_zero_row_upt_k b (Suc k) (fst (echelon_form_of_column_k ?bezout (A, if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) k)); \<forall>m>mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1). A $ m $ mod_type_class.from_nat k = (0::'a); mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) \<le> ma\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))

goal (1 subgoal):
 1. (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
[PROOF STEP]
using 1 2 not_zero_aB not_zero_bB
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> is_zero_row_upt_k a (Suc k) (fst (echelon_form_of_column_k ?bezout (A, if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) k)); \<not> is_zero_row_upt_k b (Suc k) (fst (echelon_form_of_column_k ?bezout (A, if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) k)); \<forall>m>mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1). A $ m $ mod_type_class.from_nat k = (0::'a); mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) \<le> ma\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
\<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a)
mod_type_class.from_nat i \<le> ma
\<not> is_zero_row_upt_k a (Suc k) B
\<not> is_zero_row_upt_k b (Suc k) B

goal (1 subgoal):
 1. (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
[PROOF STEP]
unfolding i B
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> is_zero_row_upt_k a (Suc k) (fst (echelon_form_of_column_k ?bezout (A, if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) k)); \<not> is_zero_row_upt_k b (Suc k) (fst (echelon_form_of_column_k ?bezout (A, if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) k)); \<forall>m>mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1). A $ m $ mod_type_class.from_nat k = (0::'a); mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) \<le> ma\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
\<forall>m>mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1). A $ m $ mod_type_class.from_nat k = (0::'a)
mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) \<le> ma
\<not> is_zero_row_upt_k a (Suc k) (fst (echelon_form_of_column_k bezout (A, if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) k))
\<not> is_zero_row_upt_k b (Suc k) (fst (echelon_form_of_column_k bezout (A, if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) k))

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

goal (2 subgoals):
 1. \<And>m. \<lbrakk>mod_type_class.from_nat (nrows A) < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 2. \<And>m ma. \<lbrakk>mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ a $ n \<noteq> (0::'a)) < (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ b $ n \<noteq> (0::'a))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>m. \<lbrakk>mod_type_class.from_nat (nrows A) < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 2. \<And>m ma. \<lbrakk>mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ a $ n \<noteq> (0::'a)) < (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ b $ n \<noteq> (0::'a))
[PROOF STEP]
assume "i = nrows A"
[PROOF STATE]
proof (state)
this:
i = nrows A

goal (2 subgoals):
 1. \<And>m. \<lbrakk>mod_type_class.from_nat (nrows A) < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i = nrows A\<rbrakk> \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
 2. \<And>m ma. \<lbrakk>mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ a $ n \<noteq> (0::'a)) < (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ b $ n \<noteq> (0::'a))
[PROOF STEP]
thus "(LEAST n. A $ a $ n \<noteq> 0) < (LEAST n. A $ b $ n \<noteq> 0)"
[PROOF STATE]
proof (prove)
using this:
i = nrows A

goal (1 subgoal):
 1. (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
[PROOF STEP]
using condition2_part4[OF e ab]
[PROOF STATE]
proof (prove)
using this:
i = nrows A
(if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) = nrows A \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))

goal (1 subgoal):
 1. (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
[PROOF STEP]
unfolding i
[PROOF STATE]
proof (prove)
using this:
(if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) = nrows A
(if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) = nrows A \<Longrightarrow> (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))

goal (1 subgoal):
 1. (LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(LEAST n. A $ a $ n \<noteq> (0::'a)) < (LEAST n. A $ b $ n \<noteq> (0::'a))

goal (1 subgoal):
 1. \<And>m ma. \<lbrakk>mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ a $ n \<noteq> (0::'a)) < (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ b $ n \<noteq> (0::'a))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>m ma. \<lbrakk>mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ a $ n \<noteq> (0::'a)) < (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ b $ n \<noteq> (0::'a))
[PROOF STEP]
let ?B2="bezout_iterate (interchange_rows A (from_nat i)
      (LEAST n. A $ n $ from_nat k \<noteq> 0 \<and> from_nat i \<le> n))
      (nrows A - Suc 0) (from_nat i) (from_nat k) bezout"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>m ma. \<lbrakk>mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ a $ n \<noteq> (0::'a)) < (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ b $ n \<noteq> (0::'a))
[PROOF STEP]
fix m
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>m ma. \<lbrakk>mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ a $ n \<noteq> (0::'a)) < (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ b $ n \<noteq> (0::'a))
[PROOF STEP]
assume 1: "from_nat i < m"
      and 2: "A $ m $ from_nat k \<noteq> 0"
      and 3: "i \<noteq> nrows A"
[PROOF STATE]
proof (state)
this:
mod_type_class.from_nat i < m
A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)
i \<noteq> nrows A

goal (1 subgoal):
 1. \<And>m ma. \<lbrakk>mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ a $ n \<noteq> (0::'a)) < (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ b $ n \<noteq> (0::'a))
[PROOF STEP]
have B_eq: "B=?B2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B = bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout
[PROOF STEP]
unfolding B echelon_form_of_column_k_def Let_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fst (case (A, i) of (A, i) \<Rightarrow> if (\<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a)) \<or> i = nrows A then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1)) = bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout
[PROOF STEP]
using 1 2 3
[PROOF STATE]
proof (prove)
using this:
mod_type_class.from_nat i < m
A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)
i \<noteq> nrows A

goal (1 subgoal):
 1. fst (case (A, i) of (A, i) \<Rightarrow> if (\<forall>m\<ge>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a)) \<or> i = nrows A then (A, i) else if \<forall>m>mod_type_class.from_nat i. A $ m $ mod_type_class.from_nat k = (0::'a) then (A, i + 1) else (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - 1) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout, i + 1)) = bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B = bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout

goal (1 subgoal):
 1. \<And>m ma. \<lbrakk>mod_type_class.from_nat i < m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a); i \<noteq> nrows A; mod_type_class.from_nat i \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ a $ n \<noteq> (0::'a)) < (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ b $ n \<noteq> (0::'a))
[PROOF STEP]
show "(LEAST n. ?B2 $ a $ n \<noteq> 0) < (LEAST n. ?B2 $ b $ n \<noteq> 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ a $ n \<noteq> (0::'a)) < (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ b $ n \<noteq> (0::'a))
[PROOF STEP]
using condition2_part5[OF ib e k ab _ _ _ 2] 1 3 not_zero_aB not_zero_bB
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> is_zero_row_upt_k a (Suc k) (fst (echelon_form_of_column_k bezout (A, if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) k)); \<not> is_zero_row_upt_k b (Suc k) (fst (echelon_form_of_column_k bezout (A, if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) k)); mod_type_class.from_nat (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) < m; (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) \<noteq> nrows A\<rbrakk> \<Longrightarrow> (LEAST n. fst (echelon_form_of_column_k bezout (A, if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) k) $ a $ n \<noteq> (0::'a)) < (LEAST n. fst (echelon_form_of_column_k bezout (A, if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) k) $ b $ n \<noteq> (0::'a))
mod_type_class.from_nat i < m
i \<noteq> nrows A
\<not> is_zero_row_upt_k a (Suc k) B
\<not> is_zero_row_upt_k b (Suc k) B

goal (1 subgoal):
 1. (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ a $ n \<noteq> (0::'a)) < (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ b $ n \<noteq> (0::'a))
[PROOF STEP]
unfolding i[symmetric] B[symmetric]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> is_zero_row_upt_k a (Suc k) B; \<not> is_zero_row_upt_k b (Suc k) B; mod_type_class.from_nat i < m; i \<noteq> nrows A\<rbrakk> \<Longrightarrow> (LEAST n. B $ a $ n \<noteq> (0::'a)) < (LEAST n. B $ b $ n \<noteq> (0::'a))
mod_type_class.from_nat i < m
i \<noteq> nrows A
\<not> is_zero_row_upt_k a (Suc k) B
\<not> is_zero_row_upt_k b (Suc k) B

goal (1 subgoal):
 1. (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ a $ n \<noteq> (0::'a)) < (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ b $ n \<noteq> (0::'a))
[PROOF STEP]
unfolding B_eq
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<not> is_zero_row_upt_k a (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout); \<not> is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout); mod_type_class.from_nat i < m; i \<noteq> nrows A\<rbrakk> \<Longrightarrow> (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ a $ n \<noteq> (0::'a)) < (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ b $ n \<noteq> (0::'a))
mod_type_class.from_nat i < m
i \<noteq> nrows A
\<not> is_zero_row_upt_k a (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout)
\<not> is_zero_row_upt_k b (Suc k) (bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout)

goal (1 subgoal):
 1. (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ a $ n \<noteq> (0::'a)) < (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ b $ n \<noteq> (0::'a))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ a $ n \<noteq> (0::'a)) < (LEAST n. bezout_iterate (interchange_rows A (mod_type_class.from_nat i) (LEAST n. A $ n $ mod_type_class.from_nat k \<noteq> (0::'a) \<and> mod_type_class.from_nat i \<le> n)) (nrows A - Suc 0) (mod_type_class.from_nat i) (mod_type_class.from_nat k) bezout $ b $ n \<noteq> (0::'a))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(LEAST n. B $ a $ n \<noteq> (0::'a)) < (LEAST n. B $ b $ n \<noteq> (0::'a))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma real_of_int_floor_add_one_gt [simp]: "r < real_of_int \<lfloor>r\<rfloor> + 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r < real_of_int \<lfloor>r\<rfloor> + 1
[PROOF STEP]
by linarith


[STATEMENT]
lemma "filterlim (\<lambda>x::real. x^2 * (arctan x - pi/2) + x) (at_right 0) at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LIM x at_top. x\<^sup>2 * (arctan x - pi / 2) + x :> at_right 0
[PROOF STEP]
by real_asymp


[STATEMENT]
lemma ffb_g_orbital: "fb\<^sub>\<F> (x\<acute>= f & G on U S @ t\<^sub>0) Q =
  {s. \<forall>X\<in>Sols f U S t\<^sub>0 s. \<forall>t\<in>U s. (\<forall>\<tau>\<in>down (U s) t. G (X \<tau>)) \<longrightarrow> (X t) \<in> Q}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fb\<^sub>\<F> x\<acute>=f & G on U S @ t\<^sub>0 Q = {s. \<forall>X\<in>Sols f U S t\<^sub>0 s. \<forall>t\<in>U s. (\<forall>\<tau>\<in>down (U s) t. G (X \<tau>)) \<longrightarrow> s2p Q (X t)}
[PROOF STEP]
unfolding ffb_eq g_orbital_eq
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {s. \<forall>s'. s2p {X t |t X. s2p (U s) t \<and> \<P> X (down (U s) t) \<subseteq> Collect G \<and> s2p (Sols f U S t\<^sub>0 s) X} s' \<longrightarrow> s2p Q s'} = {s. \<forall>X\<in>Sols f U S t\<^sub>0 s. \<forall>t\<in>U s. (\<forall>\<tau>\<in>down (U s) t. G (X \<tau>)) \<longrightarrow> s2p Q (X t)}
[PROOF STEP]
by (auto simp: fun_eq_iff)


[STATEMENT]
lemma msubst_I:
  assumes lp: "islin p"
    and nc: "isnpoly c"
    and nd: "isnpoly d"
  shows "Ifm vs (x#bs) (msubst p ((c,t),(d,s))) =
    Ifm vs (((- Itm vs (x#bs) t /  Ipoly vs c + - Itm vs (x#bs) s / Ipoly vs d) /2)#bs) p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Ifm vs (x # bs) (msubst p ((c, t), d, s)) = Ifm vs ((- Itm vs (x # bs) t / \<lparr>c\<rparr>\<^sub>p\<^bsup>vs\<^esup> + - Itm vs (x # bs) s / \<lparr>d\<rparr>\<^sub>p\<^bsup>vs\<^esup>) / (2::'a) # bs) p
[PROOF STEP]
using lp
[PROOF STATE]
proof (prove)
using this:
islin p

goal (1 subgoal):
 1. Ifm vs (x # bs) (msubst p ((c, t), d, s)) = Ifm vs ((- Itm vs (x # bs) t / \<lparr>c\<rparr>\<^sub>p\<^bsup>vs\<^esup> + - Itm vs (x # bs) s / \<lparr>d\<rparr>\<^sub>p\<^bsup>vs\<^esup>) / (2::'a) # bs) p
[PROOF STEP]
by (induct p rule: islin.induct)
    (auto simp add: tmbound0_I
      [where b = "(- (Itm vs (x # bs) t / \<lparr>c\<rparr>\<^sub>p\<^bsup>vs\<^esup>) - (Itm vs (x # bs) s / \<lparr>d\<rparr>\<^sub>p\<^bsup>vs\<^esup>)) / 2"
        and b' = x and bs = bs and vs = vs]
      msubsteq msubstneq msubstlt [OF nc nd] msubstle [OF nc nd])