[STATEMENT]
lemma make_mat_works:
  assumes A: "A\<in>carrier_mat m n" and Suc_i_less_n: "Suc i < n"
    and Q_step_def: "Q_step = (make_mat n (Suc i) (snd (Smith_1x2
        (Matrix.mat 1 2 (\<lambda>(a,b). if b = 0 then A $$ (0,0) else A $$(0,Suc i))))))"
  shows "A $$ (0,0) * Q_step $$ (0,(Suc i)) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
have n0: "0<n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < n
[PROOF STEP]
using Suc_i_less_n
[PROOF STATE]
proof (prove)
using this:
Suc i < n

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

goal (1 subgoal):
 1. A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
let ?A ="(Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
let ?S = "fst (Smith_1x2 ?A)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
let ?Q = "snd (Smith_1x2 ?A)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
have 1: "(make_mat n (Suc i) ?Q) $$ (0,Suc i) = ?Q $$ (0,1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. make_mat n (Suc i) (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) $$ (0, Suc i) = snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1)
[PROOF STEP]
unfolding make_mat_index[OF n0 Suc_i_less_n]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if 0 = 0 \<and> Suc i = 0 then snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 0) else if 0 = 0 \<and> Suc i = Suc i then snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) else if 0 = Suc i \<and> Suc i = 0 then snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (1, 0) else if 0 = Suc i \<and> Suc i = Suc i then snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (1, 1) else if 0 = Suc i then 1::'a else (0::'a)) = snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
make_mat n (Suc i) (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) $$ (0, Suc i) = snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1)

goal (1 subgoal):
 1. A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
have 2: "(make_mat n (Suc i) ?Q) $$ (Suc i, Suc i) = ?Q $$ (1,1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. make_mat n (Suc i) (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) $$ (Suc i, Suc i) = snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (1, 1)
[PROOF STEP]
unfolding make_mat_index[OF Suc_i_less_n Suc_i_less_n]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if Suc i = 0 \<and> Suc i = 0 then snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 0) else if Suc i = 0 \<and> Suc i = Suc i then snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) else if Suc i = Suc i \<and> Suc i = 0 then snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (1, 0) else if Suc i = Suc i \<and> Suc i = Suc i then snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (1, 1) else if Suc i = Suc i then 1::'a else (0::'a)) = snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (1, 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
make_mat n (Suc i) (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) $$ (Suc i, Suc i) = snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (1, 1)

goal (1 subgoal):
 1. A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
have is_SNF_A': "is_SNF ?A (1\<^sub>m 1, Smith_1x2 ?A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_SNF (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) (1\<^sub>m 1, Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))
[PROOF STEP]
using SNF_1x2_works
[PROOF STATE]
proof (prove)
using this:
\<forall>A\<in>carrier_mat 1 2. is_SNF A (1\<^sub>m 1, Smith_1x2 A)

goal (1 subgoal):
 1. is_SNF (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) (1\<^sub>m 1, Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
is_SNF (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) (1\<^sub>m 1, Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))

goal (1 subgoal):
 1. A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
have SNF_S: "Smith_normal_form_mat ?S" and S: "?S = 1\<^sub>m 1 * ?A * ?Q"
    and Q: "?Q \<in> carrier_mat 2 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Smith_normal_form_mat (fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) &&& fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) = 1\<^sub>m 1 * Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) &&& snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) \<in> carrier_mat 2 2
[PROOF STEP]
using is_SNF_A'
[PROOF STATE]
proof (prove)
using this:
is_SNF (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) (1\<^sub>m 1, Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))

goal (1 subgoal):
 1. Smith_normal_form_mat (fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) &&& fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) = 1\<^sub>m 1 * Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) &&& snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) \<in> carrier_mat 2 2
[PROOF STEP]
unfolding is_SNF_def
[PROOF STATE]
proof (prove)
using this:
case (1\<^sub>m 1, Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) of (P, S, Q) \<Rightarrow> P \<in> carrier_mat (dim_row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) (dim_row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) \<and> Q \<in> carrier_mat (dim_col (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) (dim_col (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) \<and> invertible_mat P \<and> invertible_mat Q \<and> Smith_normal_form_mat S \<and> S = P * Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)) * Q

goal (1 subgoal):
 1. Smith_normal_form_mat (fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) &&& fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) = 1\<^sub>m 1 * Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) &&& snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) \<in> carrier_mat 2 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Smith_normal_form_mat (fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))))
fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) = 1\<^sub>m 1 * Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))
snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) \<in> carrier_mat 2 2

goal (1 subgoal):
 1. A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
have "?S $$(0,1) = (?A * ?Q) $$(0,1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) = (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) $$ (0, 1)
[PROOF STEP]
unfolding S
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (1\<^sub>m 1 * Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) $$ (0, 1) = (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) $$ (0, 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) = (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) $$ (0, 1)

goal (1 subgoal):
 1. A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) = (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) $$ (0, 1)

goal (1 subgoal):
 1. A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
have "... =  Matrix.row ?A 0 \<bullet> col ?Q 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) $$ (0, 1) = Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 \<bullet> col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1
[PROOF STEP]
by (rule index_mult_mat, insert Q, auto)
[PROOF STATE]
proof (state)
this:
(Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) $$ (0, 1) = Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 \<bullet> col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1

goal (1 subgoal):
 1. A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) $$ (0, 1) = Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 \<bullet> col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1

goal (1 subgoal):
 1. A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
have "... = (\<Sum>ia = 0..<dim_vec (col ?Q 1). Matrix.row ?A 0 $v ia * col ?Q 1 $v ia)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 \<bullet> col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 = (\<Sum>ia = 0..<dim_vec (col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1). Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v ia * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v ia)
[PROOF STEP]
unfolding scalar_prod_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia = 0..<dim_vec (col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1). Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v ia * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v ia) = (\<Sum>ia = 0..<dim_vec (col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1). Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v ia * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v ia)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 \<bullet> col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 = (\<Sum>ia = 0..<dim_vec (col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1). Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v ia * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v ia)

goal (1 subgoal):
 1. A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 \<bullet> col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 = (\<Sum>ia = 0..<dim_vec (col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1). Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v ia * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v ia)

goal (1 subgoal):
 1. A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
have "... = (\<Sum>ia \<in> {0,1}. Matrix.row ?A 0 $v ia * col ?Q 1 $v ia)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia = 0..<dim_vec (col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1). Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v ia * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v ia) = (\<Sum>ia\<in>{0, 1}. Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v ia * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v ia)
[PROOF STEP]
by (rule sum.cong, insert Q, auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>ia = 0..<dim_vec (col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1). Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v ia * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v ia) = (\<Sum>ia\<in>{0, 1}. Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v ia * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v ia)

goal (1 subgoal):
 1. A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ia = 0..<dim_vec (col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1). Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v ia * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v ia) = (\<Sum>ia\<in>{0, 1}. Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v ia * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v ia)

goal (1 subgoal):
 1. A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
have "... = Matrix.row ?A 0 $v 0 * col ?Q 1 $v 0 + Matrix.row ?A 0 $v 1 * col ?Q 1 $v 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ia\<in>{0, 1}. Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v ia * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v ia) = Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v 0 * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v 0 + Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v 1 * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v 1
[PROOF STEP]
using sum_two_elements
[PROOF STATE]
proof (prove)
using this:
?a \<noteq> ?b \<Longrightarrow> sum ?f {?a, ?b} = ?f ?a + ?f ?b

goal (1 subgoal):
 1. (\<Sum>ia\<in>{0, 1}. Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v ia * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v ia) = Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v 0 * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v 0 + Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v 1 * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>ia\<in>{0, 1}. Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v ia * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v ia) = Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v 0 * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v 0 + Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v 1 * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v 1

goal (1 subgoal):
 1. A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ia\<in>{0, 1}. Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v ia * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v ia) = Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v 0 * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v 0 + Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v 1 * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v 1

goal (1 subgoal):
 1. A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
have "... = A $$ (0,0) * ?Q $$ (0,1) + A $$ (0,Suc i) * ?Q $$ (1,1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v 0 * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v 0 + Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v 1 * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v 1 = A $$ (0, 0) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) + A $$ (0, Suc i) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (1, 1)
[PROOF STEP]
by (smt One_nat_def Q carrier_matD(1) carrier_matD(2) dim_col_mat(1) dim_row_mat(1) index_col
        index_mat(1) index_row(1) lessI numeral_2_eq_2 pos2 prod.simps(2) rel_simps(93))
[PROOF STATE]
proof (state)
this:
Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v 0 * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v 0 + Matrix.row (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))) 0 $v 1 * col (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) 1 $v 1 = A $$ (0, 0) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) + A $$ (0, Suc i) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (1, 1)

goal (1 subgoal):
 1. A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) = A $$ (0, 0) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) + A $$ (0, Suc i) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (1, 1)
[PROOF STEP]
have "?S $$(0,1) = A $$ (0,0) * ?Q $$ (0,1) + A $$ (0,Suc i) * ?Q $$ (1,1)"
[PROOF STATE]
proof (prove)
using this:
fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) = A $$ (0, 0) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) + A $$ (0, Suc i) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (1, 1)

goal (1 subgoal):
 1. fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) = A $$ (0, 0) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) + A $$ (0, Suc i) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (1, 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) = A $$ (0, 0) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) + A $$ (0, Suc i) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (1, 1)

goal (1 subgoal):
 1. A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) = A $$ (0, 0) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) + A $$ (0, Suc i) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (1, 1)

goal (1 subgoal):
 1. A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
have "?S $$(0,1) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) = (0::'a)
[PROOF STEP]
using SNF_S
[PROOF STATE]
proof (prove)
using this:
Smith_normal_form_mat (fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))))

goal (1 subgoal):
 1. fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) = (0::'a)
[PROOF STEP]
unfolding Smith_normal_form_mat_def isDiagonal_mat_def
[PROOF STATE]
proof (prove)
using this:
(\<forall>a. a + 1 < min (dim_row (fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))))) (dim_col (fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))))) \<longrightarrow> fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (a, a) dvd fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (a + 1, a + 1)) \<and> (\<forall>ia j. ia \<noteq> j \<and> ia < dim_row (fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) \<and> j < dim_col (fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) \<longrightarrow> fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (ia, j) = (0::'a))

goal (1 subgoal):
 1. fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) = (0::'a)
[PROOF STEP]
by (metis (no_types, lifting) Q S card_num_simps(30) carrier_matD(2) index_mult_mat(2)
        index_mult_mat(3) index_one_mat(2) lessI n_not_Suc_n numeral_2_eq_2)
[PROOF STATE]
proof (state)
this:
fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) = (0::'a)

goal (1 subgoal):
 1. A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) = A $$ (0, 0) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) + A $$ (0, Suc i) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (1, 1)
fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) = (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) = A $$ (0, 0) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) + A $$ (0, Suc i) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (1, 1)
fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) = (0::'a)

goal (1 subgoal):
 1. A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
using 1 2
[PROOF STATE]
proof (prove)
using this:
fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) = A $$ (0, 0) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) + A $$ (0, Suc i) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (1, 1)
fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) = (0::'a)
make_mat n (Suc i) (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) $$ (0, Suc i) = snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1)
make_mat n (Suc i) (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) $$ (Suc i, Suc i) = snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (1, 1)

goal (1 subgoal):
 1. A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
unfolding Q_step_def
[PROOF STATE]
proof (prove)
using this:
fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) = A $$ (0, 0) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) + A $$ (0, Suc i) * snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (1, 1)
fst (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1) = (0::'a)
make_mat n (Suc i) (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) $$ (0, Suc i) = snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (0, 1)
make_mat n (Suc i) (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) $$ (Suc i, Suc i) = snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i)))) $$ (1, 1)

goal (1 subgoal):
 1. A $$ (0, 0) * make_mat n (Suc i) (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) $$ (0, Suc i) + A $$ (0, Suc i) * make_mat n (Suc i) (snd (Smith_1x2 (Matrix.mat 1 2 (\<lambda>(a, b). if b = 0 then A $$ (0, 0) else A $$ (0, Suc i))))) $$ (Suc i, Suc i) = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A $$ (0, 0) * Q_step $$ (0, Suc i) + A $$ (0, Suc i) * Q_step $$ (Suc i, Suc i) = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma cis_Arg_1[simp]: "cis (Arg 1) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cis (Arg 1) = 1
[PROOF STEP]
using Arg_of_real[of 1]
[PROOF STATE]
proof (prove)
using this:
Arg (cor 1) = (if 1 < 0 then pi else 0)

goal (1 subgoal):
 1. cis (Arg 1) = 1
[PROOF STEP]
by simp


[STATEMENT]
lemma arith_as_simp[simp]: "\<lbrakk>Suc n \<le> ba - aa; aa < ba\<rbrakk> \<Longrightarrow>
                    (ba < Suc (aa + (ba - Suc (aa + n) + n))) = False"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Suc n \<le> ba - aa; aa < ba\<rbrakk> \<Longrightarrow> (ba < Suc (aa + (ba - Suc (aa + n) + n))) = False
[PROOF STEP]
apply arith
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma "closure (-S) \<inter> closure S = frontier S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. closure (- S) \<inter> closure S = frontier S
[PROOF STEP]
by (auto simp add: frontier_def closure_complement)


[STATEMENT]
lemma closed_valid_path_image: "valid_path g \<Longrightarrow> closed(path_image g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. valid_path g \<Longrightarrow> closed (path_image g)
[PROOF STEP]
by (metis closed_path_image valid_path_imp_path)


[STATEMENT]
lemma coeff_mult_prod_sum:
  "coeff (\<Prod>i\<in>S. f i) (\<Sum>i\<in>S. degree (f i)) = (\<Prod>i\<in>S. coeff (f i) (degree (f i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff (prod f S) (\<Sum>i\<in>S. degree (f i)) = (\<Prod>i\<in>S. lead_coeff (f i))
[PROOF STEP]
by (induct rule: infinite_finite_induct)(simp_all add: coeff_mult_sum degree_prod_le)


[STATEMENT]
lemma r_distinguishable_k_least_bound :
  assumes "\<exists> k . r_distinguishable_k M q1 q2 k"
      and "q1 \<in> states M"
      and "q2 \<in> states M"
  shows "(LEAST k . r_distinguishable_k M q1 q2 k) \<le> (size (product (from_FSM M q1) (from_FSM M q2)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (LEAST k. r_distinguishable_k M q1 q2 k) \<le> FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2))
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> (LEAST k. r_distinguishable_k M q1 q2 k) \<le> FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2)) \<Longrightarrow> False
[PROOF STEP]
assume "\<not> (LEAST k. r_distinguishable_k M q1 q2 k) \<le> (size (product (from_FSM M q1) (from_FSM M q2)))"
[PROOF STATE]
proof (state)
this:
\<not> (LEAST k. r_distinguishable_k M q1 q2 k) \<le> FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2))

goal (1 subgoal):
 1. \<not> (LEAST k. r_distinguishable_k M q1 q2 k) \<le> FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2)) \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> (LEAST k. r_distinguishable_k M q1 q2 k) \<le> FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2))
[PROOF STEP]
have c_assm : "(size (product (from_FSM M q1) (from_FSM M q2))) < (LEAST k. r_distinguishable_k M q1 q2 k)"
[PROOF STATE]
proof (prove)
using this:
\<not> (LEAST k. r_distinguishable_k M q1 q2 k) \<le> FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2))

goal (1 subgoal):
 1. FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2)) < (LEAST k. r_distinguishable_k M q1 q2 k)
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2)) < (LEAST k. r_distinguishable_k M q1 q2 k)

goal (1 subgoal):
 1. \<not> (LEAST k. r_distinguishable_k M q1 q2 k) \<le> FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2)) \<Longrightarrow> False
[PROOF STEP]
obtain t p where "is_least_r_d_k_path M q1 q2 (t # p)"
               and "length (t # p) = Suc (LEAST k. r_distinguishable_k M q1 q2 k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>t p. \<lbrakk>is_least_r_d_k_path M q1 q2 (t # p); length (t # p) = Suc (LEAST k. r_distinguishable_k M q1 q2 k)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using is_least_r_d_k_path_length_from_r_d[OF assms(1)]
[PROOF STATE]
proof (prove)
using this:
\<exists>t p. is_least_r_d_k_path M q1 q2 (t # p) \<and> length (t # p) = Suc (LEAST k. r_distinguishable_k M q1 q2 k)

goal (1 subgoal):
 1. (\<And>t p. \<lbrakk>is_least_r_d_k_path M q1 q2 (t # p); length (t # p) = Suc (LEAST k. r_distinguishable_k M q1 q2 k)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
is_least_r_d_k_path M q1 q2 (t # p)
length (t # p) = Suc (LEAST k. r_distinguishable_k M q1 q2 k)

goal (1 subgoal):
 1. \<not> (LEAST k. r_distinguishable_k M q1 q2 k) \<le> FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2)) \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
is_least_r_d_k_path M q1 q2 (t # p)
length (t # p) = Suc (LEAST k. r_distinguishable_k M q1 q2 k)
[PROOF STEP]
have "(size (product (from_FSM M q1) (from_FSM M q2))) < length (t # p)"
[PROOF STATE]
proof (prove)
using this:
is_least_r_d_k_path M q1 q2 (t # p)
length (t # p) = Suc (LEAST k. r_distinguishable_k M q1 q2 k)

goal (1 subgoal):
 1. FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2)) < length (t # p)
[PROOF STEP]
using c_assm
[PROOF STATE]
proof (prove)
using this:
is_least_r_d_k_path M q1 q2 (t # p)
length (t # p) = Suc (LEAST k. r_distinguishable_k M q1 q2 k)
FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2)) < (LEAST k. r_distinguishable_k M q1 q2 k)

goal (1 subgoal):
 1. FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2)) < length (t # p)
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2)) < length (t # p)

goal (1 subgoal):
 1. \<not> (LEAST k. r_distinguishable_k M q1 q2 k) \<le> FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2)) \<Longrightarrow> False
[PROOF STEP]
have "distinct (map fst (t # p))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct (map fst (t # p))
[PROOF STEP]
using is_least_r_d_k_path_distinct[OF \<open>is_least_r_d_k_path M q1 q2 (t # p)\<close>]
[PROOF STATE]
proof (prove)
using this:
distinct (map fst (t # p))

goal (1 subgoal):
 1. distinct (map fst (t # p))
[PROOF STEP]
by assumption
[PROOF STATE]
proof (state)
this:
distinct (map fst (t # p))

goal (1 subgoal):
 1. \<not> (LEAST k. r_distinguishable_k M q1 q2 k) \<le> FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2)) \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
distinct (map fst (t # p))
[PROOF STEP]
have "card (set (map fst (t # p))) = length (t # p)"
[PROOF STATE]
proof (prove)
using this:
distinct (map fst (t # p))

goal (1 subgoal):
 1. card (set (map fst (t # p))) = length (t # p)
[PROOF STEP]
using distinct_card
[PROOF STATE]
proof (prove)
using this:
distinct (map fst (t # p))
distinct ?xs \<Longrightarrow> card (set ?xs) = length ?xs

goal (1 subgoal):
 1. card (set (map fst (t # p))) = length (t # p)
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
card (set (map fst (t # p))) = length (t # p)

goal (1 subgoal):
 1. \<not> (LEAST k. r_distinguishable_k M q1 q2 k) \<le> FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2)) \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
card (set (map fst (t # p))) = length (t # p)

goal (1 subgoal):
 1. \<not> (LEAST k. r_distinguishable_k M q1 q2 k) \<le> FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2)) \<Longrightarrow> False
[PROOF STEP]
have "card (set (map fst (t # p))) \<le> size (product (from_FSM M q1) (from_FSM M q2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (set (map fst (t # p))) \<le> FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2))
[PROOF STEP]
using is_least_r_d_k_path_states[OF \<open>is_least_r_d_k_path M q1 q2 (t # p)\<close> assms(2,3)] fsm_states_finite card_mono
[PROOF STATE]
proof (prove)
using this:
set (map fst (t # p)) \<subseteq> FSM.states (Product_FSM.product (from_FSM M q1) (from_FSM M q2))
finite (FSM.states ?M)
\<lbrakk>finite ?B; ?A \<subseteq> ?B\<rbrakk> \<Longrightarrow> card ?A \<le> card ?B

goal (1 subgoal):
 1. card (set (map fst (t # p))) \<le> FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2))
[PROOF STEP]
unfolding size_def
[PROOF STATE]
proof (prove)
using this:
set (map fst (t # p)) \<subseteq> FSM.states (Product_FSM.product (from_FSM M q1) (from_FSM M q2))
finite (FSM.states ?M)
\<lbrakk>finite ?B; ?A \<subseteq> ?B\<rbrakk> \<Longrightarrow> card ?A \<le> card ?B

goal (1 subgoal):
 1. card (set (map fst (t # p))) \<le> card (FSM.states (Product_FSM.product (from_FSM M q1) (from_FSM M q2)))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
card (set (map fst (t # p))) \<le> FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2))

goal (1 subgoal):
 1. \<not> (LEAST k. r_distinguishable_k M q1 q2 k) \<le> FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2)) \<Longrightarrow> False
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
card (set (map fst (t # p))) = length (t # p)
card (set (map fst (t # p))) \<le> FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2))
[PROOF STEP]
have "length (t # p) \<le> size (product (from_FSM M q1) (from_FSM M q2))"
[PROOF STATE]
proof (prove)
using this:
card (set (map fst (t # p))) = length (t # p)
card (set (map fst (t # p))) \<le> FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2))

goal (1 subgoal):
 1. length (t # p) \<le> FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2))
[PROOF STEP]
by (metis)
[PROOF STATE]
proof (state)
this:
length (t # p) \<le> FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2))

goal (1 subgoal):
 1. \<not> (LEAST k. r_distinguishable_k M q1 q2 k) \<le> FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2)) \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
length (t # p) \<le> FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2))
[PROOF STEP]
show "False"
[PROOF STATE]
proof (prove)
using this:
length (t # p) \<le> FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2))

goal (1 subgoal):
 1. False
[PROOF STEP]
using \<open>size (product (from_FSM M q1) (from_FSM M q2)) < length (t # p)\<close>
[PROOF STATE]
proof (prove)
using this:
length (t # p) \<le> FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2))
FSM.size (Product_FSM.product (from_FSM M q1) (from_FSM M q2)) < length (t # p)

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma insertion_resultant_mpoly_poly: "insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q *
  (lead_coeff q * (-1)^ degree q)^(degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ (degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ (degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))
[PROOF STEP]
let ?pa = "partial_insertion \<alpha> x"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ (degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))
[PROOF STEP]
let ?a = "insertion \<alpha>"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ (degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))
[PROOF STEP]
let ?q = "map_poly Const q"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ (degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))
[PROOF STEP]
let ?m = "mpoly_to_mpoly_poly x"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ (degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))
[PROOF STEP]
interpret a: comm_ring_hom ?a
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. comm_ring_hom (insertion \<alpha>)
[PROOF STEP]
by (rule comm_ring_hom_insertion)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ (degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))
[PROOF STEP]
define m where "m = degree (?m p) - degree (?pa p)"
[PROOF STATE]
proof (state)
this:
m = degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p)

goal (1 subgoal):
 1. insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ (degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))
[PROOF STEP]
from degree_partial_insertion_le_mpoly[of \<alpha> x p]
[PROOF STATE]
proof (chain)
picking this:
degree (partial_insertion \<alpha> x p) \<le> degree (mpoly_to_mpoly_poly x p)
[PROOF STEP]
have deg: "degree (?m p) = degree (?pa p) + m"
[PROOF STATE]
proof (prove)
using this:
degree (partial_insertion \<alpha> x p) \<le> degree (mpoly_to_mpoly_poly x p)

goal (1 subgoal):
 1. degree (mpoly_to_mpoly_poly x p) = degree (partial_insertion \<alpha> x p) + m
[PROOF STEP]
unfolding m_def
[PROOF STATE]
proof (prove)
using this:
degree (partial_insertion \<alpha> x p) \<le> degree (mpoly_to_mpoly_poly x p)

goal (1 subgoal):
 1. degree (mpoly_to_mpoly_poly x p) = degree (partial_insertion \<alpha> x p) + (degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
degree (mpoly_to_mpoly_poly x p) = degree (partial_insertion \<alpha> x p) + m

goal (1 subgoal):
 1. insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ (degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))
[PROOF STEP]
define k where "k = degree (?pa p) + m"
[PROOF STATE]
proof (state)
this:
k = degree (partial_insertion \<alpha> x p) + m

goal (1 subgoal):
 1. insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ (degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))
[PROOF STEP]
define l where "l = degree q"
[PROOF STATE]
proof (state)
this:
l = degree q

goal (1 subgoal):
 1. insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ (degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))
[PROOF STEP]
have "resultant (?pa p) q = det (sylvester_mat_sub (degree (?pa p)) (degree q) (?pa p) q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. resultant (partial_insertion \<alpha> x p) q = det (sylvester_mat_sub (degree (partial_insertion \<alpha> x p)) (degree q) (partial_insertion \<alpha> x p) q)
[PROOF STEP]
unfolding resultant_def sylvester_mat_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (sylvester_mat_sub (degree (partial_insertion \<alpha> x p)) (degree q) (partial_insertion \<alpha> x p) q) = det (sylvester_mat_sub (degree (partial_insertion \<alpha> x p)) (degree q) (partial_insertion \<alpha> x p) q)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
resultant (partial_insertion \<alpha> x p) q = det (sylvester_mat_sub (degree (partial_insertion \<alpha> x p)) (degree q) (partial_insertion \<alpha> x p) q)

goal (1 subgoal):
 1. insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ (degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))
[PROOF STEP]
have "?a (resultant_mpoly_poly x p q) = ?a (det (sylvester_mat_sub (degree (?pa p) + m) (degree q) (?m p) ?q))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. insertion \<alpha> (resultant_mpoly_poly x p q) = insertion \<alpha> (det (sylvester_mat_sub (degree (partial_insertion \<alpha> x p) + m) (degree q) (mpoly_to_mpoly_poly x p) (map_poly Const q)))
[PROOF STEP]
unfolding resultant_mpoly_poly_def resultant_def sylvester_mat_def degree_map_poly_Const deg
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. insertion \<alpha> (det (sylvester_mat_sub (degree (partial_insertion \<alpha> x p) + m) (degree q) (mpoly_to_mpoly_poly x p) (map_poly Const q))) = insertion \<alpha> (det (sylvester_mat_sub (degree (partial_insertion \<alpha> x p) + m) (degree q) (mpoly_to_mpoly_poly x p) (map_poly Const q)))
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
insertion \<alpha> (resultant_mpoly_poly x p q) = insertion \<alpha> (det (sylvester_mat_sub (degree (partial_insertion \<alpha> x p) + m) (degree q) (mpoly_to_mpoly_poly x p) (map_poly Const q)))

goal (1 subgoal):
 1. insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ (degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
insertion \<alpha> (resultant_mpoly_poly x p q) = insertion \<alpha> (det (sylvester_mat_sub (degree (partial_insertion \<alpha> x p) + m) (degree q) (mpoly_to_mpoly_poly x p) (map_poly Const q)))

goal (1 subgoal):
 1. insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ (degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))
[PROOF STEP]
have "\<dots> =
    det (a.mat_hom (sylvester_mat_sub (degree (?pa p) + m) (degree q) (?m p) ?q))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. insertion \<alpha> (det (sylvester_mat_sub (degree (partial_insertion \<alpha> x p) + m) (degree q) (mpoly_to_mpoly_poly x p) (map_poly Const q))) = det (a.mat_hom (sylvester_mat_sub (degree (partial_insertion \<alpha> x p) + m) (degree q) (mpoly_to_mpoly_poly x p) (map_poly Const q)))
[PROOF STEP]
unfolding a.hom_det
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. insertion \<alpha> (det (sylvester_mat_sub (degree (partial_insertion \<alpha> x p) + m) (degree q) (mpoly_to_mpoly_poly x p) (map_poly Const q))) = insertion \<alpha> (det (sylvester_mat_sub (degree (partial_insertion \<alpha> x p) + m) (degree q) (mpoly_to_mpoly_poly x p) (map_poly Const q)))
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
insertion \<alpha> (det (sylvester_mat_sub (degree (partial_insertion \<alpha> x p) + m) (degree q) (mpoly_to_mpoly_poly x p) (map_poly Const q))) = det (a.mat_hom (sylvester_mat_sub (degree (partial_insertion \<alpha> x p) + m) (degree q) (mpoly_to_mpoly_poly x p) (map_poly Const q)))

goal (1 subgoal):
 1. insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ (degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
insertion \<alpha> (det (sylvester_mat_sub (degree (partial_insertion \<alpha> x p) + m) (degree q) (mpoly_to_mpoly_poly x p) (map_poly Const q))) = det (a.mat_hom (sylvester_mat_sub (degree (partial_insertion \<alpha> x p) + m) (degree q) (mpoly_to_mpoly_poly x p) (map_poly Const q)))

goal (1 subgoal):
 1. insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ (degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))
[PROOF STEP]
have "a.mat_hom (sylvester_mat_sub (degree (?pa p) + m) (degree q) (?m p) ?q)
    = sylvester_mat_sub (degree (?pa p) + m) (degree q) (?pa p) q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a.mat_hom (sylvester_mat_sub (degree (partial_insertion \<alpha> x p) + m) (degree q) (mpoly_to_mpoly_poly x p) (map_poly Const q)) = sylvester_mat_sub (degree (partial_insertion \<alpha> x p) + m) (degree q) (partial_insertion \<alpha> x p) q
[PROOF STEP]
unfolding k_def[symmetric] l_def[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a.mat_hom (sylvester_mat_sub k l (mpoly_to_mpoly_poly x p) (map_poly Const q)) = sylvester_mat_sub k l (partial_insertion \<alpha> x p) q
[PROOF STEP]
by (intro eq_matI, auto simp: sylvester_mat_sub_def coeff_map_poly)
[PROOF STATE]
proof (state)
this:
a.mat_hom (sylvester_mat_sub (degree (partial_insertion \<alpha> x p) + m) (degree q) (mpoly_to_mpoly_poly x p) (map_poly Const q)) = sylvester_mat_sub (degree (partial_insertion \<alpha> x p) + m) (degree q) (partial_insertion \<alpha> x p) q

goal (1 subgoal):
 1. insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ (degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
a.mat_hom (sylvester_mat_sub (degree (partial_insertion \<alpha> x p) + m) (degree q) (mpoly_to_mpoly_poly x p) (map_poly Const q)) = sylvester_mat_sub (degree (partial_insertion \<alpha> x p) + m) (degree q) (partial_insertion \<alpha> x p) q

goal (1 subgoal):
 1. insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ (degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))
[PROOF STEP]
have "det \<dots> = det (sylvester_mat_sub (degree (?pa p)) (degree q) (?pa p) q) * (lead_coeff q * (- 1) ^ degree q) ^ m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (sylvester_mat_sub (degree (partial_insertion \<alpha> x p) + m) (degree q) (partial_insertion \<alpha> x p) q) = det (sylvester_mat_sub (degree (partial_insertion \<alpha> x p)) (degree q) (partial_insertion \<alpha> x p) q) * (lead_coeff q * (- (1::'a)) ^ degree q) ^ m
[PROOF STEP]
by (subst det_sylvester_matrix_higher_degree, simp)
[PROOF STATE]
proof (state)
this:
det (sylvester_mat_sub (degree (partial_insertion \<alpha> x p) + m) (degree q) (partial_insertion \<alpha> x p) q) = det (sylvester_mat_sub (degree (partial_insertion \<alpha> x p)) (degree q) (partial_insertion \<alpha> x p) q) * (lead_coeff q * (- (1::'a)) ^ degree q) ^ m

goal (1 subgoal):
 1. insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ (degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
det (sylvester_mat_sub (degree (partial_insertion \<alpha> x p) + m) (degree q) (partial_insertion \<alpha> x p) q) = det (sylvester_mat_sub (degree (partial_insertion \<alpha> x p)) (degree q) (partial_insertion \<alpha> x p) q) * (lead_coeff q * (- (1::'a)) ^ degree q) ^ m

goal (1 subgoal):
 1. insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ (degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))
[PROOF STEP]
have "det (sylvester_mat_sub (degree (?pa p)) (degree q) (?pa p) q) = resultant (?pa p) q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (sylvester_mat_sub (degree (partial_insertion \<alpha> x p)) (degree q) (partial_insertion \<alpha> x p) q) = resultant (partial_insertion \<alpha> x p) q
[PROOF STEP]
unfolding resultant_def sylvester_mat_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (sylvester_mat_sub (degree (partial_insertion \<alpha> x p)) (degree q) (partial_insertion \<alpha> x p) q) = det (sylvester_mat_sub (degree (partial_insertion \<alpha> x p)) (degree q) (partial_insertion \<alpha> x p) q)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
det (sylvester_mat_sub (degree (partial_insertion \<alpha> x p)) (degree q) (partial_insertion \<alpha> x p) q) = resultant (partial_insertion \<alpha> x p) q

goal (1 subgoal):
 1. insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ (degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ m
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ m

goal (1 subgoal):
 1. insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ (degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))
[PROOF STEP]
unfolding m_def
[PROOF STATE]
proof (prove)
using this:
insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ (degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))

goal (1 subgoal):
 1. insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ (degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
insertion \<alpha> (resultant_mpoly_poly x p q) = resultant (partial_insertion \<alpha> x p) q * (lead_coeff q * (- (1::'a)) ^ degree q) ^ (degree (mpoly_to_mpoly_poly x p) - degree (partial_insertion \<alpha> x p))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fixing_arr_gives_natural_transformation_2:
    assumes "A2.arr f2"
    shows "natural_transformation A1 B (\<lambda>f1. F (f1, A2.dom f2)) (\<lambda>f1. F (f1, A2.cod f2))
                                       (\<lambda>f1. F (f1, f2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. natural_transformation (\<cdot>\<^sub>A\<^sub>1) (\<cdot>\<^sub>B) (\<lambda>f1. F (f1, A2.dom f2)) (\<lambda>f1. F (f1, A2.cod f2)) (\<lambda>f1. F (f1, f2))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. natural_transformation (\<cdot>\<^sub>A\<^sub>1) (\<cdot>\<^sub>B) (\<lambda>f1. F (f1, A2.dom f2)) (\<lambda>f1. F (f1, A2.cod f2)) (\<lambda>f1. F (f1, f2))
[PROOF STEP]
interpret F': binary_functor A2 A1 B sym
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. binary_functor (\<cdot>\<^sub>A\<^sub>2) (\<cdot>\<^sub>A\<^sub>1) (\<cdot>\<^sub>B) local.sym
[PROOF STEP]
using assms(1) sym_is_binary_functor
[PROOF STATE]
proof (prove)
using this:
A2.arr f2
binary_functor (\<cdot>\<^sub>A\<^sub>2) (\<cdot>\<^sub>A\<^sub>1) (\<cdot>\<^sub>B) local.sym

goal (1 subgoal):
 1. binary_functor (\<cdot>\<^sub>A\<^sub>2) (\<cdot>\<^sub>A\<^sub>1) (\<cdot>\<^sub>B) local.sym
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. natural_transformation (\<cdot>\<^sub>A\<^sub>1) (\<cdot>\<^sub>B) (\<lambda>f1. F (f1, A2.dom f2)) (\<lambda>f1. F (f1, A2.cod f2)) (\<lambda>f1. F (f1, f2))
[PROOF STEP]
have "natural_transformation A1 B (\<lambda>f1. sym (A2.dom f2, f1)) (\<lambda>f1. sym (A2.cod f2, f1))
                                        (\<lambda>f1. sym (f2, f1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. natural_transformation (\<cdot>\<^sub>A\<^sub>1) (\<cdot>\<^sub>B) (\<lambda>f1. local.sym (A2.dom f2, f1)) (\<lambda>f1. local.sym (A2.cod f2, f1)) (\<lambda>f1. local.sym (f2, f1))
[PROOF STEP]
using assms F'.fixing_arr_gives_natural_transformation_1
[PROOF STATE]
proof (prove)
using this:
A2.arr f2
A2.arr ?f1.0 \<Longrightarrow> natural_transformation (\<cdot>\<^sub>A\<^sub>1) (\<cdot>\<^sub>B) (\<lambda>f2. local.sym (A2.dom ?f1.0, f2)) (\<lambda>f2. local.sym (A2.cod ?f1.0, f2)) (\<lambda>f2. local.sym (?f1.0, f2))

goal (1 subgoal):
 1. natural_transformation (\<cdot>\<^sub>A\<^sub>1) (\<cdot>\<^sub>B) (\<lambda>f1. local.sym (A2.dom f2, f1)) (\<lambda>f1. local.sym (A2.cod f2, f1)) (\<lambda>f1. local.sym (f2, f1))
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
natural_transformation (\<cdot>\<^sub>A\<^sub>1) (\<cdot>\<^sub>B) (\<lambda>f1. local.sym (A2.dom f2, f1)) (\<lambda>f1. local.sym (A2.cod f2, f1)) (\<lambda>f1. local.sym (f2, f1))

goal (1 subgoal):
 1. natural_transformation (\<cdot>\<^sub>A\<^sub>1) (\<cdot>\<^sub>B) (\<lambda>f1. F (f1, A2.dom f2)) (\<lambda>f1. F (f1, A2.cod f2)) (\<lambda>f1. F (f1, f2))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
natural_transformation (\<cdot>\<^sub>A\<^sub>1) (\<cdot>\<^sub>B) (\<lambda>f1. local.sym (A2.dom f2, f1)) (\<lambda>f1. local.sym (A2.cod f2, f1)) (\<lambda>f1. local.sym (f2, f1))

goal (1 subgoal):
 1. natural_transformation (\<cdot>\<^sub>A\<^sub>1) (\<cdot>\<^sub>B) (\<lambda>f1. F (f1, A2.dom f2)) (\<lambda>f1. F (f1, A2.cod f2)) (\<lambda>f1. F (f1, f2))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
natural_transformation (\<cdot>\<^sub>A\<^sub>1) (\<cdot>\<^sub>B) (\<lambda>f1. F (f1, A2.dom f2)) (\<lambda>f1. F (f1, A2.cod f2)) (\<lambda>f1. F (f1, f2))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma connectedI[intro?]:
  assumes "\<And>u v. \<lbrakk>u\<in>nodes g; v\<in>nodes g\<rbrakk> \<Longrightarrow> (u,v)\<in>(edges g)\<^sup>*"
  shows "connected g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Undirected_Graph.connected g
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?u \<in> nodes g; ?v \<in> nodes g\<rbrakk> \<Longrightarrow> (?u, ?v) \<in> (edges g)\<^sup>*

goal (1 subgoal):
 1. Undirected_Graph.connected g
[PROOF STEP]
unfolding connected_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?u \<in> nodes g; ?v \<in> nodes g\<rbrakk> \<Longrightarrow> (?u, ?v) \<in> (edges g)\<^sup>*

goal (1 subgoal):
 1. nodes g \<times> nodes g \<subseteq> (edges g)\<^sup>*
[PROOF STEP]
by auto


[STATEMENT]
lemma Icc_subset_Iic_iff[simp]:
  "{l\<le>\<^sub>a..\<le>\<^sub>ah} \<subseteq> {..\<le>\<^sub>ah'} = (\<not> l \<le>\<^sub>a h \<or> h \<le>\<^sub>a h')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ({l\<le>\<^sub>a..\<le>\<^sub>ah} \<subseteq> {..\<le>\<^sub>ah'}) = (\<not> l \<le>\<^sub>a h \<or> h \<le>\<^sub>a h')
[PROOF STEP]
unfolding interval_def ray_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ({x \<in> UNIV. l \<le>\<^sub>a x} \<inter> {x \<in> UNIV. x \<le>\<^sub>a h} \<subseteq> {x \<in> UNIV. x \<le>\<^sub>a h'}) = (\<not> l \<le>\<^sub>a h \<or> h \<le>\<^sub>a h')
[PROOF STEP]
by (blast intro: order_trans)+


[STATEMENT]
lemma toCard_inj: "\<lbrakk>|A| \<le>o r; Card_order r; x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> toCard A r x = toCard A r y \<longleftrightarrow> x = y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>|A| \<le>o r; Card_order r; x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> (toCard A r x = toCard A r y) = (x = y)
[PROOF STEP]
using toCard_pred_toCard
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>|?A| \<le>o ?r; Card_order ?r\<rbrakk> \<Longrightarrow> toCard_pred ?A ?r (toCard ?A ?r)

goal (1 subgoal):
 1. \<lbrakk>|A| \<le>o r; Card_order r; x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> (toCard A r x = toCard A r y) = (x = y)
[PROOF STEP]
unfolding inj_on_def toCard_pred_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>|?A| \<le>o ?r; Card_order ?r\<rbrakk> \<Longrightarrow> (\<forall>x\<in>?A. \<forall>y\<in>?A. toCard ?A ?r x = toCard ?A ?r y \<longrightarrow> x = y) \<and> toCard ?A ?r ` ?A \<subseteq> Field ?r \<and> Card_order ?r

goal (1 subgoal):
 1. \<lbrakk>|A| \<le>o r; Card_order r; x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> (toCard A r x = toCard A r y) = (x = y)
[PROOF STEP]
by blast


[STATEMENT]
lemma extended_distance_pos:
  assumes "a \<in> extended_distance_set"
          "b \<in> extended_distance_set"
  shows "extended_distance a b \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> extended_distance a b
[PROOF STEP]
using assms extended_distance_set_def extended_distance_triang_ineq[of a b a]
[PROOF STATE]
proof (prove)
using this:
a \<in> extended_distance_set
b \<in> extended_distance_set
extended_distance_set = {z. extended_distance z z = 0}
\<lbrakk>a \<in> extended_distance_set; b \<in> extended_distance_set; a \<in> extended_distance_set\<rbrakk> \<Longrightarrow> extended_distance a a \<le> extended_distance a b + extended_distance b a

goal (1 subgoal):
 1. 0 \<le> extended_distance a b
[PROOF STEP]
unfolding extended_distance_symmetric[of b a]
[PROOF STATE]
proof (prove)
using this:
a \<in> extended_distance_set
b \<in> extended_distance_set
extended_distance_set = {z. extended_distance z z = 0}
\<lbrakk>a \<in> extended_distance_set; b \<in> extended_distance_set; a \<in> extended_distance_set\<rbrakk> \<Longrightarrow> extended_distance a a \<le> extended_distance a b + extended_distance a b

goal (1 subgoal):
 1. 0 \<le> extended_distance a b
[PROOF STEP]
by auto


[STATEMENT]
lemma omega_super_id1: "0 \<noteq> 1 \<Longrightarrow> 1 \<le> x \<Longrightarrow> x\<^sup>\<omega> \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(0::'a) \<noteq> (1::'a); (1::'a) \<le> x\<rbrakk> \<Longrightarrow> x\<^sup>\<omega> \<noteq> (0::'a)
[PROOF STEP]
using ewp_neg_and_omega ewp_super_id1
[PROOF STATE]
proof (prove)
using this:
(\<not> ewp ?x) = (?x\<^sup>\<omega> = (0::'a))
\<lbrakk>(0::'a) \<noteq> (1::'a); (1::'a) \<le> ?x\<rbrakk> \<Longrightarrow> ewp ?x

goal (1 subgoal):
 1. \<lbrakk>(0::'a) \<noteq> (1::'a); (1::'a) \<le> x\<rbrakk> \<Longrightarrow> x\<^sup>\<omega> \<noteq> (0::'a)
[PROOF STEP]
by blast


[STATEMENT]
lemma pratt_triple_imp_prime:
  assumes "pratt_triple p a x" "p > 1" "x = p - 1" "[a ^ (p - 1) = 1] (mod p)"
  shows   "prime p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prime p
[PROOF STEP]
using lehmers_theorem[of p a] assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>2 \<le> p; \<And>x. x \<in># prime_factorization (p - 1) \<Longrightarrow> [a ^ ((p - 1) div x) \<noteq> 1] (mod p); [a ^ (p - 1) = 1] (mod p)\<rbrakk> \<Longrightarrow> prime p
pratt_triple p a x
1 < p
x = p - 1
[a ^ (p - 1) = 1] (mod p)

goal (1 subgoal):
 1. prime p
[PROOF STEP]
by (auto simp: pratt_triple_def)


[STATEMENT]
lemma p2r_simps[simp]:
  "\<lceil>P\<rceil> \<le> \<lceil>Q\<rceil> = (\<forall>s. P s \<longrightarrow> Q s)"
  "(\<lceil>P\<rceil> = \<lceil>Q\<rceil>) = (\<forall>s. P s = Q s)"
  "(\<lceil>P\<rceil> ; \<lceil>Q\<rceil>) = \<lceil>\<lambda> s. P s \<and> Q s\<rceil>"
  "(\<lceil>P\<rceil> \<union> \<lceil>Q\<rceil>) = \<lceil>\<lambda> s. P s \<or> Q s\<rceil>"
  "rel_ad \<lceil>P\<rceil> = \<lceil>\<lambda>s. \<not> P s\<rceil>"
  "rel_aka.ads_d \<lceil>P\<rceil> = \<lceil>P\<rceil>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lceil>P\<rceil> \<subseteq> \<lceil>Q\<rceil>) = (\<forall>s. P s \<longrightarrow> Q s) &&& (\<lceil>P\<rceil> = \<lceil>Q\<rceil>) = (\<forall>s. P s = Q s) &&& \<lceil>P\<rceil> ; \<lceil>Q\<rceil> = \<lceil>\<lambda>s. P s \<and> Q s\<rceil>) &&& \<lceil>P\<rceil> \<union> \<lceil>Q\<rceil> = \<lceil>\<lambda>s. P s \<or> Q s\<rceil> &&& rel_ad \<lceil>P\<rceil> = \<lceil>\<lambda>s. \<not> P s\<rceil> &&& rel_aka.ads_d \<lceil>P\<rceil> = \<lceil>P\<rceil>
[PROOF STEP]
unfolding p2r_def rel_ad_def rel_aka.ads_d_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (({(s, s) |s. P s} \<subseteq> {(s, s) |s. Q s}) = (\<forall>s. P s \<longrightarrow> Q s) &&& ({(s, s) |s. P s} = {(s, s) |s. Q s}) = (\<forall>s. P s = Q s) &&& {(s, s) |s. P s} ; {(s, s) |s. Q s} = {(s, s) |s. P s \<and> Q s}) &&& {(s, s) |s. P s} \<union> {(s, s) |s. Q s} = {(s, s) |s. P s \<or> Q s} &&& {(x, x) |x. \<nexists>y. (x, y) \<in> {(s, s) |s. P s}} = {(s, s) |s. \<not> P s} &&& {(x, x) |x. \<nexists>y. (x, y) \<in> {(x, x) |x. \<nexists>y. (x, y) \<in> {(s, s) |s. P s}}} = {(s, s) |s. P s}
[PROOF STEP]
by auto


[STATEMENT]
lemma normal_exponent_bounds_int:
  "2 - 2 ^ (LENGTH('e) - 1) - int LENGTH('f) \<le> normal_exponent x"
  "normal_exponent x \<le> 2 ^ (LENGTH('e) - 1) - int LENGTH('f) - 1"
  if "is_normal x"
  for x::"('e, 'f)float"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 - 2 ^ (LENGTH('e) - 1) - int LENGTH('f) \<le> normal_exponent x &&& normal_exponent x \<le> 2 ^ (LENGTH('e) - 1) - int LENGTH('f) - 1
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
is_normal x

goal (1 subgoal):
 1. 2 - 2 ^ (LENGTH('e) - 1) - int LENGTH('f) \<le> normal_exponent x &&& normal_exponent x \<le> 2 ^ (LENGTH('e) - 1) - int LENGTH('f) - 1
[PROOF STEP]
apply (auto simp add: normal_exponent_def is_normal_def emax_eq bias_def diff_le_eq diff_less_eq
    mask_eq_exp_minus_1 of_nat_diff simp flip: zless_nat_eq_int_zless power_Suc)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < IEEE.exponent x; IEEE.exponent x < 2 ^ LENGTH('e) - Suc 0\<rbrakk> \<Longrightarrow> IEEE.exponent x < nat (2 ^ LENGTH('e) - 1)
[PROOF STEP]
apply (simp flip: power_Suc mask_eq_exp_minus_1 add: nat_mask_eq)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < IEEE.exponent x; IEEE.exponent x < 2 ^ LENGTH('e) - Suc 0\<rbrakk> \<Longrightarrow> IEEE.exponent x < mask LENGTH('e)
[PROOF STEP]
apply (simp add: mask_eq_exp_minus_1)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma oprod_minus_Id:
  assumes r: "Total r" "\<not> (r \<le> Id)" and r': "Total r'" "\<not> (r' \<le> Id)"
  shows "(r *o r') - Id \<le> (r - Id) *o (r' - Id)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r *o r' - Id \<subseteq> (r - Id) *o (r' - Id)
[PROOF STEP]
unfolding oprod_def Total_Id_Field[OF r] Total_Id_Field[OF r']
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {((x1, y1), x2, y2). (y1, y2) \<in> r' - Id \<and> x1 \<in> Field (r - Id) \<and> x2 \<in> Field (r - Id) \<or> (y1, y2) \<in> Restr Id (Field (r' - Id)) \<and> (x1, x2) \<in> r} - Id \<subseteq> {((x1, y1), x2, y2). (y1, y2) \<in> r' - Id - Id \<and> x1 \<in> Field (r - Id) \<and> x2 \<in> Field (r - Id) \<or> (y1, y2) \<in> Restr Id (Field (r' - Id)) \<and> (x1, x2) \<in> r - Id}
[PROOF STEP]
by auto


[STATEMENT]
lemma has_vector_derivative_mult[derivative_intros]:
  "(f has_vector_derivative f') (at x within s) \<Longrightarrow> (g has_vector_derivative g') (at x within s) \<Longrightarrow>
    ((\<lambda>x. f x * g x) has_vector_derivative (f x * g' + f' * g x)) (at x within s)"
  for f g :: "real \<Rightarrow> 'a::real_normed_algebra"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(f has_vector_derivative f') (at x within s); (g has_vector_derivative g') (at x within s)\<rbrakk> \<Longrightarrow> ((\<lambda>x. f x * g x) has_vector_derivative f x * g' + f' * g x) (at x within s)
[PROOF STEP]
by (rule bounded_bilinear.has_vector_derivative[OF bounded_bilinear_mult])


[STATEMENT]
lemma gcd_numeral_red: "gcd (numeral x::int) (numeral y) = gcd (numeral y) (numeral x mod numeral y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcd (numeral x) (numeral y) = gcd (numeral y) (numeral x mod numeral y)
[PROOF STEP]
by (fact gcd_red_int)


[STATEMENT]
lemma fetch_aft_erase_b_b:
  "fetch (mopup_a n @ shift mopup_b (2 * n)) (2*n + 3) Bk
  = (R, Suc (2 * n + 3))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fetch (mopup_a n @ shift mopup_b (2 * n)) (2 * n + 3) Bk = (R, Suc (2 * n + 3))
[PROOF STEP]
apply(subgoal_tac "length (mopup_a n) = 4 * n")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. length (mopup_a n) = 4 * n \<Longrightarrow> fetch (mopup_a n @ shift mopup_b (2 * n)) (2 * n + 3) Bk = (R, Suc (2 * n + 3))
 2. length (mopup_a n) = 4 * n
[PROOF STEP]
apply(subgoal_tac "2*n + 3 = Suc (2*n + 2)", simp only: fetch.simps)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<lbrakk>length (mopup_a n) = 4 * n; 2 * n + 3 = Suc (2 * n + 2)\<rbrakk> \<Longrightarrow> (case nth_of (mopup_a n @ shift mopup_b (2 * n)) (2 * (2 * n + 2)) of None \<Rightarrow> (Nop, 0) | Some i \<Rightarrow> i) = (R, Suc (Suc (2 * n + 2)))
 2. length (mopup_a n) = 4 * n \<Longrightarrow> 2 * n + 3 = Suc (2 * n + 2)
 3. length (mopup_a n) = 4 * n
[PROOF STEP]
apply(auto simp: mopup_b_def nth_append shift.simps)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma MStep_Compose:
  "\<lbrakk>(M,l,s,n,l1,r):MStep; (M,l1,r,k,l2,t):MStep; nk=n+k\<rbrakk>
  \<Longrightarrow> (M,l,s,nk,l2,t):MStep"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(M, l, s, n, l1, r) \<in> MStep; (M, l1, r, k, l2, t) \<in> MStep; nk = n + k\<rbrakk> \<Longrightarrow> (M, l, s, nk, l2, t) \<in> MStep
[PROOF STEP]
(*<*)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(M, l, s, n, l1, r) \<in> MStep; (M, l1, r, k, l2, t) \<in> MStep; nk = n + k\<rbrakk> \<Longrightarrow> (M, l, s, nk, l2, t) \<in> MStep
[PROOF STEP]
by (drule MStep_Compose_Aux, fastforce)


[STATEMENT]
lemma bij_imp_card_image: "card (f ` X) = card X"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (f ` X) = card X
[PROOF STEP]
by (metis bij bij_iff card.infinite finite_imageD inj_onI inj_on_iff_eq_card)


[STATEMENT]
lemma mult_left_one: "1 * a = (a::'a::semiring_1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (1::'a) * a = a
[PROOF STEP]
by simp


[STATEMENT]
lemma bit_Suc:
  \<open>bit a (Suc n) \<longleftrightarrow> bit (a div 2) n\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bit a (Suc n) = bit (a div (2::'a)) n
[PROOF STEP]
using div_exp_eq [of a 1 n]
[PROOF STATE]
proof (prove)
using this:
a div (2::'a) ^ 1 div (2::'a) ^ n = a div (2::'a) ^ (1 + n)

goal (1 subgoal):
 1. bit a (Suc n) = bit (a div (2::'a)) n
[PROOF STEP]
by (simp add: bit_iff_odd)


[STATEMENT]
theorem wls_skel_swap:
assumes "wls s X"
shows "skel (X #[x1 \<and> x2]_xs) = skel X"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. skel (X #[x1 \<and> x2]_xs) = skel X
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
wls s X

goal (1 subgoal):
 1. skel (X #[x1 \<and> x2]_xs) = skel X
[PROOF STEP]
by (intro skel_swap) auto


[STATEMENT]
theorem language_Reverse_nfa [simp]:
     "nfa.language (Reverse_nfa M) = (rev ` dfa.language M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nfa.language (Reverse_nfa M) = rev ` language
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. nfa.language (Reverse_nfa M) = rev ` language
[PROOF STEP]
interpret NR: nfa "Reverse_nfa M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nfa (Reverse_nfa M)
[PROOF STEP]
by (rule nfa_Reverse_nfa)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. NR.language = rev ` language
[PROOF STEP]
have "NR.language = {u. rev u \<in> dfa.language M}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. NR.language = {u. rev u \<in> language}
[PROOF STEP]
proof (rule set_eqI, simp)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. (x \<in> NR.language) = (rev x \<in> language)
[PROOF STEP]
fix u
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. (x \<in> NR.language) = (rev x \<in> language)
[PROOF STEP]
have "\<And>Q q'. q' \<in> dfa.states M \<Longrightarrow>
                   q' \<in> NR.nextl Q u \<longleftrightarrow> dfa.nextl M q' (rev u) \<in> Q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>Q q'. q' \<in> dfa.states M \<Longrightarrow> (q' \<in> NR.nextl Q u) = (nextl q' (rev u) \<in> Q)
[PROOF STEP]
by (induct u rule: List.rev_induct) (auto simp: nxt)
[PROOF STATE]
proof (state)
this:
?q' \<in> dfa.states M \<Longrightarrow> (?q' \<in> NR.nextl ?Q u) = (nextl ?q' (rev u) \<in> ?Q)

goal (1 subgoal):
 1. \<And>x. (x \<in> NR.language) = (rev x \<in> language)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?q' \<in> dfa.states M \<Longrightarrow> (?q' \<in> NR.nextl ?Q u) = (nextl ?q' (rev u) \<in> ?Q)
[PROOF STEP]
show "u \<in> nfa.language (Reverse_nfa M) \<longleftrightarrow> rev u \<in> language"
[PROOF STATE]
proof (prove)
using this:
?q' \<in> dfa.states M \<Longrightarrow> (?q' \<in> NR.nextl ?Q u) = (nextl ?q' (rev u) \<in> ?Q)

goal (1 subgoal):
 1. (u \<in> NR.language) = (rev u \<in> language)
[PROOF STEP]
by (simp add: NR.language_def language_def)
[PROOF STATE]
proof (state)
this:
(u \<in> NR.language) = (rev u \<in> language)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
NR.language = {u. rev u \<in> language}

goal (1 subgoal):
 1. NR.language = rev ` language
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
NR.language = {u. rev u \<in> language}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
NR.language = {u. rev u \<in> language}

goal (1 subgoal):
 1. NR.language = rev ` language
[PROOF STEP]
by (force simp add: language_def)
[PROOF STATE]
proof (state)
this:
NR.language = rev ` language

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma tl_drop_Suc: "tl (drop i xs) = drop (Suc i) xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tl (drop i xs) = drop (Suc i) xs
[PROOF STEP]
proof (induct i arbitrary: xs)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>xs. tl (drop 0 xs) = drop (Suc 0) xs
 2. \<And>i xs. (\<And>xs. tl (drop i xs) = drop (Suc i) xs) \<Longrightarrow> tl (drop (Suc i) xs) = drop (Suc (Suc i)) xs
[PROOF STEP]
case (0 xs)
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. \<And>xs. tl (drop 0 xs) = drop (Suc 0) xs
 2. \<And>i xs. (\<And>xs. tl (drop i xs) = drop (Suc i) xs) \<Longrightarrow> tl (drop (Suc i) xs) = drop (Suc (Suc i)) xs
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tl (drop 0 xs) = drop (Suc 0) xs
[PROOF STEP]
by (cases xs, auto)
[PROOF STATE]
proof (state)
this:
tl (drop 0 xs) = drop (Suc 0) xs

goal (1 subgoal):
 1. \<And>i xs. (\<And>xs. tl (drop i xs) = drop (Suc i) xs) \<Longrightarrow> tl (drop (Suc i) xs) = drop (Suc (Suc i)) xs
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i xs. (\<And>xs. tl (drop i xs) = drop (Suc i) xs) \<Longrightarrow> tl (drop (Suc i) xs) = drop (Suc (Suc i)) xs
[PROOF STEP]
case (Suc i xs)
[PROOF STATE]
proof (state)
this:
tl (drop i ?xs) = drop (Suc i) ?xs

goal (1 subgoal):
 1. \<And>i xs. (\<And>xs. tl (drop i xs) = drop (Suc i) xs) \<Longrightarrow> tl (drop (Suc i) xs) = drop (Suc (Suc i)) xs
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
tl (drop i ?xs) = drop (Suc i) ?xs

goal (1 subgoal):
 1. tl (drop (Suc i) xs) = drop (Suc (Suc i)) xs
[PROOF STEP]
by (cases xs, auto)
[PROOF STATE]
proof (state)
this:
tl (drop (Suc i) xs) = drop (Suc (Suc i)) xs

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ant_eq_0_conv [simp]: "(ant n = 0) = (n = 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (ant n = 0) = (n = 0)
[PROOF STEP]
apply (simp add:Zero_ant_def)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma Stirling_2: "Stirling (Suc n) (Suc (Suc 0)) = 2 ^ n - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Stirling (Suc n) (Suc (Suc 0)) = 2 ^ n - 1
[PROOF STEP]
using Stirling_2_2
[PROOF STATE]
proof (prove)
using this:
Stirling (Suc (Suc ?n)) (Suc (Suc 0)) = 2 ^ Suc ?n - 1

goal (1 subgoal):
 1. Stirling (Suc n) (Suc (Suc 0)) = 2 ^ n - 1
[PROOF STEP]
by (cases n) simp_all