[STATEMENT]
lemma diagonal_to_Smith_i_dvd_jj:
  fixes A::"'a::{bezout_ring}^'b::mod_type^'c::mod_type"
  assumes ib: "is_bezout_ext bezout"
  and i_min: "i < min (nrows A) (ncols A)"
  and elements_xs_range: "\<forall>x. x \<in> set xs \<longrightarrow> x<min (nrows A) (ncols A)"
  and "to_nat a \<in> set xs"
  and "to_nat a = to_nat b"
  and "to_nat a \<noteq> i"
  and "distinct xs"
shows "(diagonal_to_Smith_i xs A i bezout) $ (from_nat i) $ (from_nat i)
       dvd (diagonal_to_Smith_i xs A i bezout) $ a $ b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diagonal_to_Smith_i xs A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs A i bezout $ a $ b
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
is_bezout_ext bezout
i < min (nrows A) (ncols A)
\<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A)
to_nat a \<in> set xs
to_nat a = to_nat b
to_nat a \<noteq> i
distinct xs

goal (1 subgoal):
 1. diagonal_to_Smith_i xs A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs A i bezout $ a $ b
[PROOF STEP]
proof (induct xs A i bezout rule: diagonal_to_Smith_i.induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>A i bezout. \<lbrakk>is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set [] \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set []; to_nat a = to_nat b; to_nat a \<noteq> i; distinct []\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i [] A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i [] A i bezout $ a $ b
 2. \<And>j xs A i bezout. \<lbrakk>\<lbrakk>A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs A i bezout $ a $ b; \<And>x xa y xb ya xc yb xd yc xe. \<lbrakk>\<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; x = bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j); (xa, y) = x; (xb, ya) = y; (xc, yb) = ya; (xd, yc) = yb; xe = diagonal_step A i j yc xd; is_bezout_ext bezout; i < min (nrows xe) (ncols xe); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows xe) (ncols xe); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs xe i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs xe i bezout $ a $ b; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set (j # xs) \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set (j # xs); to_nat a = to_nat b; to_nat a \<noteq> i; distinct (j # xs)\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
case (1 A i)
[PROOF STATE]
proof (state)
this:
is_bezout_ext bezout_
i < min (nrows A) (ncols A)
\<forall>x. x \<in> set [] \<longrightarrow> x < min (nrows A) (ncols A)
to_nat a \<in> set []
to_nat a = to_nat b
to_nat a \<noteq> i
distinct []

goal (2 subgoals):
 1. \<And>A i bezout. \<lbrakk>is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set [] \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set []; to_nat a = to_nat b; to_nat a \<noteq> i; distinct []\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i [] A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i [] A i bezout $ a $ b
 2. \<And>j xs A i bezout. \<lbrakk>\<lbrakk>A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs A i bezout $ a $ b; \<And>x xa y xb ya xc yb xd yc xe. \<lbrakk>\<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; x = bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j); (xa, y) = x; (xb, ya) = y; (xc, yb) = ya; (xd, yc) = yb; xe = diagonal_step A i j yc xd; is_bezout_ext bezout; i < min (nrows xe) (ncols xe); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows xe) (ncols xe); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs xe i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs xe i bezout $ a $ b; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set (j # xs) \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set (j # xs); to_nat a = to_nat b; to_nat a \<noteq> i; distinct (j # xs)\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
is_bezout_ext bezout_
i < min (nrows A) (ncols A)
\<forall>x. x \<in> set [] \<longrightarrow> x < min (nrows A) (ncols A)
to_nat a \<in> set []
to_nat a = to_nat b
to_nat a \<noteq> i
distinct []
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
is_bezout_ext bezout_
i < min (nrows A) (ncols A)
\<forall>x. x \<in> set [] \<longrightarrow> x < min (nrows A) (ncols A)
to_nat a \<in> set []
to_nat a = to_nat b
to_nat a \<noteq> i
distinct []

goal (1 subgoal):
 1. diagonal_to_Smith_i [] A i bezout_ $ from_nat i $ from_nat i dvd diagonal_to_Smith_i [] A i bezout_ $ a $ b
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i [] A i bezout_ $ from_nat i $ from_nat i dvd diagonal_to_Smith_i [] A i bezout_ $ a $ b

goal (1 subgoal):
 1. \<And>j xs A i bezout. \<lbrakk>\<lbrakk>A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs A i bezout $ a $ b; \<And>x xa y xb ya xc yb xd yc xe. \<lbrakk>\<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; x = bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j); (xa, y) = x; (xb, ya) = y; (xc, yb) = ya; (xd, yc) = yb; xe = diagonal_step A i j yc xd; is_bezout_ext bezout; i < min (nrows xe) (ncols xe); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows xe) (ncols xe); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs xe i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs xe i bezout $ a $ b; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set (j # xs) \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set (j # xs); to_nat a = to_nat b; to_nat a \<noteq> i; distinct (j # xs)\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>j xs A i bezout. \<lbrakk>\<lbrakk>A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs A i bezout $ a $ b; \<And>x xa y xb ya xc yb xd yc xe. \<lbrakk>\<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; x = bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j); (xa, y) = x; (xb, ya) = y; (xc, yb) = ya; (xd, yc) = yb; xe = diagonal_step A i j yc xd; is_bezout_ext bezout; i < min (nrows xe) (ncols xe); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows xe) (ncols xe); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs xe i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs xe i bezout $ a $ b; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set (j # xs) \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set (j # xs); to_nat a = to_nat b; to_nat a \<noteq> i; distinct (j # xs)\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
case (2 j xs A i bezout)
[PROOF STATE]
proof (state)
this:
\<lbrakk>A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs A i bezout $ a $ b
\<lbrakk>\<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; ?x = bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j); (?xa, ?y) = ?x; (?xb, ?ya) = ?y; (?xc, ?yb) = ?ya; (?xd, ?yc) = ?yb; ?xe = diagonal_step A i j ?yc ?xd; is_bezout_ext bezout; i < min (nrows ?xe) (ncols ?xe); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows ?xe) (ncols ?xe); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs ?xe i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs ?xe i bezout $ a $ b
is_bezout_ext bezout
i < min (nrows A) (ncols A)
\<forall>x. x \<in> set (j # xs) \<longrightarrow> x < min (nrows A) (ncols A)
to_nat a \<in> set (j # xs)
to_nat a = to_nat b
to_nat a \<noteq> i
distinct (j # xs)

goal (1 subgoal):
 1. \<And>j xs A i bezout. \<lbrakk>\<lbrakk>A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs A i bezout $ a $ b; \<And>x xa y xb ya xc yb xd yc xe. \<lbrakk>\<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; x = bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j); (xa, y) = x; (xb, ya) = y; (xc, yb) = ya; (xd, yc) = yb; xe = diagonal_step A i j yc xd; is_bezout_ext bezout; i < min (nrows xe) (ncols xe); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows xe) (ncols xe); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs xe i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs xe i bezout $ a $ b; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set (j # xs) \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set (j # xs); to_nat a = to_nat b; to_nat a \<noteq> i; distinct (j # xs)\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
let ?Aii = "A $ from_nat i $ from_nat i"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>j xs A i bezout. \<lbrakk>\<lbrakk>A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs A i bezout $ a $ b; \<And>x xa y xb ya xc yb xd yc xe. \<lbrakk>\<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; x = bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j); (xa, y) = x; (xb, ya) = y; (xc, yb) = ya; (xd, yc) = yb; xe = diagonal_step A i j yc xd; is_bezout_ext bezout; i < min (nrows xe) (ncols xe); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows xe) (ncols xe); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs xe i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs xe i bezout $ a $ b; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set (j # xs) \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set (j # xs); to_nat a = to_nat b; to_nat a \<noteq> i; distinct (j # xs)\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
let ?Ajj = "A $ from_nat j $ from_nat j"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>j xs A i bezout. \<lbrakk>\<lbrakk>A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs A i bezout $ a $ b; \<And>x xa y xb ya xc yb xd yc xe. \<lbrakk>\<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; x = bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j); (xa, y) = x; (xb, ya) = y; (xc, yb) = ya; (xd, yc) = yb; xe = diagonal_step A i j yc xd; is_bezout_ext bezout; i < min (nrows xe) (ncols xe); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows xe) (ncols xe); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs xe i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs xe i bezout $ a $ b; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set (j # xs) \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set (j # xs); to_nat a = to_nat b; to_nat a \<noteq> i; distinct (j # xs)\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
let ?p="case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p,q,u,v,d) \<Rightarrow> p"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>j xs A i bezout. \<lbrakk>\<lbrakk>A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs A i bezout $ a $ b; \<And>x xa y xb ya xc yb xd yc xe. \<lbrakk>\<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; x = bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j); (xa, y) = x; (xb, ya) = y; (xc, yb) = ya; (xd, yc) = yb; xe = diagonal_step A i j yc xd; is_bezout_ext bezout; i < min (nrows xe) (ncols xe); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows xe) (ncols xe); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs xe i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs xe i bezout $ a $ b; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set (j # xs) \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set (j # xs); to_nat a = to_nat b; to_nat a \<noteq> i; distinct (j # xs)\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
let ?q="case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p,q,u,v,d) \<Rightarrow> q"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>j xs A i bezout. \<lbrakk>\<lbrakk>A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs A i bezout $ a $ b; \<And>x xa y xb ya xc yb xd yc xe. \<lbrakk>\<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; x = bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j); (xa, y) = x; (xb, ya) = y; (xc, yb) = ya; (xd, yc) = yb; xe = diagonal_step A i j yc xd; is_bezout_ext bezout; i < min (nrows xe) (ncols xe); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows xe) (ncols xe); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs xe i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs xe i bezout $ a $ b; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set (j # xs) \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set (j # xs); to_nat a = to_nat b; to_nat a \<noteq> i; distinct (j # xs)\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
let ?u="case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p,q,u,v,d) \<Rightarrow> u"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>j xs A i bezout. \<lbrakk>\<lbrakk>A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs A i bezout $ a $ b; \<And>x xa y xb ya xc yb xd yc xe. \<lbrakk>\<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; x = bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j); (xa, y) = x; (xb, ya) = y; (xc, yb) = ya; (xd, yc) = yb; xe = diagonal_step A i j yc xd; is_bezout_ext bezout; i < min (nrows xe) (ncols xe); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows xe) (ncols xe); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs xe i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs xe i bezout $ a $ b; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set (j # xs) \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set (j # xs); to_nat a = to_nat b; to_nat a \<noteq> i; distinct (j # xs)\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
let ?v="case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p,q,u,v,d) \<Rightarrow> v"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>j xs A i bezout. \<lbrakk>\<lbrakk>A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs A i bezout $ a $ b; \<And>x xa y xb ya xc yb xd yc xe. \<lbrakk>\<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; x = bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j); (xa, y) = x; (xb, ya) = y; (xc, yb) = ya; (xd, yc) = yb; xe = diagonal_step A i j yc xd; is_bezout_ext bezout; i < min (nrows xe) (ncols xe); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows xe) (ncols xe); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs xe i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs xe i bezout $ a $ b; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set (j # xs) \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set (j # xs); to_nat a = to_nat b; to_nat a \<noteq> i; distinct (j # xs)\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
let ?d="case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p,q,u,v,d) \<Rightarrow> d"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>j xs A i bezout. \<lbrakk>\<lbrakk>A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs A i bezout $ a $ b; \<And>x xa y xb ya xc yb xd yc xe. \<lbrakk>\<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; x = bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j); (xa, y) = x; (xb, ya) = y; (xc, yb) = ya; (xd, yc) = yb; xe = diagonal_step A i j yc xd; is_bezout_ext bezout; i < min (nrows xe) (ncols xe); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows xe) (ncols xe); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs xe i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs xe i bezout $ a $ b; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set (j # xs) \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set (j # xs); to_nat a = to_nat b; to_nat a \<noteq> i; distinct (j # xs)\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
let ?A'="diagonal_step A i j ?d ?v"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>j xs A i bezout. \<lbrakk>\<lbrakk>A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs A i bezout $ a $ b; \<And>x xa y xb ya xc yb xd yc xe. \<lbrakk>\<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; x = bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j); (xa, y) = x; (xb, ya) = y; (xc, yb) = ya; (xd, yc) = yb; xe = diagonal_step A i j yc xd; is_bezout_ext bezout; i < min (nrows xe) (ncols xe); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows xe) (ncols xe); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs xe i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs xe i bezout $ a $ b; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set (j # xs) \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set (j # xs); to_nat a = to_nat b; to_nat a \<noteq> i; distinct (j # xs)\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
have pquvd: "(?p, ?q, ?u, ?v,?d) = bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> p, case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> q, case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> u, case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v, case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) = bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j)
[PROOF STEP]
by (simp add: split_beta)
[PROOF STATE]
proof (state)
this:
(case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> p, case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> q, case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> u, case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v, case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) = bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j)

goal (1 subgoal):
 1. \<And>j xs A i bezout. \<lbrakk>\<lbrakk>A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs A i bezout $ a $ b; \<And>x xa y xb ya xc yb xd yc xe. \<lbrakk>\<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; x = bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j); (xa, y) = x; (xb, ya) = y; (xc, yb) = ya; (xd, yc) = yb; xe = diagonal_step A i j yc xd; is_bezout_ext bezout; i < min (nrows xe) (ncols xe); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows xe) (ncols xe); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs xe i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs xe i bezout $ a $ b; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set (j # xs) \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set (j # xs); to_nat a = to_nat b; to_nat a \<noteq> i; distinct (j # xs)\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
note ib = "2.prems"(1)
[PROOF STATE]
proof (state)
this:
is_bezout_ext bezout

goal (1 subgoal):
 1. \<And>j xs A i bezout. \<lbrakk>\<lbrakk>A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs A i bezout $ a $ b; \<And>x xa y xb ya xc yb xd yc xe. \<lbrakk>\<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; x = bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j); (xa, y) = x; (xb, ya) = y; (xc, yb) = ya; (xd, yc) = yb; xe = diagonal_step A i j yc xd; is_bezout_ext bezout; i < min (nrows xe) (ncols xe); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows xe) (ncols xe); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs xe i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs xe i bezout $ a $ b; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set (j # xs) \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set (j # xs); to_nat a = to_nat b; to_nat a \<noteq> i; distinct (j # xs)\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
note to_nat_a_not_i = 2(8)
[PROOF STATE]
proof (state)
this:
to_nat a \<noteq> i

goal (1 subgoal):
 1. \<And>j xs A i bezout. \<lbrakk>\<lbrakk>A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs A i bezout $ a $ b; \<And>x xa y xb ya xc yb xd yc xe. \<lbrakk>\<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; x = bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j); (xa, y) = x; (xb, ya) = y; (xc, yb) = ya; (xd, yc) = yb; xe = diagonal_step A i j yc xd; is_bezout_ext bezout; i < min (nrows xe) (ncols xe); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows xe) (ncols xe); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs xe i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs xe i bezout $ a $ b; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set (j # xs) \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set (j # xs); to_nat a = to_nat b; to_nat a \<noteq> i; distinct (j # xs)\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
note i_min = 2(4)
[PROOF STATE]
proof (state)
this:
i < min (nrows A) (ncols A)

goal (1 subgoal):
 1. \<And>j xs A i bezout. \<lbrakk>\<lbrakk>A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs A i bezout $ a $ b; \<And>x xa y xb ya xc yb xd yc xe. \<lbrakk>\<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; x = bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j); (xa, y) = x; (xb, ya) = y; (xc, yb) = ya; (xd, yc) = yb; xe = diagonal_step A i j yc xd; is_bezout_ext bezout; i < min (nrows xe) (ncols xe); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows xe) (ncols xe); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs xe i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs xe i bezout $ a $ b; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set (j # xs) \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set (j # xs); to_nat a = to_nat b; to_nat a \<noteq> i; distinct (j # xs)\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
note elements_xs = "2.prems"(3)
[PROOF STATE]
proof (state)
this:
\<forall>x. x \<in> set (j # xs) \<longrightarrow> x < min (nrows A) (ncols A)

goal (1 subgoal):
 1. \<And>j xs A i bezout. \<lbrakk>\<lbrakk>A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs A i bezout $ a $ b; \<And>x xa y xb ya xc yb xd yc xe. \<lbrakk>\<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; x = bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j); (xa, y) = x; (xb, ya) = y; (xc, yb) = ya; (xd, yc) = yb; xe = diagonal_step A i j yc xd; is_bezout_ext bezout; i < min (nrows xe) (ncols xe); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows xe) (ncols xe); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs xe i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs xe i bezout $ a $ b; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set (j # xs) \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set (j # xs); to_nat a = to_nat b; to_nat a \<noteq> i; distinct (j # xs)\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
note a_eq_b = "2.prems"(5)
[PROOF STATE]
proof (state)
this:
to_nat a = to_nat b

goal (1 subgoal):
 1. \<And>j xs A i bezout. \<lbrakk>\<lbrakk>A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs A i bezout $ a $ b; \<And>x xa y xb ya xc yb xd yc xe. \<lbrakk>\<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; x = bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j); (xa, y) = x; (xb, ya) = y; (xc, yb) = ya; (xd, yc) = yb; xe = diagonal_step A i j yc xd; is_bezout_ext bezout; i < min (nrows xe) (ncols xe); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows xe) (ncols xe); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs xe i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs xe i bezout $ a $ b; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set (j # xs) \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set (j # xs); to_nat a = to_nat b; to_nat a \<noteq> i; distinct (j # xs)\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
note a_in_j_xs = 2(6)
[PROOF STATE]
proof (state)
this:
to_nat a \<in> set (j # xs)

goal (1 subgoal):
 1. \<And>j xs A i bezout. \<lbrakk>\<lbrakk>A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs A i bezout $ a $ b; \<And>x xa y xb ya xc yb xd yc xe. \<lbrakk>\<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; x = bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j); (xa, y) = x; (xb, ya) = y; (xc, yb) = ya; (xd, yc) = yb; xe = diagonal_step A i j yc xd; is_bezout_ext bezout; i < min (nrows xe) (ncols xe); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows xe) (ncols xe); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs xe i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs xe i bezout $ a $ b; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set (j # xs) \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set (j # xs); to_nat a = to_nat b; to_nat a \<noteq> i; distinct (j # xs)\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
note distinct = 2(9)
[PROOF STATE]
proof (state)
this:
distinct (j # xs)

goal (1 subgoal):
 1. \<And>j xs A i bezout. \<lbrakk>\<lbrakk>A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs A i bezout $ a $ b; \<And>x xa y xb ya xc yb xd yc xe. \<lbrakk>\<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j; x = bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j); (xa, y) = x; (xb, ya) = y; (xc, yb) = ya; (xd, yc) = yb; xe = diagonal_step A i j yc xd; is_bezout_ext bezout; i < min (nrows xe) (ncols xe); \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows xe) (ncols xe); to_nat a \<in> set xs; to_nat a = to_nat b; to_nat a \<noteq> i; distinct xs\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i xs xe i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs xe i bezout $ a $ b; is_bezout_ext bezout; i < min (nrows A) (ncols A); \<forall>x. x \<in> set (j # xs) \<longrightarrow> x < min (nrows A) (ncols A); to_nat a \<in> set (j # xs); to_nat a = to_nat b; to_nat a \<noteq> i; distinct (j # xs)\<rbrakk> \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
proof (cases "?Aii dvd ?Ajj")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
 2. \<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j

goal (2 subgoals):
 1. A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
 2. \<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
note Aii_dvd_Ajj = True
[PROOF STATE]
proof (state)
this:
A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j

goal (2 subgoals):
 1. A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
 2. \<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
proof (cases "to_nat a = j")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. to_nat a = j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
 2. to_nat a \<noteq> j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
to_nat a = j

goal (2 subgoals):
 1. to_nat a = j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
 2. to_nat a \<noteq> j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
have a: "a = (from_nat j::'c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a = from_nat j
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
to_nat a = j

goal (1 subgoal):
 1. a = from_nat j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a = from_nat j

goal (2 subgoals):
 1. to_nat a = j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
 2. to_nat a \<noteq> j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
have b: "b = (from_nat j::'b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b = from_nat j
[PROOF STEP]
using True a_eq_b
[PROOF STATE]
proof (prove)
using this:
to_nat a = j
to_nat a = to_nat b

goal (1 subgoal):
 1. b = from_nat j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
b = from_nat j

goal (2 subgoals):
 1. to_nat a = j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
 2. to_nat a \<noteq> j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
have "diagonal_to_Smith_i (j # xs) A i bezout = diagonal_to_Smith_i xs A i bezout"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diagonal_to_Smith_i (j # xs) A i bezout = diagonal_to_Smith_i xs A i bezout
[PROOF STEP]
using Aii_dvd_Ajj
[PROOF STATE]
proof (prove)
using this:
A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j

goal (1 subgoal):
 1. diagonal_to_Smith_i (j # xs) A i bezout = diagonal_to_Smith_i xs A i bezout
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i (j # xs) A i bezout = diagonal_to_Smith_i xs A i bezout

goal (2 subgoals):
 1. to_nat a = j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
 2. to_nat a \<noteq> j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i (j # xs) A i bezout = diagonal_to_Smith_i xs A i bezout

goal (2 subgoals):
 1. to_nat a = j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
 2. to_nat a \<noteq> j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
have "... $ from_nat j $ from_nat j = A $ from_nat j $ from_nat j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diagonal_to_Smith_i xs A i bezout $ from_nat j $ from_nat j = A $ from_nat j $ from_nat j
[PROOF STEP]
proof (rule diagonal_to_Smith_i_preserves_previous_diagonal[OF ib i_min])
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. to_nat (from_nat j) \<notin> set xs
 2. to_nat (from_nat j) = to_nat (from_nat j)
 3. to_nat (from_nat j) \<noteq> i
 4. \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A)
[PROOF STEP]
show "to_nat (from_nat j::'c) \<notin> set xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. to_nat (from_nat j) \<notin> set xs
[PROOF STEP]
using True a_in_j_xs distinct
[PROOF STATE]
proof (prove)
using this:
to_nat a = j
to_nat a \<in> set (j # xs)
distinct (j # xs)

goal (1 subgoal):
 1. to_nat (from_nat j) \<notin> set xs
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
to_nat (from_nat j) \<notin> set xs

goal (3 subgoals):
 1. to_nat (from_nat j) = to_nat (from_nat j)
 2. to_nat (from_nat j) \<noteq> i
 3. \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A)
[PROOF STEP]
show "to_nat (from_nat j::'c) = to_nat (from_nat j::'b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. to_nat (from_nat j) = to_nat (from_nat j)
[PROOF STEP]
by (metis True a_eq_b from_nat_to_nat_id)
[PROOF STATE]
proof (state)
this:
to_nat (from_nat j) = to_nat (from_nat j)

goal (2 subgoals):
 1. to_nat (from_nat j) \<noteq> i
 2. \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A)
[PROOF STEP]
show "to_nat (from_nat j::'c) \<noteq> i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. to_nat (from_nat j) \<noteq> i
[PROOF STEP]
using True to_nat_a_not_i
[PROOF STATE]
proof (prove)
using this:
to_nat a = j
to_nat a \<noteq> i

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

goal (1 subgoal):
 1. \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A)
[PROOF STEP]
show "\<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A)
[PROOF STEP]
using elements_xs
[PROOF STATE]
proof (prove)
using this:
\<forall>x. x \<in> set (j # xs) \<longrightarrow> x < min (nrows A) (ncols A)

goal (1 subgoal):
 1. \<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>x. x \<in> set xs \<longrightarrow> x < min (nrows A) (ncols A)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i xs A i bezout $ from_nat j $ from_nat j = A $ from_nat j $ from_nat j

goal (2 subgoals):
 1. to_nat a = j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
 2. to_nat a \<noteq> j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
diagonal_to_Smith_i (j # xs) A i bezout $ from_nat j $ from_nat j = A $ from_nat j $ from_nat j
[PROOF STEP]
have "diagonal_to_Smith_i (j # xs) A i bezout $ from_nat j $ from_nat j
        = A $ from_nat j $ from_nat j "
[PROOF STATE]
proof (prove)
using this:
diagonal_to_Smith_i (j # xs) A i bezout $ from_nat j $ from_nat j = A $ from_nat j $ from_nat j

goal (1 subgoal):
 1. diagonal_to_Smith_i (j # xs) A i bezout $ from_nat j $ from_nat j = A $ from_nat j $ from_nat j
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i (j # xs) A i bezout $ from_nat j $ from_nat j = A $ from_nat j $ from_nat j

goal (2 subgoals):
 1. to_nat a = j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
 2. to_nat a \<noteq> j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
hence "diagonal_to_Smith_i (j # xs) A i bezout $ a $ b = ?Ajj"
[PROOF STATE]
proof (prove)
using this:
diagonal_to_Smith_i (j # xs) A i bezout $ from_nat j $ from_nat j = A $ from_nat j $ from_nat j

goal (1 subgoal):
 1. diagonal_to_Smith_i (j # xs) A i bezout $ a $ b = A $ from_nat j $ from_nat j
[PROOF STEP]
unfolding a b
[PROOF STATE]
proof (prove)
using this:
diagonal_to_Smith_i (j # xs) A i bezout $ from_nat j $ from_nat j = A $ from_nat j $ from_nat j

goal (1 subgoal):
 1. diagonal_to_Smith_i (j # xs) A i bezout $ from_nat j $ from_nat j = A $ from_nat j $ from_nat j
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i (j # xs) A i bezout $ a $ b = A $ from_nat j $ from_nat j

goal (2 subgoals):
 1. to_nat a = j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
 2. to_nat a \<noteq> j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i (j # xs) A i bezout $ a $ b = A $ from_nat j $ from_nat j

goal (2 subgoals):
 1. to_nat a = j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
 2. to_nat a \<noteq> j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
have "diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd ?Aii"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd A $ from_nat i $ from_nat i
[PROOF STEP]
by (rule diagonal_to_Smith_i_dvd_ii[OF ib])
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd A $ from_nat i $ from_nat i

goal (2 subgoals):
 1. to_nat a = j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
 2. to_nat a \<noteq> j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
diagonal_to_Smith_i (j # xs) A i bezout $ a $ b = A $ from_nat j $ from_nat j
diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd A $ from_nat i $ from_nat i
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
diagonal_to_Smith_i (j # xs) A i bezout $ a $ b = A $ from_nat j $ from_nat j
diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd A $ from_nat i $ from_nat i

goal (1 subgoal):
 1. diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
using Aii_dvd_Ajj dvd_trans
[PROOF STATE]
proof (prove)
using this:
diagonal_to_Smith_i (j # xs) A i bezout $ a $ b = A $ from_nat j $ from_nat j
diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd A $ from_nat i $ from_nat i
A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j
\<lbrakk>?a dvd ?b; ?b dvd ?c\<rbrakk> \<Longrightarrow> ?a dvd ?c

goal (1 subgoal):
 1. diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b

goal (1 subgoal):
 1. to_nat a \<noteq> j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. to_nat a \<noteq> j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
to_nat a \<noteq> j

goal (1 subgoal):
 1. to_nat a \<noteq> j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
have a_in_xs: "to_nat a \<in> set xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. to_nat a \<in> set xs
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
to_nat a \<noteq> j

goal (1 subgoal):
 1. to_nat a \<in> set xs
[PROOF STEP]
using "2.prems"(4)
[PROOF STATE]
proof (prove)
using this:
to_nat a \<noteq> j
to_nat a \<in> set (j # xs)

goal (1 subgoal):
 1. to_nat a \<in> set xs
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
to_nat a \<in> set xs

goal (1 subgoal):
 1. to_nat a \<noteq> j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
have "diagonal_to_Smith_i (j # xs) A i bezout = diagonal_to_Smith_i xs A i bezout"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diagonal_to_Smith_i (j # xs) A i bezout = diagonal_to_Smith_i xs A i bezout
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j

goal (1 subgoal):
 1. diagonal_to_Smith_i (j # xs) A i bezout = diagonal_to_Smith_i xs A i bezout
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i (j # xs) A i bezout = diagonal_to_Smith_i xs A i bezout

goal (1 subgoal):
 1. to_nat a \<noteq> j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i (j # xs) A i bezout = diagonal_to_Smith_i xs A i bezout

goal (1 subgoal):
 1. to_nat a \<noteq> j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
have "...  $ (from_nat i) $ (from_nat i) dvd diagonal_to_Smith_i xs A i bezout $ a $ b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diagonal_to_Smith_i xs A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs A i bezout $ a $ b
[PROOF STEP]
by (rule "2.hyps"(1)[OF True ib i_min _ a_in_xs a_eq_b to_nat_a_not_i])
           (insert elements_xs distinct, auto)
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i xs A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs A i bezout $ a $ b

goal (1 subgoal):
 1. to_nat a \<noteq> j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b

goal (1 subgoal):
 1. diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b

goal (1 subgoal):
 1. \<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j

goal (1 subgoal):
 1. \<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
note Aii_not_dvd_Ajj = False
[PROOF STATE]
proof (state)
this:
\<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j

goal (1 subgoal):
 1. \<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
proof (cases "to_nat a \<in> set xs")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. to_nat a \<in> set xs \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
 2. to_nat a \<notin> set xs \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
to_nat a \<in> set xs

goal (2 subgoals):
 1. to_nat a \<in> set xs \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
 2. to_nat a \<notin> set xs \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
note a_in_xs = True
[PROOF STATE]
proof (state)
this:
to_nat a \<in> set xs

goal (2 subgoals):
 1. to_nat a \<in> set xs \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
 2. to_nat a \<notin> set xs \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
have "diagonal_to_Smith_i (j # xs) A i bezout = diagonal_to_Smith_i xs ?A' i bezout"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diagonal_to_Smith_i (j # xs) A i bezout = diagonal_to_Smith_i xs (diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v)) i bezout
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
\<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j

goal (1 subgoal):
 1. diagonal_to_Smith_i (j # xs) A i bezout = diagonal_to_Smith_i xs (diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v)) i bezout
[PROOF STEP]
by (auto simp add: split_beta)
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i (j # xs) A i bezout = diagonal_to_Smith_i xs (diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v)) i bezout

goal (2 subgoals):
 1. to_nat a \<in> set xs \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
 2. to_nat a \<notin> set xs \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i (j # xs) A i bezout = diagonal_to_Smith_i xs (diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v)) i bezout

goal (2 subgoals):
 1. to_nat a \<in> set xs \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
 2. to_nat a \<notin> set xs \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
have "... $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs ?A' i bezout $ a $ b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diagonal_to_Smith_i xs (diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v)) i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs (diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v)) i bezout $ a $ b
[PROOF STEP]
by (rule "2.hyps"(2)[OF False _ _ _ _ _ _ _ _ _ a_in_xs a_eq_b to_nat_a_not_i ])
           (insert elements_xs distinct i_min ib pquvd, auto simp add: nrows_def ncols_def)
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i xs (diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v)) i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i xs (diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v)) i bezout $ a $ b

goal (2 subgoals):
 1. to_nat a \<in> set xs \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
 2. to_nat a \<notin> set xs \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b

goal (1 subgoal):
 1. diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b

goal (1 subgoal):
 1. to_nat a \<notin> set xs \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. to_nat a \<notin> set xs \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
to_nat a \<notin> set xs

goal (1 subgoal):
 1. to_nat a \<notin> set xs \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
have to_nat_a_eq_j: "to_nat a = j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. to_nat a = j
[PROOF STEP]
using False a_in_j_xs
[PROOF STATE]
proof (prove)
using this:
to_nat a \<notin> set xs
to_nat a \<in> set (j # xs)

goal (1 subgoal):
 1. to_nat a = j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
to_nat a = j

goal (1 subgoal):
 1. to_nat a \<notin> set xs \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
have a: "a = (from_nat j::'c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a = from_nat j
[PROOF STEP]
using to_nat_a_eq_j
[PROOF STATE]
proof (prove)
using this:
to_nat a = j

goal (1 subgoal):
 1. a = from_nat j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a = from_nat j

goal (1 subgoal):
 1. to_nat a \<notin> set xs \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
have b: "b = (from_nat j::'b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b = from_nat j
[PROOF STEP]
using to_nat_a_eq_j a_eq_b
[PROOF STATE]
proof (prove)
using this:
to_nat a = j
to_nat a = to_nat b

goal (1 subgoal):
 1. b = from_nat j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
b = from_nat j

goal (1 subgoal):
 1. to_nat a \<notin> set xs \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
have d_eq: "diagonal_to_Smith_i (j # xs) A i bezout = diagonal_to_Smith_i xs ?A' i bezout"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diagonal_to_Smith_i (j # xs) A i bezout = diagonal_to_Smith_i xs (diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v)) i bezout
[PROOF STEP]
using Aii_not_dvd_Ajj
[PROOF STATE]
proof (prove)
using this:
\<not> A $ from_nat i $ from_nat i dvd A $ from_nat j $ from_nat j

goal (1 subgoal):
 1. diagonal_to_Smith_i (j # xs) A i bezout = diagonal_to_Smith_i xs (diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v)) i bezout
[PROOF STEP]
by (simp add: split_beta)
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i (j # xs) A i bezout = diagonal_to_Smith_i xs (diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v)) i bezout

goal (1 subgoal):
 1. to_nat a \<notin> set xs \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i (j # xs) A i bezout = diagonal_to_Smith_i xs (diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v)) i bezout

goal (1 subgoal):
 1. to_nat a \<notin> set xs \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
have "... $ a $ b = ?A' $ a $ b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diagonal_to_Smith_i xs (diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v)) i bezout $ a $ b = diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ a $ b
[PROOF STEP]
by (rule diagonal_to_Smith_i_preserves_previous_diagonal[OF ib _ False a_eq_b to_nat_a_not_i])
           (insert i_min elements_xs ib, auto)
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i xs (diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v)) i bezout $ a $ b = diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ a $ b

goal (1 subgoal):
 1. to_nat a \<notin> set xs \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
diagonal_to_Smith_i (j # xs) A i bezout $ a $ b = diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ a $ b
[PROOF STEP]
have "diagonal_to_Smith_i (j # xs) A i bezout $ a $ b = ?A' $ a $ b"
[PROOF STATE]
proof (prove)
using this:
diagonal_to_Smith_i (j # xs) A i bezout $ a $ b = diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ a $ b

goal (1 subgoal):
 1. diagonal_to_Smith_i (j # xs) A i bezout $ a $ b = diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ a $ b
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i (j # xs) A i bezout $ a $ b = diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ a $ b

goal (1 subgoal):
 1. to_nat a \<notin> set xs \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i (j # xs) A i bezout $ a $ b = diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ a $ b

goal (1 subgoal):
 1. to_nat a \<notin> set xs \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
have "diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i
        dvd ?A' $ from_nat i $ from_nat i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ from_nat i $ from_nat i
[PROOF STEP]
using d_eq diagonal_to_Smith_i_dvd_ii[OF ib]
[PROOF STATE]
proof (prove)
using this:
diagonal_to_Smith_i (j # xs) A i bezout = diagonal_to_Smith_i xs (diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v)) i bezout
diagonal_to_Smith_i ?xs ?A ?i bezout $ from_nat ?i $ from_nat ?i dvd ?A $ from_nat ?i $ from_nat ?i

goal (1 subgoal):
 1. diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ from_nat i $ from_nat i
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ from_nat i $ from_nat i

goal (1 subgoal):
 1. to_nat a \<notin> set xs \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ from_nat i $ from_nat i

goal (1 subgoal):
 1. to_nat a \<notin> set xs \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
have "?A' $ from_nat i $ from_nat i dvd ?A' $ from_nat j $ from_nat j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ from_nat i $ from_nat i dvd diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ from_nat j $ from_nat j
[PROOF STEP]
unfolding diagonal_step_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>a b. if a = from_nat i \<and> b = from_nat i then case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d else if a = from_nat j \<and> b = from_nat j then (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) * A $ from_nat j $ from_nat j else A $ a $ b) $ from_nat i $ from_nat i dvd (\<chi>a b. if a = from_nat i \<and> b = from_nat i then case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d else if a = from_nat j \<and> b = from_nat j then (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) * A $ from_nat j $ from_nat j else A $ a $ b) $ from_nat j $ from_nat j
[PROOF STEP]
using ib
[PROOF STATE]
proof (prove)
using this:
is_bezout_ext bezout

goal (1 subgoal):
 1. (\<chi>a b. if a = from_nat i \<and> b = from_nat i then case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d else if a = from_nat j \<and> b = from_nat j then (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) * A $ from_nat j $ from_nat j else A $ a $ b) $ from_nat i $ from_nat i dvd (\<chi>a b. if a = from_nat i \<and> b = from_nat i then case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d else if a = from_nat j \<and> b = from_nat j then (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) * A $ from_nat j $ from_nat j else A $ a $ b) $ from_nat j $ from_nat j
[PROOF STEP]
unfolding is_bezout_ext_def split_beta
[PROOF STATE]
proof (prove)
using this:
\<forall>a b. let prod = bezout a b in fst prod * a + fst (snd prod) * b = snd (snd (snd (snd prod))) \<and> snd (snd (snd (snd prod))) dvd a \<and> snd (snd (snd (snd prod))) dvd b \<and> (\<forall>d'. d' dvd a \<and> d' dvd b \<longrightarrow> d' dvd snd (snd (snd (snd prod)))) \<and> snd (snd (snd (snd prod))) * fst (snd (snd prod)) = - b \<and> snd (snd (snd (snd prod))) * fst (snd (snd (snd prod))) = a

goal (1 subgoal):
 1. (\<chi>a b. if a = from_nat i \<and> b = from_nat i then snd (snd (snd (snd (bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j))))) else if a = from_nat j \<and> b = from_nat j then fst (snd (snd (snd (bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j))))) * A $ from_nat j $ from_nat j else A $ a $ b) $ from_nat i $ from_nat i dvd (\<chi>a b. if a = from_nat i \<and> b = from_nat i then snd (snd (snd (snd (bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j))))) else if a = from_nat j \<and> b = from_nat j then fst (snd (snd (snd (bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j))))) * A $ from_nat j $ from_nat j else A $ a $ b) $ from_nat j $ from_nat j
[PROOF STEP]
by (auto, meson dvd_mult)+
[PROOF STATE]
proof (state)
this:
diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ from_nat i $ from_nat i dvd diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ from_nat j $ from_nat j

goal (1 subgoal):
 1. to_nat a \<notin> set xs \<Longrightarrow> diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
diagonal_to_Smith_i (j # xs) A i bezout $ a $ b = diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ a $ b
diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ from_nat i $ from_nat i
diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ from_nat i $ from_nat i dvd diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ from_nat j $ from_nat j
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
diagonal_to_Smith_i (j # xs) A i bezout $ a $ b = diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ a $ b
diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ from_nat i $ from_nat i
diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ from_nat i $ from_nat i dvd diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ from_nat j $ from_nat j

goal (1 subgoal):
 1. diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
using dvd_trans a b
[PROOF STATE]
proof (prove)
using this:
diagonal_to_Smith_i (j # xs) A i bezout $ a $ b = diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ a $ b
diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ from_nat i $ from_nat i
diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ from_nat i $ from_nat i dvd diagonal_step A i j (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> d) (case bezout (A $ from_nat i $ from_nat i) (A $ from_nat j $ from_nat j) of (p, q, u, v, d) \<Rightarrow> v) $ from_nat j $ from_nat j
\<lbrakk>?a dvd ?b; ?b dvd ?c\<rbrakk> \<Longrightarrow> ?a dvd ?c
a = from_nat j
b = from_nat j

goal (1 subgoal):
 1. diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
diagonal_to_Smith_i (j # xs) A i bezout $ from_nat i $ from_nat i dvd diagonal_to_Smith_i (j # xs) A i bezout $ a $ b

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma linear_order_imp_linorder: "linear_order {(A, B). leq A B} \<Longrightarrow> class.linorder leq (\<lambda>x y. leq x y \<and> \<not> leq y x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. linear_order {(A, B). leq A B} \<Longrightarrow> class.linorder leq (\<lambda>x y. leq x y \<and> \<not> leq y x)
[PROOF STEP]
by(unfold_locales)(auto 4 4 simp add: linear_order_on_def partial_order_on_def preorder_on_def dest: refl_onD antisymD transD total_onD)


[STATEMENT]
lemma entails_transitive:
  assumes "entails_formula S1 S2"
  assumes "entails_formula S2 S3"
  shows "entails_formula S1 S3"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. entails_formula S1 S3
[PROOF STEP]
by (meson assms entailment_implies_validity validity_implies_entailment)


[STATEMENT]
lemma dvd_prime_factors [intro]:
  "y \<noteq> 0 \<Longrightarrow> x dvd y \<Longrightarrow> prime_factors x \<subseteq> prime_factors y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>y \<noteq> (0::'a); x dvd y\<rbrakk> \<Longrightarrow> prime_factors x \<subseteq> prime_factors y
[PROOF STEP]
by (intro set_mset_mono, subst prime_factorization_subset_iff_dvd) auto


[STATEMENT]
lemma cltn2_left_inverse_ex:
  "\<exists> B. cltn2_compose B A = cltn2_id"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>B. cltn2_compose B A = cltn2_id
[PROOF STEP]
using cltn2_left_inverse
[PROOF STATE]
proof (prove)
using this:
cltn2_compose (cltn2_inverse ?A) ?A = cltn2_id

goal (1 subgoal):
 1. \<exists>B. cltn2_compose B A = cltn2_id
[PROOF STEP]
..