[STATEMENT]
lemma irreflexive_linorder_matrix_1:
  fixes f :: "('a::finite,'b::linorder_stone_relation_algebra_expansion) square"
  assumes "matrix_stone_relation_algebra.irreflexive f"
    shows "f (i,i) = bot"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f (i, i) = bot
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. f (i, i) = bot
[PROOF STEP]
have "(top::'b) = mone (i,i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. top = mone (i, i)
[PROOF STEP]
by (simp add: one_matrix_def)
[PROOF STATE]
proof (state)
this:
top = mone (i, i)

goal (1 subgoal):
 1. f (i, i) = bot
[PROOF STEP]
hence "(bot::'b) = (\<ominus>mone) (i,i)"
[PROOF STATE]
proof (prove)
using this:
top = mone (i, i)

goal (1 subgoal):
 1. bot = (\<ominus> mone) (i, i)
[PROOF STEP]
by (simp add: uminus_matrix_def)
[PROOF STATE]
proof (state)
this:
bot = (\<ominus> mone) (i, i)

goal (1 subgoal):
 1. f (i, i) = bot
[PROOF STEP]
hence "f (i,i) \<le> bot"
[PROOF STATE]
proof (prove)
using this:
bot = (\<ominus> mone) (i, i)

goal (1 subgoal):
 1. f (i, i) \<le> bot
[PROOF STEP]
by (metis assms less_eq_matrix_def)
[PROOF STATE]
proof (state)
this:
f (i, i) \<le> bot

goal (1 subgoal):
 1. f (i, i) = bot
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
f (i, i) \<le> bot

goal (1 subgoal):
 1. f (i, i) = bot
[PROOF STEP]
by (simp add: bot.extremum_unique)
[PROOF STATE]
proof (state)
this:
f (i, i) = bot

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma set_less_eq_aux_antisym: "\<lbrakk> A \<sqsubseteq>' B; B \<sqsubseteq>' A \<rbrakk> \<Longrightarrow> A = B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A \<sqsubseteq>' B; B \<sqsubseteq>' A\<rbrakk> \<Longrightarrow> A = B
[PROOF STEP]
by(auto simp add: set_less_eq_aux_def dest: set_less_aux_antisym)


[STATEMENT]
lemma Osum_Refl:
assumes FLD: "Field r Int Field r' = {}" and
        REFL: "Refl r" and REFL': "Refl r'"
shows "Refl (r Osum r')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Refl (r \<union>o r')
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
Field r \<inter> Field r' = {}
Refl r
Refl r'

goal (1 subgoal):
 1. Refl (r \<union>o r')
[PROOF STEP]
unfolding refl_on_def Field_Osum
[PROOF STATE]
proof (prove)
using this:
Field r \<inter> Field r' = {}
r \<subseteq> Field r \<times> Field r \<and> (\<forall>x\<in>Field r. (x, x) \<in> r)
r' \<subseteq> Field r' \<times> Field r' \<and> (\<forall>x\<in>Field r'. (x, x) \<in> r')

goal (1 subgoal):
 1. r \<union>o r' \<subseteq> (Field r \<union> Field r') \<times> (Field r \<union> Field r') \<and> (\<forall>x\<in>Field r \<union> Field r'. (x, x) \<in> r \<union>o r')
[PROOF STEP]
unfolding Osum_def
[PROOF STATE]
proof (prove)
using this:
Field r \<inter> Field r' = {}
r \<subseteq> Field r \<times> Field r \<and> (\<forall>x\<in>Field r. (x, x) \<in> r)
r' \<subseteq> Field r' \<times> Field r' \<and> (\<forall>x\<in>Field r'. (x, x) \<in> r')

goal (1 subgoal):
 1. r \<union> r' \<union> {(a, a'). a \<in> Field r \<and> a' \<in> Field r'} \<subseteq> (Field r \<union> Field r') \<times> (Field r \<union> Field r') \<and> (\<forall>x\<in>Field r \<union> Field r'. (x, x) \<in> r \<union> r' \<union> {(a, a'). a \<in> Field r \<and> a' \<in> Field r'})
[PROOF STEP]
by blast


[STATEMENT]
lemma closure_contains_Sup:
  fixes S :: "real set"
  assumes "S \<noteq> {}" "bdd_above S"
  shows "Sup S \<in> closure S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Sup S \<in> closure S
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Sup S \<in> closure S
[PROOF STEP]
have *: "\<forall>x\<in>S. x \<le> Sup S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>S. x \<le> Sup S
[PROOF STEP]
using cSup_upper[of _ S] assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?x \<in> S; bdd_above S\<rbrakk> \<Longrightarrow> ?x \<le> Sup S
S \<noteq> {}
bdd_above S

goal (1 subgoal):
 1. \<forall>x\<in>S. x \<le> Sup S
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
\<forall>x\<in>S. x \<le> Sup S

goal (1 subgoal):
 1. Sup S \<in> closure S
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
\<forall>x\<in>S. x \<le> Sup S

goal (1 subgoal):
 1. Sup S \<in> closure S
[PROOF STEP]
fix e :: real
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Sup S \<in> closure S
[PROOF STEP]
assume "e > 0"
[PROOF STATE]
proof (state)
this:
0 < e

goal (1 subgoal):
 1. Sup S \<in> closure S
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 < e
[PROOF STEP]
have "Sup S - e < Sup S"
[PROOF STATE]
proof (prove)
using this:
0 < e

goal (1 subgoal):
 1. Sup S - e < Sup S
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Sup S - e < Sup S

goal (1 subgoal):
 1. Sup S \<in> closure S
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
S \<noteq> {}
bdd_above S
Sup S - e < Sup S
[PROOF STEP]
obtain x where "x \<in> S" "Sup S - e < x"
[PROOF STATE]
proof (prove)
using this:
S \<noteq> {}
bdd_above S
Sup S - e < Sup S

goal (1 subgoal):
 1. (\<And>x. \<lbrakk>x \<in> S; Sup S - e < x\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (subst (asm) less_cSup_iff) auto
[PROOF STATE]
proof (state)
this:
x \<in> S
Sup S - e < x

goal (1 subgoal):
 1. Sup S \<in> closure S
[PROOF STEP]
with *
[PROOF STATE]
proof (chain)
picking this:
\<forall>x\<in>S. x \<le> Sup S
x \<in> S
Sup S - e < x
[PROOF STEP]
have "\<exists>x\<in>S. dist x (Sup S) < e"
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>S. x \<le> Sup S
x \<in> S
Sup S - e < x

goal (1 subgoal):
 1. \<exists>x\<in>S. dist x (Sup S) < e
[PROOF STEP]
by (intro bexI[of _ x]) (auto simp: dist_real_def)
[PROOF STATE]
proof (state)
this:
\<exists>x\<in>S. dist x (Sup S) < e

goal (1 subgoal):
 1. Sup S \<in> closure S
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
0 < ?e2 \<Longrightarrow> \<exists>x\<in>S. dist x (Sup S) < ?e2

goal (1 subgoal):
 1. Sup S \<in> closure S
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 < ?e2 \<Longrightarrow> \<exists>x\<in>S. dist x (Sup S) < ?e2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
0 < ?e2 \<Longrightarrow> \<exists>x\<in>S. dist x (Sup S) < ?e2

goal (1 subgoal):
 1. Sup S \<in> closure S
[PROOF STEP]
unfolding closure_approachable
[PROOF STATE]
proof (prove)
using this:
0 < ?e2 \<Longrightarrow> \<exists>x\<in>S. dist x (Sup S) < ?e2

goal (1 subgoal):
 1. \<forall>e>0. \<exists>y\<in>S. dist y (Sup S) < e
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Sup S \<in> closure S

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sorted_list_of_set_map_strict:
  assumes "strict_mono_on {0..<n} g"
  shows "sorted_list_of_set (g ` {0..<n}) = map g [0..<n]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted_list_of_set (g ` {0..<n}) = map g [0..<n]
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
strict_mono_on {0..<n} g

goal (1 subgoal):
 1. sorted_list_of_set (g ` {0..<n}) = map g [0..<n]
[PROOF STEP]
proof (induct n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. strict_mono_on {0..<0} g \<Longrightarrow> sorted_list_of_set (g ` {0..<0}) = map g [0..<0]
 2. \<And>n. \<lbrakk>strict_mono_on {0..<n} g \<Longrightarrow> sorted_list_of_set (g ` {0..<n}) = map g [0..<n]; strict_mono_on {0..<Suc n} g\<rbrakk> \<Longrightarrow> sorted_list_of_set (g ` {0..<Suc n}) = map g [0..<Suc n]
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
strict_mono_on {0..<0} g

goal (2 subgoals):
 1. strict_mono_on {0..<0} g \<Longrightarrow> sorted_list_of_set (g ` {0..<0}) = map g [0..<0]
 2. \<And>n. \<lbrakk>strict_mono_on {0..<n} g \<Longrightarrow> sorted_list_of_set (g ` {0..<n}) = map g [0..<n]; strict_mono_on {0..<Suc n} g\<rbrakk> \<Longrightarrow> sorted_list_of_set (g ` {0..<Suc n}) = map g [0..<Suc n]
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
strict_mono_on {0..<0} g
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
strict_mono_on {0..<0} g

goal (1 subgoal):
 1. sorted_list_of_set (g ` {0..<0}) = map g [0..<0]
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
sorted_list_of_set (g ` {0..<0}) = map g [0..<0]

goal (1 subgoal):
 1. \<And>n. \<lbrakk>strict_mono_on {0..<n} g \<Longrightarrow> sorted_list_of_set (g ` {0..<n}) = map g [0..<n]; strict_mono_on {0..<Suc n} g\<rbrakk> \<Longrightarrow> sorted_list_of_set (g ` {0..<Suc n}) = map g [0..<Suc n]
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>strict_mono_on {0..<n} g \<Longrightarrow> sorted_list_of_set (g ` {0..<n}) = map g [0..<n]; strict_mono_on {0..<Suc n} g\<rbrakk> \<Longrightarrow> sorted_list_of_set (g ` {0..<Suc n}) = map g [0..<Suc n]
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
strict_mono_on {0..<n} g \<Longrightarrow> sorted_list_of_set (g ` {0..<n}) = map g [0..<n]
strict_mono_on {0..<Suc n} g

goal (1 subgoal):
 1. \<And>n. \<lbrakk>strict_mono_on {0..<n} g \<Longrightarrow> sorted_list_of_set (g ` {0..<n}) = map g [0..<n]; strict_mono_on {0..<Suc n} g\<rbrakk> \<Longrightarrow> sorted_list_of_set (g ` {0..<Suc n}) = map g [0..<Suc n]
[PROOF STEP]
note sg = Suc.prems
[PROOF STATE]
proof (state)
this:
strict_mono_on {0..<Suc n} g

goal (1 subgoal):
 1. \<And>n. \<lbrakk>strict_mono_on {0..<n} g \<Longrightarrow> sorted_list_of_set (g ` {0..<n}) = map g [0..<n]; strict_mono_on {0..<Suc n} g\<rbrakk> \<Longrightarrow> sorted_list_of_set (g ` {0..<Suc n}) = map g [0..<Suc n]
[PROOF STEP]
have sg_n: "strict_mono_on {0..<n} g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. strict_mono_on {0..<n} g
[PROOF STEP]
using sg
[PROOF STATE]
proof (prove)
using this:
strict_mono_on {0..<Suc n} g

goal (1 subgoal):
 1. strict_mono_on {0..<n} g
[PROOF STEP]
unfolding strict_mono_on_def
[PROOF STATE]
proof (prove)
using this:
\<forall>r s. r \<in> {0..<Suc n} \<and> s \<in> {0..<Suc n} \<and> r < s \<longrightarrow> g r < g s

goal (1 subgoal):
 1. \<forall>r s. r \<in> {0..<n} \<and> s \<in> {0..<n} \<and> r < s \<longrightarrow> g r < g s
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
strict_mono_on {0..<n} g

goal (1 subgoal):
 1. \<And>n. \<lbrakk>strict_mono_on {0..<n} g \<Longrightarrow> sorted_list_of_set (g ` {0..<n}) = map g [0..<n]; strict_mono_on {0..<Suc n} g\<rbrakk> \<Longrightarrow> sorted_list_of_set (g ` {0..<Suc n}) = map g [0..<Suc n]
[PROOF STEP]
have g_image_rw: "g ` {0..<Suc n} = insert (g n) (g ` {0..<n})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g ` {0..<Suc n} = insert (g n) (g ` {0..<n})
[PROOF STEP]
by (simp add: set_upt_Suc)
[PROOF STATE]
proof (state)
this:
g ` {0..<Suc n} = insert (g n) (g ` {0..<n})

goal (1 subgoal):
 1. \<And>n. \<lbrakk>strict_mono_on {0..<n} g \<Longrightarrow> sorted_list_of_set (g ` {0..<n}) = map g [0..<n]; strict_mono_on {0..<Suc n} g\<rbrakk> \<Longrightarrow> sorted_list_of_set (g ` {0..<Suc n}) = map g [0..<Suc n]
[PROOF STEP]
have "sorted_list_of_set (g ` {0..<Suc n}) = sorted_list_of_set (insert (g n) (g ` {0..<n}))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted_list_of_set (g ` {0..<Suc n}) = sorted_list_of_set (insert (g n) (g ` {0..<n}))
[PROOF STEP]
using g_image_rw
[PROOF STATE]
proof (prove)
using this:
g ` {0..<Suc n} = insert (g n) (g ` {0..<n})

goal (1 subgoal):
 1. sorted_list_of_set (g ` {0..<Suc n}) = sorted_list_of_set (insert (g n) (g ` {0..<n}))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sorted_list_of_set (g ` {0..<Suc n}) = sorted_list_of_set (insert (g n) (g ` {0..<n}))

goal (1 subgoal):
 1. \<And>n. \<lbrakk>strict_mono_on {0..<n} g \<Longrightarrow> sorted_list_of_set (g ` {0..<n}) = map g [0..<n]; strict_mono_on {0..<Suc n} g\<rbrakk> \<Longrightarrow> sorted_list_of_set (g ` {0..<Suc n}) = map g [0..<Suc n]
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sorted_list_of_set (g ` {0..<Suc n}) = sorted_list_of_set (insert (g n) (g ` {0..<n}))

goal (1 subgoal):
 1. \<And>n. \<lbrakk>strict_mono_on {0..<n} g \<Longrightarrow> sorted_list_of_set (g ` {0..<n}) = map g [0..<n]; strict_mono_on {0..<Suc n} g\<rbrakk> \<Longrightarrow> sorted_list_of_set (g ` {0..<Suc n}) = map g [0..<Suc n]
[PROOF STEP]
have "... = insort (g n) (sorted_list_of_set (g ` {0..<n}))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted_list_of_set (insert (g n) (g ` {0..<n})) = insort (g n) (sorted_list_of_set (g ` {0..<n}))
[PROOF STEP]
proof (rule sorted_list_of_set_insert)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. finite (g ` {0..<n})
 2. g n \<notin> g ` {0..<n}
[PROOF STEP]
have "inj_on g {0..<Suc n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on g {0..<Suc n}
[PROOF STEP]
using sg strict_mono_on_imp_inj_on
[PROOF STATE]
proof (prove)
using this:
strict_mono_on {0..<Suc n} g
strict_mono_on ?A ?f \<Longrightarrow> inj_on ?f ?A

goal (1 subgoal):
 1. inj_on g {0..<Suc n}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
inj_on g {0..<Suc n}

goal (2 subgoals):
 1. finite (g ` {0..<n})
 2. g n \<notin> g ` {0..<n}
[PROOF STEP]
thus "g n \<notin> g ` {0..<n}"
[PROOF STATE]
proof (prove)
using this:
inj_on g {0..<Suc n}

goal (1 subgoal):
 1. g n \<notin> g ` {0..<n}
[PROOF STEP]
unfolding inj_on_def
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>{0..<Suc n}. \<forall>y\<in>{0..<Suc n}. g x = g y \<longrightarrow> x = y

goal (1 subgoal):
 1. g n \<notin> g ` {0..<n}
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
g n \<notin> g ` {0..<n}

goal (1 subgoal):
 1. finite (g ` {0..<n})
[PROOF STEP]
qed (simp)
[PROOF STATE]
proof (state)
this:
sorted_list_of_set (insert (g n) (g ` {0..<n})) = insort (g n) (sorted_list_of_set (g ` {0..<n}))

goal (1 subgoal):
 1. \<And>n. \<lbrakk>strict_mono_on {0..<n} g \<Longrightarrow> sorted_list_of_set (g ` {0..<n}) = map g [0..<n]; strict_mono_on {0..<Suc n} g\<rbrakk> \<Longrightarrow> sorted_list_of_set (g ` {0..<Suc n}) = map g [0..<Suc n]
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sorted_list_of_set (insert (g n) (g ` {0..<n})) = insort (g n) (sorted_list_of_set (g ` {0..<n}))

goal (1 subgoal):
 1. \<And>n. \<lbrakk>strict_mono_on {0..<n} g \<Longrightarrow> sorted_list_of_set (g ` {0..<n}) = map g [0..<n]; strict_mono_on {0..<Suc n} g\<rbrakk> \<Longrightarrow> sorted_list_of_set (g ` {0..<Suc n}) = map g [0..<Suc n]
[PROOF STEP]
have "... = insort (g n) (map g [0..<n])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. insort (g n) (sorted_list_of_set (g ` {0..<n})) = insort (g n) (map g [0..<n])
[PROOF STEP]
using Suc.hyps sg
[PROOF STATE]
proof (prove)
using this:
strict_mono_on {0..<n} g \<Longrightarrow> sorted_list_of_set (g ` {0..<n}) = map g [0..<n]
strict_mono_on {0..<Suc n} g

goal (1 subgoal):
 1. insort (g n) (sorted_list_of_set (g ` {0..<n})) = insort (g n) (map g [0..<n])
[PROOF STEP]
unfolding strict_mono_on_def
[PROOF STATE]
proof (prove)
using this:
\<forall>r s. r \<in> {0..<n} \<and> s \<in> {0..<n} \<and> r < s \<longrightarrow> g r < g s \<Longrightarrow> sorted_list_of_set (g ` {0..<n}) = map g [0..<n]
\<forall>r s. r \<in> {0..<Suc n} \<and> s \<in> {0..<Suc n} \<and> r < s \<longrightarrow> g r < g s

goal (1 subgoal):
 1. insort (g n) (sorted_list_of_set (g ` {0..<n})) = insort (g n) (map g [0..<n])
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
insort (g n) (sorted_list_of_set (g ` {0..<n})) = insort (g n) (map g [0..<n])

goal (1 subgoal):
 1. \<And>n. \<lbrakk>strict_mono_on {0..<n} g \<Longrightarrow> sorted_list_of_set (g ` {0..<n}) = map g [0..<n]; strict_mono_on {0..<Suc n} g\<rbrakk> \<Longrightarrow> sorted_list_of_set (g ` {0..<Suc n}) = map g [0..<Suc n]
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
insort (g n) (sorted_list_of_set (g ` {0..<n})) = insort (g n) (map g [0..<n])

goal (1 subgoal):
 1. \<And>n. \<lbrakk>strict_mono_on {0..<n} g \<Longrightarrow> sorted_list_of_set (g ` {0..<n}) = map g [0..<n]; strict_mono_on {0..<Suc n} g\<rbrakk> \<Longrightarrow> sorted_list_of_set (g ` {0..<Suc n}) = map g [0..<Suc n]
[PROOF STEP]
have "... = map g [0..<Suc n]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. insort (g n) (map g [0..<n]) = map g [0..<Suc n]
[PROOF STEP]
proof (simp, rule sorted_insort_is_snoc)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. sorted (map g [0..<n])
 2. \<forall>x\<in>set (map g [0..<n]). x \<le> g n
[PROOF STEP]
show "sorted (map g [0..<n])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted (map g [0..<n])
[PROOF STEP]
by (rule sorted_map_strict[OF sg_n])
[PROOF STATE]
proof (state)
this:
sorted (map g [0..<n])

goal (1 subgoal):
 1. \<forall>x\<in>set (map g [0..<n]). x \<le> g n
[PROOF STEP]
show "\<forall>x\<in>set (map g [0..<n]). x \<le> g n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>set (map g [0..<n]). x \<le> g n
[PROOF STEP]
using sg
[PROOF STATE]
proof (prove)
using this:
strict_mono_on {0..<Suc n} g

goal (1 subgoal):
 1. \<forall>x\<in>set (map g [0..<n]). x \<le> g n
[PROOF STEP]
unfolding strict_mono_on_def
[PROOF STATE]
proof (prove)
using this:
\<forall>r s. r \<in> {0..<Suc n} \<and> s \<in> {0..<Suc n} \<and> r < s \<longrightarrow> g r < g s

goal (1 subgoal):
 1. \<forall>x\<in>set (map g [0..<n]). x \<le> g n
[PROOF STEP]
by (simp add: less_imp_le)
[PROOF STATE]
proof (state)
this:
\<forall>x\<in>set (map g [0..<n]). x \<le> g n

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
insort (g n) (map g [0..<n]) = map g [0..<Suc n]

goal (1 subgoal):
 1. \<And>n. \<lbrakk>strict_mono_on {0..<n} g \<Longrightarrow> sorted_list_of_set (g ` {0..<n}) = map g [0..<n]; strict_mono_on {0..<Suc n} g\<rbrakk> \<Longrightarrow> sorted_list_of_set (g ` {0..<Suc n}) = map g [0..<Suc n]
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sorted_list_of_set (g ` {0..<Suc n}) = map g [0..<Suc n]
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
sorted_list_of_set (g ` {0..<Suc n}) = map g [0..<Suc n]

goal (1 subgoal):
 1. sorted_list_of_set (g ` {0..<Suc n}) = map g [0..<Suc n]
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
sorted_list_of_set (g ` {0..<Suc n}) = map g [0..<Suc n]

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma neg_meas_set_union:
  assumes "neg_meas_set A"
    and "neg_meas_set B"
  shows "neg_meas_set (A \<union> B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. neg_meas_set (A \<union> B)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. neg_meas_set (A \<union> B)
[PROOF STEP]
define C where "C = B - A"
[PROOF STATE]
proof (state)
this:
C = B - A

goal (1 subgoal):
 1. neg_meas_set (A \<union> B)
[PROOF STEP]
have "A\<union> C = A\<union> B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<union> C = A \<union> B
[PROOF STEP]
unfolding C_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<union> (B - A) = A \<union> B
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A \<union> C = A \<union> B

goal (1 subgoal):
 1. neg_meas_set (A \<union> B)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
A \<union> C = A \<union> B

goal (1 subgoal):
 1. neg_meas_set (A \<union> B)
[PROOF STEP]
have "neg_meas_set (A\<union> C)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. neg_meas_set (A \<union> C)
[PROOF STEP]
proof (rule neg_meas_disj_union)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. neg_meas_set A
 2. neg_meas_set C
 3. A \<inter> C = {}
[PROOF STEP]
show "neg_meas_set C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. neg_meas_set C
[PROOF STEP]
unfolding C_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. neg_meas_set (B - A)
[PROOF STEP]
by (meson Diff_subset assms(1) assms(2) sets.Diff neg_meas_set_def
          neg_meas_subset signed_measure_space_axioms)
[PROOF STATE]
proof (state)
this:
neg_meas_set C

goal (2 subgoals):
 1. neg_meas_set A
 2. A \<inter> C = {}
[PROOF STEP]
show "neg_meas_set A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. neg_meas_set A
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
neg_meas_set A
neg_meas_set B

goal (1 subgoal):
 1. neg_meas_set A
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
neg_meas_set A

goal (1 subgoal):
 1. A \<inter> C = {}
[PROOF STEP]
show "A \<inter> C = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<inter> C = {}
[PROOF STEP]
unfolding C_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<inter> (B - A) = {}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A \<inter> C = {}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
neg_meas_set (A \<union> C)

goal (1 subgoal):
 1. neg_meas_set (A \<union> B)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
A \<union> C = A \<union> B
neg_meas_set (A \<union> C)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
A \<union> C = A \<union> B
neg_meas_set (A \<union> C)

goal (1 subgoal):
 1. neg_meas_set (A \<union> B)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
neg_meas_set (A \<union> B)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma squarefree_power_iff:
  "squarefree (n ^ m) \<longleftrightarrow> m = 0 \<or> is_unit n \<or> (squarefree n \<and> m = 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. squarefree (n ^ m) = (m = 0 \<or> is_unit n \<or> squarefree n \<and> m = 1)
[PROOF STEP]
proof safe
[PROOF STATE]
proof (state)
goal (5 subgoals):
 1. \<lbrakk>squarefree (n ^ m); 0 < m; \<not> is_unit n\<rbrakk> \<Longrightarrow> squarefree n
 2. \<lbrakk>squarefree (n ^ m); 0 < m; \<not> is_unit n\<rbrakk> \<Longrightarrow> m = 1
 3. m = 0 \<Longrightarrow> squarefree (n ^ 0)
 4. is_unit n \<Longrightarrow> squarefree (n ^ m)
 5. \<lbrakk>squarefree n; m = 1\<rbrakk> \<Longrightarrow> squarefree (n ^ 1)
[PROOF STEP]
assume "squarefree (n ^ m)" "m > 0" "\<not>is_unit n"
[PROOF STATE]
proof (state)
this:
squarefree (n ^ m)
0 < m
\<not> is_unit n

goal (5 subgoals):
 1. \<lbrakk>squarefree (n ^ m); 0 < m; \<not> is_unit n\<rbrakk> \<Longrightarrow> squarefree n
 2. \<lbrakk>squarefree (n ^ m); 0 < m; \<not> is_unit n\<rbrakk> \<Longrightarrow> m = 1
 3. m = 0 \<Longrightarrow> squarefree (n ^ 0)
 4. is_unit n \<Longrightarrow> squarefree (n ^ m)
 5. \<lbrakk>squarefree n; m = 1\<rbrakk> \<Longrightarrow> squarefree (n ^ 1)
[PROOF STEP]
show "m = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m = 1
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. m \<noteq> 1 \<Longrightarrow> False
[PROOF STEP]
assume "m \<noteq> 1"
[PROOF STATE]
proof (state)
this:
m \<noteq> 1

goal (1 subgoal):
 1. m \<noteq> 1 \<Longrightarrow> False
[PROOF STEP]
with \<open>m > 0\<close>
[PROOF STATE]
proof (chain)
picking this:
0 < m
m \<noteq> 1
[PROOF STEP]
have "n ^ 2 dvd n ^ m"
[PROOF STATE]
proof (prove)
using this:
0 < m
m \<noteq> 1

goal (1 subgoal):
 1. n\<^sup>2 dvd n ^ m
[PROOF STEP]
by (intro le_imp_power_dvd) auto
[PROOF STATE]
proof (state)
this:
n\<^sup>2 dvd n ^ m

goal (1 subgoal):
 1. m \<noteq> 1 \<Longrightarrow> False
[PROOF STEP]
from this and \<open>\<not>is_unit n\<close>
[PROOF STATE]
proof (chain)
picking this:
n\<^sup>2 dvd n ^ m
\<not> is_unit n
[PROOF STEP]
have "\<not>squarefree (n ^ m)"
[PROOF STATE]
proof (prove)
using this:
n\<^sup>2 dvd n ^ m
\<not> is_unit n

goal (1 subgoal):
 1. \<not> squarefree (n ^ m)
[PROOF STEP]
by (rule not_squarefreeI)
[PROOF STATE]
proof (state)
this:
\<not> squarefree (n ^ m)

goal (1 subgoal):
 1. m \<noteq> 1 \<Longrightarrow> False
[PROOF STEP]
with \<open>squarefree (n ^ m)\<close>
[PROOF STATE]
proof (chain)
picking this:
squarefree (n ^ m)
\<not> squarefree (n ^ m)
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
squarefree (n ^ m)
\<not> squarefree (n ^ m)

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
m = 1

goal (4 subgoals):
 1. \<lbrakk>squarefree (n ^ m); 0 < m; \<not> is_unit n\<rbrakk> \<Longrightarrow> squarefree n
 2. m = 0 \<Longrightarrow> squarefree (n ^ 0)
 3. is_unit n \<Longrightarrow> squarefree (n ^ m)
 4. \<lbrakk>squarefree n; m = 1\<rbrakk> \<Longrightarrow> squarefree (n ^ 1)
[PROOF STEP]
qed (auto simp: is_unit_power_iff dest: squarefree_powerD)


[STATEMENT]
lemma digit_gen_sum_repr_variant:
  assumes "b>1"
  shows "n = (\<Sum>k<n.((nth_digit n k b)*b^k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n = (\<Sum>k<n. nth_digit n k b * b ^ k)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n = (\<Sum>k<n. nth_digit n k b * b ^ k)
[PROOF STEP]
have "n < b^n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n < b ^ n
[PROOF STEP]
using \<open>b>1\<close>
[PROOF STATE]
proof (prove)
using this:
1 < b

goal (1 subgoal):
 1. n < b ^ n
[PROOF STEP]
apply (induct n, auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>n < b ^ n; Suc 0 < b\<rbrakk> \<Longrightarrow> Suc n < b * b ^ n
[PROOF STEP]
by (simp add: less_trans_Suc)
[PROOF STATE]
proof (state)
this:
n < b ^ n

goal (1 subgoal):
 1. n = (\<Sum>k<n. nth_digit n k b * b ^ k)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n < b ^ n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
n < b ^ n

goal (1 subgoal):
 1. n = (\<Sum>k<n. nth_digit n k b * b ^ k)
[PROOF STEP]
using digit_gen_sum_repr \<open>b>1\<close>
[PROOF STATE]
proof (prove)
using this:
n < b ^ n
\<lbrakk>?n < ?b ^ ?c; 1 < ?b\<rbrakk> \<Longrightarrow> ?n = (\<Sum>k<?c. nth_digit ?n k ?b * ?b ^ k)
1 < b

goal (1 subgoal):
 1. n = (\<Sum>k<n. nth_digit n k b * b ^ k)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
n = (\<Sum>k<n. nth_digit n k b * b ^ k)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma bin_morph_of_maps: "bin_morph_of x y = List.maps (case_finite_2 x y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bin_morph_of x y = List.maps (case_finite_2 x y)
[PROOF STEP]
unfolding bin_morph_of_def maps_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>u. concat (map (\<lambda>a. if a = bin0 then x else y) u)) = (\<lambda>xs. concat (map (case_finite_2 x y) xs))
[PROOF STEP]
unfolding case_finite_2_if_else
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>u. concat (map (\<lambda>a. if a = bin0 then x else y) u)) = (\<lambda>xs. concat (map (\<lambda>a. if a = bin0 then x else y) xs))
[PROOF STEP]
by simp


[STATEMENT]
lemma lcompare_double_ge_0: "lcompare_double x y \<ge> 0 \<longleftrightarrow> lle_double y x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0 \<le> lcompare_double x y) = lle_double y x
[PROOF STEP]
unfolding lle_double_def lcompare_double_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0 \<le> (if Code_Double.is_zero x \<and> Code_Double.is_zero y then compare_double (copysign_double 1 x) (copysign_double 1 y) else compare_double x y)) = ((if Code_Double.is_zero y \<and> Code_Double.is_zero x then compare_double (copysign_double 1 y) (copysign_double 1 x) else compare_double y x) \<le> 0)
[PROOF STEP]
using compare_double_swap not_less
[PROOF STATE]
proof (prove)
using this:
(0 < compare_double ?x ?y) = (compare_double ?y ?x < 0)
(\<not> ?x < ?y) = (?y \<le> ?x)

goal (1 subgoal):
 1. (0 \<le> (if Code_Double.is_zero x \<and> Code_Double.is_zero y then compare_double (copysign_double 1 x) (copysign_double 1 y) else compare_double x y)) = ((if Code_Double.is_zero y \<and> Code_Double.is_zero x then compare_double (copysign_double 1 y) (copysign_double 1 x) else compare_double y x) \<le> 0)
[PROOF STEP]
by auto


[STATEMENT]
lemma Pring_universal_prop_assms:
  assumes "is_poly_tuple m fs"
  assumes "length fs = n"
  shows  "(\<lambda>i. fs!i) \<in> {..<n} \<rightarrow> carrier (coord_ring R m)"
           "ring_hom_ring R (coord_ring R m) coord_const"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (!) fs \<in> {..<n} \<rightarrow> carrier (R [\<X>\<^bsub>m\<^esub>]) &&& ring_hom_ring R (R [\<X>\<^bsub>m\<^esub>]) R.indexed_const
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>x. x \<in> {..<n} \<Longrightarrow> fs ! x \<in> carrier (R [\<X>\<^bsub>m\<^esub>])
 2. ring_hom_ring R (R [\<X>\<^bsub>m\<^esub>]) R.indexed_const
[PROOF STEP]
show "\<And>x. x \<in> {..<n} \<Longrightarrow> fs ! x \<in> carrier (coord_ring R m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> {..<n} \<Longrightarrow> fs ! x \<in> carrier (R [\<X>\<^bsub>m\<^esub>])
[PROOF STEP]
using assms  is_poly_tupleE
[PROOF STATE]
proof (prove)
using this:
is_poly_tuple m fs
length fs = n
\<lbrakk>is_poly_tuple ?n ?fs; ?j < length ?fs\<rbrakk> \<Longrightarrow> ?fs ! ?j \<in> carrier (R [\<X>\<^bsub>?n\<^esub>])

goal (1 subgoal):
 1. \<And>x. x \<in> {..<n} \<Longrightarrow> fs ! x \<in> carrier (R [\<X>\<^bsub>m\<^esub>])
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
?x30 \<in> {..<n} \<Longrightarrow> fs ! ?x30 \<in> carrier (R [\<X>\<^bsub>m\<^esub>])

goal (1 subgoal):
 1. ring_hom_ring R (R [\<X>\<^bsub>m\<^esub>]) R.indexed_const
[PROOF STEP]
show "ring_hom_ring R (coord_ring R m) coord_const"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ring_hom_ring R (R [\<X>\<^bsub>m\<^esub>]) R.indexed_const
[PROOF STEP]
using R.indexed_const_ring_hom coord_const_ring_hom
[PROOF STATE]
proof (prove)
using this:
ring_hom_ring R (Pring R ?I) R.indexed_const
ring_hom_ring R (R [\<X>\<^bsub>?n\<^esub>]) R.indexed_const

goal (1 subgoal):
 1. ring_hom_ring R (R [\<X>\<^bsub>m\<^esub>]) R.indexed_const
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
ring_hom_ring R (R [\<X>\<^bsub>m\<^esub>]) R.indexed_const

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem coeff_poly_from_roots:
  fixes f :: "'a \<Rightarrow> 'b :: comm_ring_1"
  assumes fin: "finite A" and k: "k \<le> card A"
  shows   "coeff (\<Prod>x\<in>A. [:-f x, 1:]) k =
             (-1) ^ (card A - k) * (\<Sum>X | X \<subseteq> A \<and> card X = card A - k. (\<Prod>x\<in>X. f x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff (\<Prod>x\<in>A. [:- f x, 1::'b:]) k = (- (1::'b)) ^ (card A - k) * (\<Sum>X | X \<subseteq> A \<and> card X = card A - k. prod f X)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. coeff (\<Prod>x\<in>A. [:- f x, 1::'b:]) k = (- (1::'b)) ^ (card A - k) * (\<Sum>X | X \<subseteq> A \<and> card X = card A - k. prod f X)
[PROOF STEP]
have "(\<Prod>x\<in>A. [:-f x, 1:]) = (\<Sum>X\<in>Pow A. monom ((-1) ^ card X * (\<Prod>x\<in>X. f x)) (card (A - X)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>x\<in>A. [:- f x, 1::'b:]) = (\<Sum>X\<in>Pow A. monom ((- (1::'b)) ^ card X * prod f X) (card (A - X)))
[PROOF STEP]
by (intro poly_from_roots fin)
[PROOF STATE]
proof (state)
this:
(\<Prod>x\<in>A. [:- f x, 1::'b:]) = (\<Sum>X\<in>Pow A. monom ((- (1::'b)) ^ card X * prod f X) (card (A - X)))

goal (1 subgoal):
 1. coeff (\<Prod>x\<in>A. [:- f x, 1::'b:]) k = (- (1::'b)) ^ (card A - k) * (\<Sum>X | X \<subseteq> A \<and> card X = card A - k. prod f X)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Prod>x\<in>A. [:- f x, 1::'b:]) = (\<Sum>X\<in>Pow A. monom ((- (1::'b)) ^ card X * prod f X) (card (A - X)))

goal (1 subgoal):
 1. coeff (\<Prod>x\<in>A. [:- f x, 1::'b:]) k = (- (1::'b)) ^ (card A - k) * (\<Sum>X | X \<subseteq> A \<and> card X = card A - k. prod f X)
[PROOF STEP]
have "coeff \<dots> k = (\<Sum>X | X \<subseteq> A \<and> card X = card A - k. (-1) ^ (card A - k) * (\<Prod>x\<in>X. f x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeff (\<Sum>X\<in>Pow A. monom ((- (1::'b)) ^ card X * prod f X) (card (A - X))) k = (\<Sum>X | X \<subseteq> A \<and> card X = card A - k. (- (1::'b)) ^ (card A - k) * prod f X)
[PROOF STEP]
unfolding coeff_sum coeff_monom
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>Pow A. if card (A - x) = k then (- (1::'b)) ^ card x * prod f x else (0::'b)) = (\<Sum>X | X \<subseteq> A \<and> card X = card A - k. (- (1::'b)) ^ (card A - k) * prod f X)
[PROOF STEP]
using finite_subset[OF _ fin] k card_mono[OF fin]
[PROOF STATE]
proof (prove)
using this:
?A \<subseteq> A \<Longrightarrow> finite ?A
k \<le> card A
?A \<subseteq> A \<Longrightarrow> card ?A \<le> card A

goal (1 subgoal):
 1. (\<Sum>x\<in>Pow A. if card (A - x) = k then (- (1::'b)) ^ card x * prod f x else (0::'b)) = (\<Sum>X | X \<subseteq> A \<and> card X = card A - k. (- (1::'b)) ^ (card A - k) * prod f X)
[PROOF STEP]
by (intro sum.mono_neutral_cong_right) (auto simp: card_Diff_subset)
[PROOF STATE]
proof (state)
this:
coeff (\<Sum>X\<in>Pow A. monom ((- (1::'b)) ^ card X * prod f X) (card (A - X))) k = (\<Sum>X | X \<subseteq> A \<and> card X = card A - k. (- (1::'b)) ^ (card A - k) * prod f X)

goal (1 subgoal):
 1. coeff (\<Prod>x\<in>A. [:- f x, 1::'b:]) k = (- (1::'b)) ^ (card A - k) * (\<Sum>X | X \<subseteq> A \<and> card X = card A - k. prod f X)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
coeff (\<Sum>X\<in>Pow A. monom ((- (1::'b)) ^ card X * prod f X) (card (A - X))) k = (\<Sum>X | X \<subseteq> A \<and> card X = card A - k. (- (1::'b)) ^ (card A - k) * prod f X)

goal (1 subgoal):
 1. coeff (\<Prod>x\<in>A. [:- f x, 1::'b:]) k = (- (1::'b)) ^ (card A - k) * (\<Sum>X | X \<subseteq> A \<and> card X = card A - k. prod f X)
[PROOF STEP]
have "\<dots> = (-1) ^ (card A - k) * (\<Sum>X | X \<subseteq> A \<and> card X = card A - k. (\<Prod>x\<in>X. f x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>X | X \<subseteq> A \<and> card X = card A - k. (- (1::'b)) ^ (card A - k) * prod f X) = (- (1::'b)) ^ (card A - k) * (\<Sum>X | X \<subseteq> A \<and> card X = card A - k. prod f X)
[PROOF STEP]
by (simp add: sum_distrib_left)
[PROOF STATE]
proof (state)
this:
(\<Sum>X | X \<subseteq> A \<and> card X = card A - k. (- (1::'b)) ^ (card A - k) * prod f X) = (- (1::'b)) ^ (card A - k) * (\<Sum>X | X \<subseteq> A \<and> card X = card A - k. prod f X)

goal (1 subgoal):
 1. coeff (\<Prod>x\<in>A. [:- f x, 1::'b:]) k = (- (1::'b)) ^ (card A - k) * (\<Sum>X | X \<subseteq> A \<and> card X = card A - k. prod f X)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
coeff (\<Prod>x\<in>A. [:- f x, 1::'b:]) k = (- (1::'b)) ^ (card A - k) * (\<Sum>X | X \<subseteq> A \<and> card X = card A - k. prod f X)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
coeff (\<Prod>x\<in>A. [:- f x, 1::'b:]) k = (- (1::'b)) ^ (card A - k) * (\<Sum>X | X \<subseteq> A \<and> card X = card A - k. prod f X)

goal (1 subgoal):
 1. coeff (\<Prod>x\<in>A. [:- f x, 1::'b:]) k = (- (1::'b)) ^ (card A - k) * (\<Sum>X | X \<subseteq> A \<and> card X = card A - k. prod f X)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
coeff (\<Prod>x\<in>A. [:- f x, 1::'b:]) k = (- (1::'b)) ^ (card A - k) * (\<Sum>X | X \<subseteq> A \<and> card X = card A - k. prod f X)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma multiset_eq_iff: "M = N \<longleftrightarrow> (\<forall>a. count M a = count N a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (M = N) = (\<forall>a. count M a = count N a)
[PROOF STEP]
by (simp only: count_inject [symmetric] fun_eq_iff)


[STATEMENT]
lemma int_encode_bound: "dioph_is_node ks l m \<Longrightarrow>
  int_encode m < nat (2 * max \<bar>l\<bar> (\<Sum>k\<leftarrow>ks. \<bar>k\<bar>) + 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dioph_is_node ks l m \<Longrightarrow> int_encode m < nat (2 * max \<bar>l\<bar> (sum_list (map abs ks)) + 1)
[PROOF STEP]
by (simp add: dioph_is_node_def int_encode_def sum_encode_def) arith


[STATEMENT]
lemma newton_poly_impl_int: assumes len: "length xs = length fs"
  and dist: "distinct xs"
  shows "newton_poly_impl_int = (let p = newton_poly_impl (map rat_of_int xs) (map of_int fs)
    in if set (coeffs p) \<subseteq> \<int> then Some (map_poly int_of_rat p) else None)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.newton_poly_impl_int = (let p = newton_poly_impl (map rat_of_int xs) (map rat_of_int fs) in if set (coeffs p) \<subseteq> \<int> then Some (map_poly int_of_rat p) else None)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. local.newton_poly_impl_int = (let p = newton_poly_impl (map rat_of_int xs) (map rat_of_int fs) in if set (coeffs p) \<subseteq> \<int> then Some (map_poly int_of_rat p) else None)
[PROOF STEP]
let ?ir = "int_of_rat"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. local.newton_poly_impl_int = (let p = newton_poly_impl (map rat_of_int xs) (map rat_of_int fs) in if set (coeffs p) \<subseteq> \<int> then Some (map_poly int_of_rat p) else None)
[PROOF STEP]
let ?ri = "rat_of_int"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. local.newton_poly_impl_int = (let p = newton_poly_impl (map rat_of_int xs) (map rat_of_int fs) in if set (coeffs p) \<subseteq> \<int> then Some (map_poly int_of_rat p) else None)
[PROOF STEP]
let ?mir = "map ?ir"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. local.newton_poly_impl_int = (let p = newton_poly_impl (map rat_of_int xs) (map rat_of_int fs) in if set (coeffs p) \<subseteq> \<int> then Some (map_poly int_of_rat p) else None)
[PROOF STEP]
let ?mri = "map ?ri"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. local.newton_poly_impl_int = (let p = newton_poly_impl (map rat_of_int xs) (map rat_of_int fs) in if set (coeffs p) \<subseteq> \<int> then Some (map_poly int_of_rat p) else None)
[PROOF STEP]
let ?nc = "newton_coefficients (?mri xs) (?mri fs)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. local.newton_poly_impl_int = (let p = newton_poly_impl (map rat_of_int xs) (map rat_of_int fs) in if set (coeffs p) \<subseteq> \<int> then Some (map_poly int_of_rat p) else None)
[PROOF STEP]
have id: "newton_poly_impl_int = (if set ?nc \<subseteq> \<int>
    then Some (horner_composition (rev (?mir ?nc)) xs) else None)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.newton_poly_impl_int = (if set (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)) \<subseteq> \<int> then Some (horner_composition (rev (map int_of_rat (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)))) xs) else None)
[PROOF STEP]
unfolding newton_poly_impl_int_def newton_coefficients_int[OF dist len] Let_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (case if set (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)) \<subseteq> \<int> then Some (map int_of_rat (newton_coefficients (map rat_of_int xs) (map rat_of_int fs))) else None of None \<Rightarrow> None | Some nc \<Rightarrow> Some (horner_composition (rev nc) xs)) = (if set (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)) \<subseteq> \<int> then Some (horner_composition (rev (map int_of_rat (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)))) xs) else None)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
local.newton_poly_impl_int = (if set (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)) \<subseteq> \<int> then Some (horner_composition (rev (map int_of_rat (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)))) xs) else None)

goal (1 subgoal):
 1. local.newton_poly_impl_int = (let p = newton_poly_impl (map rat_of_int xs) (map rat_of_int fs) in if set (coeffs p) \<subseteq> \<int> then Some (map_poly int_of_rat p) else None)
[PROOF STEP]
have len: "length (rev ?nc) \<le> Suc (length xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs))) \<le> Suc (length xs)
[PROOF STEP]
unfolding length_rev
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)) \<le> Suc (length xs)
[PROOF STEP]
by (subst newton_coefficients[OF refl], insert len, auto)
[PROOF STATE]
proof (state)
this:
length (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs))) \<le> Suc (length xs)

goal (1 subgoal):
 1. local.newton_poly_impl_int = (let p = newton_poly_impl (map rat_of_int xs) (map rat_of_int fs) in if set (coeffs p) \<subseteq> \<int> then Some (map_poly int_of_rat p) else None)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.newton_poly_impl_int = (let p = newton_poly_impl (map rat_of_int xs) (map rat_of_int fs) in if set (coeffs p) \<subseteq> \<int> then Some (map_poly int_of_rat p) else None)
[PROOF STEP]
unfolding id
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if set (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)) \<subseteq> \<int> then Some (horner_composition (rev (map int_of_rat (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)))) xs) else None) = (let p = newton_poly_impl (map rat_of_int xs) (map rat_of_int fs) in if set (coeffs p) \<subseteq> \<int> then Some (map_poly int_of_rat p) else None)
[PROOF STEP]
unfolding newton_poly_impl_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if set (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)) \<subseteq> \<int> then Some (horner_composition (rev (map int_of_rat (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)))) xs) else None) = (let p = horner_composition (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs))) (map rat_of_int xs) in if set (coeffs p) \<subseteq> \<int> then Some (map_poly int_of_rat p) else None)
[PROOF STEP]
unfolding Let_def set_rev rev_map horner_coeffs_ints[OF len]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if set (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)) \<subseteq> \<int> then Some (horner_composition (map int_of_rat (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)))) xs) else None) = (if set (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)) \<subseteq> \<int> then Some (map_poly int_of_rat (horner_composition (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs))) (map rat_of_int xs))) else None)
[PROOF STEP]
proof (rule if_cong[OF refl _ refl], rule arg_cong[of _ _ Some])
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. set (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)) \<subseteq> \<int> \<Longrightarrow> horner_composition (map int_of_rat (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)))) xs = map_poly int_of_rat (horner_composition (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs))) (map rat_of_int xs))
[PROOF STEP]
define cs where "cs = rev ?nc"
[PROOF STATE]
proof (state)
this:
cs = rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs))

goal (1 subgoal):
 1. set (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)) \<subseteq> \<int> \<Longrightarrow> horner_composition (map int_of_rat (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)))) xs = map_poly int_of_rat (horner_composition (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs))) (map rat_of_int xs))
[PROOF STEP]
define ics where "ics = map ?ir cs"
[PROOF STATE]
proof (state)
this:
ics = map int_of_rat cs

goal (1 subgoal):
 1. set (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)) \<subseteq> \<int> \<Longrightarrow> horner_composition (map int_of_rat (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)))) xs = map_poly int_of_rat (horner_composition (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs))) (map rat_of_int xs))
[PROOF STEP]
assume "set ?nc \<subseteq> \<int>"
[PROOF STATE]
proof (state)
this:
set (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)) \<subseteq> \<int>

goal (1 subgoal):
 1. set (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)) \<subseteq> \<int> \<Longrightarrow> horner_composition (map int_of_rat (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)))) xs = map_poly int_of_rat (horner_composition (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs))) (map rat_of_int xs))
[PROOF STEP]
hence "set cs \<subseteq> \<int>"
[PROOF STATE]
proof (prove)
using this:
set (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)) \<subseteq> \<int>

goal (1 subgoal):
 1. set cs \<subseteq> \<int>
[PROOF STEP]
unfolding cs_def
[PROOF STATE]
proof (prove)
using this:
set (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)) \<subseteq> \<int>

goal (1 subgoal):
 1. set (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs))) \<subseteq> \<int>
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set cs \<subseteq> \<int>

goal (1 subgoal):
 1. set (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)) \<subseteq> \<int> \<Longrightarrow> horner_composition (map int_of_rat (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)))) xs = map_poly int_of_rat (horner_composition (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs))) (map rat_of_int xs))
[PROOF STEP]
hence ics: "cs = ?mri ics"
[PROOF STATE]
proof (prove)
using this:
set cs \<subseteq> \<int>

goal (1 subgoal):
 1. cs = map rat_of_int ics
[PROOF STEP]
unfolding ics_def map_map o_def
[PROOF STATE]
proof (prove)
using this:
set cs \<subseteq> \<int>

goal (1 subgoal):
 1. cs = map (\<lambda>x. rat_of_int (int_of_rat x)) cs
[PROOF STEP]
by (simp add: map_idI subset_code(1))
[PROOF STATE]
proof (state)
this:
cs = map rat_of_int ics

goal (1 subgoal):
 1. set (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)) \<subseteq> \<int> \<Longrightarrow> horner_composition (map int_of_rat (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)))) xs = map_poly int_of_rat (horner_composition (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs))) (map rat_of_int xs))
[PROOF STEP]
have id: "horner_composition (rev ?nc) (?mri xs) = map_poly ?ri (horner_composition ics xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. horner_composition (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs))) (map rat_of_int xs) = of_int_poly (horner_composition ics xs)
[PROOF STEP]
unfolding cs_def[symmetric] ics
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. horner_composition (map rat_of_int ics) (map rat_of_int xs) = of_int_poly (horner_composition ics xs)
[PROOF STEP]
by (rule of_int_poly_hom.horner_composition_hom)
[PROOF STATE]
proof (state)
this:
horner_composition (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs))) (map rat_of_int xs) = of_int_poly (horner_composition ics xs)

goal (1 subgoal):
 1. set (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)) \<subseteq> \<int> \<Longrightarrow> horner_composition (map int_of_rat (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)))) xs = map_poly int_of_rat (horner_composition (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs))) (map rat_of_int xs))
[PROOF STEP]
show "horner_composition (?mir (rev ?nc)) xs
      = map_poly ?ir (horner_composition (rev ?nc) (?mri xs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. horner_composition (map int_of_rat (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)))) xs = map_poly int_of_rat (horner_composition (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs))) (map rat_of_int xs))
[PROOF STEP]
unfolding id
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. horner_composition (map int_of_rat (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)))) xs = map_poly int_of_rat (of_int_poly (horner_composition ics xs))
[PROOF STEP]
unfolding cs_def[symmetric] ics_def[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. horner_composition ics xs = map_poly int_of_rat (of_int_poly (horner_composition ics xs))
[PROOF STEP]
by (subst map_poly_map_poly, auto simp: o_def map_poly_idI)
[PROOF STATE]
proof (state)
this:
horner_composition (map int_of_rat (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs)))) xs = map_poly int_of_rat (horner_composition (rev (newton_coefficients (map rat_of_int xs) (map rat_of_int fs))) (map rat_of_int xs))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
local.newton_poly_impl_int = (let p = newton_poly_impl (map rat_of_int xs) (map rat_of_int fs) in if set (coeffs p) \<subseteq> \<int> then Some (map_poly int_of_rat p) else None)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma trace_mult_symm:
  fixes A B :: "'a::comm_semiring_0^^'n"
  shows "trace (A * B) = trace (B * A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Square_Matrix.trace (A * B) = Square_Matrix.trace (B * A)
[PROOF STEP]
by transfer (auto intro: sum.swap simp: mult.commute)


[STATEMENT]
lemma condition_1:
  fixes A::"'a::{field}^'columns::{mod_type}^'rows::{mod_type}" and k::nat
  defines ia:"ia\<equiv>(if \<forall>m. is_zero_row_upt_k m k A then 0 else to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1)"
  defines B:"B\<equiv>(snd (Gauss_Jordan_column_k (ia,A) k))"
  assumes rref: "reduced_row_echelon_form_upt_k A k"
  and zero_i_suc_k: "is_zero_row_upt_k i (Suc k) B" and i_less_j: "i < j"
  shows "is_zero_row_upt_k j (Suc k) B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_zero_row_upt_k j (Suc k) B
[PROOF STEP]
proof (unfold B Gauss_Jordan_column_k_def ia Let_def fst_conv snd_conv, auto, unfold from_nat_to_nat_greatest)
[PROOF STATE]
proof (state)
goal (5 subgoals):
 1. \<lbrakk>\<forall>m. is_zero_row_upt_k m k A; \<forall>m\<ge>mod_type_class.from_nat 0. A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 2. \<And>m. \<lbrakk>\<forall>m. is_zero_row_upt_k m k A; mod_type_class.from_nat 0 \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A (mod_type_class.from_nat 0) (mod_type_class.from_nat k))
 3. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; \<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 4. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 5. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))
[PROOF STEP]
assume zero_k: "\<forall>m\<ge>from_nat 0. A $ m $ from_nat k = 0"  and all_zero: "\<forall>m. is_zero_row_upt_k m k A"
[PROOF STATE]
proof (state)
this:
\<forall>m\<ge>mod_type_class.from_nat 0. A $ m $ mod_type_class.from_nat k = (0::'a)
\<forall>m. is_zero_row_upt_k m k A

goal (5 subgoals):
 1. \<lbrakk>\<forall>m. is_zero_row_upt_k m k A; \<forall>m\<ge>mod_type_class.from_nat 0. A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 2. \<And>m. \<lbrakk>\<forall>m. is_zero_row_upt_k m k A; mod_type_class.from_nat 0 \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A (mod_type_class.from_nat 0) (mod_type_class.from_nat k))
 3. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; \<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 4. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 5. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))
[PROOF STEP]
show "is_zero_row_upt_k j (Suc k) A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_zero_row_upt_k j (Suc k) A
[PROOF STEP]
using condition_1_part_1[OF zero_k all_zero]
[PROOF STATE]
proof (prove)
using this:
is_zero_row_upt_k ?j (Suc k) A

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

goal (4 subgoals):
 1. \<And>m. \<lbrakk>\<forall>m. is_zero_row_upt_k m k A; mod_type_class.from_nat 0 \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A (mod_type_class.from_nat 0) (mod_type_class.from_nat k))
 2. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; \<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 3. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 4. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. \<And>m. \<lbrakk>\<forall>m. is_zero_row_upt_k m k A; mod_type_class.from_nat 0 \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A (mod_type_class.from_nat 0) (mod_type_class.from_nat k))
 2. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; \<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 3. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 4. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))
[PROOF STEP]
fix m
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. \<And>m. \<lbrakk>\<forall>m. is_zero_row_upt_k m k A; mod_type_class.from_nat 0 \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A (mod_type_class.from_nat 0) (mod_type_class.from_nat k))
 2. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; \<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 3. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 4. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))
[PROOF STEP]
assume all_zero: "\<forall>m. is_zero_row_upt_k m k A" and Amk_not_zero: "A $ m $ from_nat k \<noteq> 0"
[PROOF STATE]
proof (state)
this:
\<forall>m. is_zero_row_upt_k m k A
A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)

goal (4 subgoals):
 1. \<And>m. \<lbrakk>\<forall>m. is_zero_row_upt_k m k A; mod_type_class.from_nat 0 \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A (mod_type_class.from_nat 0) (mod_type_class.from_nat k))
 2. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; \<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 3. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 4. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))
[PROOF STEP]
have j_not_0: "j \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. j \<noteq> (0::'rows)
[PROOF STEP]
using i_less_j least_mod_type not_le
[PROOF STATE]
proof (prove)
using this:
i < j
(0::?'a) \<le> ?n
(\<not> ?x \<le> ?y) = (?y < ?x)

goal (1 subgoal):
 1. j \<noteq> (0::'rows)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
j \<noteq> (0::'rows)

goal (4 subgoals):
 1. \<And>m. \<lbrakk>\<forall>m. is_zero_row_upt_k m k A; mod_type_class.from_nat 0 \<le> m; A $ m $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A (mod_type_class.from_nat 0) (mod_type_class.from_nat k))
 2. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; \<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 3. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 4. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))
[PROOF STEP]
show "is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A (from_nat 0) (from_nat k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A (mod_type_class.from_nat 0) (mod_type_class.from_nat k))
[PROOF STEP]
using condition_1_part_2[OF j_not_0 all_zero Amk_not_zero]
[PROOF STATE]
proof (prove)
using this:
is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A (mod_type_class.from_nat 0) (mod_type_class.from_nat k))

goal (1 subgoal):
 1. is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A (mod_type_class.from_nat 0) (mod_type_class.from_nat k))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A (mod_type_class.from_nat 0) (mod_type_class.from_nat k))

goal (3 subgoals):
 1. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; \<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 2. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 3. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; \<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 2. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 3. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))
[PROOF STEP]
fix m
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; \<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 2. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 3. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))
[PROOF STEP]
assume not_zero_mkA: "\<not> is_zero_row_upt_k m k A"
    and zero_below_greatest: "\<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + 1. A $ m $ from_nat k = 0"
[PROOF STATE]
proof (state)
this:
\<not> is_zero_row_upt_k m k A
\<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k = (0::'a)

goal (3 subgoals):
 1. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; \<forall>m\<ge>(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows). A $ m $ mod_type_class.from_nat k = (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 2. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 3. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))
[PROOF STEP]
show "is_zero_row_upt_k j (Suc k) A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_zero_row_upt_k j (Suc k) A
[PROOF STEP]
using condition_1_part_3[OF rref i_less_j not_zero_mkA zero_below_greatest] zero_i_suc_k
[PROOF STATE]
proof (prove)
using this:
is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k)) \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
is_zero_row_upt_k i (Suc k) B

goal (1 subgoal):
 1. is_zero_row_upt_k j (Suc k) A
[PROOF STEP]
unfolding B ia
[PROOF STATE]
proof (prove)
using this:
is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k)) \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k))

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

goal (2 subgoals):
 1. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 2. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 2. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))
[PROOF STEP]
fix m
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 2. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))
[PROOF STEP]
assume not_zero_m: "\<not> is_zero_row_upt_k m k A"
    and greatest_eq_card: "Suc (to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) =  nrows A"
[PROOF STATE]
proof (state)
this:
\<not> is_zero_row_upt_k m k A
Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A

goal (2 subgoals):
 1. \<And>m. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) = nrows A\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
 2. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))
[PROOF STEP]
show "is_zero_row_upt_k j (Suc k) A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_zero_row_upt_k j (Suc k) A
[PROOF STEP]
using condition_1_part_4[OF rref _ i_less_j not_zero_m greatest_eq_card] zero_i_suc_k
[PROOF STATE]
proof (prove)
using this:
is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k)) \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
is_zero_row_upt_k i (Suc k) B

goal (1 subgoal):
 1. is_zero_row_upt_k j (Suc k) A
[PROOF STEP]
unfolding B ia nrows_def
[PROOF STATE]
proof (prove)
using this:
is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k)) \<Longrightarrow> is_zero_row_upt_k j (Suc k) A
is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k))

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

goal (1 subgoal):
 1. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))
[PROOF STEP]
fix m ma
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))
[PROOF STEP]
assume not_zero_m: "\<not> is_zero_row_upt_k m k A"
    and greatest_not_card: "Suc (to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A"
and greatest_less_ma: "(GREATEST n. \<not> is_zero_row_upt_k n k A) + 1 \<le> ma"
    and A_ma_k_not_zero: "A $ ma $ from_nat k \<noteq> 0"
[PROOF STATE]
proof (state)
this:
\<not> is_zero_row_upt_k m k A
Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A
(GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma
A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)

goal (1 subgoal):
 1. \<And>m ma. \<lbrakk>\<not> is_zero_row_upt_k m k A; Suc (mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A)) \<noteq> nrows A; (GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows) \<le> ma; A $ ma $ mod_type_class.from_nat k \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))
[PROOF STEP]
show "is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + 1) (from_nat k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))
[PROOF STEP]
using condition_1_part_5[OF rref _ i_less_j not_zero_m greatest_not_card greatest_less_ma A_ma_k_not_zero]
[PROOF STATE]
proof (prove)
using this:
is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k)) \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))

goal (1 subgoal):
 1. is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))
[PROOF STEP]
using zero_i_suc_k
[PROOF STATE]
proof (prove)
using this:
is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k)) \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))
is_zero_row_upt_k i (Suc k) B

goal (1 subgoal):
 1. is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))
[PROOF STEP]
unfolding B ia
[PROOF STATE]
proof (prove)
using this:
is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k)) \<Longrightarrow> is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))
is_zero_row_upt_k i (Suc k) (snd (Gauss_Jordan_column_k (if \<forall>m. is_zero_row_upt_k m k A then 0 else mod_type_class.to_nat (GREATEST n. \<not> is_zero_row_upt_k n k A) + 1, A) k))

goal (1 subgoal):
 1. is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
is_zero_row_upt_k j (Suc k) (Gauss_Jordan_in_ij A ((GREATEST n. \<not> is_zero_row_upt_k n k A) + (1::'rows)) (mod_type_class.from_nat k))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma convex_affine_closure_Int:
  fixes S T :: "'n::euclidean_space set"
  assumes "convex S"
    and "affine T"
    and "rel_interior S \<inter> T \<noteq> {}"
  shows "closure (S \<inter> T) = closure S \<inter> T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. closure (S \<inter> T) = closure S \<inter> T
[PROOF STEP]
by (metis affine_imp_convex assms convex_closure_inter_two rel_interior_affine rel_interior_eq_closure)


[STATEMENT]
lemma rcis_cmod_Arg: "rcis (cmod z) (Arg z) = z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rcis (cmod z) (Arg z) = z
[PROOF STEP]
by (cases "z = 0") (simp_all add: rcis_def cis_Arg sgn_div_norm of_real_def)


[STATEMENT]
lemma param_apfst[param]:
  "(apfst,apfst)\<in>(Ra\<rightarrow>Rb)\<rightarrow>\<langle>Ra,Rc\<rangle>prod_rel\<rightarrow>\<langle>Rb,Rc\<rangle>prod_rel"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (apfst, apfst) \<in> (Ra \<rightarrow> Rb) \<rightarrow> Ra \<times>\<^sub>r Rc \<rightarrow> Rb \<times>\<^sub>r Rc
[PROOF STEP]
unfolding apfst_def[abs_def]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>f. map_prod f id, \<lambda>f. map_prod f id) \<in> (Ra \<rightarrow> Rb) \<rightarrow> Ra \<times>\<^sub>r Rc \<rightarrow> Rb \<times>\<^sub>r Rc
[PROOF STEP]
by parametricity


[STATEMENT]
lemma dual_all [iff?]: "(\<forall>x. P (dual x)) = (\<forall>x'. P x')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x. P (dual x)) = (\<forall>x'. P x')
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<forall>x. P (dual x)) = (\<forall>x'. P x')
[PROOF STEP]
have "(\<forall>x \<in> UNIV. P (dual x)) = (\<forall>x' \<in> dual ` UNIV. P x')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x\<in>UNIV. P (dual x)) = (\<forall>x'\<in>range dual. P x')
[PROOF STEP]
by (rule dual_ball)
[PROOF STATE]
proof (state)
this:
(\<forall>x\<in>UNIV. P (dual x)) = (\<forall>x'\<in>range dual. P x')

goal (1 subgoal):
 1. (\<forall>x. P (dual x)) = (\<forall>x'. P x')
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<forall>x\<in>UNIV. P (dual x)) = (\<forall>x'\<in>range dual. P x')

goal (1 subgoal):
 1. (\<forall>x. P (dual x)) = (\<forall>x'. P x')
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<forall>x. P (dual x)) = (\<forall>x'. P x')

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma stream_space_eq_distr: "stream_space M = distr (\<Pi>\<^sub>M i\<in>UNIV. M) (stream_space M) to_stream"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. stream_space M = distr (Pi\<^sub>M UNIV (\<lambda>i. M)) (stream_space M) to_stream
[PROOF STEP]
unfolding stream_space_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distr (Pi\<^sub>M UNIV (\<lambda>i. M)) (vimage_algebra (streams (space M)) (!!) (Pi\<^sub>M UNIV (\<lambda>i. M))) to_stream = distr (Pi\<^sub>M UNIV (\<lambda>i. M)) (distr (Pi\<^sub>M UNIV (\<lambda>i. M)) (vimage_algebra (streams (space M)) (!!) (Pi\<^sub>M UNIV (\<lambda>i. M))) to_stream) to_stream
[PROOF STEP]
by (rule distr_cong) auto


[STATEMENT]
lemma homeomorphism_on_compact:
  fixes f::"'a::topological_space \<Rightarrow> 'b::t2_space"
  assumes "continuous_on S f"
          "compact S"
          "inj_on f S"
  shows "homeomorphism_on S f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. homeomorphism_on S f
[PROOF STEP]
unfolding homeomorphism_on_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Ex (homeomorphism S (f ` S) f)
[PROOF STEP]
using homeomorphism_compact[OF assms(2) assms(1) _ assms(3)]
[PROOF STATE]
proof (prove)
using this:
f ` S = ?t \<Longrightarrow> \<exists>g. homeomorphism S ?t f g

goal (1 subgoal):
 1. Ex (homeomorphism S (f ` S) f)
[PROOF STEP]
by auto


[STATEMENT]
lemma col_transitivity_2:
  assumes "P \<noteq> Q" and
    "Col P Q A" and
    "Col P Q B"
  shows "Col Q A B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Col Q A B
[PROOF STEP]
by (metis Tarski_neutral_dimensionless.col_transitivity_1 Tarski_neutral_dimensionless_axioms assms(1) assms(2) assms(3) not_col_permutation_4)