[STATEMENT]
lemma bezout_matrix_JNF_mult_eq:
  assumes A': "A' \<in> carrier_mat m n" and a: "a\<le>m"  and b: "b\<le>m" and ab: "a \<noteq> b"
  and A_def: "A = A' @\<^sub>r B" and B: "B \<in> carrier_mat n n"
  assumes pquvd: "(p,q,u,v,d) = euclid_ext2 (A$$(a,j)) (A$$(b,j))"
  shows "Matrix.mat (dim_row A) (dim_col A)
          (\<lambda>(i,k). if i = a then (p*A$$(a,k) + q*A$$(b,k))
                   else if i = b then u * A$$(a,k) + v * A$$(b,k)
                   else A$$(i,k)
            ) = (bezout_matrix_JNF A a b j euclid_ext2) * A" (is "?A = ?BM * A")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) = bezout_matrix_JNF A a b j euclid_ext2 * A
[PROOF STEP]
proof (rule eq_matI)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i ja. \<lbrakk>i < dim_row (bezout_matrix_JNF A a b j euclid_ext2 * A); ja < dim_col (bezout_matrix_JNF A a b j euclid_ext2 * A)\<rbrakk> \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
 2. dim_row (Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k))) = dim_row (bezout_matrix_JNF A a b j euclid_ext2 * A)
 3. dim_col (Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k))) = dim_col (bezout_matrix_JNF A a b j euclid_ext2 * A)
[PROOF STEP]
have A: "A \<in> carrier_mat (m+n) n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<in> carrier_mat (m + n) n
[PROOF STEP]
using A_def A' B
[PROOF STATE]
proof (prove)
using this:
A = A' @\<^sub>r B
A' \<in> carrier_mat m n
B \<in> carrier_mat n n

goal (1 subgoal):
 1. A \<in> carrier_mat (m + n) n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
A \<in> carrier_mat (m + n) n

goal (3 subgoals):
 1. \<And>i ja. \<lbrakk>i < dim_row (bezout_matrix_JNF A a b j euclid_ext2 * A); ja < dim_col (bezout_matrix_JNF A a b j euclid_ext2 * A)\<rbrakk> \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
 2. dim_row (Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k))) = dim_row (bezout_matrix_JNF A a b j euclid_ext2 * A)
 3. dim_col (Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k))) = dim_col (bezout_matrix_JNF A a b j euclid_ext2 * A)
[PROOF STEP]
hence A_carrier: "?A \<in> carrier_mat (m+n) n"
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat (m + n) n

goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) \<in> carrier_mat (m + n) n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) \<in> carrier_mat (m + n) n

goal (3 subgoals):
 1. \<And>i ja. \<lbrakk>i < dim_row (bezout_matrix_JNF A a b j euclid_ext2 * A); ja < dim_col (bezout_matrix_JNF A a b j euclid_ext2 * A)\<rbrakk> \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
 2. dim_row (Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k))) = dim_row (bezout_matrix_JNF A a b j euclid_ext2 * A)
 3. dim_col (Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k))) = dim_col (bezout_matrix_JNF A a b j euclid_ext2 * A)
[PROOF STEP]
show dr: "dim_row ?A = dim_row (?BM * A)" and dc: "dim_col ?A = dim_col (?BM * A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row (Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k))) = dim_row (bezout_matrix_JNF A a b j euclid_ext2 * A) &&& dim_col (Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k))) = dim_col (bezout_matrix_JNF A a b j euclid_ext2 * A)
[PROOF STEP]
unfolding bezout_matrix_JNF_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row (Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k))) = dim_row (Matrix.mat (dim_row A) (dim_row A) (\<lambda>(x, y). let (p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j)) in if x = a \<and> y = a then p else if x = a \<and> y = b then q else if x = b \<and> y = a then u else if x = b \<and> y = b then v else if x = y then 1::'a else (0::'a)) * A) &&& dim_col (Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k))) = dim_col (Matrix.mat (dim_row A) (dim_row A) (\<lambda>(x, y). let (p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j)) in if x = a \<and> y = a then p else if x = a \<and> y = b then q else if x = b \<and> y = a then u else if x = b \<and> y = b then v else if x = y then 1::'a else (0::'a)) * A)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
dim_row (Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k))) = dim_row (bezout_matrix_JNF A a b j euclid_ext2 * A)
dim_col (Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k))) = dim_col (bezout_matrix_JNF A a b j euclid_ext2 * A)

goal (1 subgoal):
 1. \<And>i ja. \<lbrakk>i < dim_row (bezout_matrix_JNF A a b j euclid_ext2 * A); ja < dim_col (bezout_matrix_JNF A a b j euclid_ext2 * A)\<rbrakk> \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
fix i ja
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i ja. \<lbrakk>i < dim_row (bezout_matrix_JNF A a b j euclid_ext2 * A); ja < dim_col (bezout_matrix_JNF A a b j euclid_ext2 * A)\<rbrakk> \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
assume i: "i < dim_row  (?BM * A)" and ja: "ja < dim_col (?BM * A)"
[PROOF STATE]
proof (state)
this:
i < dim_row (bezout_matrix_JNF A a b j euclid_ext2 * A)
ja < dim_col (bezout_matrix_JNF A a b j euclid_ext2 * A)

goal (1 subgoal):
 1. \<And>i ja. \<lbrakk>i < dim_row (bezout_matrix_JNF A a b j euclid_ext2 * A); ja < dim_col (bezout_matrix_JNF A a b j euclid_ext2 * A)\<rbrakk> \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
let ?f = "\<lambda>ia. (bezout_matrix_JNF A a b j euclid_ext2) $$ (i,ia) * A $$ (ia,ja)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i ja. \<lbrakk>i < dim_row (bezout_matrix_JNF A a b j euclid_ext2 * A); ja < dim_col (bezout_matrix_JNF A a b j euclid_ext2 * A)\<rbrakk> \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have dv: "dim_vec (col A ja) = m+n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec (col A ja) = m + n
[PROOF STEP]
using A
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat (m + n) n

goal (1 subgoal):
 1. dim_vec (col A ja) = m + n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
dim_vec (col A ja) = m + n

goal (1 subgoal):
 1. \<And>i ja. \<lbrakk>i < dim_row (bezout_matrix_JNF A a b j euclid_ext2 * A); ja < dim_col (bezout_matrix_JNF A a b j euclid_ext2 * A)\<rbrakk> \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have i_dr: "i<dim_row A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i < dim_row A
[PROOF STEP]
using i A
[PROOF STATE]
proof (prove)
using this:
i < dim_row (bezout_matrix_JNF A a b j euclid_ext2 * A)
A \<in> carrier_mat (m + n) n

goal (1 subgoal):
 1. i < dim_row A
[PROOF STEP]
unfolding bezout_matrix_JNF_def
[PROOF STATE]
proof (prove)
using this:
i < dim_row (Matrix.mat (dim_row A) (dim_row A) (\<lambda>(x, y). let (p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j)) in if x = a \<and> y = a then p else if x = a \<and> y = b then q else if x = b \<and> y = a then u else if x = b \<and> y = b then v else if x = y then 1::'a else (0::'a)) * A)
A \<in> carrier_mat (m + n) n

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

goal (1 subgoal):
 1. \<And>i ja. \<lbrakk>i < dim_row (bezout_matrix_JNF A a b j euclid_ext2 * A); ja < dim_col (bezout_matrix_JNF A a b j euclid_ext2 * A)\<rbrakk> \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have a_dr: "a<dim_row A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a < dim_row A
[PROOF STEP]
using A a ja
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat (m + n) n
a \<le> m
ja < dim_col (bezout_matrix_JNF A a b j euclid_ext2 * A)

goal (1 subgoal):
 1. a < dim_row A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a < dim_row A

goal (1 subgoal):
 1. \<And>i ja. \<lbrakk>i < dim_row (bezout_matrix_JNF A a b j euclid_ext2 * A); ja < dim_col (bezout_matrix_JNF A a b j euclid_ext2 * A)\<rbrakk> \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have b_dr: "b<dim_row A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b < dim_row A
[PROOF STEP]
using A b ja
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat (m + n) n
b \<le> m
ja < dim_col (bezout_matrix_JNF A a b j euclid_ext2 * A)

goal (1 subgoal):
 1. b < dim_row A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
b < dim_row A

goal (1 subgoal):
 1. \<And>i ja. \<lbrakk>i < dim_row (bezout_matrix_JNF A a b j euclid_ext2 * A); ja < dim_col (bezout_matrix_JNF A a b j euclid_ext2 * A)\<rbrakk> \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
show "?A $$ (i,ja) = (?BM * A) $$ (i,ja)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have "(?BM * A) $$ (i,ja) = Matrix.row ?BM i \<bullet> col A ja"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja) = row (bezout_matrix_JNF A a b j euclid_ext2) i \<bullet> col A ja
[PROOF STEP]
by (rule index_mult_mat, insert i ja, auto)
[PROOF STATE]
proof (state)
this:
(bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja) = row (bezout_matrix_JNF A a b j euclid_ext2) i \<bullet> col A ja

goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja) = row (bezout_matrix_JNF A a b j euclid_ext2) i \<bullet> col A ja

goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have "... = (\<Sum>ia = 0..<dim_vec (col A ja).
          Matrix.row (bezout_matrix_JNF A a b j euclid_ext2) i $v ia * col A ja $v ia)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. row (bezout_matrix_JNF A a b j euclid_ext2) i \<bullet> col A ja = (\<Sum>ia = 0..<dim_vec (col A ja). row (bezout_matrix_JNF A a b j euclid_ext2) i $v ia * col A ja $v ia)
[PROOF STEP]
by (simp add: scalar_prod_def)
[PROOF STATE]
proof (state)
this:
row (bezout_matrix_JNF A a b j euclid_ext2) i \<bullet> col A ja = (\<Sum>ia = 0..<dim_vec (col A ja). row (bezout_matrix_JNF A a b j euclid_ext2) i $v ia * col A ja $v ia)

goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
row (bezout_matrix_JNF A a b j euclid_ext2) i \<bullet> col A ja = (\<Sum>ia = 0..<dim_vec (col A ja). row (bezout_matrix_JNF A a b j euclid_ext2) i $v ia * col A ja $v ia)

goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have "... = (\<Sum>ia = 0..<m+n. ?f ia)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia = 0..<dim_vec (col A ja). row (bezout_matrix_JNF A a b j euclid_ext2) i $v ia * col A ja $v ia) = (\<Sum>ia = 0..<m + n. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja))
[PROOF STEP]
by (rule sum.cong, insert A i dr dc, auto) (smt bezout_matrix_JNF_def carrier_matD(1)
          dim_col_mat(1) index_col index_mult_mat(3) index_row(1) ja)
[PROOF STATE]
proof (state)
this:
(\<Sum>ia = 0..<dim_vec (col A ja). row (bezout_matrix_JNF A a b j euclid_ext2) i $v ia * col A ja $v ia) = (\<Sum>ia = 0..<m + n. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja))

goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ia = 0..<dim_vec (col A ja). row (bezout_matrix_JNF A a b j euclid_ext2) i $v ia * col A ja $v ia) = (\<Sum>ia = 0..<m + n. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja))

goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have "... = (\<Sum>ia \<in> ({a,b} \<union> ({0..<m+n} - {a,b})). ?f ia)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia = 0..<m + n. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = (\<Sum>ia\<in>{a, b} \<union> ({0..<m + n} - {a, b}). bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja))
[PROOF STEP]
by (rule sum.cong, insert a a_dr b A ja, auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>ia = 0..<m + n. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = (\<Sum>ia\<in>{a, b} \<union> ({0..<m + n} - {a, b}). bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja))

goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ia = 0..<m + n. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = (\<Sum>ia\<in>{a, b} \<union> ({0..<m + n} - {a, b}). bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja))

goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have "... = sum ?f {a,b} + sum ?f ({0..<m+n} - {a,b})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<in>{a, b} \<union> ({0..<m + n} - {a, b}). bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = (\<Sum>ia\<in>{a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) + (\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja))
[PROOF STEP]
by (rule sum.union_disjoint, auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>ia\<in>{a, b} \<union> ({0..<m + n} - {a, b}). bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = (\<Sum>ia\<in>{a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) + (\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja))

goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja) = (\<Sum>ia\<in>{a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) + (\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja))
[PROOF STEP]
have BM_A_ija_eq: "(?BM * A) $$ (i,ja) = sum ?f {a,b} + sum ?f ({0..<m+n} - {a,b})"
[PROOF STATE]
proof (prove)
using this:
(bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja) = (\<Sum>ia\<in>{a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) + (\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja))

goal (1 subgoal):
 1. (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja) = (\<Sum>ia\<in>{a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) + (\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja) = (\<Sum>ia\<in>{a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) + (\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja))

goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
proof (cases "i = a")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i = a \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
 2. i \<noteq> a \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
i = a

goal (2 subgoals):
 1. i = a \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
 2. i \<noteq> a \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have sum0: "sum ?f ({0..<m+n} - {a,b}) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = (0::'a)
[PROOF STEP]
proof (rule sum.neutral, rule)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + n} - {a, b} \<Longrightarrow> bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + n} - {a, b} \<Longrightarrow> bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)
[PROOF STEP]
assume x: "x \<in> {0..<m + n} - {a, b}"
[PROOF STATE]
proof (state)
this:
x \<in> {0..<m + n} - {a, b}

goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + n} - {a, b} \<Longrightarrow> bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)
[PROOF STEP]
hence xm: "x < m+n"
[PROOF STATE]
proof (prove)
using this:
x \<in> {0..<m + n} - {a, b}

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

goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + n} - {a, b} \<Longrightarrow> bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)
[PROOF STEP]
have x_not_i: "x \<noteq> i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<noteq> i
[PROOF STEP]
using True x
[PROOF STATE]
proof (prove)
using this:
i = a
x \<in> {0..<m + n} - {a, b}

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

goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + n} - {a, b} \<Longrightarrow> bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)
[PROOF STEP]
have x_dr: "x < dim_row A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < dim_row A
[PROOF STEP]
using x A
[PROOF STATE]
proof (prove)
using this:
x \<in> {0..<m + n} - {a, b}
A \<in> carrier_mat (m + n) n

goal (1 subgoal):
 1. x < dim_row A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x < dim_row A

goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + n} - {a, b} \<Longrightarrow> bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)
[PROOF STEP]
have "bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) = (0::'a)
[PROOF STEP]
unfolding bezout_matrix_JNF_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_row A) (\<lambda>(x, y). let (p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j)) in if x = a \<and> y = a then p else if x = a \<and> y = b then q else if x = b \<and> y = a then u else if x = b \<and> y = b then v else if x = y then 1::'a else (0::'a)) $$ (i, x) = (0::'a)
[PROOF STEP]
unfolding index_mat(1)[OF i_dr x_dr]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (case (i, x) of (x, y) \<Rightarrow> let (p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j)) in if x = a \<and> y = a then p else if x = a \<and> y = b then q else if x = b \<and> y = a then u else if x = b \<and> y = b then v else if x = y then 1::'a else (0::'a)) = (0::'a)
[PROOF STEP]
using x_not_i x
[PROOF STATE]
proof (prove)
using this:
x \<noteq> i
x \<in> {0..<m + n} - {a, b}

goal (1 subgoal):
 1. (case (i, x) of (x, y) \<Rightarrow> let (p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j)) in if x = a \<and> y = a then p else if x = a \<and> y = b then q else if x = b \<and> y = a then u else if x = b \<and> y = b then v else if x = y then 1::'a else (0::'a)) = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) = (0::'a)

goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + n} - {a, b} \<Longrightarrow> bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)
[PROOF STEP]
thus "bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = 0"
[PROOF STATE]
proof (prove)
using this:
bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) = (0::'a)

goal (1 subgoal):
 1. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = (0::'a)

goal (2 subgoals):
 1. i = a \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
 2. i \<noteq> a \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have fa: "bezout_matrix_JNF A a b j euclid_ext2 $$ (i, a) = p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, a) = p
[PROOF STEP]
unfolding bezout_matrix_JNF_def index_mat(1)[OF i_dr a_dr]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (case (i, a) of (x, y) \<Rightarrow> let (p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j)) in if x = a \<and> y = a then p else if x = a \<and> y = b then q else if x = b \<and> y = a then u else if x = b \<and> y = b then v else if x = y then 1::'a else (0::'a)) = p
[PROOF STEP]
using True pquvd
[PROOF STATE]
proof (prove)
using this:
i = a
(p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j))

goal (1 subgoal):
 1. (case (i, a) of (x, y) \<Rightarrow> let (p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j)) in if x = a \<and> y = a then p else if x = a \<and> y = b then q else if x = b \<and> y = a then u else if x = b \<and> y = b then v else if x = y then 1::'a else (0::'a)) = p
[PROOF STEP]
by (auto, metis split_conv)
[PROOF STATE]
proof (state)
this:
bezout_matrix_JNF A a b j euclid_ext2 $$ (i, a) = p

goal (2 subgoals):
 1. i = a \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
 2. i \<noteq> a \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have fb: "bezout_matrix_JNF A a b j euclid_ext2 $$ (i, b) = q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, b) = q
[PROOF STEP]
unfolding bezout_matrix_JNF_def index_mat(1)[OF i_dr b_dr]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (case (i, b) of (x, y) \<Rightarrow> let (p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j)) in if x = a \<and> y = a then p else if x = a \<and> y = b then q else if x = b \<and> y = a then u else if x = b \<and> y = b then v else if x = y then 1::'a else (0::'a)) = q
[PROOF STEP]
using True pquvd ab
[PROOF STATE]
proof (prove)
using this:
i = a
(p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j))
a \<noteq> b

goal (1 subgoal):
 1. (case (i, b) of (x, y) \<Rightarrow> let (p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j)) in if x = a \<and> y = a then p else if x = a \<and> y = b then q else if x = b \<and> y = a then u else if x = b \<and> y = b then v else if x = y then 1::'a else (0::'a)) = q
[PROOF STEP]
by (auto, metis split_conv)
[PROOF STATE]
proof (state)
this:
bezout_matrix_JNF A a b j euclid_ext2 $$ (i, b) = q

goal (2 subgoals):
 1. i = a \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
 2. i \<noteq> a \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have "sum ?f {a,b} + sum ?f ({0..<m+n} - {a,b}) = ?f a + ?f b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<in>{a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) + (\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = bezout_matrix_JNF A a b j euclid_ext2 $$ (i, a) * A $$ (a, ja) + bezout_matrix_JNF A a b j euclid_ext2 $$ (i, b) * A $$ (b, ja)
[PROOF STEP]
using sum0
[PROOF STATE]
proof (prove)
using this:
(\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = (0::'a)

goal (1 subgoal):
 1. (\<Sum>ia\<in>{a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) + (\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = bezout_matrix_JNF A a b j euclid_ext2 $$ (i, a) * A $$ (a, ja) + bezout_matrix_JNF A a b j euclid_ext2 $$ (i, b) * A $$ (b, ja)
[PROOF STEP]
by (simp add: ab)
[PROOF STATE]
proof (state)
this:
(\<Sum>ia\<in>{a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) + (\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = bezout_matrix_JNF A a b j euclid_ext2 $$ (i, a) * A $$ (a, ja) + bezout_matrix_JNF A a b j euclid_ext2 $$ (i, b) * A $$ (b, ja)

goal (2 subgoals):
 1. i = a \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
 2. i \<noteq> a \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ia\<in>{a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) + (\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = bezout_matrix_JNF A a b j euclid_ext2 $$ (i, a) * A $$ (a, ja) + bezout_matrix_JNF A a b j euclid_ext2 $$ (i, b) * A $$ (b, ja)

goal (2 subgoals):
 1. i = a \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
 2. i \<noteq> a \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have "... = p * A $$ (a, ja) + q * A $$ (b, ja)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, a) * A $$ (a, ja) + bezout_matrix_JNF A a b j euclid_ext2 $$ (i, b) * A $$ (b, ja) = p * A $$ (a, ja) + q * A $$ (b, ja)
[PROOF STEP]
unfolding fa fb
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p * A $$ (a, ja) + q * A $$ (b, ja) = p * A $$ (a, ja) + q * A $$ (b, ja)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
bezout_matrix_JNF A a b j euclid_ext2 $$ (i, a) * A $$ (a, ja) + bezout_matrix_JNF A a b j euclid_ext2 $$ (i, b) * A $$ (b, ja) = p * A $$ (a, ja) + q * A $$ (b, ja)

goal (2 subgoals):
 1. i = a \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
 2. i \<noteq> a \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
bezout_matrix_JNF A a b j euclid_ext2 $$ (i, a) * A $$ (a, ja) + bezout_matrix_JNF A a b j euclid_ext2 $$ (i, b) * A $$ (b, ja) = p * A $$ (a, ja) + q * A $$ (b, ja)

goal (2 subgoals):
 1. i = a \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
 2. i \<noteq> a \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have "... = ?A $$ (i,ja)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p * A $$ (a, ja) + q * A $$ (b, ja) = Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja)
[PROOF STEP]
using A True dr i ja
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat (m + n) n
i = a
dim_row (Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k))) = dim_row (bezout_matrix_JNF A a b j euclid_ext2 * A)
i < dim_row (bezout_matrix_JNF A a b j euclid_ext2 * A)
ja < dim_col (bezout_matrix_JNF A a b j euclid_ext2 * A)

goal (1 subgoal):
 1. p * A $$ (a, ja) + q * A $$ (b, ja) = Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
p * A $$ (a, ja) + q * A $$ (b, ja) = Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja)

goal (2 subgoals):
 1. i = a \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
 2. i \<noteq> a \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>ia\<in>{a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) + (\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>ia\<in>{a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) + (\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja)

goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
using BM_A_ija_eq
[PROOF STATE]
proof (prove)
using this:
(\<Sum>ia\<in>{a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) + (\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja)
(bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja) = (\<Sum>ia\<in>{a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) + (\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja))

goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)

goal (1 subgoal):
 1. i \<noteq> a \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i \<noteq> a \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
i \<noteq> a

goal (1 subgoal):
 1. i \<noteq> a \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
note i_not_a = False
[PROOF STATE]
proof (state)
this:
i \<noteq> a

goal (1 subgoal):
 1. i \<noteq> a \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
proof (cases "i=b")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i = b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
 2. i \<noteq> b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
i = b

goal (2 subgoals):
 1. i = b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
 2. i \<noteq> b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have sum0: "sum ?f ({0..<m+n} - {a,b}) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = (0::'a)
[PROOF STEP]
proof (rule sum.neutral, rule)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + n} - {a, b} \<Longrightarrow> bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + n} - {a, b} \<Longrightarrow> bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)
[PROOF STEP]
assume x: "x \<in> {0..<m + n} - {a, b}"
[PROOF STATE]
proof (state)
this:
x \<in> {0..<m + n} - {a, b}

goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + n} - {a, b} \<Longrightarrow> bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)
[PROOF STEP]
hence xm: "x < m+n"
[PROOF STATE]
proof (prove)
using this:
x \<in> {0..<m + n} - {a, b}

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

goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + n} - {a, b} \<Longrightarrow> bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)
[PROOF STEP]
have x_not_i: "x \<noteq> i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<noteq> i
[PROOF STEP]
using True x
[PROOF STATE]
proof (prove)
using this:
i = b
x \<in> {0..<m + n} - {a, b}

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

goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + n} - {a, b} \<Longrightarrow> bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)
[PROOF STEP]
have x_dr: "x < dim_row A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < dim_row A
[PROOF STEP]
using x A
[PROOF STATE]
proof (prove)
using this:
x \<in> {0..<m + n} - {a, b}
A \<in> carrier_mat (m + n) n

goal (1 subgoal):
 1. x < dim_row A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x < dim_row A

goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + n} - {a, b} \<Longrightarrow> bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)
[PROOF STEP]
have "bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) = (0::'a)
[PROOF STEP]
unfolding bezout_matrix_JNF_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_row A) (\<lambda>(x, y). let (p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j)) in if x = a \<and> y = a then p else if x = a \<and> y = b then q else if x = b \<and> y = a then u else if x = b \<and> y = b then v else if x = y then 1::'a else (0::'a)) $$ (i, x) = (0::'a)
[PROOF STEP]
unfolding index_mat(1)[OF i_dr x_dr]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (case (i, x) of (x, y) \<Rightarrow> let (p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j)) in if x = a \<and> y = a then p else if x = a \<and> y = b then q else if x = b \<and> y = a then u else if x = b \<and> y = b then v else if x = y then 1::'a else (0::'a)) = (0::'a)
[PROOF STEP]
using x_not_i x
[PROOF STATE]
proof (prove)
using this:
x \<noteq> i
x \<in> {0..<m + n} - {a, b}

goal (1 subgoal):
 1. (case (i, x) of (x, y) \<Rightarrow> let (p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j)) in if x = a \<and> y = a then p else if x = a \<and> y = b then q else if x = b \<and> y = a then u else if x = b \<and> y = b then v else if x = y then 1::'a else (0::'a)) = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) = (0::'a)

goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + n} - {a, b} \<Longrightarrow> bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)
[PROOF STEP]
thus "bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = 0"
[PROOF STATE]
proof (prove)
using this:
bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) = (0::'a)

goal (1 subgoal):
 1. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = (0::'a)

goal (2 subgoals):
 1. i = b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
 2. i \<noteq> b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have fa: "bezout_matrix_JNF A a b j euclid_ext2 $$ (i, a) = u"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, a) = u
[PROOF STEP]
unfolding bezout_matrix_JNF_def index_mat(1)[OF i_dr a_dr]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (case (i, a) of (x, y) \<Rightarrow> let (p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j)) in if x = a \<and> y = a then p else if x = a \<and> y = b then q else if x = b \<and> y = a then u else if x = b \<and> y = b then v else if x = y then 1::'a else (0::'a)) = u
[PROOF STEP]
using True i_not_a pquvd
[PROOF STATE]
proof (prove)
using this:
i = b
i \<noteq> a
(p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j))

goal (1 subgoal):
 1. (case (i, a) of (x, y) \<Rightarrow> let (p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j)) in if x = a \<and> y = a then p else if x = a \<and> y = b then q else if x = b \<and> y = a then u else if x = b \<and> y = b then v else if x = y then 1::'a else (0::'a)) = u
[PROOF STEP]
by (auto, metis split_conv)
[PROOF STATE]
proof (state)
this:
bezout_matrix_JNF A a b j euclid_ext2 $$ (i, a) = u

goal (2 subgoals):
 1. i = b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
 2. i \<noteq> b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have fb: "bezout_matrix_JNF A a b j euclid_ext2 $$ (i, b) = v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, b) = v
[PROOF STEP]
unfolding bezout_matrix_JNF_def index_mat(1)[OF i_dr b_dr]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (case (i, b) of (x, y) \<Rightarrow> let (p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j)) in if x = a \<and> y = a then p else if x = a \<and> y = b then q else if x = b \<and> y = a then u else if x = b \<and> y = b then v else if x = y then 1::'a else (0::'a)) = v
[PROOF STEP]
using True i_not_a pquvd ab
[PROOF STATE]
proof (prove)
using this:
i = b
i \<noteq> a
(p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j))
a \<noteq> b

goal (1 subgoal):
 1. (case (i, b) of (x, y) \<Rightarrow> let (p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j)) in if x = a \<and> y = a then p else if x = a \<and> y = b then q else if x = b \<and> y = a then u else if x = b \<and> y = b then v else if x = y then 1::'a else (0::'a)) = v
[PROOF STEP]
by (auto, metis split_conv)
[PROOF STATE]
proof (state)
this:
bezout_matrix_JNF A a b j euclid_ext2 $$ (i, b) = v

goal (2 subgoals):
 1. i = b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
 2. i \<noteq> b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have "sum ?f {a,b} + sum ?f ({0..<m+n} - {a,b}) = ?f a + ?f b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<in>{a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) + (\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = bezout_matrix_JNF A a b j euclid_ext2 $$ (i, a) * A $$ (a, ja) + bezout_matrix_JNF A a b j euclid_ext2 $$ (i, b) * A $$ (b, ja)
[PROOF STEP]
using sum0
[PROOF STATE]
proof (prove)
using this:
(\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = (0::'a)

goal (1 subgoal):
 1. (\<Sum>ia\<in>{a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) + (\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = bezout_matrix_JNF A a b j euclid_ext2 $$ (i, a) * A $$ (a, ja) + bezout_matrix_JNF A a b j euclid_ext2 $$ (i, b) * A $$ (b, ja)
[PROOF STEP]
by (simp add: ab)
[PROOF STATE]
proof (state)
this:
(\<Sum>ia\<in>{a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) + (\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = bezout_matrix_JNF A a b j euclid_ext2 $$ (i, a) * A $$ (a, ja) + bezout_matrix_JNF A a b j euclid_ext2 $$ (i, b) * A $$ (b, ja)

goal (2 subgoals):
 1. i = b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
 2. i \<noteq> b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ia\<in>{a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) + (\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = bezout_matrix_JNF A a b j euclid_ext2 $$ (i, a) * A $$ (a, ja) + bezout_matrix_JNF A a b j euclid_ext2 $$ (i, b) * A $$ (b, ja)

goal (2 subgoals):
 1. i = b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
 2. i \<noteq> b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have "... = u * A $$ (a, ja) + v * A $$ (b, ja)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, a) * A $$ (a, ja) + bezout_matrix_JNF A a b j euclid_ext2 $$ (i, b) * A $$ (b, ja) = u * A $$ (a, ja) + v * A $$ (b, ja)
[PROOF STEP]
unfolding fa fb
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. u * A $$ (a, ja) + v * A $$ (b, ja) = u * A $$ (a, ja) + v * A $$ (b, ja)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
bezout_matrix_JNF A a b j euclid_ext2 $$ (i, a) * A $$ (a, ja) + bezout_matrix_JNF A a b j euclid_ext2 $$ (i, b) * A $$ (b, ja) = u * A $$ (a, ja) + v * A $$ (b, ja)

goal (2 subgoals):
 1. i = b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
 2. i \<noteq> b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
bezout_matrix_JNF A a b j euclid_ext2 $$ (i, a) * A $$ (a, ja) + bezout_matrix_JNF A a b j euclid_ext2 $$ (i, b) * A $$ (b, ja) = u * A $$ (a, ja) + v * A $$ (b, ja)

goal (2 subgoals):
 1. i = b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
 2. i \<noteq> b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have "... = ?A $$ (i,ja)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. u * A $$ (a, ja) + v * A $$ (b, ja) = Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja)
[PROOF STEP]
using A True i_not_a dr i ja
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat (m + n) n
i = b
i \<noteq> a
dim_row (Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k))) = dim_row (bezout_matrix_JNF A a b j euclid_ext2 * A)
i < dim_row (bezout_matrix_JNF A a b j euclid_ext2 * A)
ja < dim_col (bezout_matrix_JNF A a b j euclid_ext2 * A)

goal (1 subgoal):
 1. u * A $$ (a, ja) + v * A $$ (b, ja) = Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
u * A $$ (a, ja) + v * A $$ (b, ja) = Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja)

goal (2 subgoals):
 1. i = b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
 2. i \<noteq> b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>ia\<in>{a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) + (\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>ia\<in>{a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) + (\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja)

goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
using BM_A_ija_eq
[PROOF STATE]
proof (prove)
using this:
(\<Sum>ia\<in>{a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) + (\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja)
(bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja) = (\<Sum>ia\<in>{a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) + (\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja))

goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)

goal (1 subgoal):
 1. i \<noteq> b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i \<noteq> b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
i \<noteq> b

goal (1 subgoal):
 1. i \<noteq> b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
note i_not_b = False
[PROOF STATE]
proof (state)
this:
i \<noteq> b

goal (1 subgoal):
 1. i \<noteq> b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have sum0: "sum ?f ({0..<m+n} - {a,b} - {i}) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<in>{0..<m + n} - {a, b} - {i}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = (0::'a)
[PROOF STEP]
proof (rule sum.neutral, rule)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + n} - {a, b} - {i} \<Longrightarrow> bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + n} - {a, b} - {i} \<Longrightarrow> bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)
[PROOF STEP]
assume x: "x \<in> {0..<m + n} - {a, b} - {i}"
[PROOF STATE]
proof (state)
this:
x \<in> {0..<m + n} - {a, b} - {i}

goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + n} - {a, b} - {i} \<Longrightarrow> bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)
[PROOF STEP]
hence xm: "x < m+n"
[PROOF STATE]
proof (prove)
using this:
x \<in> {0..<m + n} - {a, b} - {i}

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

goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + n} - {a, b} - {i} \<Longrightarrow> bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)
[PROOF STEP]
have x_not_i: "x \<noteq> i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<noteq> i
[PROOF STEP]
using x
[PROOF STATE]
proof (prove)
using this:
x \<in> {0..<m + n} - {a, b} - {i}

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

goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + n} - {a, b} - {i} \<Longrightarrow> bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)
[PROOF STEP]
have x_dr: "x < dim_row A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < dim_row A
[PROOF STEP]
using x A
[PROOF STATE]
proof (prove)
using this:
x \<in> {0..<m + n} - {a, b} - {i}
A \<in> carrier_mat (m + n) n

goal (1 subgoal):
 1. x < dim_row A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x < dim_row A

goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + n} - {a, b} - {i} \<Longrightarrow> bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)
[PROOF STEP]
have "bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) = (0::'a)
[PROOF STEP]
unfolding bezout_matrix_JNF_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_row A) (\<lambda>(x, y). let (p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j)) in if x = a \<and> y = a then p else if x = a \<and> y = b then q else if x = b \<and> y = a then u else if x = b \<and> y = b then v else if x = y then 1::'a else (0::'a)) $$ (i, x) = (0::'a)
[PROOF STEP]
unfolding index_mat(1)[OF i_dr x_dr]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (case (i, x) of (x, y) \<Rightarrow> let (p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j)) in if x = a \<and> y = a then p else if x = a \<and> y = b then q else if x = b \<and> y = a then u else if x = b \<and> y = b then v else if x = y then 1::'a else (0::'a)) = (0::'a)
[PROOF STEP]
using x_not_i x
[PROOF STATE]
proof (prove)
using this:
x \<noteq> i
x \<in> {0..<m + n} - {a, b} - {i}

goal (1 subgoal):
 1. (case (i, x) of (x, y) \<Rightarrow> let (p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j)) in if x = a \<and> y = a then p else if x = a \<and> y = b then q else if x = b \<and> y = a then u else if x = b \<and> y = b then v else if x = y then 1::'a else (0::'a)) = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) = (0::'a)

goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + n} - {a, b} - {i} \<Longrightarrow> bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)
[PROOF STEP]
thus "bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = 0"
[PROOF STATE]
proof (prove)
using this:
bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) = (0::'a)

goal (1 subgoal):
 1. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
bezout_matrix_JNF A a b j euclid_ext2 $$ (i, x) * A $$ (x, ja) = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>ia\<in>{0..<m + n} - {a, b} - {i}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = (0::'a)

goal (1 subgoal):
 1. i \<noteq> b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have fa: "bezout_matrix_JNF A a b j euclid_ext2 $$ (i, a) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, a) = (0::'a)
[PROOF STEP]
unfolding bezout_matrix_JNF_def index_mat(1)[OF i_dr a_dr]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (case (i, a) of (x, y) \<Rightarrow> let (p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j)) in if x = a \<and> y = a then p else if x = a \<and> y = b then q else if x = b \<and> y = a then u else if x = b \<and> y = b then v else if x = y then 1::'a else (0::'a)) = (0::'a)
[PROOF STEP]
using False i_not_a pquvd
[PROOF STATE]
proof (prove)
using this:
i \<noteq> b
i \<noteq> a
(p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j))

goal (1 subgoal):
 1. (case (i, a) of (x, y) \<Rightarrow> let (p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j)) in if x = a \<and> y = a then p else if x = a \<and> y = b then q else if x = b \<and> y = a then u else if x = b \<and> y = b then v else if x = y then 1::'a else (0::'a)) = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
bezout_matrix_JNF A a b j euclid_ext2 $$ (i, a) = (0::'a)

goal (1 subgoal):
 1. i \<noteq> b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have fb: "bezout_matrix_JNF A a b j euclid_ext2 $$ (i, b) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, b) = (0::'a)
[PROOF STEP]
unfolding bezout_matrix_JNF_def index_mat(1)[OF i_dr b_dr]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (case (i, b) of (x, y) \<Rightarrow> let (p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j)) in if x = a \<and> y = a then p else if x = a \<and> y = b then q else if x = b \<and> y = a then u else if x = b \<and> y = b then v else if x = y then 1::'a else (0::'a)) = (0::'a)
[PROOF STEP]
using False i_not_a pquvd
[PROOF STATE]
proof (prove)
using this:
i \<noteq> b
i \<noteq> a
(p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j))

goal (1 subgoal):
 1. (case (i, b) of (x, y) \<Rightarrow> let (p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j)) in if x = a \<and> y = a then p else if x = a \<and> y = b then q else if x = b \<and> y = a then u else if x = b \<and> y = b then v else if x = y then 1::'a else (0::'a)) = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
bezout_matrix_JNF A a b j euclid_ext2 $$ (i, b) = (0::'a)

goal (1 subgoal):
 1. i \<noteq> b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have "sum ?f ({0..<m+n} - {a,b}) = sum ?f (insert i ({0..<m+n} - {a,b} - {i}))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = (\<Sum>ia\<in>insert i ({0..<m + n} - {a, b} - {i}). bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja))
[PROOF STEP]
by (rule sum.cong, insert i_dr A i_not_a i_not_b, auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = (\<Sum>ia\<in>insert i ({0..<m + n} - {a, b} - {i}). bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja))

goal (1 subgoal):
 1. i \<noteq> b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = (\<Sum>ia\<in>insert i ({0..<m + n} - {a, b} - {i}). bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja))

goal (1 subgoal):
 1. i \<noteq> b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have "... = ?f i + sum ?f ({0..<m+n} - {a,b} - {i})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<in>insert i ({0..<m + n} - {a, b} - {i}). bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = bezout_matrix_JNF A a b j euclid_ext2 $$ (i, i) * A $$ (i, ja) + (\<Sum>ia\<in>{0..<m + n} - {a, b} - {i}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja))
[PROOF STEP]
by (rule sum.insert, auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>ia\<in>insert i ({0..<m + n} - {a, b} - {i}). bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = bezout_matrix_JNF A a b j euclid_ext2 $$ (i, i) * A $$ (i, ja) + (\<Sum>ia\<in>{0..<m + n} - {a, b} - {i}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja))

goal (1 subgoal):
 1. i \<noteq> b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ia\<in>insert i ({0..<m + n} - {a, b} - {i}). bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = bezout_matrix_JNF A a b j euclid_ext2 $$ (i, i) * A $$ (i, ja) + (\<Sum>ia\<in>{0..<m + n} - {a, b} - {i}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja))

goal (1 subgoal):
 1. i \<noteq> b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have "... = ?f i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, i) * A $$ (i, ja) + (\<Sum>ia\<in>{0..<m + n} - {a, b} - {i}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = bezout_matrix_JNF A a b j euclid_ext2 $$ (i, i) * A $$ (i, ja)
[PROOF STEP]
using sum0
[PROOF STATE]
proof (prove)
using this:
(\<Sum>ia\<in>{0..<m + n} - {a, b} - {i}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = (0::'a)

goal (1 subgoal):
 1. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, i) * A $$ (i, ja) + (\<Sum>ia\<in>{0..<m + n} - {a, b} - {i}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = bezout_matrix_JNF A a b j euclid_ext2 $$ (i, i) * A $$ (i, ja)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
bezout_matrix_JNF A a b j euclid_ext2 $$ (i, i) * A $$ (i, ja) + (\<Sum>ia\<in>{0..<m + n} - {a, b} - {i}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = bezout_matrix_JNF A a b j euclid_ext2 $$ (i, i) * A $$ (i, ja)

goal (1 subgoal):
 1. i \<noteq> b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
bezout_matrix_JNF A a b j euclid_ext2 $$ (i, i) * A $$ (i, ja) + (\<Sum>ia\<in>{0..<m + n} - {a, b} - {i}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = bezout_matrix_JNF A a b j euclid_ext2 $$ (i, i) * A $$ (i, ja)

goal (1 subgoal):
 1. i \<noteq> b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
have "... = ?A $$ (i,ja)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, i) * A $$ (i, ja) = Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja)
[PROOF STEP]
unfolding bezout_matrix_JNF_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_row A) (\<lambda>(x, y). let (p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j)) in if x = a \<and> y = a then p else if x = a \<and> y = b then q else if x = b \<and> y = a then u else if x = b \<and> y = b then v else if x = y then 1::'a else (0::'a)) $$ (i, i) * A $$ (i, ja) = Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja)
[PROOF STEP]
using i_not_a i_not_b  A dr i ja
[PROOF STATE]
proof (prove)
using this:
i \<noteq> a
i \<noteq> b
A \<in> carrier_mat (m + n) n
dim_row (Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k))) = dim_row (bezout_matrix_JNF A a b j euclid_ext2 * A)
i < dim_row (bezout_matrix_JNF A a b j euclid_ext2 * A)
ja < dim_col (bezout_matrix_JNF A a b j euclid_ext2 * A)

goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_row A) (\<lambda>(x, y). let (p, q, u, v, d) = euclid_ext2 (A $$ (a, j)) (A $$ (b, j)) in if x = a \<and> y = a then p else if x = a \<and> y = b then q else if x = b \<and> y = a then u else if x = b \<and> y = b then v else if x = y then 1::'a else (0::'a)) $$ (i, i) * A $$ (i, ja) = Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja)
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
bezout_matrix_JNF A a b j euclid_ext2 $$ (i, i) * A $$ (i, ja) = Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja)

goal (1 subgoal):
 1. i \<noteq> b \<Longrightarrow> Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja)

goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)
[PROOF STEP]
unfolding BM_A_ija_eq
[PROOF STATE]
proof (prove)
using this:
(\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja)

goal (1 subgoal):
 1. Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (\<Sum>ia\<in>{a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) + (\<Sum>ia\<in>{0..<m + n} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja))
[PROOF STEP]
by (simp add: ab fa fb)
[PROOF STATE]
proof (state)
this:
Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Matrix.mat (dim_row A) (dim_col A) (\<lambda>(i, k). if i = a then p * A $$ (a, k) + q * A $$ (b, k) else if i = b then u * A $$ (a, k) + v * A $$ (b, k) else A $$ (i, k)) $$ (i, ja) = (bezout_matrix_JNF A a b j euclid_ext2 * A) $$ (i, ja)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma i_Exec_Stream_Init_nth_gr0_calc: "
  0 < n \<Longrightarrow>
  i_Exec_Comp_Stream_Init trans_fun input c n =
  trans_fun (input (n - 1)) (i_Exec_Comp_Stream_Init trans_fun input c (n - 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < n \<Longrightarrow> i_Exec_Comp_Stream_Init trans_fun input c n = trans_fun (input (n - 1)) (i_Exec_Comp_Stream_Init trans_fun input c (n - 1))
[PROOF STEP]
by (clarsimp simp: gr0_conv_Suc i_Exec_Stream_Init_nth_Suc_calc)


[STATEMENT]
lemma ChiPlus_ChiRel_Ex2 [rule_format]:
  "\<lbrakk> (S,T) \<in> ChiPlus A \<rbrakk> \<Longrightarrow> (S,T) \<notin> ChiRel A \<longrightarrow>
    (\<exists> U. (S,U) \<in> ChiRel A \<and> (U,T) \<in> ChiPlus A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (S, T) \<in> ChiPlus A \<Longrightarrow> (S, T) \<notin> ChiRel A \<longrightarrow> (\<exists>U. (S, U) \<in> ChiRel A \<and> (U, T) \<in> ChiPlus A)
[PROOF STEP]
apply (unfold ChiPlus_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (S, T) \<in> (ChiRel A)\<^sup>+ \<Longrightarrow> (S, T) \<notin> ChiRel A \<longrightarrow> (\<exists>U. (S, U) \<in> ChiRel A \<and> (U, T) \<in> (ChiRel A)\<^sup>+)
[PROOF STEP]
apply (rule_tac a="S" and b="T" and r="(ChiRel A)" in converse_trancl_induct)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. (S, T) \<in> (ChiRel A)\<^sup>+ \<Longrightarrow> (S, T) \<in> (ChiRel A)\<^sup>+
 2. \<And>y. \<lbrakk>(S, T) \<in> (ChiRel A)\<^sup>+; (y, T) \<in> ChiRel A\<rbrakk> \<Longrightarrow> (y, T) \<notin> ChiRel A \<longrightarrow> (\<exists>U. (y, U) \<in> ChiRel A \<and> (U, T) \<in> (ChiRel A)\<^sup>+)
 3. \<And>y z. \<lbrakk>(S, T) \<in> (ChiRel A)\<^sup>+; (y, z) \<in> ChiRel A; (z, T) \<in> (ChiRel A)\<^sup>+; (z, T) \<notin> ChiRel A \<longrightarrow> (\<exists>U. (z, U) \<in> ChiRel A \<and> (U, T) \<in> (ChiRel A)\<^sup>+)\<rbrakk> \<Longrightarrow> (y, T) \<notin> ChiRel A \<longrightarrow> (\<exists>U. (y, U) \<in> ChiRel A \<and> (U, T) \<in> (ChiRel A)\<^sup>+)
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma convex_positive_orthant: "convex {x::'a::euclidean_space. (\<forall>i\<in>Basis. 0 \<le> x\<bullet>i)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. convex {x. \<forall>i\<in>Basis. 0 \<le> x \<bullet> i}
[PROOF STEP]
by (rule convex_prod) (simp flip: atLeast_def)


[STATEMENT]
lemma is_contraction_\<L>: "is_contraction \<L>\<^sub>b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_contraction \<L>\<^sub>b
[PROOF STEP]
using contraction_\<L> zero_le_disc disc_lt_one
[PROOF STATE]
proof (prove)
using this:
dist (\<L>\<^sub>b ?v) (\<L>\<^sub>b ?u) \<le> l * dist ?v ?u
0 \<le> l
l < 1

goal (1 subgoal):
 1. is_contraction \<L>\<^sub>b
[PROOF STEP]
unfolding is_contraction_def
[PROOF STATE]
proof (prove)
using this:
dist (\<L>\<^sub>b ?v) (\<L>\<^sub>b ?u) \<le> l * dist ?v ?u
0 \<le> l
l < 1

goal (1 subgoal):
 1. \<exists>l\<ge>0. l < 1 \<and> (\<forall>v u. dist (\<L>\<^sub>b v) (\<L>\<^sub>b u) \<le> l * dist v u)
[PROOF STEP]
by blast


[STATEMENT]
lemma abelian_groupI:
  fixes R (structure)
  assumes "\<And>x y. \<lbrakk> x \<in> carrier R; y \<in> carrier R \<rbrakk> \<Longrightarrow> x \<oplus> y \<in> carrier R"
      and "\<zero> \<in> carrier R"
      and "\<And>x y z. \<lbrakk> x \<in> carrier R; y \<in> carrier R; z \<in> carrier R \<rbrakk> \<Longrightarrow> (x \<oplus> y) \<oplus> z = x \<oplus> (y \<oplus> z)"
      and "\<And>x y. \<lbrakk> x \<in> carrier R; y \<in> carrier R \<rbrakk> \<Longrightarrow> x \<oplus> y = y \<oplus> x"
      and "\<And>x. x \<in> carrier R \<Longrightarrow> \<zero> \<oplus> x = x"
      and "\<And>x. x \<in> carrier R \<Longrightarrow> \<exists>y \<in> carrier R. y \<oplus> x = \<zero>"
  shows "abelian_group R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. abelian_group R
[PROOF STEP]
by (auto intro!: abelian_group.intro abelian_monoidI
      abelian_group_axioms.intro comm_monoidI comm_groupI
    intro: assms)


[STATEMENT]
theorem gt_or_eq_compat_App: "s' \<ge>\<^sub>t s \<Longrightarrow> t' \<ge>\<^sub>t t \<Longrightarrow> App s' t' \<ge>\<^sub>t App s t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>s' \<ge>\<^sub>t s; t' \<ge>\<^sub>t t\<rbrakk> \<Longrightarrow> App s' t' \<ge>\<^sub>t App s t
[PROOF STEP]
using gt_compat_fun gt_compat_arg
[PROOF STATE]
proof (prove)
using this:
?t' >\<^sub>t ?t \<Longrightarrow> App ?s ?t' >\<^sub>t App ?s ?t
\<lbrakk>?s' >\<^sub>t ?s; ?t' \<ge>\<^sub>t ?t\<rbrakk> \<Longrightarrow> App ?s' ?t' >\<^sub>t App ?s ?t

goal (1 subgoal):
 1. \<lbrakk>s' \<ge>\<^sub>t s; t' \<ge>\<^sub>t t\<rbrakk> \<Longrightarrow> App s' t' \<ge>\<^sub>t App s t
[PROOF STEP]
by blast


[STATEMENT]
lemma finite_ta_rhs_states [simp]:
  "finite {q. \<exists>p. p |\<in>| rule_target_states (rules \<A>) \<and> (p = q \<or> (p, q) |\<in>| (eps \<A>)|\<^sup>+|)}" (is "finite ?Set")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {q. \<exists>p. p |\<in>| rule_target_states (rules \<A>) \<and> (p = q \<or> (p, q) |\<in>| (eps \<A>)|\<^sup>+|)}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. finite {q. \<exists>p. p |\<in>| rule_target_states (rules \<A>) \<and> (p = q \<or> (p, q) |\<in>| (eps \<A>)|\<^sup>+|)}
[PROOF STEP]
have "?Set \<subseteq> fset (\<Q> \<A>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {q. \<exists>p. p |\<in>| rule_target_states (rules \<A>) \<and> (p = q \<or> (p, q) |\<in>| (eps \<A>)|\<^sup>+|)} \<subseteq> fset (\<Q> \<A>)
[PROOF STEP]
by (auto dest: rule_statesD)
       (metis eps_trancl_statesD notin_fset rule_statesD(1))+
[PROOF STATE]
proof (state)
this:
{q. \<exists>p. p |\<in>| rule_target_states (rules \<A>) \<and> (p = q \<or> (p, q) |\<in>| (eps \<A>)|\<^sup>+|)} \<subseteq> fset (\<Q> \<A>)

goal (1 subgoal):
 1. finite {q. \<exists>p. p |\<in>| rule_target_states (rules \<A>) \<and> (p = q \<or> (p, q) |\<in>| (eps \<A>)|\<^sup>+|)}
[PROOF STEP]
from finite_subset[OF this]
[PROOF STATE]
proof (chain)
picking this:
finite (fset (\<Q> \<A>)) \<Longrightarrow> finite {q. \<exists>p. p |\<in>| rule_target_states (rules \<A>) \<and> (p = q \<or> (p, q) |\<in>| (eps \<A>)|\<^sup>+|)}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
finite (fset (\<Q> \<A>)) \<Longrightarrow> finite {q. \<exists>p. p |\<in>| rule_target_states (rules \<A>) \<and> (p = q \<or> (p, q) |\<in>| (eps \<A>)|\<^sup>+|)}

goal (1 subgoal):
 1. finite {q. \<exists>p. p |\<in>| rule_target_states (rules \<A>) \<and> (p = q \<or> (p, q) |\<in>| (eps \<A>)|\<^sup>+|)}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite {q. \<exists>p. p |\<in>| rule_target_states (rules \<A>) \<and> (p = q \<or> (p, q) |\<in>| (eps \<A>)|\<^sup>+|)}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma K5_card:
  assumes "K\<^bsub>5\<^esub> (mk_graph' G)" shows "ig_verts_cnt G = 5"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ig_verts_cnt G = 5
[PROOF STEP]
using assms distinct_ig_verts
[PROOF STATE]
proof (prove)
using this:
K\<^bsub>5\<^esub> (with_proj (mk_graph' G))
distinct (ig_verts ?G)

goal (1 subgoal):
 1. ig_verts_cnt G = 5
[PROOF STEP]
unfolding complete_digraph_pair_def
[PROOF STATE]
proof (prove)
using this:
finite (pverts (mk_graph' G)) \<and> card (pverts (mk_graph' G)) = 5 \<and> parcs (mk_graph' G) = {(u, v). (u, v) \<in> pverts (mk_graph' G) \<times> pverts (mk_graph' G) \<and> u \<noteq> v}
distinct (ig_verts ?G)

goal (1 subgoal):
 1. ig_verts_cnt G = 5
[PROOF STEP]
by (auto simp add: mkg'_simps distinct_card)


[STATEMENT]
lemma n_mult_glbI': "n z \<le> n x \<Longrightarrow>  n z \<le> n y \<Longrightarrow> n z \<le> n x \<cdot> n y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>!z \<le> !x; !z \<le> !y\<rbrakk> \<Longrightarrow> !z \<le> !x \<cdot> !y
[PROOF STEP]
by (metis mult_isor n_ord_def_alt)


[STATEMENT]
lemma (in is_iso_dghm) iso_inv_dghm_ObjMap_dghm_ObjMap_app[dghm_cs_simps]:
  assumes "a \<in>\<^sub>\<circ> \<AA>\<lparr>Obj\<rparr>"
  shows "inv_dghm \<FF>\<lparr>ObjMap\<rparr>\<lparr>\<FF>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr>\<rparr> = a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inv_dghm \<FF>\<lparr>ObjMap\<rparr>\<lparr>\<FF>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr>\<rparr> = a
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. inv_dghm \<FF>\<lparr>ObjMap\<rparr>\<lparr>\<FF>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr>\<rparr> = a
[PROOF STEP]
from is_iso_dghm_is_iso_arr[OF is_iso_dghm_axioms]
[PROOF STATE]
proof (chain)
picking this:
inv_dghm \<FF> : \<BB> \<mapsto>\<mapsto>\<^sub>D\<^sub>G\<^sub>.\<^sub>i\<^sub>s\<^sub>o\<^bsub>\<alpha>\<^esub> \<AA>
inv_dghm \<FF> \<circ>\<^sub>D\<^sub>G\<^sub>H\<^sub>M \<FF> = dghm_id \<AA>
\<FF> \<circ>\<^sub>D\<^sub>G\<^sub>H\<^sub>M inv_dghm \<FF> = dghm_id \<BB>
[PROOF STEP]
have
    "(inv_dghm \<FF> \<circ>\<^sub>D\<^sub>G\<^sub>H\<^sub>M \<FF>)\<lparr>ObjMap\<rparr>\<lparr>a\<rparr> = dghm_id \<AA>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr>"
[PROOF STATE]
proof (prove)
using this:
inv_dghm \<FF> : \<BB> \<mapsto>\<mapsto>\<^sub>D\<^sub>G\<^sub>.\<^sub>i\<^sub>s\<^sub>o\<^bsub>\<alpha>\<^esub> \<AA>
inv_dghm \<FF> \<circ>\<^sub>D\<^sub>G\<^sub>H\<^sub>M \<FF> = dghm_id \<AA>
\<FF> \<circ>\<^sub>D\<^sub>G\<^sub>H\<^sub>M inv_dghm \<FF> = dghm_id \<BB>

goal (1 subgoal):
 1. (inv_dghm \<FF> \<circ>\<^sub>D\<^sub>G\<^sub>H\<^sub>M \<FF>)\<lparr>ObjMap\<rparr>\<lparr>a\<rparr> = dghm_id \<AA>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(inv_dghm \<FF> \<circ>\<^sub>D\<^sub>G\<^sub>H\<^sub>M \<FF>)\<lparr>ObjMap\<rparr>\<lparr>a\<rparr> = dghm_id \<AA>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr>

goal (1 subgoal):
 1. inv_dghm \<FF>\<lparr>ObjMap\<rparr>\<lparr>\<FF>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr>\<rparr> = a
[PROOF STEP]
from this assms
[PROOF STATE]
proof (chain)
picking this:
(inv_dghm \<FF> \<circ>\<^sub>D\<^sub>G\<^sub>H\<^sub>M \<FF>)\<lparr>ObjMap\<rparr>\<lparr>a\<rparr> = dghm_id \<AA>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr>
a \<in>\<^sub>\<circ> \<AA>\<lparr>Obj\<rparr>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(inv_dghm \<FF> \<circ>\<^sub>D\<^sub>G\<^sub>H\<^sub>M \<FF>)\<lparr>ObjMap\<rparr>\<lparr>a\<rparr> = dghm_id \<AA>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr>
a \<in>\<^sub>\<circ> \<AA>\<lparr>Obj\<rparr>

goal (1 subgoal):
 1. inv_dghm \<FF>\<lparr>ObjMap\<rparr>\<lparr>\<FF>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr>\<rparr> = a
[PROOF STEP]
by
      (
        cs_prems cs_shallow
          cs_simp: dg_cs_simps cs_intro: dg_cs_intros dghm_cs_intros
      )
[PROOF STATE]
proof (state)
this:
inv_dghm \<FF>\<lparr>ObjMap\<rparr>\<lparr>\<FF>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr>\<rparr> = a

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma trcl_cons_conv:
  "(u,a#xs,v)\<in>trcl R \<longleftrightarrow> (\<exists>uh. (u,a,uh)\<in>R \<and> (uh,xs,v)\<in>trcl R)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((u, a # xs, v) \<in> trcl R) = (\<exists>uh. (u, a, uh) \<in> R \<and> (uh, xs, v) \<in> trcl R)
[PROOF STEP]
by (auto dest!: trcl_uncons)


[STATEMENT]
lemma exp_ge_add_one_self [simp]: "1 + x \<le> exp x"
  for x :: real
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 + x \<le> exp x
[PROOF STEP]
proof (cases "0 \<le> x \<or> x \<le> -1")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 \<le> x \<or> x \<le> - 1 \<Longrightarrow> 1 + x \<le> exp x
 2. \<not> (0 \<le> x \<or> x \<le> - 1) \<Longrightarrow> 1 + x \<le> exp x
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
0 \<le> x \<or> x \<le> - 1

goal (2 subgoals):
 1. 0 \<le> x \<or> x \<le> - 1 \<Longrightarrow> 1 + x \<le> exp x
 2. \<not> (0 \<le> x \<or> x \<le> - 1) \<Longrightarrow> 1 + x \<le> exp x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 \<le> x \<or> x \<le> - 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
0 \<le> x \<or> x \<le> - 1

goal (1 subgoal):
 1. 1 + x \<le> exp x
[PROOF STEP]
by (meson exp_ge_add_one_self_aux exp_ge_zero order.trans real_add_le_0_iff)
[PROOF STATE]
proof (state)
this:
1 + x \<le> exp x

goal (1 subgoal):
 1. \<not> (0 \<le> x \<or> x \<le> - 1) \<Longrightarrow> 1 + x \<le> exp x
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> (0 \<le> x \<or> x \<le> - 1) \<Longrightarrow> 1 + x \<le> exp x
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> (0 \<le> x \<or> x \<le> - 1)

goal (1 subgoal):
 1. \<not> (0 \<le> x \<or> x \<le> - 1) \<Longrightarrow> 1 + x \<le> exp x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> (0 \<le> x \<or> x \<le> - 1)
[PROOF STEP]
have ln1: "ln (1 + x) \<le> x"
[PROOF STATE]
proof (prove)
using this:
\<not> (0 \<le> x \<or> x \<le> - 1)

goal (1 subgoal):
 1. ln (1 + x) \<le> x
[PROOF STEP]
using ln_one_minus_pos_upper_bound [of "-x"]
[PROOF STATE]
proof (prove)
using this:
\<not> (0 \<le> x \<or> x \<le> - 1)
\<lbrakk>0 \<le> - x; - x < 1\<rbrakk> \<Longrightarrow> ln (1 - - x) \<le> - (- x)

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

goal (1 subgoal):
 1. \<not> (0 \<le> x \<or> x \<le> - 1) \<Longrightarrow> 1 + x \<le> exp x
[PROOF STEP]
have "1 + x = exp (ln (1 + x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 + x = exp (ln (1 + x))
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
\<not> (0 \<le> x \<or> x \<le> - 1)

goal (1 subgoal):
 1. 1 + x = exp (ln (1 + x))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
1 + x = exp (ln (1 + x))

goal (1 subgoal):
 1. \<not> (0 \<le> x \<or> x \<le> - 1) \<Longrightarrow> 1 + x \<le> exp x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 + x = exp (ln (1 + x))

goal (1 subgoal):
 1. \<not> (0 \<le> x \<or> x \<le> - 1) \<Longrightarrow> 1 + x \<le> exp x
[PROOF STEP]
have "\<dots> \<le> exp x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. exp (ln (1 + x)) \<le> exp x
[PROOF STEP]
by (simp add: ln1)
[PROOF STATE]
proof (state)
this:
exp (ln (1 + x)) \<le> exp x

goal (1 subgoal):
 1. \<not> (0 \<le> x \<or> x \<le> - 1) \<Longrightarrow> 1 + x \<le> exp x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
1 + x \<le> exp x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
1 + x \<le> exp x

goal (1 subgoal):
 1. 1 + x \<le> exp x
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
1 + x \<le> exp x

goal:
No subgoals!
[PROOF STEP]
qed