[STATEMENT]
lemma bezout_matrix_JNF_mult_eq':
  assumes A': "A' \<in> carrier_mat m n" and a: "a<m"  and b: "b<m" and ab: "a \<noteq> b"
  and A_def: "A = A' @\<^sub>r B" and B: "B \<in> carrier_mat t 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+t) n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<in> carrier_mat (m + t) 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 t n

goal (1 subgoal):
 1. A \<in> carrier_mat (m + t) n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
A \<in> carrier_mat (m + t) 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+t) n"
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat (m + t) 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 + t) 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 + t) 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+t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec (col A ja) = m + t
[PROOF STEP]
using A
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat (m + t) n

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

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 + t) 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 + t) 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 + t) n
a < 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 + t) n
b < 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+t. ?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 + t. 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 + t. 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 + t. 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+t} - {a,b})). ?f ia)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia = 0..<m + t. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = (\<Sum>ia\<in>{a, b} \<union> ({0..<m + t} - {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 + t. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = (\<Sum>ia\<in>{a, b} \<union> ({0..<m + t} - {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 + t. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = (\<Sum>ia\<in>{a, b} \<union> ({0..<m + t} - {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+t} - {a,b})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<in>{a, b} \<union> ({0..<m + t} - {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 + t} - {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 + t} - {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 + t} - {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 + t} - {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+t} - {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 + t} - {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 + t} - {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 + t} - {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+t} - {a,b}) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<in>{0..<m + t} - {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 + t} - {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 + t} - {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 + t} - {a, b}"
[PROOF STATE]
proof (state)
this:
x \<in> {0..<m + t} - {a, b}

goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + t} - {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+t"
[PROOF STATE]
proof (prove)
using this:
x \<in> {0..<m + t} - {a, b}

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

goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + t} - {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 + t} - {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 + t} - {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 + t} - {a, b}
A \<in> carrier_mat (m + t) 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 + t} - {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 + t} - {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 + t} - {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 + t} - {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+t} - {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 + t} - {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 + t} - {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 + t} - {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 + t} - {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 + t} - {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 + t) 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 + t} - {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 + t} - {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 + t} - {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 + t} - {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+t} - {a,b}) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<in>{0..<m + t} - {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 + t} - {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 + t} - {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 + t} - {a, b}"
[PROOF STATE]
proof (state)
this:
x \<in> {0..<m + t} - {a, b}

goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + t} - {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+t"
[PROOF STATE]
proof (prove)
using this:
x \<in> {0..<m + t} - {a, b}

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

goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + t} - {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 + t} - {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 + t} - {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 + t} - {a, b}
A \<in> carrier_mat (m + t) 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 + t} - {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 + t} - {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 + t} - {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 + t} - {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+t} - {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 + t} - {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 + t} - {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 + t} - {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 + t} - {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 + t} - {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 + t) 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 + t} - {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 + t} - {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 + t} - {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 + t} - {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+t} - {a,b} - {i}) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<in>{0..<m + t} - {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 + t} - {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 + t} - {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 + t} - {a, b} - {i}"
[PROOF STATE]
proof (state)
this:
x \<in> {0..<m + t} - {a, b} - {i}

goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + t} - {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+t"
[PROOF STATE]
proof (prove)
using this:
x \<in> {0..<m + t} - {a, b} - {i}

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

goal (1 subgoal):
 1. \<And>x. x \<in> {0..<m + t} - {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 + t} - {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 + t} - {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 + t} - {a, b} - {i}
A \<in> carrier_mat (m + t) 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 + t} - {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 + t} - {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 + t} - {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 + t} - {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+t} - {a,b}) = sum ?f (insert i ({0..<m+t} - {a,b} - {i}))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<in>{0..<m + t} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = (\<Sum>ia\<in>insert i ({0..<m + t} - {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 + t} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = (\<Sum>ia\<in>insert i ({0..<m + t} - {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 + t} - {a, b}. bezout_matrix_JNF A a b j euclid_ext2 $$ (i, ia) * A $$ (ia, ja)) = (\<Sum>ia\<in>insert i ({0..<m + t} - {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+t} - {a,b} - {i})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<in>insert i ({0..<m + t} - {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 + t} - {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 + t} - {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 + t} - {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 + t} - {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 + t} - {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 + t} - {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 + t} - {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 + t} - {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 + t} - {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 + t} - {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 + t) 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 + t} - {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 + t} - {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 + t} - {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 + t} - {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 accum2_lemma [simp]:
  shows "rec_eval (rec_accum2 f) [x, y1, y2] = (\<Prod> z \<le> x. rec_eval f  [z, y1, y2])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rec_eval (rec_accum2 f) [x, y1, y2] = (\<Prod>z\<le>x. rec_eval f [z, y1, y2])
[PROOF STEP]
by (induct x) (simp_all add: rec_accum2_def)


[STATEMENT]
lemma negligible_multc: "negligible (\<lambda>\<eta>. f \<eta> * c) \<longleftrightarrow> negligible f \<or> c = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. negligible (\<lambda>\<eta>. f \<eta> * c) = (negligible f \<or> c = 0)
[PROOF STEP]
by(subst mult.commute)(simp add: negligible_cmult)


[STATEMENT]
lemma eval_inverse_primfun:
  "eval_primfun (inverse_primfun f) x = inverse (eval_primfun f x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eval_primfun (inverse_primfun f) x = inverse (eval_primfun f x)
[PROOF STEP]
by (induction f rule: inverse_primfun.induct) (simp_all add: powr_minus)


[STATEMENT]
lemma remove_lemma: "x \<in> nat_to_set u \<Longrightarrow> set_to_nat (nat_to_set u - {x}) = u - 2 ^ x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> nat_to_set u \<Longrightarrow> set_to_nat (nat_to_set u - {x}) = u - 2 ^ x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x \<in> nat_to_set u \<Longrightarrow> set_to_nat (nat_to_set u - {x}) = u - 2 ^ x
[PROOF STEP]
assume A: "x \<in> nat_to_set u"
[PROOF STATE]
proof (state)
this:
x \<in> nat_to_set u

goal (1 subgoal):
 1. x \<in> nat_to_set u \<Longrightarrow> set_to_nat (nat_to_set u - {x}) = u - 2 ^ x
[PROOF STEP]
define D where "D = nat_to_set u - {x}"
[PROOF STATE]
proof (state)
this:
D = nat_to_set u - {x}

goal (1 subgoal):
 1. x \<in> nat_to_set u \<Longrightarrow> set_to_nat (nat_to_set u - {x}) = u - 2 ^ x
[PROOF STEP]
from A D_def
[PROOF STATE]
proof (chain)
picking this:
x \<in> nat_to_set u
D = nat_to_set u - {x}
[PROOF STEP]
have S1: "x \<notin> D"
[PROOF STATE]
proof (prove)
using this:
x \<in> nat_to_set u
D = nat_to_set u - {x}

goal (1 subgoal):
 1. x \<notin> D
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<notin> D

goal (1 subgoal):
 1. x \<in> nat_to_set u \<Longrightarrow> set_to_nat (nat_to_set u - {x}) = u - 2 ^ x
[PROOF STEP]
have "finite (nat_to_set u)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (nat_to_set u)
[PROOF STEP]
by (rule nat_to_set_is_finite)
[PROOF STATE]
proof (state)
this:
finite (nat_to_set u)

goal (1 subgoal):
 1. x \<in> nat_to_set u \<Longrightarrow> set_to_nat (nat_to_set u - {x}) = u - 2 ^ x
[PROOF STEP]
with D_def
[PROOF STATE]
proof (chain)
picking this:
D = nat_to_set u - {x}
finite (nat_to_set u)
[PROOF STEP]
have D_finite: "finite D"
[PROOF STATE]
proof (prove)
using this:
D = nat_to_set u - {x}
finite (nat_to_set u)

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

goal (1 subgoal):
 1. x \<in> nat_to_set u \<Longrightarrow> set_to_nat (nat_to_set u - {x}) = u - 2 ^ x
[PROOF STEP]
let ?f = "\<lambda> (x::nat). (2::nat)^x"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x \<in> nat_to_set u \<Longrightarrow> set_to_nat (nat_to_set u - {x}) = u - 2 ^ x
[PROOF STEP]
from set_to_nat_def
[PROOF STATE]
proof (chain)
picking this:
set_to_nat = sum ((^) 2)
[PROOF STEP]
have "set_to_nat (D \<union> {x}) = sum ?f (D \<union> {x})"
[PROOF STATE]
proof (prove)
using this:
set_to_nat = sum ((^) 2)

goal (1 subgoal):
 1. set_to_nat (D \<union> {x}) = sum ((^) 2) (D \<union> {x})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set_to_nat (D \<union> {x}) = sum ((^) 2) (D \<union> {x})

goal (1 subgoal):
 1. x \<in> nat_to_set u \<Longrightarrow> set_to_nat (nat_to_set u - {x}) = u - 2 ^ x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
set_to_nat (D \<union> {x}) = sum ((^) 2) (D \<union> {x})

goal (1 subgoal):
 1. x \<in> nat_to_set u \<Longrightarrow> set_to_nat (nat_to_set u - {x}) = u - 2 ^ x
[PROOF STEP]
from D_finite S1
[PROOF STATE]
proof (chain)
picking this:
finite D
x \<notin> D
[PROOF STEP]
have "\<dots> = ?f x + sum ?f D"
[PROOF STATE]
proof (prove)
using this:
finite D
x \<notin> D

goal (1 subgoal):
 1. sum ((^) 2) (D \<union> {x}) = 2 ^ x + sum ((^) 2) D
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sum ((^) 2) (D \<union> {x}) = 2 ^ x + sum ((^) 2) D

goal (1 subgoal):
 1. x \<in> nat_to_set u \<Longrightarrow> set_to_nat (nat_to_set u - {x}) = u - 2 ^ x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum ((^) 2) (D \<union> {x}) = 2 ^ x + sum ((^) 2) D

goal (1 subgoal):
 1. x \<in> nat_to_set u \<Longrightarrow> set_to_nat (nat_to_set u - {x}) = u - 2 ^ x
[PROOF STEP]
from set_to_nat_def
[PROOF STATE]
proof (chain)
picking this:
set_to_nat = sum ((^) 2)
[PROOF STEP]
have "\<dots> = 2 ^ x + set_to_nat D"
[PROOF STATE]
proof (prove)
using this:
set_to_nat = sum ((^) 2)

goal (1 subgoal):
 1. 2 ^ x + sum ((^) 2) D = 2 ^ x + set_to_nat D
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
2 ^ x + sum ((^) 2) D = 2 ^ x + set_to_nat D

goal (1 subgoal):
 1. x \<in> nat_to_set u \<Longrightarrow> set_to_nat (nat_to_set u - {x}) = u - 2 ^ x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
set_to_nat (D \<union> {x}) = 2 ^ x + set_to_nat D
[PROOF STEP]
have S2: "set_to_nat (D \<union> {x}) = set_to_nat D + 2 ^ x"
[PROOF STATE]
proof (prove)
using this:
set_to_nat (D \<union> {x}) = 2 ^ x + set_to_nat D

goal (1 subgoal):
 1. set_to_nat (D \<union> {x}) = set_to_nat D + 2 ^ x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set_to_nat (D \<union> {x}) = set_to_nat D + 2 ^ x

goal (1 subgoal):
 1. x \<in> nat_to_set u \<Longrightarrow> set_to_nat (nat_to_set u - {x}) = u - 2 ^ x
[PROOF STEP]
from A D_def
[PROOF STATE]
proof (chain)
picking this:
x \<in> nat_to_set u
D = nat_to_set u - {x}
[PROOF STEP]
have "D \<union> {x} = nat_to_set u"
[PROOF STATE]
proof (prove)
using this:
x \<in> nat_to_set u
D = nat_to_set u - {x}

goal (1 subgoal):
 1. D \<union> {x} = nat_to_set u
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
D \<union> {x} = nat_to_set u

goal (1 subgoal):
 1. x \<in> nat_to_set u \<Longrightarrow> set_to_nat (nat_to_set u - {x}) = u - 2 ^ x
[PROOF STEP]
with S2
[PROOF STATE]
proof (chain)
picking this:
set_to_nat (D \<union> {x}) = set_to_nat D + 2 ^ x
D \<union> {x} = nat_to_set u
[PROOF STEP]
have S3: "u = set_to_nat D + 2 ^ x"
[PROOF STATE]
proof (prove)
using this:
set_to_nat (D \<union> {x}) = set_to_nat D + 2 ^ x
D \<union> {x} = nat_to_set u

goal (1 subgoal):
 1. u = set_to_nat D + 2 ^ x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
u = set_to_nat D + 2 ^ x

goal (1 subgoal):
 1. x \<in> nat_to_set u \<Longrightarrow> set_to_nat (nat_to_set u - {x}) = u - 2 ^ x
[PROOF STEP]
from A
[PROOF STATE]
proof (chain)
picking this:
x \<in> nat_to_set u
[PROOF STEP]
have S4: "2 ^ x \<le> u"
[PROOF STATE]
proof (prove)
using this:
x \<in> nat_to_set u

goal (1 subgoal):
 1. 2 ^ x \<le> u
[PROOF STEP]
by (rule nat_to_set_upper_bound)
[PROOF STATE]
proof (state)
this:
2 ^ x \<le> u

goal (1 subgoal):
 1. x \<in> nat_to_set u \<Longrightarrow> set_to_nat (nat_to_set u - {x}) = u - 2 ^ x
[PROOF STEP]
with S3 D_def
[PROOF STATE]
proof (chain)
picking this:
u = set_to_nat D + 2 ^ x
D = nat_to_set u - {x}
2 ^ x \<le> u
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
u = set_to_nat D + 2 ^ x
D = nat_to_set u - {x}
2 ^ x \<le> u

goal (1 subgoal):
 1. set_to_nat (nat_to_set u - {x}) = u - 2 ^ x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set_to_nat (nat_to_set u - {x}) = u - 2 ^ x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Min_le_Max: "\<lbrakk> finite A; A \<noteq> {} \<rbrakk> \<Longrightarrow> Min A \<le> Max A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite A; A \<noteq> {}\<rbrakk> \<Longrightarrow> Min A \<le> Max A
[PROOF STEP]
by (rule Max_ge[OF _ Min_in])


[STATEMENT]
lemma Fract_less_one_iff: "0 < b \<Longrightarrow> Fract a b < 1 \<longleftrightarrow> a < b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < b \<Longrightarrow> (Fract a b < 1) = (a < b)
[PROOF STEP]
by (simp add: One_rat_def mult_less_cancel_right_disj)


[STATEMENT]
lemma coprime_set_non_empty:
  assumes "N > 2"
  shows "coprime_set N \<noteq> {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coprime_set N \<noteq> {}
[PROOF STEP]
by(simp add: coprime_set_def; metis assms(1) Suc_lessE coprime_Suc_right_nat lessI numeral_2_eq_2)


[STATEMENT]
lemma fps_fps_exp_compose_minus [simp]:
  "fps_compose (fps_exp c) (-fps_X) = fps_exp (-c :: 'a :: field_char_0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fps_exp c oo - fps_X = fps_exp (- c)
[PROOF STEP]
using fps_exp_compose_linear[of c "-1 :: 'a"]
[PROOF STATE]
proof (prove)
using this:
fps_exp c oo fps_const (- (1::'a)) * fps_X = fps_exp (- (1::'a) * c)

goal (1 subgoal):
 1. fps_exp c oo - fps_X = fps_exp (- c)
[PROOF STEP]
unfolding fps_const_neg [symmetric] fps_const_1_eq_1
[PROOF STATE]
proof (prove)
using this:
fps_exp c oo - 1 * fps_X = fps_exp (- (1::'a) * c)

goal (1 subgoal):
 1. fps_exp c oo - fps_X = fps_exp (- c)
[PROOF STEP]
by simp