[STATEMENT]
theorem (in field) finite_field_mult_group_has_gen :
  assumes finite: "finite (carrier R)"
  shows "\<exists> a \<in> carrier (mult_of R) . carrier (mult_of R) = {a[^]i | i::nat . i \<in> UNIV}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
note mult_of_simps[simp]
[PROOF STATE]
proof (state)
this:
carrier (mult_of ?R) = carrier ?R - {\<zero>\<^bsub>?R\<^esub>}
(\<otimes>\<^bsub>mult_of ?R\<^esub>) = (\<otimes>\<^bsub>?R\<^esub>)
([^]\<^bsub>mult_of ?R\<^esub>) = ([^]\<^bsub>?R\<^esub>)
\<one>\<^bsub>mult_of ?R\<^esub> = \<one>\<^bsub>?R\<^esub>

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
have finite': "finite (carrier (mult_of R))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (carrier (mult_of R))
[PROOF STEP]
using finite
[PROOF STATE]
proof (prove)
using this:
finite (carrier R)

goal (1 subgoal):
 1. finite (carrier (mult_of R))
[PROOF STEP]
by (rule finite_mult_of)
[PROOF STATE]
proof (state)
this:
finite (carrier (mult_of R))

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
interpret G: group "mult_of R" rewrites
      "([^]\<^bsub>mult_of R\<^esub>) = (([^]) :: _ \<Rightarrow> nat \<Rightarrow> _)" and "\<one>\<^bsub>mult_of R\<^esub> = \<one>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Group.group (mult_of R) &&& ([^]\<^bsub>mult_of R\<^esub>) = ([^]) &&& \<one>\<^bsub>mult_of R\<^esub> = \<one>
[PROOF STEP]
by (rule field_mult_group) (simp_all add: fun_eq_iff nat_pow_def)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
let ?N = "\<lambda> x . card {a \<in> carrier (mult_of R). group.ord (mult_of R) a  = x}"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
have "0 < order R - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < order R - 1
[PROOF STEP]
unfolding order_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < card (carrier R) - 1
[PROOF STEP]
using card_mono[OF finite, of "{\<zero>, \<one>}"]
[PROOF STATE]
proof (prove)
using this:
{\<zero>, \<one>} \<subseteq> carrier R \<Longrightarrow> card {\<zero>, \<one>} \<le> card (carrier R)

goal (1 subgoal):
 1. 0 < card (carrier R) - 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 < order R - 1

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 < order R - 1
[PROOF STEP]
have *: "0 < order (mult_of R)"
[PROOF STATE]
proof (prove)
using this:
0 < order R - 1

goal (1 subgoal):
 1. 0 < order (mult_of R)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < order R - 1
finite (carrier R)

goal (1 subgoal):
 1. 0 < order (mult_of R)
[PROOF STEP]
by (simp add: order_mult_of)
[PROOF STATE]
proof (state)
this:
0 < order (mult_of R)

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
have fin: "finite {d. d dvd order (mult_of R) }"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {d. d dvd order (mult_of R)}
[PROOF STEP]
using dvd_nat_bounds[OF *]
[PROOF STATE]
proof (prove)
using this:
?n dvd order (mult_of R) \<Longrightarrow> 0 < ?n \<and> ?n \<le> order (mult_of R)

goal (1 subgoal):
 1. finite {d. d dvd order (mult_of R)}
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
finite {d. d dvd order (mult_of R)}

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
have "(\<Sum>d | d dvd order (mult_of R). ?N d)
      = card (UN d:{d . d dvd order (mult_of R) }. {a \<in> carrier (mult_of R). group.ord (mult_of R) a  = d})"
      (is "_ = card ?U")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>d | d dvd order (mult_of R). card {a \<in> carrier (mult_of R). G.ord a = d}) = card (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d})
[PROOF STEP]
using fin finite
[PROOF STATE]
proof (prove)
using this:
finite {d. d dvd order (mult_of R)}
finite (carrier R)

goal (1 subgoal):
 1. (\<Sum>d | d dvd order (mult_of R). card {a \<in> carrier (mult_of R). G.ord a = d}) = card (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d})
[PROOF STEP]
by (subst card_UN_disjoint) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd order (mult_of R). card {a \<in> carrier (mult_of R). G.ord a = d}) = card (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d})

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd order (mult_of R). card {a \<in> carrier (mult_of R). G.ord a = d}) = card (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d})

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
have "?U = carrier (mult_of R)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d}) = carrier (mult_of R)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d}) \<subseteq> carrier (mult_of R)
 2. carrier (mult_of R) \<subseteq> (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d})
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d}) \<subseteq> carrier (mult_of R)
 2. carrier (mult_of R) \<subseteq> (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d})
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d}) \<subseteq> carrier (mult_of R)
 2. carrier (mult_of R) \<subseteq> (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d})
[PROOF STEP]
assume x: "x \<in> carrier (mult_of R)"
[PROOF STATE]
proof (state)
this:
x \<in> carrier (mult_of R)

goal (2 subgoals):
 1. (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d}) \<subseteq> carrier (mult_of R)
 2. carrier (mult_of R) \<subseteq> (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d})
[PROOF STEP]
hence x': "x\<in>carrier (mult_of R)"
[PROOF STATE]
proof (prove)
using this:
x \<in> carrier (mult_of R)

goal (1 subgoal):
 1. x \<in> carrier (mult_of R)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
x \<in> carrier (mult_of R)

goal (2 subgoals):
 1. (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d}) \<subseteq> carrier (mult_of R)
 2. carrier (mult_of R) \<subseteq> (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d})
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> carrier (mult_of R)
[PROOF STEP]
have "group.ord (mult_of R) x dvd order (mult_of R)"
[PROOF STATE]
proof (prove)
using this:
x \<in> carrier (mult_of R)

goal (1 subgoal):
 1. G.ord x dvd order (mult_of R)
[PROOF STEP]
using G.ord_dvd_group_order
[PROOF STATE]
proof (prove)
using this:
x \<in> carrier (mult_of R)
?a \<in> carrier (mult_of R) \<Longrightarrow> G.ord ?a dvd order (mult_of R)

goal (1 subgoal):
 1. G.ord x dvd order (mult_of R)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
G.ord x dvd order (mult_of R)

goal (2 subgoals):
 1. (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d}) \<subseteq> carrier (mult_of R)
 2. carrier (mult_of R) \<subseteq> (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d})
[PROOF STEP]
hence "x \<in> ?U"
[PROOF STATE]
proof (prove)
using this:
G.ord x dvd order (mult_of R)

goal (1 subgoal):
 1. x \<in> (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d})
[PROOF STEP]
using dvd_nat_bounds[of "order (mult_of R)" "group.ord (mult_of R) x"] x
[PROOF STATE]
proof (prove)
using this:
G.ord x dvd order (mult_of R)
\<lbrakk>0 < order (mult_of R); G.ord x dvd order (mult_of R)\<rbrakk> \<Longrightarrow> 0 < G.ord x \<and> G.ord x \<le> order (mult_of R)
x \<in> carrier (mult_of R)

goal (1 subgoal):
 1. x \<in> (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d})
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
x \<in> (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d})

goal (2 subgoals):
 1. (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d}) \<subseteq> carrier (mult_of R)
 2. carrier (mult_of R) \<subseteq> (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d})
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?x2 \<in> carrier (mult_of R) \<Longrightarrow> ?x2 \<in> (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d})

goal (2 subgoals):
 1. (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d}) \<subseteq> carrier (mult_of R)
 2. carrier (mult_of R) \<subseteq> (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d})
[PROOF STEP]
thus "carrier (mult_of R) \<subseteq> ?U"
[PROOF STATE]
proof (prove)
using this:
?x2 \<in> carrier (mult_of R) \<Longrightarrow> ?x2 \<in> (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d})

goal (1 subgoal):
 1. carrier (mult_of R) \<subseteq> (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d})
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
carrier (mult_of R) \<subseteq> (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d})

goal (1 subgoal):
 1. (\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d}) \<subseteq> carrier (mult_of R)
[PROOF STEP]
qed auto
[PROOF STATE]
proof (state)
this:
(\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d}) = carrier (mult_of R)

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Union>d\<in>{d. d dvd order (mult_of R)}. {a \<in> carrier (mult_of R). G.ord a = d}) = carrier (mult_of R)

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
have "card ... = order (mult_of R)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (carrier (mult_of R)) = order (mult_of R)
[PROOF STEP]
using order_mult_of finite'
[PROOF STATE]
proof (prove)
using this:
finite (carrier R) \<Longrightarrow> order (mult_of R) = order R - 1
finite (carrier (mult_of R))

goal (1 subgoal):
 1. card (carrier (mult_of R)) = order (mult_of R)
[PROOF STEP]
by (simp add: order_def)
[PROOF STATE]
proof (state)
this:
card (carrier (mult_of R)) = order (mult_of R)

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>d | d dvd order (mult_of R). card {a \<in> carrier (mult_of R). G.ord a = d}) = order (mult_of R)
[PROOF STEP]
have sum_Ns_eq: "(\<Sum>d | d dvd order (mult_of R). ?N d) = order (mult_of R)"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>d | d dvd order (mult_of R). card {a \<in> carrier (mult_of R). G.ord a = d}) = order (mult_of R)

goal (1 subgoal):
 1. (\<Sum>d | d dvd order (mult_of R). card {a \<in> carrier (mult_of R). G.ord a = d}) = order (mult_of R)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd order (mult_of R). card {a \<in> carrier (mult_of R). G.ord a = d}) = order (mult_of R)

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd order (mult_of R). card {a \<in> carrier (mult_of R). G.ord a = d}) = order (mult_of R)

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
fix d
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
assume d: "d dvd order (mult_of R)"
[PROOF STATE]
proof (state)
this:
d dvd order (mult_of R)

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
have "card {a \<in> carrier (mult_of R). group.ord (mult_of R) a = d} \<le> phi' d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {a \<in> carrier (mult_of R). G.ord a = d} \<le> phi' d
[PROOF STEP]
proof cases
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ?P \<Longrightarrow> card {a \<in> carrier (mult_of R). G.ord a = d} \<le> phi' d
 2. \<not> ?P \<Longrightarrow> card {a \<in> carrier (mult_of R). G.ord a = d} \<le> phi' d
[PROOF STEP]
assume "card {a \<in> carrier (mult_of R). group.ord (mult_of R) a = d} = 0"
[PROOF STATE]
proof (state)
this:
card {a \<in> carrier (mult_of R). G.ord a = d} = 0

goal (2 subgoals):
 1. ?P \<Longrightarrow> card {a \<in> carrier (mult_of R). G.ord a = d} \<le> phi' d
 2. \<not> ?P \<Longrightarrow> card {a \<in> carrier (mult_of R). G.ord a = d} \<le> phi' d
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
card {a \<in> carrier (mult_of R). G.ord a = d} = 0

goal (1 subgoal):
 1. card {a \<in> carrier (mult_of R). G.ord a = d} \<le> phi' d
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
card {a \<in> carrier (mult_of R). G.ord a = d} \<le> phi' d

goal (1 subgoal):
 1. card {a \<in> carrier (mult_of R). G.ord a = d} \<noteq> 0 \<Longrightarrow> card {a \<in> carrier (mult_of R). G.ord a = d} \<le> phi' d
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card {a \<in> carrier (mult_of R). G.ord a = d} \<noteq> 0 \<Longrightarrow> card {a \<in> carrier (mult_of R). G.ord a = d} \<le> phi' d
[PROOF STEP]
assume "card {a \<in> carrier (mult_of R). group.ord (mult_of R) a = d} \<noteq> 0"
[PROOF STATE]
proof (state)
this:
card {a \<in> carrier (mult_of R). G.ord a = d} \<noteq> 0

goal (1 subgoal):
 1. card {a \<in> carrier (mult_of R). G.ord a = d} \<noteq> 0 \<Longrightarrow> card {a \<in> carrier (mult_of R). G.ord a = d} \<le> phi' d
[PROOF STEP]
hence "\<exists>a \<in> carrier (mult_of R). group.ord (mult_of R) a = d"
[PROOF STATE]
proof (prove)
using this:
card {a \<in> carrier (mult_of R). G.ord a = d} \<noteq> 0

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). G.ord a = d
[PROOF STEP]
by (auto simp: card_eq_0_iff)
[PROOF STATE]
proof (state)
this:
\<exists>a\<in>carrier (mult_of R). G.ord a = d

goal (1 subgoal):
 1. card {a \<in> carrier (mult_of R). G.ord a = d} \<noteq> 0 \<Longrightarrow> card {a \<in> carrier (mult_of R). G.ord a = d} \<le> phi' d
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<exists>a\<in>carrier (mult_of R). G.ord a = d

goal (1 subgoal):
 1. card {a \<in> carrier (mult_of R). G.ord a = d} \<le> phi' d
[PROOF STEP]
using num_elems_of_ord_eq_phi'[OF finite d]
[PROOF STATE]
proof (prove)
using this:
\<exists>a\<in>carrier (mult_of R). G.ord a = d
\<exists>a\<in>carrier (mult_of R). G.ord a = d \<Longrightarrow> card {a \<in> carrier (mult_of R). G.ord a = d} = phi' d

goal (1 subgoal):
 1. card {a \<in> carrier (mult_of R). G.ord a = d} \<le> phi' d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card {a \<in> carrier (mult_of R). G.ord a = d} \<le> phi' d

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
card {a \<in> carrier (mult_of R). G.ord a = d} \<le> phi' d

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?d2 dvd order (mult_of R) \<Longrightarrow> card {a \<in> carrier (mult_of R). G.ord a = ?d2} \<le> phi' ?d2

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
hence all_le: "\<And>i. i \<in> {d. d dvd order (mult_of R) }
        \<Longrightarrow> (\<lambda>i. card {a \<in> carrier (mult_of R). group.ord (mult_of R) a = i}) i \<le> (\<lambda>i. phi' i) i"
[PROOF STATE]
proof (prove)
using this:
?d2 dvd order (mult_of R) \<Longrightarrow> card {a \<in> carrier (mult_of R). G.ord a = ?d2} \<le> phi' ?d2

goal (1 subgoal):
 1. \<And>i. i \<in> {d. d dvd order (mult_of R)} \<Longrightarrow> card {a \<in> carrier (mult_of R). G.ord a = i} \<le> phi' i
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
?i \<in> {d. d dvd order (mult_of R)} \<Longrightarrow> card {a \<in> carrier (mult_of R). G.ord a = ?i} \<le> phi' ?i

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
hence le: "(\<Sum>i | i dvd order (mult_of R). ?N i)
            \<le> (\<Sum>i | i dvd order (mult_of R). phi' i)"
[PROOF STATE]
proof (prove)
using this:
?i \<in> {d. d dvd order (mult_of R)} \<Longrightarrow> card {a \<in> carrier (mult_of R). G.ord a = ?i} \<le> phi' ?i

goal (1 subgoal):
 1. (\<Sum>i | i dvd order (mult_of R). card {a \<in> carrier (mult_of R). G.ord a = i}) \<le> (\<Sum>i | i dvd order (mult_of R). phi' i)
[PROOF STEP]
using sum_mono[of "{d .  d dvd order (mult_of R)}"
                  "\<lambda>i. card {a \<in> carrier (mult_of R). group.ord (mult_of R) a = i}"]
[PROOF STATE]
proof (prove)
using this:
?i \<in> {d. d dvd order (mult_of R)} \<Longrightarrow> card {a \<in> carrier (mult_of R). G.ord a = ?i} \<le> phi' ?i
(\<And>i. i \<in> {d. d dvd order (mult_of R)} \<Longrightarrow> card {a \<in> carrier (mult_of R). G.ord a = i} \<le> ?g i) \<Longrightarrow> (\<Sum>i\<in>{d. d dvd order (mult_of R)}. card {a \<in> carrier (mult_of R). G.ord a = i}) \<le> sum ?g {d. d dvd order (mult_of R)}

goal (1 subgoal):
 1. (\<Sum>i | i dvd order (mult_of R). card {a \<in> carrier (mult_of R). G.ord a = i}) \<le> (\<Sum>i | i dvd order (mult_of R). phi' i)
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
(\<Sum>i | i dvd order (mult_of R). card {a \<in> carrier (mult_of R). G.ord a = i}) \<le> (\<Sum>i | i dvd order (mult_of R). phi' i)

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
have "order (mult_of R) = (\<Sum>d | d dvd order (mult_of R). phi' d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. order (mult_of R) = (\<Sum>d | d dvd order (mult_of R). phi' d)
[PROOF STEP]
using *
[PROOF STATE]
proof (prove)
using this:
0 < order (mult_of R)

goal (1 subgoal):
 1. order (mult_of R) = (\<Sum>d | d dvd order (mult_of R). phi' d)
[PROOF STEP]
by (simp add: sum_phi'_factors)
[PROOF STATE]
proof (state)
this:
order (mult_of R) = (\<Sum>d | d dvd order (mult_of R). phi' d)

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
hence eq: "(\<Sum>i | i dvd order (mult_of R). ?N i)
          = (\<Sum>i | i dvd order (mult_of R). phi' i)"
[PROOF STATE]
proof (prove)
using this:
order (mult_of R) = (\<Sum>d | d dvd order (mult_of R). phi' d)

goal (1 subgoal):
 1. (\<Sum>i | i dvd order (mult_of R). card {a \<in> carrier (mult_of R). G.ord a = i}) = (\<Sum>i | i dvd order (mult_of R). phi' i)
[PROOF STEP]
using le sum_Ns_eq
[PROOF STATE]
proof (prove)
using this:
order (mult_of R) = (\<Sum>d | d dvd order (mult_of R). phi' d)
(\<Sum>i | i dvd order (mult_of R). card {a \<in> carrier (mult_of R). G.ord a = i}) \<le> (\<Sum>i | i dvd order (mult_of R). phi' i)
(\<Sum>d | d dvd order (mult_of R). card {a \<in> carrier (mult_of R). G.ord a = d}) = order (mult_of R)

goal (1 subgoal):
 1. (\<Sum>i | i dvd order (mult_of R). card {a \<in> carrier (mult_of R). G.ord a = i}) = (\<Sum>i | i dvd order (mult_of R). phi' i)
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
(\<Sum>i | i dvd order (mult_of R). card {a \<in> carrier (mult_of R). G.ord a = i}) = (\<Sum>i | i dvd order (mult_of R). phi' i)

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
have "\<And>i. i \<in> {d. d dvd order (mult_of R) } \<Longrightarrow> ?N i = (\<lambda>i. phi' i) i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i \<in> {d. d dvd order (mult_of R)} \<Longrightarrow> card {a \<in> carrier (mult_of R). G.ord a = i} = phi' i
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. \<lbrakk>i \<in> {d. d dvd order (mult_of R)}; card {a \<in> carrier (mult_of R). G.ord a = i} \<noteq> phi' i\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. \<lbrakk>i \<in> {d. d dvd order (mult_of R)}; card {a \<in> carrier (mult_of R). G.ord a = i} \<noteq> phi' i\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
assume i1: "i \<in> {d. d dvd order (mult_of R)}" and "?N i \<noteq> phi' i"
[PROOF STATE]
proof (state)
this:
i \<in> {d. d dvd order (mult_of R)}
card {a \<in> carrier (mult_of R). G.ord a = i} \<noteq> phi' i

goal (1 subgoal):
 1. \<And>i. \<lbrakk>i \<in> {d. d dvd order (mult_of R)}; card {a \<in> carrier (mult_of R). G.ord a = i} \<noteq> phi' i\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
hence "?N i = 0"
[PROOF STATE]
proof (prove)
using this:
i \<in> {d. d dvd order (mult_of R)}
card {a \<in> carrier (mult_of R). G.ord a = i} \<noteq> phi' i

goal (1 subgoal):
 1. card {a \<in> carrier (mult_of R). G.ord a = i} = 0
[PROOF STEP]
using num_elems_of_ord_eq_phi'[OF finite, of i]
[PROOF STATE]
proof (prove)
using this:
i \<in> {d. d dvd order (mult_of R)}
card {a \<in> carrier (mult_of R). G.ord a = i} \<noteq> phi' i
\<lbrakk>i dvd order (mult_of R); \<exists>a\<in>carrier (mult_of R). G.ord a = i\<rbrakk> \<Longrightarrow> card {a \<in> carrier (mult_of R). G.ord a = i} = phi' i

goal (1 subgoal):
 1. card {a \<in> carrier (mult_of R). G.ord a = i} = 0
[PROOF STEP]
by (auto simp: card_eq_0_iff)
[PROOF STATE]
proof (state)
this:
card {a \<in> carrier (mult_of R). G.ord a = i} = 0

goal (1 subgoal):
 1. \<And>i. \<lbrakk>i \<in> {d. d dvd order (mult_of R)}; card {a \<in> carrier (mult_of R). G.ord a = i} \<noteq> phi' i\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
card {a \<in> carrier (mult_of R). G.ord a = i} = 0

goal (1 subgoal):
 1. \<And>i. \<lbrakk>i \<in> {d. d dvd order (mult_of R)}; card {a \<in> carrier (mult_of R). G.ord a = i} \<noteq> phi' i\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
have "0 < i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < i
[PROOF STEP]
using * i1
[PROOF STATE]
proof (prove)
using this:
0 < order (mult_of R)
i \<in> {d. d dvd order (mult_of R)}

goal (1 subgoal):
 1. 0 < i
[PROOF STEP]
by (simp add: dvd_nat_bounds[of "order (mult_of R)" i])
[PROOF STATE]
proof (state)
this:
0 < i

goal (1 subgoal):
 1. \<And>i. \<lbrakk>i \<in> {d. d dvd order (mult_of R)}; card {a \<in> carrier (mult_of R). G.ord a = i} \<noteq> phi' i\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
card {a \<in> carrier (mult_of R). G.ord a = i} = 0
0 < i
[PROOF STEP]
have "?N i < phi' i"
[PROOF STATE]
proof (prove)
using this:
card {a \<in> carrier (mult_of R). G.ord a = i} = 0
0 < i

goal (1 subgoal):
 1. card {a \<in> carrier (mult_of R). G.ord a = i} < phi' i
[PROOF STEP]
using phi'_nonzero
[PROOF STATE]
proof (prove)
using this:
card {a \<in> carrier (mult_of R). G.ord a = i} = 0
0 < i
0 < ?m \<Longrightarrow> 0 < phi' ?m

goal (1 subgoal):
 1. card {a \<in> carrier (mult_of R). G.ord a = i} < phi' i
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
card {a \<in> carrier (mult_of R). G.ord a = i} < phi' i

goal (1 subgoal):
 1. \<And>i. \<lbrakk>i \<in> {d. d dvd order (mult_of R)}; card {a \<in> carrier (mult_of R). G.ord a = i} \<noteq> phi' i\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
hence "(\<Sum>i | i dvd order (mult_of R). ?N i)
         < (\<Sum>i | i dvd order (mult_of R). phi' i)"
[PROOF STATE]
proof (prove)
using this:
card {a \<in> carrier (mult_of R). G.ord a = i} < phi' i

goal (1 subgoal):
 1. (\<Sum>i | i dvd order (mult_of R). card {a \<in> carrier (mult_of R). G.ord a = i}) < (\<Sum>i | i dvd order (mult_of R). phi' i)
[PROOF STEP]
using sum_strict_mono_ex1[OF fin, of "?N" "\<lambda> i . phi' i"]
            i1 all_le
[PROOF STATE]
proof (prove)
using this:
card {a \<in> carrier (mult_of R). G.ord a = i} < phi' i
\<lbrakk>\<forall>x\<in>{d. d dvd order (mult_of R)}. card {a \<in> carrier (mult_of R). G.ord a = x} \<le> phi' x; \<exists>a\<in>{d. d dvd order (mult_of R)}. card {aa \<in> carrier (mult_of R). G.ord aa = a} < phi' a\<rbrakk> \<Longrightarrow> (\<Sum>x\<in>{d. d dvd order (mult_of R)}. card {a \<in> carrier (mult_of R). G.ord a = x}) < sum phi' {d. d dvd order (mult_of R)}
i \<in> {d. d dvd order (mult_of R)}
?i \<in> {d. d dvd order (mult_of R)} \<Longrightarrow> card {a \<in> carrier (mult_of R). G.ord a = ?i} \<le> phi' ?i

goal (1 subgoal):
 1. (\<Sum>i | i dvd order (mult_of R). card {a \<in> carrier (mult_of R). G.ord a = i}) < (\<Sum>i | i dvd order (mult_of R). phi' i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>i | i dvd order (mult_of R). card {a \<in> carrier (mult_of R). G.ord a = i}) < (\<Sum>i | i dvd order (mult_of R). phi' i)

goal (1 subgoal):
 1. \<And>i. \<lbrakk>i \<in> {d. d dvd order (mult_of R)}; card {a \<in> carrier (mult_of R). G.ord a = i} \<noteq> phi' i\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
thus False
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i | i dvd order (mult_of R). card {a \<in> carrier (mult_of R). G.ord a = i}) < (\<Sum>i | i dvd order (mult_of R). phi' i)

goal (1 subgoal):
 1. False
[PROOF STEP]
using eq
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i | i dvd order (mult_of R). card {a \<in> carrier (mult_of R). G.ord a = i}) < (\<Sum>i | i dvd order (mult_of R). phi' i)
(\<Sum>i | i dvd order (mult_of R). card {a \<in> carrier (mult_of R). G.ord a = i}) = (\<Sum>i | i dvd order (mult_of R). phi' i)

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?i \<in> {d. d dvd order (mult_of R)} \<Longrightarrow> card {a \<in> carrier (mult_of R). G.ord a = ?i} = phi' ?i

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
hence "?N (order (mult_of R)) > 0"
[PROOF STATE]
proof (prove)
using this:
?i \<in> {d. d dvd order (mult_of R)} \<Longrightarrow> card {a \<in> carrier (mult_of R). G.ord a = ?i} = phi' ?i

goal (1 subgoal):
 1. 0 < card {a \<in> carrier (mult_of R). G.ord a = order (mult_of R)}
[PROOF STEP]
using *
[PROOF STATE]
proof (prove)
using this:
?i \<in> {d. d dvd order (mult_of R)} \<Longrightarrow> card {a \<in> carrier (mult_of R). G.ord a = ?i} = phi' ?i
0 < order (mult_of R)

goal (1 subgoal):
 1. 0 < card {a \<in> carrier (mult_of R). G.ord a = order (mult_of R)}
[PROOF STEP]
by (simp add: phi'_nonzero)
[PROOF STATE]
proof (state)
this:
0 < card {a \<in> carrier (mult_of R). G.ord a = order (mult_of R)}

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 < card {a \<in> carrier (mult_of R). G.ord a = order (mult_of R)}
[PROOF STEP]
obtain a where a: "a \<in> carrier (mult_of R)" and a_ord: "group.ord (mult_of R) a = order (mult_of R)"
[PROOF STATE]
proof (prove)
using this:
0 < card {a \<in> carrier (mult_of R). G.ord a = order (mult_of R)}

goal (1 subgoal):
 1. (\<And>a. \<lbrakk>a \<in> carrier (mult_of R); G.ord a = order (mult_of R)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp add: card_gt_0_iff)
[PROOF STATE]
proof (state)
this:
a \<in> carrier (mult_of R)
G.ord a = order (mult_of R)

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
hence set_eq: "{a[^]i | i::nat. i \<in> UNIV} = (\<lambda>x. a[^]x) ` {0 .. group.ord (mult_of R) a - 1}"
[PROOF STATE]
proof (prove)
using this:
a \<in> carrier (mult_of R)
G.ord a = order (mult_of R)

goal (1 subgoal):
 1. {a [^] i |i. i \<in> UNIV} = ([^]) a ` {0..G.ord a - 1}
[PROOF STEP]
using G.ord_elems[OF finite']
[PROOF STATE]
proof (prove)
using this:
a \<in> carrier (mult_of R)
G.ord a = order (mult_of R)
?a \<in> carrier (mult_of R) \<Longrightarrow> {?a [^] x |x. x \<in> UNIV} = {?a [^] x |x. x \<in> {0..G.ord ?a - 1}}

goal (1 subgoal):
 1. {a [^] i |i. i \<in> UNIV} = ([^]) a ` {0..G.ord a - 1}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{a [^] i |i. i \<in> UNIV} = ([^]) a ` {0..G.ord a - 1}

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
have card_eq: "card ((\<lambda>x. a[^]x) ` {0 .. group.ord (mult_of R) a - 1}) = card {0 .. group.ord (mult_of R) a - 1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (([^]) a ` {0..G.ord a - 1}) = card {0..G.ord a - 1}
[PROOF STEP]
by (intro card_image G.ord_inj finite' a)
[PROOF STATE]
proof (state)
this:
card (([^]) a ` {0..G.ord a - 1}) = card {0..G.ord a - 1}

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
hence "card ((\<lambda> x . a[^]x) ` {0 .. group.ord (mult_of R) a - 1}) = card {0 ..order (mult_of R) - 1}"
[PROOF STATE]
proof (prove)
using this:
card (([^]) a ` {0..G.ord a - 1}) = card {0..G.ord a - 1}

goal (1 subgoal):
 1. card (([^]) a ` {0..G.ord a - 1}) = card {0..order (mult_of R) - 1}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
card (([^]) a ` {0..G.ord a - 1}) = card {0..G.ord a - 1}
finite (carrier R)

goal (1 subgoal):
 1. card (([^]) a ` {0..G.ord a - 1}) = card {0..order (mult_of R) - 1}
[PROOF STEP]
by (simp add: card_eq a_ord)
[PROOF STATE]
proof (state)
this:
card (([^]) a ` {0..G.ord a - 1}) = card {0..order (mult_of R) - 1}

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
hence card_R_minus_1: "card {a[^]i | i::nat. i \<in> UNIV} =  order (mult_of R)"
[PROOF STATE]
proof (prove)
using this:
card (([^]) a ` {0..G.ord a - 1}) = card {0..order (mult_of R) - 1}

goal (1 subgoal):
 1. card {a [^] i |i. i \<in> UNIV} = order (mult_of R)
[PROOF STEP]
using *
[PROOF STATE]
proof (prove)
using this:
card (([^]) a ` {0..G.ord a - 1}) = card {0..order (mult_of R) - 1}
0 < order (mult_of R)

goal (1 subgoal):
 1. card {a [^] i |i. i \<in> UNIV} = order (mult_of R)
[PROOF STEP]
by (subst set_eq) auto
[PROOF STATE]
proof (state)
this:
card {a [^] i |i. i \<in> UNIV} = order (mult_of R)

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
have **: "{a[^]i | i::nat. i \<in> UNIV} \<subseteq> carrier (mult_of R)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {a [^] i |i. i \<in> UNIV} \<subseteq> carrier (mult_of R)
[PROOF STEP]
using G.nat_pow_closed[OF a]
[PROOF STATE]
proof (prove)
using this:
a [^] ?n \<in> carrier (mult_of R)

goal (1 subgoal):
 1. {a [^] i |i. i \<in> UNIV} \<subseteq> carrier (mult_of R)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{a [^] i |i. i \<in> UNIV} \<subseteq> carrier (mult_of R)

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
with _
[PROOF STATE]
proof (chain)
picking this:
PROP ?psi \<Longrightarrow> PROP ?psi
{a [^] i |i. i \<in> UNIV} \<subseteq> carrier (mult_of R)
[PROOF STEP]
have "carrier (mult_of R) = {a[^]i|i::nat. i \<in> UNIV}"
[PROOF STATE]
proof (prove)
using this:
PROP ?psi \<Longrightarrow> PROP ?psi
{a [^] i |i. i \<in> UNIV} \<subseteq> carrier (mult_of R)

goal (1 subgoal):
 1. carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
by (rule card_seteq[symmetric]) (simp_all add: card_R_minus_1 finite order_def del: UNIV_I)
[PROOF STATE]
proof (state)
this:
carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
using a
[PROOF STATE]
proof (prove)
using this:
carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
a \<in> carrier (mult_of R)

goal (1 subgoal):
 1. \<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>a\<in>carrier (mult_of R). carrier (mult_of R) = {a [^] i |i. i \<in> UNIV}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in group) IDirProd_one_right:
  assumes "A \<subseteq> carrier G"
  shows "IDirProd G A {\<one>} = generate G A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. IDirProd G A {\<one>} = generate G A
[PROOF STEP]
unfolding IDirProd_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. generate G (A \<union> {\<one>}) = generate G A
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. generate G (A \<union> {\<one>}) \<subseteq> generate G A
 2. generate G A \<subseteq> generate G (A \<union> {\<one>})
[PROOF STEP]
interpret sA: subgroup "(generate G A)" G
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. subgroup (generate G A) G
[PROOF STEP]
using assms generate_is_subgroup
[PROOF STATE]
proof (prove)
using this:
A \<subseteq> carrier G
?H \<subseteq> carrier G \<Longrightarrow> subgroup (generate G ?H) G

goal (1 subgoal):
 1. subgroup (generate G A) G
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. generate G (A \<union> {\<one>}) \<subseteq> generate G A
 2. generate G A \<subseteq> generate G (A \<union> {\<one>})
[PROOF STEP]
interpret sAone: subgroup "(generate G (A \<union> {\<one>}))" G
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. subgroup (generate G (A \<union> {\<one>})) G
[PROOF STEP]
using assms generate_is_subgroup
[PROOF STATE]
proof (prove)
using this:
A \<subseteq> carrier G
?H \<subseteq> carrier G \<Longrightarrow> subgroup (generate G ?H) G

goal (1 subgoal):
 1. subgroup (generate G (A \<union> {\<one>})) G
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. generate G (A \<union> {\<one>}) \<subseteq> generate G A
 2. generate G A \<subseteq> generate G (A \<union> {\<one>})
[PROOF STEP]
show "generate G (A \<union> {\<one>}) \<subseteq> generate G A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. generate G (A \<union> {\<one>}) \<subseteq> generate G A
[PROOF STEP]
using generate_subgroup_incl[of "A \<union> {\<one>}" "generate G A"]
          generate.incl assms sA.one_closed sA.subgroup_axioms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>A \<union> {\<one>} \<subseteq> generate G A; subgroup (generate G A) G\<rbrakk> \<Longrightarrow> generate G (A \<union> {\<one>}) \<subseteq> generate G A
?h \<in> ?H \<Longrightarrow> ?h \<in> generate ?G ?H
A \<subseteq> carrier G
\<one> \<in> generate G A
subgroup (generate G A) G

goal (1 subgoal):
 1. generate G (A \<union> {\<one>}) \<subseteq> generate G A
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
generate G (A \<union> {\<one>}) \<subseteq> generate G A

goal (1 subgoal):
 1. generate G A \<subseteq> generate G (A \<union> {\<one>})
[PROOF STEP]
show "generate G A \<subseteq> generate G (A \<union> {\<one>})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. generate G A \<subseteq> generate G (A \<union> {\<one>})
[PROOF STEP]
using mono_generate[of A "A \<union> {\<one>}"]
[PROOF STATE]
proof (prove)
using this:
A \<subseteq> A \<union> {\<one>} \<Longrightarrow> generate G A \<subseteq> generate G (A \<union> {\<one>})

goal (1 subgoal):
 1. generate G A \<subseteq> generate G (A \<union> {\<one>})
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
generate G A \<subseteq> generate G (A \<union> {\<one>})

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ker_of_idmap:"Ring A \<Longrightarrow> ker\<^bsub>A,A\<^esub> (ridmap A) = {\<zero>\<^bsub>A\<^esub>}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Ring A \<Longrightarrow> ker\<^bsub>A,A\<^esub> ridmap A = {\<zero>\<^bsub>A\<^esub>}
[PROOF STEP]
apply (simp add:ker_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Ring A \<Longrightarrow> {a \<in> carrier A. ridmap A a = \<zero>\<^bsub>A\<^esub>} = {\<zero>\<^bsub>A\<^esub>}
[PROOF STEP]
apply (simp add:ridmap_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Ring A \<Longrightarrow> {a. (a \<in> carrier A \<longrightarrow> a = \<zero>\<^bsub>A\<^esub>) \<and> a \<in> carrier A} = {\<zero>\<^bsub>A\<^esub>}
[PROOF STEP]
apply (rule equalityI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. Ring A \<Longrightarrow> {a. (a \<in> carrier A \<longrightarrow> a = \<zero>\<^bsub>A\<^esub>) \<and> a \<in> carrier A} \<subseteq> {\<zero>\<^bsub>A\<^esub>}
 2. Ring A \<Longrightarrow> {\<zero>\<^bsub>A\<^esub>} \<subseteq> {a. (a \<in> carrier A \<longrightarrow> a = \<zero>\<^bsub>A\<^esub>) \<and> a \<in> carrier A}
[PROOF STEP]
apply (rule subsetI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x. \<lbrakk>Ring A; x \<in> {a. (a \<in> carrier A \<longrightarrow> a = \<zero>\<^bsub>A\<^esub>) \<and> a \<in> carrier A}\<rbrakk> \<Longrightarrow> x \<in> {\<zero>\<^bsub>A\<^esub>}
 2. Ring A \<Longrightarrow> {\<zero>\<^bsub>A\<^esub>} \<subseteq> {a. (a \<in> carrier A \<longrightarrow> a = \<zero>\<^bsub>A\<^esub>) \<and> a \<in> carrier A}
[PROOF STEP]
apply (simp add:CollectI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Ring A \<Longrightarrow> {\<zero>\<^bsub>A\<^esub>} \<subseteq> {a. (a \<in> carrier A \<longrightarrow> a = \<zero>\<^bsub>A\<^esub>) \<and> a \<in> carrier A}
[PROOF STEP]
apply (rule subsetI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>Ring A; x \<in> {\<zero>\<^bsub>A\<^esub>}\<rbrakk> \<Longrightarrow> x \<in> {a. (a \<in> carrier A \<longrightarrow> a = \<zero>\<^bsub>A\<^esub>) \<and> a \<in> carrier A}
[PROOF STEP]
apply (simp add:CollectI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>Ring A; x = \<zero>\<^bsub>A\<^esub>\<rbrakk> \<Longrightarrow> \<zero>\<^bsub>A\<^esub> \<in> carrier A
[PROOF STEP]
apply (simp add:Ring.ring_zero)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma iMin_Un[rule_format]: "
  \<lbrakk> A \<noteq> {}; B \<noteq> {} \<rbrakk> \<Longrightarrow>
  iMin (A \<union> B) = min (iMin A) (iMin B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A \<noteq> {}; B \<noteq> {}\<rbrakk> \<Longrightarrow> iMin (A \<union> B) = min (iMin A) (iMin B)
[PROOF STEP]
apply (rule order_antisym)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>A \<noteq> {}; B \<noteq> {}\<rbrakk> \<Longrightarrow> iMin (A \<union> B) \<le> min (iMin A) (iMin B)
 2. \<lbrakk>A \<noteq> {}; B \<noteq> {}\<rbrakk> \<Longrightarrow> min (iMin A) (iMin B) \<le> iMin (A \<union> B)
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>A \<noteq> {}; B \<noteq> {}\<rbrakk> \<Longrightarrow> iMin (A \<union> B) \<le> iMin A \<and> iMin (A \<union> B) \<le> iMin B
 2. \<lbrakk>A \<noteq> {}; B \<noteq> {}\<rbrakk> \<Longrightarrow> min (iMin A) (iMin B) \<le> iMin (A \<union> B)
[PROOF STEP]
apply (blast intro: iMin_subset)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A \<noteq> {}; B \<noteq> {}\<rbrakk> \<Longrightarrow> min (iMin A) (iMin B) \<le> iMin (A \<union> B)
[PROOF STEP]
apply (simp add: min_le_iff_disj)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A \<noteq> {}; B \<noteq> {}\<rbrakk> \<Longrightarrow> iMin A \<le> iMin (A \<union> B) \<or> iMin B \<le> iMin (A \<union> B)
[PROOF STEP]
apply (insert iMinI_ex2[of "A\<union>B"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A \<noteq> {}; B \<noteq> {}; A \<union> B \<noteq> {} \<Longrightarrow> iMin (A \<union> B) \<in> A \<union> B\<rbrakk> \<Longrightarrow> iMin A \<le> iMin (A \<union> B) \<or> iMin B \<le> iMin (A \<union> B)
[PROOF STEP]
apply (blast intro: iMin_le)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma vangle_inverse:
  "vangle (- v\<^sub>1) v\<^sub>2 = pi - vangle v\<^sub>1 v\<^sub>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vangle (- v\<^sub>1) v\<^sub>2 = pi - vangle v\<^sub>1 v\<^sub>2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. vangle (- v\<^sub>1) v\<^sub>2 = pi - vangle v\<^sub>1 v\<^sub>2
[PROOF STEP]
have "\<bar>v\<^sub>1 \<bullet> v\<^sub>2 / (norm v\<^sub>1 * norm v\<^sub>2)\<bar> \<le> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>v\<^sub>1 \<bullet> v\<^sub>2 / (norm v\<^sub>1 * norm v\<^sub>2)\<bar> \<le> 1
[PROOF STEP]
proof cases
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ?P \<Longrightarrow> \<bar>v\<^sub>1 \<bullet> v\<^sub>2 / (norm v\<^sub>1 * norm v\<^sub>2)\<bar> \<le> 1
 2. \<not> ?P \<Longrightarrow> \<bar>v\<^sub>1 \<bullet> v\<^sub>2 / (norm v\<^sub>1 * norm v\<^sub>2)\<bar> \<le> 1
[PROOF STEP]
assume "v\<^sub>1 \<noteq> 0 \<and> v\<^sub>2 \<noteq> 0"
[PROOF STATE]
proof (state)
this:
v\<^sub>1 \<noteq> (0::'a) \<and> v\<^sub>2 \<noteq> (0::'a)

goal (2 subgoals):
 1. ?P \<Longrightarrow> \<bar>v\<^sub>1 \<bullet> v\<^sub>2 / (norm v\<^sub>1 * norm v\<^sub>2)\<bar> \<le> 1
 2. \<not> ?P \<Longrightarrow> \<bar>v\<^sub>1 \<bullet> v\<^sub>2 / (norm v\<^sub>1 * norm v\<^sub>2)\<bar> \<le> 1
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
v\<^sub>1 \<noteq> (0::'a) \<and> v\<^sub>2 \<noteq> (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
v\<^sub>1 \<noteq> (0::'a) \<and> v\<^sub>2 \<noteq> (0::'a)

goal (1 subgoal):
 1. \<bar>v\<^sub>1 \<bullet> v\<^sub>2 / (norm v\<^sub>1 * norm v\<^sub>2)\<bar> \<le> 1
[PROOF STEP]
by (simp add: Cauchy_Schwarz_ineq2)
[PROOF STATE]
proof (state)
this:
\<bar>v\<^sub>1 \<bullet> v\<^sub>2 / (norm v\<^sub>1 * norm v\<^sub>2)\<bar> \<le> 1

goal (1 subgoal):
 1. \<not> (v\<^sub>1 \<noteq> (0::'a) \<and> v\<^sub>2 \<noteq> (0::'a)) \<Longrightarrow> \<bar>v\<^sub>1 \<bullet> v\<^sub>2 / (norm v\<^sub>1 * norm v\<^sub>2)\<bar> \<le> 1
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> (v\<^sub>1 \<noteq> (0::'a) \<and> v\<^sub>2 \<noteq> (0::'a)) \<Longrightarrow> \<bar>v\<^sub>1 \<bullet> v\<^sub>2 / (norm v\<^sub>1 * norm v\<^sub>2)\<bar> \<le> 1
[PROOF STEP]
assume "\<not> (v\<^sub>1 \<noteq> 0 \<and> v\<^sub>2 \<noteq> 0)"
[PROOF STATE]
proof (state)
this:
\<not> (v\<^sub>1 \<noteq> (0::'a) \<and> v\<^sub>2 \<noteq> (0::'a))

goal (1 subgoal):
 1. \<not> (v\<^sub>1 \<noteq> (0::'a) \<and> v\<^sub>2 \<noteq> (0::'a)) \<Longrightarrow> \<bar>v\<^sub>1 \<bullet> v\<^sub>2 / (norm v\<^sub>1 * norm v\<^sub>2)\<bar> \<le> 1
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
\<not> (v\<^sub>1 \<noteq> (0::'a) \<and> v\<^sub>2 \<noteq> (0::'a))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> (v\<^sub>1 \<noteq> (0::'a) \<and> v\<^sub>2 \<noteq> (0::'a))

goal (1 subgoal):
 1. \<bar>v\<^sub>1 \<bullet> v\<^sub>2 / (norm v\<^sub>1 * norm v\<^sub>2)\<bar> \<le> 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<bar>v\<^sub>1 \<bullet> v\<^sub>2 / (norm v\<^sub>1 * norm v\<^sub>2)\<bar> \<le> 1

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<bar>v\<^sub>1 \<bullet> v\<^sub>2 / (norm v\<^sub>1 * norm v\<^sub>2)\<bar> \<le> 1

goal (1 subgoal):
 1. vangle (- v\<^sub>1) v\<^sub>2 = pi - vangle v\<^sub>1 v\<^sub>2
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
\<bar>v\<^sub>1 \<bullet> v\<^sub>2 / (norm v\<^sub>1 * norm v\<^sub>2)\<bar> \<le> 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<bar>v\<^sub>1 \<bullet> v\<^sub>2 / (norm v\<^sub>1 * norm v\<^sub>2)\<bar> \<le> 1

goal (1 subgoal):
 1. vangle (- v\<^sub>1) v\<^sub>2 = pi - vangle v\<^sub>1 v\<^sub>2
[PROOF STEP]
unfolding vangle_def
[PROOF STATE]
proof (prove)
using this:
\<bar>v\<^sub>1 \<bullet> v\<^sub>2 / (norm v\<^sub>1 * norm v\<^sub>2)\<bar> \<le> 1

goal (1 subgoal):
 1. (if - v\<^sub>1 = (0::'a) \<or> v\<^sub>2 = (0::'a) then pi / 2 else arccos (- v\<^sub>1 \<bullet> v\<^sub>2 / (norm (- v\<^sub>1) * norm v\<^sub>2))) = pi - (if v\<^sub>1 = (0::'a) \<or> v\<^sub>2 = (0::'a) then pi / 2 else arccos (v\<^sub>1 \<bullet> v\<^sub>2 / (norm v\<^sub>1 * norm v\<^sub>2)))
[PROOF STEP]
by (simp add: arccos_minus_abs)
[PROOF STATE]
proof (state)
this:
vangle (- v\<^sub>1) v\<^sub>2 = pi - vangle v\<^sub>1 v\<^sub>2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma card_odd[simp]: "card {a \<in> Collect odd. a < 2 * n} = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {a \<in> {a. odd a}. a < 2 * n} = n
[PROOF STEP]
proof (induction n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. card {a \<in> {a. odd a}. a < 2 * 0} = 0
 2. \<And>n. card {a \<in> {a. odd a}. a < 2 * n} = n \<Longrightarrow> card {a \<in> {a. odd a}. a < 2 * Suc n} = Suc n
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. card {a \<in> {a. odd a}. a < 2 * 0} = 0
 2. \<And>n. card {a \<in> {a. odd a}. a < 2 * n} = n \<Longrightarrow> card {a \<in> {a. odd a}. a < 2 * Suc n} = Suc n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {a \<in> {a. odd a}. a < 2 * 0} = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card {a \<in> {a. odd a}. a < 2 * 0} = 0

goal (1 subgoal):
 1. \<And>n. card {a \<in> {a. odd a}. a < 2 * n} = n \<Longrightarrow> card {a \<in> {a. odd a}. a < 2 * Suc n} = Suc n
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. card {a \<in> {a. odd a}. a < 2 * n} = n \<Longrightarrow> card {a \<in> {a. odd a}. a < 2 * Suc n} = Suc n
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
card {a \<in> {a. odd a}. a < 2 * n} = n

goal (1 subgoal):
 1. \<And>n. card {a \<in> {a. odd a}. a < 2 * n} = n \<Longrightarrow> card {a \<in> {a. odd a}. a < 2 * Suc n} = Suc n
[PROOF STEP]
have "{a \<in> Collect odd. a < 2 * Suc n} = insert (2*n+1) {a \<in> Collect odd. a < 2 * n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {a \<in> {a. odd a}. a < 2 * Suc n} = insert (2 * n + 1) {a \<in> {a. odd a}. a < 2 * n}
[PROOF STEP]
using le_eq_less_or_eq less_Suc_eq_le subset_antisym
[PROOF STATE]
proof (prove)
using this:
(?m \<le> ?n) = (?m < ?n \<or> ?m = ?n)
(?m < Suc ?n) = (?m \<le> ?n)
\<lbrakk>?A \<subseteq> ?B; ?B \<subseteq> ?A\<rbrakk> \<Longrightarrow> ?A = ?B

goal (1 subgoal):
 1. {a \<in> {a. odd a}. a < 2 * Suc n} = insert (2 * n + 1) {a \<in> {a. odd a}. a < 2 * n}
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
{a \<in> {a. odd a}. a < 2 * Suc n} = insert (2 * n + 1) {a \<in> {a. odd a}. a < 2 * n}

goal (1 subgoal):
 1. \<And>n. card {a \<in> {a. odd a}. a < 2 * n} = n \<Longrightarrow> card {a \<in> {a. odd a}. a < 2 * Suc n} = Suc n
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {a \<in> {a. odd a}. a < 2 * Suc n} = Suc n
[PROOF STEP]
unfolding \<open>{a \<in> Collect odd. a < 2 * Suc n} = insert (2*n+1) {a \<in> Collect odd. a < 2 * n}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (insert (2 * n + 1) {a \<in> {a. odd a}. a < 2 * n}) = Suc n
[PROOF STEP]
using Suc card_insert_disjoint[of "{a \<in> Collect even. a < 2 * n}" "2*n"]
[PROOF STATE]
proof (prove)
using this:
card {a \<in> {a. odd a}. a < 2 * n} = n
\<lbrakk>finite {a \<in> Collect even. a < 2 * n}; 2 * n \<notin> {a \<in> Collect even. a < 2 * n}\<rbrakk> \<Longrightarrow> card (insert (2 * n) {a \<in> Collect even. a < 2 * n}) = Suc (card {a \<in> Collect even. a < 2 * n})

goal (1 subgoal):
 1. card (insert (2 * n + 1) {a \<in> {a. odd a}. a < 2 * n}) = Suc n
[PROOF STEP]
by (simp add: finite_M_bounded_by_nat less_not_refl2)
[PROOF STATE]
proof (state)
this:
card {a \<in> {a. odd a}. a < 2 * Suc n} = Suc n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma primitive_root_unity_exists: assumes "k \<noteq> 0" "x ^ k = 1"
  shows "\<exists> k'. k' \<le> k \<and> primitive_root_unity k' x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>k'\<le>k. primitive_root_unity k' x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>k'\<le>k. primitive_root_unity k' x
[PROOF STEP]
let ?P = "\<lambda> k. x ^ k = 1 \<and> k \<noteq> 0"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>k'\<le>k. primitive_root_unity k' x
[PROOF STEP]
define k' where "k' = (LEAST k. ?P k)"
[PROOF STATE]
proof (state)
this:
k' = (LEAST k. x ^ k = (1::'a) \<and> k \<noteq> 0)

goal (1 subgoal):
 1. \<exists>k'\<le>k. primitive_root_unity k' x
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
k \<noteq> 0
x ^ k = (1::'a)
[PROOF STEP]
have Pk: "\<exists> k. ?P k"
[PROOF STATE]
proof (prove)
using this:
k \<noteq> 0
x ^ k = (1::'a)

goal (1 subgoal):
 1. \<exists>k. x ^ k = (1::'a) \<and> k \<noteq> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>k. x ^ k = (1::'a) \<and> k \<noteq> 0

goal (1 subgoal):
 1. \<exists>k'\<le>k. primitive_root_unity k' x
[PROOF STEP]
from LeastI_ex[OF Pk, folded k'_def]
[PROOF STATE]
proof (chain)
picking this:
x ^ k' = (1::'a) \<and> k' \<noteq> 0
[PROOF STEP]
have "k' \<noteq> 0" "x ^ k' = 1"
[PROOF STATE]
proof (prove)
using this:
x ^ k' = (1::'a) \<and> k' \<noteq> 0

goal (1 subgoal):
 1. k' \<noteq> 0 &&& x ^ k' = (1::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
k' \<noteq> 0
x ^ k' = (1::'a)

goal (1 subgoal):
 1. \<exists>k'\<le>k. primitive_root_unity k' x
[PROOF STEP]
with not_less_Least[of _ ?P, folded k'_def]
[PROOF STATE]
proof (chain)
picking this:
?k < k' \<Longrightarrow> \<not> (x ^ ?k = (1::'a) \<and> ?k \<noteq> 0)
k' \<noteq> 0
x ^ k' = (1::'a)
[PROOF STEP]
have "primitive_root_unity k' x"
[PROOF STATE]
proof (prove)
using this:
?k < k' \<Longrightarrow> \<not> (x ^ ?k = (1::'a) \<and> ?k \<noteq> 0)
k' \<noteq> 0
x ^ k' = (1::'a)

goal (1 subgoal):
 1. primitive_root_unity k' x
[PROOF STEP]
unfolding primitive_root_unity_def
[PROOF STATE]
proof (prove)
using this:
?k < k' \<Longrightarrow> \<not> (x ^ ?k = (1::'a) \<and> ?k \<noteq> 0)
k' \<noteq> 0
x ^ k' = (1::'a)

goal (1 subgoal):
 1. k' \<noteq> 0 \<and> x ^ k' = (1::'a) \<and> (\<forall>k'a<k'. k'a \<noteq> 0 \<longrightarrow> x ^ k'a \<noteq> (1::'a))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
primitive_root_unity k' x

goal (1 subgoal):
 1. \<exists>k'\<le>k. primitive_root_unity k' x
[PROOF STEP]
with primitive_root_unityD(3)[OF this assms]
[PROOF STATE]
proof (chain)
picking this:
k' \<le> k
primitive_root_unity k' x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
k' \<le> k
primitive_root_unity k' x

goal (1 subgoal):
 1. \<exists>k'\<le>k. primitive_root_unity k' x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>k'\<le>k. primitive_root_unity k' x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Radon_ex_lemma:
  assumes "finite c" "affine_dependent c"
  shows "\<exists>u. sum u c = 0 \<and> (\<exists>v\<in>c. u v \<noteq> 0) \<and> sum (\<lambda>v. u v *\<^sub>R v) c = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>u. sum u c = 0 \<and> (\<exists>v\<in>c. u v \<noteq> 0) \<and> (\<Sum>v\<in>c. u v *\<^sub>R v) = (0::'a)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>u. sum u c = 0 \<and> (\<exists>v\<in>c. u v \<noteq> 0) \<and> (\<Sum>v\<in>c. u v *\<^sub>R v) = (0::'a)
[PROOF STEP]
from assms(2)[unfolded affine_dependent_explicit]
[PROOF STATE]
proof (chain)
picking this:
\<exists>S u. finite S \<and> S \<subseteq> c \<and> sum u S = 0 \<and> (\<exists>v\<in>S. u v \<noteq> 0) \<and> (\<Sum>v\<in>S. u v *\<^sub>R v) = (0::'a)
[PROOF STEP]
obtain S u where
      "finite S" "S \<subseteq> c" "sum u S = 0" "\<exists>v\<in>S. u v \<noteq> 0" "(\<Sum>v\<in>S. u v *\<^sub>R v) = 0"
[PROOF STATE]
proof (prove)
using this:
\<exists>S u. finite S \<and> S \<subseteq> c \<and> sum u S = 0 \<and> (\<exists>v\<in>S. u v \<noteq> 0) \<and> (\<Sum>v\<in>S. u v *\<^sub>R v) = (0::'a)

goal (1 subgoal):
 1. (\<And>S u. \<lbrakk>finite S; S \<subseteq> c; sum u S = 0; \<exists>v\<in>S. u v \<noteq> 0; (\<Sum>v\<in>S. u v *\<^sub>R v) = (0::'a)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
finite S
S \<subseteq> c
sum u S = 0
\<exists>v\<in>S. u v \<noteq> 0
(\<Sum>v\<in>S. u v *\<^sub>R v) = (0::'a)

goal (1 subgoal):
 1. \<exists>u. sum u c = 0 \<and> (\<exists>v\<in>c. u v \<noteq> 0) \<and> (\<Sum>v\<in>c. u v *\<^sub>R v) = (0::'a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
finite S
S \<subseteq> c
sum u S = 0
\<exists>v\<in>S. u v \<noteq> 0
(\<Sum>v\<in>S. u v *\<^sub>R v) = (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
finite S
S \<subseteq> c
sum u S = 0
\<exists>v\<in>S. u v \<noteq> 0
(\<Sum>v\<in>S. u v *\<^sub>R v) = (0::'a)

goal (1 subgoal):
 1. \<exists>u. sum u c = 0 \<and> (\<exists>v\<in>c. u v \<noteq> 0) \<and> (\<Sum>v\<in>c. u v *\<^sub>R v) = (0::'a)
[PROOF STEP]
apply (rule_tac x="\<lambda>v. if v\<in>S then u v else 0" in exI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite S; S \<subseteq> c; sum u S = 0; \<exists>v\<in>S. u v \<noteq> 0; (\<Sum>v\<in>S. u v *\<^sub>R v) = (0::'a)\<rbrakk> \<Longrightarrow> (\<Sum>v\<in>c. if v \<in> S then u v else 0) = 0 \<and> (\<exists>v\<in>c. (if v \<in> S then u v else 0) \<noteq> 0) \<and> (\<Sum>v\<in>c. (if v \<in> S then u v else 0) *\<^sub>R v) = (0::'a)
[PROOF STEP]
unfolding if_smult scaleR_zero_left
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite S; S \<subseteq> c; sum u S = 0; \<exists>v\<in>S. u v \<noteq> 0; (\<Sum>v\<in>S. u v *\<^sub>R v) = (0::'a)\<rbrakk> \<Longrightarrow> (\<Sum>v\<in>c. if v \<in> S then u v else 0) = 0 \<and> (\<exists>v\<in>c. (if v \<in> S then u v else 0) \<noteq> 0) \<and> (\<Sum>v\<in>c. if v \<in> S then u v *\<^sub>R v else (0::'a)) = (0::'a)
[PROOF STEP]
by (auto simp: Int_absorb1 sum.inter_restrict[OF \<open>finite c\<close>, symmetric])
[PROOF STATE]
proof (state)
this:
\<exists>u. sum u c = 0 \<and> (\<exists>v\<in>c. u v \<noteq> 0) \<and> (\<Sum>v\<in>c. u v *\<^sub>R v) = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mtx_invertible_def: "mtx_invertible A \<longleftrightarrow> (\<exists>A'. A' * A = 1 \<and> A * A' = 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mtx_invertible A = (\<exists>A'. A' * A = 1 \<and> A * A' = 1)
[PROOF STEP]
apply (unfold sq_mtx_inv_def times_sq_mtx_def one_sq_mtx_def invertible_def, clarsimp, safe)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>A'. \<lbrakk>to_vec A ** A' = mat 1; A' ** to_vec A = mat 1\<rbrakk> \<Longrightarrow> \<exists>A'. to_mtx (to_vec A' ** to_vec A) = to_mtx (mat 1) \<and> to_mtx (to_vec A ** to_vec A') = to_mtx (mat 1)
 2. \<And>A'. \<lbrakk>to_mtx (to_vec A' ** to_vec A) = to_mtx (mat 1); to_mtx (to_vec A ** to_vec A') = to_mtx (mat 1)\<rbrakk> \<Longrightarrow> \<exists>A'. to_vec A ** A' = mat 1 \<and> A' ** to_vec A = mat 1
[PROOF STEP]
apply(rule_tac x="to_mtx A'" in exI, simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>A'. \<lbrakk>to_mtx (to_vec A' ** to_vec A) = to_mtx (mat 1); to_mtx (to_vec A ** to_vec A') = to_mtx (mat 1)\<rbrakk> \<Longrightarrow> \<exists>A'. to_vec A ** A' = mat 1 \<and> A' ** to_vec A = mat 1
[PROOF STEP]
by (rule_tac x="to_vec A'" in exI, simp add: to_mtx_inject)


[STATEMENT]
lemma num_wtn_shift_conv:
  assumes "E \<in> sets M"
    and "\<bar>\<mu> E\<bar> < \<infinity>"
  shows "(\<lambda>n. 1/(num_wtn E n - 1)) \<longlonglongrightarrow> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. 1 / real (num_wtn E n - 1)) \<longlonglongrightarrow> 0
[PROOF STEP]
proof (rule summable_LIMSEQ_zero)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. summable (\<lambda>n. 1 / real (num_wtn E n - 1))
[PROOF STEP]
show "summable (\<lambda>n. 1 / real (num_wtn E n - 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. summable (\<lambda>n. 1 / real (num_wtn E n - 1))
[PROOF STEP]
using assms inv_num_wtn_shift_summable
[PROOF STATE]
proof (prove)
using this:
E \<in> sets M
\<bar>\<mu> E\<bar> < \<infinity>
\<lbrakk>?E \<in> sets M; \<bar>\<mu> ?E\<bar> < \<infinity>\<rbrakk> \<Longrightarrow> summable (\<lambda>n. 1 / real (num_wtn ?E n - 1))

goal (1 subgoal):
 1. summable (\<lambda>n. 1 / real (num_wtn E n - 1))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
summable (\<lambda>n. 1 / real (num_wtn E n - 1))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fls_base_factor_mult:
  fixes f g :: "'a::semiring_no_zero_divisors fls"
  shows "fls_base_factor (f * g) = fls_base_factor f * fls_base_factor g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fls_base_factor (f * g) = fls_base_factor f * fls_base_factor g
[PROOF STEP]
by    (cases "f\<noteq>0 \<and> g\<noteq>0")
        (auto simp: fls_times_both_shifted_simp)


[STATEMENT]
lemma bij_betw_insert:
assumes "b \<notin> A" and "f b \<notin> A'" and "bij_betw f A A'"
shows "bij_betw f (insert b A) (insert (f b) A')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij_betw f (insert b A) (insert (f b) A')
[PROOF STEP]
using notIn_Un_bij_betw[OF assms]
[PROOF STATE]
proof (prove)
using this:
bij_betw f (A \<union> {b}) (A' \<union> {f b})

goal (1 subgoal):
 1. bij_betw f (insert b A) (insert (f b) A')
[PROOF STEP]
by auto


[STATEMENT]
lemma prod_rel_comp: "(A \<times>\<^sub>r B) O (C \<times>\<^sub>r D) = (A O C) \<times>\<^sub>r (B O D)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (A \<times>\<^sub>r B) O (C \<times>\<^sub>r D) = A O C \<times>\<^sub>r B O D
[PROOF STEP]
unfolding prod_rel_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {((a, b), a', b'). (a, a') \<in> A \<and> (b, b') \<in> B} O {((a, b), a', b'). (a, a') \<in> C \<and> (b, b') \<in> D} = {((a, b), a', b'). (a, a') \<in> A O C \<and> (b, b') \<in> B O D}
[PROOF STEP]
by auto


[STATEMENT]
lemma sq_mtx_diag_one[simp]: "(\<d>\<i>\<a>\<g> i. 1) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<d>\<i>\<a>\<g> i. 1) = 1
[PROOF STEP]
by (subst sq_mtx_eq_iff, simp add: one_sq_mtx_def mat_def axis_def)


[STATEMENT]
lemma times0_right [simp]: "(A::'a::semiring_1^'n^'m) ** (0::'a ^'p^'n) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A ** 0 = 0
[PROOF STEP]
by (simp add: matrix_matrix_mult_def zero_vec_def)


[STATEMENT]
lemma continuous_on_topological:
  "continuous_on s f \<longleftrightarrow>
    (\<forall>x\<in>s. \<forall>B. open B \<longrightarrow> f x \<in> B \<longrightarrow> (\<exists>A. open A \<and> x \<in> A \<and> (\<forall>y\<in>s. y \<in> A \<longrightarrow> f y \<in> B)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous_on s f = (\<forall>x\<in>s. \<forall>B. open B \<longrightarrow> f x \<in> B \<longrightarrow> (\<exists>A. open A \<and> x \<in> A \<and> (\<forall>y\<in>s. y \<in> A \<longrightarrow> f y \<in> B)))
[PROOF STEP]
unfolding continuous_on_def tendsto_def eventually_at_topological
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x\<in>s. \<forall>S. open S \<longrightarrow> f x \<in> S \<longrightarrow> (\<exists>Sa. open Sa \<and> x \<in> Sa \<and> (\<forall>xa\<in>Sa. xa \<noteq> x \<longrightarrow> xa \<in> s \<longrightarrow> f xa \<in> S))) = (\<forall>x\<in>s. \<forall>B. open B \<longrightarrow> f x \<in> B \<longrightarrow> (\<exists>A. open A \<and> x \<in> A \<and> (\<forall>y\<in>s. y \<in> A \<longrightarrow> f y \<in> B)))
[PROOF STEP]
by metis


[STATEMENT]
lemma poly_no_roots_greater:
  "(\<forall>x. x > a \<longrightarrow> poly p x \<noteq> 0) \<longleftrightarrow>
       ((p \<noteq> 0 \<and> count_roots_above p a = 0))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x>a. poly p x \<noteq> 0) = (p \<noteq> 0 \<and> count_roots_above p a = 0)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<forall>x>a. poly p x \<noteq> 0) = (p \<noteq> 0 \<and> count_roots_above p a = 0)
[PROOF STEP]
have "\<forall>x. \<not> a < x \<Longrightarrow> False"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x. \<not> a < x \<Longrightarrow> False
[PROOF STEP]
by (metis gt_ex)
[PROOF STATE]
proof (state)
this:
\<forall>x. \<not> a < x \<Longrightarrow> False

goal (1 subgoal):
 1. (\<forall>x>a. poly p x \<noteq> 0) = (p \<noteq> 0 \<and> count_roots_above p a = 0)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<forall>x. \<not> a < x \<Longrightarrow> False

goal (1 subgoal):
 1. (\<forall>x>a. poly p x \<noteq> 0) = (p \<noteq> 0 \<and> count_roots_above p a = 0)
[PROOF STEP]
by (auto simp: count_roots_above_correct card_eq_0_iff
                        intro: poly_roots_finite )
[PROOF STATE]
proof (state)
this:
(\<forall>x>a. poly p x \<noteq> 0) = (p \<noteq> 0 \<and> count_roots_above p a = 0)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma complex_eq_if_Re_eq:
  assumes "is_real z1" and "is_real z2"
  shows "z1 = z2 \<longleftrightarrow> Re z1 = Re z2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (z1 = z2) = (Re z1 = Re z2)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
is_real z1
is_real z2

goal (1 subgoal):
 1. (z1 = z2) = (Re z1 = Re z2)
[PROOF STEP]
by (cases z1, cases z2) auto


[STATEMENT]
lemma word_le_minus_mono_right:
  fixes x :: "'a :: len word"
  shows "\<lbrakk> z \<le> y; y \<le> x; z \<le> x \<rbrakk> \<Longrightarrow> x - y \<le> x - z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>z \<le> y; y \<le> x; z \<le> x\<rbrakk> \<Longrightarrow> x - y \<le> x - z
[PROOF STEP]
apply (rule word_sub_mono)
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. \<lbrakk>z \<le> y; y \<le> x; z \<le> x\<rbrakk> \<Longrightarrow> x \<le> x
 2. \<lbrakk>z \<le> y; y \<le> x; z \<le> x\<rbrakk> \<Longrightarrow> z \<le> y
 3. \<lbrakk>z \<le> y; y \<le> x; z \<le> x\<rbrakk> \<Longrightarrow> x - y \<le> x
 4. \<lbrakk>z \<le> y; y \<le> x; z \<le> x\<rbrakk> \<Longrightarrow> x - z \<le> x
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<lbrakk>z \<le> y; y \<le> x; z \<le> x\<rbrakk> \<Longrightarrow> z \<le> y
 2. \<lbrakk>z \<le> y; y \<le> x; z \<le> x\<rbrakk> \<Longrightarrow> x - y \<le> x
 3. \<lbrakk>z \<le> y; y \<le> x; z \<le> x\<rbrakk> \<Longrightarrow> x - z \<le> x
[PROOF STEP]
apply assumption
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>z \<le> y; y \<le> x; z \<le> x\<rbrakk> \<Longrightarrow> x - y \<le> x
 2. \<lbrakk>z \<le> y; y \<le> x; z \<le> x\<rbrakk> \<Longrightarrow> x - z \<le> x
[PROOF STEP]
apply (erule word_sub_le)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>z \<le> y; y \<le> x; z \<le> x\<rbrakk> \<Longrightarrow> x - z \<le> x
[PROOF STEP]
apply (erule word_sub_le)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma real_le_affinity: "0 < m \<Longrightarrow> y \<le> m * x + c \<longleftrightarrow> inverse m * y + - (c / m) \<le> x"
  for m :: "'a::linordered_field"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0::'a) < m \<Longrightarrow> (y \<le> m * x + c) = (inverse m * y + - (c / m) \<le> x)
[PROOF STEP]
by (simp add: field_simps)


[STATEMENT]
lemma (in state_space)
  shows "\<Gamma>\<turnstile> \<lbrace>\<acute>M = 0 \<and> \<acute>S = 0\<rbrace>
          WHILE \<acute>M \<noteq> a
          INV \<lbrace>\<acute>S = \<acute>M * b\<rbrace>
          DO \<acute>S :== \<acute>S + b;; \<acute>M :== \<acute>M + 1 OD
          \<lbrace>\<acute>S = a * b\<rbrace>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Gamma>\<turnstile> \<lbrace>\<acute>M = 0 \<and> \<acute>S = 0\<rbrace> WHILE \<acute>M \<noteq> a INV \<lbrace>\<acute>S = \<acute>M * b\<rbrace> DO \<acute>S :== \<acute>S + b;; \<acute>M :== \<acute>M + 1 OD \<lbrace>\<acute>S = a * b\<rbrace>
[PROOF STEP]
apply vcg
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>M S. \<lbrakk>M = 0; S = 0\<rbrakk> \<Longrightarrow> S = M * b
 2. \<And>M S. \<lbrakk>S = M * b; M \<noteq> a\<rbrakk> \<Longrightarrow> S + b = (M + 1) * b
 3. \<And>M S. \<lbrakk>S = M * b; \<not> M \<noteq> a\<rbrakk> \<Longrightarrow> S = a * b
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma n_subset_enum_correct_aux1:
  "\<lbrakk>distinct xs; length ys = length xs\<rbrakk>
    \<Longrightarrow> set (filter_bool_list ys xs) \<in> n_subsets (set xs) (count_list ys True)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>distinct xs; length ys = length xs\<rbrakk> \<Longrightarrow> set (filter_bool_list ys xs) \<in> n_subsets (set xs) (count_list ys True)
[PROOF STEP]
unfolding n_subsets_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>distinct xs; length ys = length xs\<rbrakk> \<Longrightarrow> set (filter_bool_list ys xs) \<in> {B. B \<subseteq> set xs \<and> card B = count_list ys True}
[PROOF STEP]
by (auto simp: filter_bool_list_card filter_bool_list_elem)


[STATEMENT]
lemma ft_2: assumes dx: "dim_vec x = 2"
  and be: "x $ 0 = False \<and> x $ 1 = True"
  shows "ceros_of_boolean_input x = {0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ceros_of_boolean_input x = {0}
[PROOF STEP]
using dx be
[PROOF STATE]
proof (prove)
using this:
dim_vec x = 2
x $ 0 = False \<and> x $ 1 = True

goal (1 subgoal):
 1. ceros_of_boolean_input x = {0}
[PROOF STEP]
unfolding ceros_of_boolean_input_def
[PROOF STATE]
proof (prove)
using this:
dim_vec x = 2
x $ 0 = False \<and> x $ 1 = True

goal (1 subgoal):
 1. {xa. xa < dim_vec x \<and> x $ xa = False} = {0}
[PROOF STEP]
using less_2_cases
[PROOF STATE]
proof (prove)
using this:
dim_vec x = 2
x $ 0 = False \<and> x $ 1 = True
?n < 2 \<Longrightarrow> ?n = 0 \<or> ?n = Suc 0

goal (1 subgoal):
 1. {xa. xa < dim_vec x \<and> x $ xa = False} = {0}
[PROOF STEP]
by auto


[STATEMENT]
lemma nlists_append:
  "xs @ ys \<in> nlists k A \<longleftrightarrow>
   k = length(xs @ ys) \<and> xs \<in> nlists (length xs) A \<and> ys \<in> nlists (length ys) A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (xs @ ys \<in> nlists k A) = (k = length (xs @ ys) \<and> xs \<in> nlists (length xs) A \<and> ys \<in> nlists (length ys) A)
[PROOF STEP]
unfolding nlists_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (xs @ ys \<in> {xs. length xs = k \<and> set xs \<subseteq> A}) = (k = length (xs @ ys) \<and> xs \<in> {xsa. length xsa = length xs \<and> set xsa \<subseteq> A} \<and> ys \<in> {xs. length xs = length ys \<and> set xs \<subseteq> A})
[PROOF STEP]
by (auto)


[STATEMENT]
theorem residuated_pairI [intro]:
  assumes "\<forall>x y. x \<le> y \<longrightarrow> f x \<le> f y"
  and "\<forall>x y. x \<le> y \<longrightarrow> g x \<le> g y"
  and "\<forall>x. x \<le> (g o f) x"
  and "\<forall>x. (f o g) x \<le> x"
  shows "residuated_pair f g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. residuated_pair f g
[PROOF STEP]
by (metis assms comp_apply local.order_trans residuated_pair_def antisym)


[STATEMENT]
lemma nn_integral_real_affine_lebesgue:
  fixes c :: real assumes f[measurable]: "f \<in> borel_measurable lebesgue" and c: "c \<noteq> 0"
  shows "(\<integral>\<^sup>+x. f x \<partial>lebesgue) = ennreal\<bar>c\<bar> * (\<integral>\<^sup>+x. f(t + c * x) \<partial>lebesgue)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integral\<^sup>N lebesgue f = ennreal \<bar>c\<bar> * \<integral>\<^sup>+ x. f (t + c * x) \<partial>lebesgue
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. integral\<^sup>N lebesgue f = ennreal \<bar>c\<bar> * \<integral>\<^sup>+ x. f (t + c * x) \<partial>lebesgue
[PROOF STEP]
have "(\<integral>\<^sup>+x. f x \<partial>lebesgue) = (\<integral>\<^sup>+x. f x \<partial>density (distr lebesgue lebesgue (\<lambda>x. t + c * x)) (\<lambda>x. ennreal \<bar>c\<bar>))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integral\<^sup>N lebesgue f = integral\<^sup>N (density (distr lebesgue lebesgue (\<lambda>x. t + c * x)) (\<lambda>x. ennreal \<bar>c\<bar>)) f
[PROOF STEP]
using lebesgue_real_affine c
[PROOF STATE]
proof (prove)
using this:
?c \<noteq> 0 \<Longrightarrow> lebesgue = density (distr lebesgue lebesgue (\<lambda>x. ?t + ?c * x)) (\<lambda>_. ennreal \<bar>?c\<bar>)
c \<noteq> 0

goal (1 subgoal):
 1. integral\<^sup>N lebesgue f = integral\<^sup>N (density (distr lebesgue lebesgue (\<lambda>x. t + c * x)) (\<lambda>x. ennreal \<bar>c\<bar>)) f
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
integral\<^sup>N lebesgue f = integral\<^sup>N (density (distr lebesgue lebesgue (\<lambda>x. t + c * x)) (\<lambda>x. ennreal \<bar>c\<bar>)) f

goal (1 subgoal):
 1. integral\<^sup>N lebesgue f = ennreal \<bar>c\<bar> * \<integral>\<^sup>+ x. f (t + c * x) \<partial>lebesgue
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
integral\<^sup>N lebesgue f = integral\<^sup>N (density (distr lebesgue lebesgue (\<lambda>x. t + c * x)) (\<lambda>x. ennreal \<bar>c\<bar>)) f

goal (1 subgoal):
 1. integral\<^sup>N lebesgue f = ennreal \<bar>c\<bar> * \<integral>\<^sup>+ x. f (t + c * x) \<partial>lebesgue
[PROOF STEP]
have "\<dots> = \<integral>\<^sup>+ x. ennreal \<bar>c\<bar> * f x \<partial>distr lebesgue lebesgue (\<lambda>x. t + c * x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integral\<^sup>N (density (distr lebesgue lebesgue (\<lambda>x. t + c * x)) (\<lambda>x. ennreal \<bar>c\<bar>)) f = \<integral>\<^sup>+ x. ennreal \<bar>c\<bar> * f x \<partial>distr lebesgue lebesgue (\<lambda>x. t + c * x)
[PROOF STEP]
by (subst nn_integral_density) auto
[PROOF STATE]
proof (state)
this:
integral\<^sup>N (density (distr lebesgue lebesgue (\<lambda>x. t + c * x)) (\<lambda>x. ennreal \<bar>c\<bar>)) f = \<integral>\<^sup>+ x. ennreal \<bar>c\<bar> * f x \<partial>distr lebesgue lebesgue (\<lambda>x. t + c * x)

goal (1 subgoal):
 1. integral\<^sup>N lebesgue f = ennreal \<bar>c\<bar> * \<integral>\<^sup>+ x. f (t + c * x) \<partial>lebesgue
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
integral\<^sup>N (density (distr lebesgue lebesgue (\<lambda>x. t + c * x)) (\<lambda>x. ennreal \<bar>c\<bar>)) f = \<integral>\<^sup>+ x. ennreal \<bar>c\<bar> * f x \<partial>distr lebesgue lebesgue (\<lambda>x. t + c * x)

goal (1 subgoal):
 1. integral\<^sup>N lebesgue f = ennreal \<bar>c\<bar> * \<integral>\<^sup>+ x. f (t + c * x) \<partial>lebesgue
[PROOF STEP]
have "\<dots> = ennreal \<bar>c\<bar> * integral\<^sup>N (distr lebesgue lebesgue (\<lambda>x. t + c * x)) f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal \<bar>c\<bar> * f x \<partial>distr lebesgue lebesgue (\<lambda>x. t + c * x) = ennreal \<bar>c\<bar> * integral\<^sup>N (distr lebesgue lebesgue (\<lambda>x. t + c * x)) f
[PROOF STEP]
using f measurable_distr_eq1 nn_integral_cmult
[PROOF STATE]
proof (prove)
using this:
f \<in> borel_measurable lebesgue
distr ?Mf ?Nf ?f \<rightarrow>\<^sub>M ?Mf' = ?Nf \<rightarrow>\<^sub>M ?Mf'
?f \<in> borel_measurable ?M \<Longrightarrow> \<integral>\<^sup>+ x. ?c * ?f x \<partial>?M = ?c * integral\<^sup>N ?M ?f

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal \<bar>c\<bar> * f x \<partial>distr lebesgue lebesgue (\<lambda>x. t + c * x) = ennreal \<bar>c\<bar> * integral\<^sup>N (distr lebesgue lebesgue (\<lambda>x. t + c * x)) f
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. ennreal \<bar>c\<bar> * f x \<partial>distr lebesgue lebesgue (\<lambda>x. t + c * x) = ennreal \<bar>c\<bar> * integral\<^sup>N (distr lebesgue lebesgue (\<lambda>x. t + c * x)) f

goal (1 subgoal):
 1. integral\<^sup>N lebesgue f = ennreal \<bar>c\<bar> * \<integral>\<^sup>+ x. f (t + c * x) \<partial>lebesgue
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. ennreal \<bar>c\<bar> * f x \<partial>distr lebesgue lebesgue (\<lambda>x. t + c * x) = ennreal \<bar>c\<bar> * integral\<^sup>N (distr lebesgue lebesgue (\<lambda>x. t + c * x)) f

goal (1 subgoal):
 1. integral\<^sup>N lebesgue f = ennreal \<bar>c\<bar> * \<integral>\<^sup>+ x. f (t + c * x) \<partial>lebesgue
[PROOF STEP]
have "\<dots> = \<bar>c\<bar> * (\<integral>\<^sup>+x. f(t + c * x) \<partial>lebesgue)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ennreal \<bar>c\<bar> * integral\<^sup>N (distr lebesgue lebesgue (\<lambda>x. t + c * x)) f = ennreal \<bar>c\<bar> * \<integral>\<^sup>+ x. f (t + c * x) \<partial>lebesgue
[PROOF STEP]
using lebesgue_affine_measurable[where c= "\<lambda>x::real. c"]
[PROOF STATE]
proof (prove)
using this:
(\<And>j. j \<in> Basis \<Longrightarrow> c \<noteq> 0) \<Longrightarrow> (\<lambda>x. ?t + (\<Sum>j\<in>Basis. (c * (x \<bullet> j)) *\<^sub>R j)) \<in> lebesgue \<rightarrow>\<^sub>M lebesgue

goal (1 subgoal):
 1. ennreal \<bar>c\<bar> * integral\<^sup>N (distr lebesgue lebesgue (\<lambda>x. t + c * x)) f = ennreal \<bar>c\<bar> * \<integral>\<^sup>+ x. f (t + c * x) \<partial>lebesgue
[PROOF STEP]
by (subst nn_integral_distr) (force+)
[PROOF STATE]
proof (state)
this:
ennreal \<bar>c\<bar> * integral\<^sup>N (distr lebesgue lebesgue (\<lambda>x. t + c * x)) f = ennreal \<bar>c\<bar> * \<integral>\<^sup>+ x. f (t + c * x) \<partial>lebesgue

goal (1 subgoal):
 1. integral\<^sup>N lebesgue f = ennreal \<bar>c\<bar> * \<integral>\<^sup>+ x. f (t + c * x) \<partial>lebesgue
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
integral\<^sup>N lebesgue f = ennreal \<bar>c\<bar> * \<integral>\<^sup>+ x. f (t + c * x) \<partial>lebesgue
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
integral\<^sup>N lebesgue f = ennreal \<bar>c\<bar> * \<integral>\<^sup>+ x. f (t + c * x) \<partial>lebesgue

goal (1 subgoal):
 1. integral\<^sup>N lebesgue f = ennreal \<bar>c\<bar> * \<integral>\<^sup>+ x. f (t + c * x) \<partial>lebesgue
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
integral\<^sup>N lebesgue f = ennreal \<bar>c\<bar> * \<integral>\<^sup>+ x. f (t + c * x) \<partial>lebesgue

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Zmax_geTr:"f \<in> {j. j \<le> (n::nat)} \<rightarrow> (UNIV::int set) \<longrightarrow>
                    (\<forall>j\<in>{j. j \<le> n}. (f j) \<le> Zmax n f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f \<in> {j. j \<le> n} \<rightarrow> UNIV \<longrightarrow> (\<forall>j\<in>{j. j \<le> n}. f j \<le> Zmax n f)
[PROOF STEP]
apply (induct_tac n,
       rule impI, rule ballI,
       simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. f \<in> {j. j \<le> n} \<rightarrow> UNIV \<longrightarrow> (\<forall>j\<in>{j. j \<le> n}. f j \<le> Zmax n f) \<Longrightarrow> f \<in> {j. j \<le> Suc n} \<rightarrow> UNIV \<longrightarrow> (\<forall>j\<in>{j. j \<le> Suc n}. f j \<le> Zmax (Suc n) f)
[PROOF STEP]
apply (rule impI, rule ballI,
       frule func_pre, simp,
       case_tac "j = Suc n", simp, rule zmax_ge_r,
       cut_tac x = j and n = n in Nset_pre, simp, assumption,
       thin_tac "j \<le> Suc n",
       simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n j. \<lbrakk>\<forall>j\<le>n. f j \<le> Zmax n f; j \<le> n\<rbrakk> \<Longrightarrow> f j \<le> zmax (Zmax n f) (f (Suc n))
[PROOF STEP]
apply (cut_tac x = "Zmax n f" and y = "f (Suc n)" in zmax_ge_l,
       frule_tac x = j in spec,
       thin_tac "\<forall>j\<le>n. f j \<le> Zmax n f")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n j. \<lbrakk>j \<le> n; Zmax n f \<le> zmax (Zmax n f) (f (Suc n)); j \<le> n \<longrightarrow> f j \<le> Zmax n f\<rbrakk> \<Longrightarrow> f j \<le> zmax (Zmax n f) (f (Suc n))
[PROOF STEP]
apply  simp
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma int_nat_eq:
 assumes "int (a::nat) = int b"
 shows "a = b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a = b
[PROOF STEP]
using  assms of_nat_eq_iff
[PROOF STATE]
proof (prove)
using this:
int a = int b
(of_nat ?m = of_nat ?n) = (?m = ?n)

goal (1 subgoal):
 1. a = b
[PROOF STEP]
by auto


[STATEMENT]
lemma tendsto_powr2:
  fixes a :: real
  assumes f: "(f \<longlongrightarrow> a) F"
    and g: "(g \<longlongrightarrow> b) F"
    and "\<forall>\<^sub>F x in F. 0 \<le> f x"
    and b: "0 < b"
  shows "((\<lambda>x. f x powr g x) \<longlongrightarrow> a powr b) F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. f x powr g x) \<longlongrightarrow> a powr b) F
[PROOF STEP]
using tendsto_powr'[of f a F g b] assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>(f \<longlongrightarrow> a) F; (g \<longlongrightarrow> b) F; a \<noteq> 0 \<or> 0 < b \<and> (\<forall>\<^sub>F x in F. 0 \<le> f x)\<rbrakk> \<Longrightarrow> ((\<lambda>x. f x powr g x) \<longlongrightarrow> a powr b) F
(f \<longlongrightarrow> a) F
(g \<longlongrightarrow> b) F
\<forall>\<^sub>F x in F. 0 \<le> f x
0 < b

goal (1 subgoal):
 1. ((\<lambda>x. f x powr g x) \<longlongrightarrow> a powr b) F
[PROOF STEP]
by auto


[STATEMENT]
lemma cod_S':
  "\<And>(A::type_scheme list) (t::typ).
   cod (\<lambda>n. if n : free_tv A Un free_tv t then S n else TVar n) \<subseteq>
   free_tv ($ S A) Un free_tv ($ S t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>A t. cod (\<lambda>n. if n \<in> free_tv A \<union> free_tv t then S n else TVar n) \<subseteq> free_tv ($ S A) \<union> free_tv ($ S t)
[PROOF STEP]
apply (unfold free_tv_subst cod_def subset_eq)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>A t. \<forall>x\<in>\<Union>m\<in>Type.dom (\<lambda>n. if n \<in> free_tv A \<union> free_tv t then S n else TVar n). free_tv (if m \<in> free_tv A \<union> free_tv t then S m else TVar m). x \<in> free_tv ($ S A) \<union> free_tv ($ S t)
[PROOF STEP]
apply (rule ballI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>A t x. x \<in> (\<Union>m\<in>Type.dom (\<lambda>n. if n \<in> free_tv A \<union> free_tv t then S n else TVar n). free_tv (if m \<in> free_tv A \<union> free_tv t then S m else TVar m)) \<Longrightarrow> x \<in> free_tv ($ S A) \<union> free_tv ($ S t)
[PROOF STEP]
apply (erule UN_E)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>A t x m. \<lbrakk>m \<in> Type.dom (\<lambda>n. if n \<in> free_tv A \<union> free_tv t then S n else TVar n); x \<in> free_tv (if m \<in> free_tv A \<union> free_tv t then S m else TVar m)\<rbrakk> \<Longrightarrow> x \<in> free_tv ($ S A) \<union> free_tv ($ S t)
[PROOF STEP]
apply (drule dom_S' [THEN subsetD])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>A t x m. \<lbrakk>x \<in> free_tv (if m \<in> free_tv A \<union> free_tv t then S m else TVar m); m \<in> free_tv A \<union> free_tv t\<rbrakk> \<Longrightarrow> x \<in> free_tv ($ S A) \<union> free_tv ($ S t)
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>A t x m. \<lbrakk>x \<in> free_tv (S m); m \<in> free_tv A \<or> m \<in> free_tv t\<rbrakk> \<Longrightarrow> x \<in> free_tv ($ S A) \<or> x \<in> free_tv ($ S t)
[PROOF STEP]
apply (fast dest: free_tv_of_substitutions_extend_to_scheme_lists intro: free_tv_of_substitutions_extend_to_types [THEN subsetD])
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma prob_space_convolution_density:
  fixes f:: "real \<Rightarrow> _"
  fixes g:: "real \<Rightarrow> _"
  assumes [measurable]: "f\<in> borel_measurable borel"
  assumes [measurable]: "g\<in> borel_measurable borel"
  assumes gt_0[simp]: "\<And>x. 0 \<le> f x" "\<And>x. 0 \<le> g x"
  assumes "prob_space (density lborel f)" (is "prob_space ?F")
  assumes "prob_space (density lborel g)" (is "prob_space ?G")
  shows "prob_space (density lborel (\<lambda>x.\<integral>\<^sup>+y. f (x - y) * g y \<partial>lborel))" (is "prob_space ?D")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prob_space (density lborel (\<lambda>x. \<integral>\<^sup>+ y. f (x - y) * g y \<partial>lborel))
[PROOF STEP]
proof (subst convolution_density[symmetric])
[PROOF STATE]
proof (state)
goal (5 subgoals):
 1. f \<in> borel_measurable borel
 2. g \<in> borel_measurable borel
 3. finite_measure (density lborel f)
 4. finite_measure (density lborel g)
 5. prob_space (density lborel f \<star> density lborel g)
[PROOF STEP]
interpret F: prob_space ?F
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prob_space (density lborel f)
[PROOF STEP]
by fact
[PROOF STATE]
proof (state)
goal (5 subgoals):
 1. f \<in> borel_measurable borel
 2. g \<in> borel_measurable borel
 3. finite_measure (density lborel f)
 4. finite_measure (density lborel g)
 5. prob_space (density lborel f \<star> density lborel g)
[PROOF STEP]
show "finite_measure ?F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite_measure (density lborel f)
[PROOF STEP]
by unfold_locales
[PROOF STATE]
proof (state)
this:
finite_measure (density lborel f)

goal (4 subgoals):
 1. f \<in> borel_measurable borel
 2. g \<in> borel_measurable borel
 3. finite_measure (density lborel g)
 4. prob_space (density lborel f \<star> density lborel g)
[PROOF STEP]
interpret G: prob_space ?G
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prob_space (density lborel g)
[PROOF STEP]
by fact
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. f \<in> borel_measurable borel
 2. g \<in> borel_measurable borel
 3. finite_measure (density lborel g)
 4. prob_space (density lborel f \<star> density lborel g)
[PROOF STEP]
show "finite_measure ?G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite_measure (density lborel g)
[PROOF STEP]
by unfold_locales
[PROOF STATE]
proof (state)
this:
finite_measure (density lborel g)

goal (3 subgoals):
 1. f \<in> borel_measurable borel
 2. g \<in> borel_measurable borel
 3. prob_space (density lborel f \<star> density lborel g)
[PROOF STEP]
interpret FG: pair_prob_space ?F ?G
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pair_prob_space (density lborel f) (density lborel g)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. f \<in> borel_measurable borel
 2. g \<in> borel_measurable borel
 3. prob_space (density lborel f \<star> density lborel g)
[PROOF STEP]
show "prob_space (density lborel f \<star> density lborel g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prob_space (density lborel f \<star> density lborel g)
[PROOF STEP]
unfolding convolution_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prob_space (distr (density lborel f \<Otimes>\<^sub>M density lborel g) borel (\<lambda>(x, y). x + y))
[PROOF STEP]
by (rule FG.prob_space_distr) simp
[PROOF STATE]
proof (state)
this:
prob_space (density lborel f \<star> density lborel g)

goal (2 subgoals):
 1. f \<in> borel_measurable borel
 2. g \<in> borel_measurable borel
[PROOF STEP]
qed simp_all


[STATEMENT]
lemma Esigma_prime_sum:
  fixes k:: nat assumes "prime m" "k \<ge>1"
  shows "Esigma (m^k) =( m^(k+(1::nat)) -(1::nat)) /(m-1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (Esigma (m ^ k)) = real (m ^ (k + 1) - 1) / (real m - 1)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. real (Esigma (m ^ k)) = real (m ^ (k + 1) - 1) / (real m - 1)
[PROOF STEP]
have "m > 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 < m
[PROOF STEP]
using \<open>prime m\<close> prime_gt_1_nat
[PROOF STATE]
proof (prove)
using this:
prime m
prime ?p \<Longrightarrow> 1 < ?p

goal (1 subgoal):
 1. 1 < m
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
1 < m

goal (1 subgoal):
 1. real (Esigma (m ^ k)) = real (m ^ (k + 1) - 1) / (real m - 1)
[PROOF STEP]
have A: " Esigma (m^k) =( \<Sum> j= 0..k.( m^j)) "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Esigma (m ^ k) = sum ((^) m) {0..k}
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Esigma (m ^ k) = sum ((^) m) {0..k}
[PROOF STEP]
have AA: "divisor_set (m^k) = (\<lambda>j. m ^ j) ` {0..k}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. divisor_set (m ^ k) = (^) m ` {0..k}
[PROOF STEP]
using assms prime_ge_1_nat
[PROOF STATE]
proof (prove)
using this:
prime m
1 \<le> k
prime ?p \<Longrightarrow> 1 \<le> ?p

goal (1 subgoal):
 1. divisor_set (m ^ k) = (^) m ` {0..k}
[PROOF STEP]
by (auto simp add: power_increasing prime_ge_Suc_0_nat divisor_set divisor_def image_iff
 divides_primepow_nat)
[PROOF STATE]
proof (state)
this:
divisor_set (m ^ k) = (^) m ` {0..k}

goal (1 subgoal):
 1. Esigma (m ^ k) = sum ((^) m) {0..k}
[PROOF STEP]
have \<section>: "\<Sum> ((\<lambda>j. m ^ j) ` {..k}) = sum (\<lambda>j. m ^ j) {0..k}"  for k
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Sum> ((^) m ` {..k}) = sum ((^) m) {0..k}
[PROOF STEP]
proof (induction k)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<Sum> ((^) m ` {..0}) = sum ((^) m) {0..0}
 2. \<And>k. \<Sum> ((^) m ` {..k}) = sum ((^) m) {0..k} \<Longrightarrow> \<Sum> ((^) m ` {..Suc k}) = sum ((^) m) {0..Suc k}
[PROOF STEP]
case (Suc k)
[PROOF STATE]
proof (state)
this:
\<Sum> ((^) m ` {..k}) = sum ((^) m) {0..k}

goal (2 subgoals):
 1. \<Sum> ((^) m ` {..0}) = sum ((^) m) {0..0}
 2. \<And>k. \<Sum> ((^) m ` {..k}) = sum ((^) m) {0..k} \<Longrightarrow> \<Sum> ((^) m ` {..Suc k}) = sum ((^) m) {0..Suc k}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<Sum> ((^) m ` {..k}) = sum ((^) m) {0..k}
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
\<Sum> ((^) m ` {..k}) = sum ((^) m) {0..k}

goal (1 subgoal):
 1. \<Sum> ((^) m ` {..Suc k}) = sum ((^) m) {0..Suc k}
[PROOF STEP]
apply (clarsimp simp: atMost_Suc)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Sum> ((^) m ` {..k}) = sum ((^) m) {0..k} \<Longrightarrow> \<Sum> (insert (m * m ^ k) ((^) m ` {..k})) = sum ((^) m) {0..k} + m * m ^ k
[PROOF STEP]
by (smt add.commute add_le_same_cancel1 assms(1) atMost_iff finite_atMost finite_imageI
image_iff le_zero_eq power_add power_one_right prime_power_inj sum.insert zero_neq_one)
[PROOF STATE]
proof (state)
this:
\<Sum> ((^) m ` {..Suc k}) = sum ((^) m) {0..Suc k}

goal (1 subgoal):
 1. \<Sum> ((^) m ` {..0}) = sum ((^) m) {0..0}
[PROOF STEP]
qed auto
[PROOF STATE]
proof (state)
this:
\<Sum> ((^) m ` {..?k}) = sum ((^) m) {0..?k}

goal (1 subgoal):
 1. Esigma (m ^ k) = sum ((^) m) {0..k}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Esigma (m ^ k) = sum ((^) m) {0..k}
[PROOF STEP]
by (metis "\<section>" AA Esigma_def atMost_atLeast0)
[PROOF STATE]
proof (state)
this:
Esigma (m ^ k) = sum ((^) m) {0..k}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Esigma (m ^ k) = sum ((^) m) {0..k}

goal (1 subgoal):
 1. real (Esigma (m ^ k)) = real (m ^ (k + 1) - 1) / (real m - 1)
[PROOF STEP]
have B: "(\<Sum> i\<le>k.( m^i)) = ( m^Suc k -(1::nat)) /(m-(1::nat))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (sum ((^) m) {..k}) = real (m ^ Suc k - 1) / real (m - 1)
[PROOF STEP]
using assms \<open>m > 1\<close> Set_Interval.geometric_sum  [of m "Suc k"]
[PROOF STATE]
proof (prove)
using this:
prime m
1 \<le> k
1 < m
real m \<noteq> 1 \<Longrightarrow> sum ((^) (real m)) {..<Suc k} = (real m ^ Suc k - 1) / (real m - 1)

goal (1 subgoal):
 1. real (sum ((^) m) {..k}) = real (m ^ Suc k - 1) / real (m - 1)
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>prime m; Suc 0 \<le> k; Suc 0 < m; sum ((^) (real m)) {..<k} + real m ^ k = (real m * real m ^ k - 1) / (real m - 1)\<rbrakk> \<Longrightarrow> sum ((^) (real m)) {..k} = real (m * m ^ k - Suc 0) / real (m - Suc 0)
[PROOF STEP]
by (metis One_nat_def lessThan_Suc_atMost nat_one_le_power of_nat_1 of_nat_diff of_nat_mult
of_nat_power one_le_mult_iff prime_ge_Suc_0_nat sum.lessThan_Suc)
[PROOF STATE]
proof (state)
this:
real (sum ((^) m) {..k}) = real (m ^ Suc k - 1) / real (m - 1)

goal (1 subgoal):
 1. real (Esigma (m ^ k)) = real (m ^ (k + 1) - 1) / (real m - 1)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (Esigma (m ^ k)) = real (m ^ (k + 1) - 1) / (real m - 1)
[PROOF STEP]
using A B assms
[PROOF STATE]
proof (prove)
using this:
Esigma (m ^ k) = sum ((^) m) {0..k}
real (sum ((^) m) {..k}) = real (m ^ Suc k - 1) / real (m - 1)
prime m
1 \<le> k

goal (1 subgoal):
 1. real (Esigma (m ^ k)) = real (m ^ (k + 1) - 1) / (real m - 1)
[PROOF STEP]
by (metis Suc_eq_plus1 atMost_atLeast0 of_nat_1 of_nat_diff prime_ge_1_nat)
[PROOF STATE]
proof (state)
this:
real (Esigma (m ^ k)) = real (m ^ (k + 1) - 1) / (real m - 1)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma measurable_limit2 [measurable]:
  fixes u::"nat \<Rightarrow> 'a \<Rightarrow> real"
  assumes [measurable]: "\<And>n. u n \<in> borel_measurable M" "v \<in> borel_measurable M"
  shows "Measurable.pred M (\<lambda>x. (\<lambda>n. u n x) \<longlonglongrightarrow> v x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Measurable.pred M (\<lambda>x. (\<lambda>n. u n x) \<longlonglongrightarrow> v x)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Measurable.pred M (\<lambda>x. (\<lambda>n. u n x) \<longlonglongrightarrow> v x)
[PROOF STEP]
define w where "w = (\<lambda>n x. u n x - v x)"
[PROOF STATE]
proof (state)
this:
w = (\<lambda>n x. u n x - v x)

goal (1 subgoal):
 1. Measurable.pred M (\<lambda>x. (\<lambda>n. u n x) \<longlonglongrightarrow> v x)
[PROOF STEP]
have [measurable]: "w n \<in> borel_measurable M" for n
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. w n \<in> borel_measurable M
[PROOF STEP]
unfolding w_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. u n x - v x) \<in> borel_measurable M
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
w ?n \<in> borel_measurable M

goal (1 subgoal):
 1. Measurable.pred M (\<lambda>x. (\<lambda>n. u n x) \<longlonglongrightarrow> v x)
[PROOF STEP]
have "((\<lambda>n. u n x) \<longlonglongrightarrow> v x) \<longleftrightarrow> ((\<lambda>n. w n x) \<longlonglongrightarrow> 0)" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. u n x) \<longlonglongrightarrow> v x = (\<lambda>n. w n x) \<longlonglongrightarrow> 0
[PROOF STEP]
unfolding w_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. u n x) \<longlonglongrightarrow> v x = (\<lambda>n. u n x - v x) \<longlonglongrightarrow> 0
[PROOF STEP]
using Lim_null
[PROOF STATE]
proof (prove)
using this:
(?f \<longlongrightarrow> ?l) ?net = ((\<lambda>x. ?f x - ?l) \<longlongrightarrow> (0::?'b)) ?net

goal (1 subgoal):
 1. (\<lambda>n. u n x) \<longlonglongrightarrow> v x = (\<lambda>n. u n x - v x) \<longlonglongrightarrow> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>n. u n ?x) \<longlonglongrightarrow> v ?x = (\<lambda>n. w n ?x) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. Measurable.pred M (\<lambda>x. (\<lambda>n. u n x) \<longlonglongrightarrow> v x)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>n. u n ?x) \<longlonglongrightarrow> v ?x = (\<lambda>n. w n ?x) \<longlonglongrightarrow> 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. u n ?x) \<longlonglongrightarrow> v ?x = (\<lambda>n. w n ?x) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. Measurable.pred M (\<lambda>x. (\<lambda>n. u n x) \<longlonglongrightarrow> v x)
[PROOF STEP]
using measurable_limit
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. u n ?x) \<longlonglongrightarrow> v ?x = (\<lambda>n. w n ?x) \<longlonglongrightarrow> 0
(\<And>n. ?f n \<in> borel_measurable ?M) \<Longrightarrow> Measurable.pred ?M (\<lambda>x. (\<lambda>n. ?f n x) \<longlonglongrightarrow> ?c)

goal (1 subgoal):
 1. Measurable.pred M (\<lambda>x. (\<lambda>n. u n x) \<longlonglongrightarrow> v x)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Measurable.pred M (\<lambda>x. (\<lambda>n. u n x) \<longlonglongrightarrow> v x)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma continuous_closed_graph_gen:
  fixes T :: "'b::real_normed_vector set"
  assumes contf: "continuous_on S f" and fim: "f ` S \<subseteq> T"
    shows "closedin (top_of_set (S \<times> T)) ((\<lambda>x. Pair x (f x)) ` S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. closedin (top_of_set (S \<times> T)) ((\<lambda>x. (x, f x)) ` S)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. closedin (top_of_set (S \<times> T)) ((\<lambda>x. (x, f x)) ` S)
[PROOF STEP]
have eq: "((\<lambda>x. Pair x (f x)) ` S) = (S \<times> T \<inter> (\<lambda>z. (f \<circ> fst)z - snd z) -` {0})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. (x, f x)) ` S = S \<times> T \<inter> (\<lambda>z. (f \<circ> fst) z - snd z) -` {0::'b}
[PROOF STEP]
using fim
[PROOF STATE]
proof (prove)
using this:
f ` S \<subseteq> T

goal (1 subgoal):
 1. (\<lambda>x. (x, f x)) ` S = S \<times> T \<inter> (\<lambda>z. (f \<circ> fst) z - snd z) -` {0::'b}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>x. (x, f x)) ` S = S \<times> T \<inter> (\<lambda>z. (f \<circ> fst) z - snd z) -` {0::'b}

goal (1 subgoal):
 1. closedin (top_of_set (S \<times> T)) ((\<lambda>x. (x, f x)) ` S)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. closedin (top_of_set (S \<times> T)) ((\<lambda>x. (x, f x)) ` S)
[PROOF STEP]
unfolding eq
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. closedin (top_of_set (S \<times> T)) (S \<times> T \<inter> (\<lambda>z. (f \<circ> fst) z - snd z) -` {0::'b})
[PROOF STEP]
by (intro continuous_intros continuous_closedin_preimage continuous_on_subset [OF contf]) auto
[PROOF STATE]
proof (state)
this:
closedin (top_of_set (S \<times> T)) ((\<lambda>x. (x, f x)) ` S)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma reflexive_linorder_matrix_2:
  fixes f :: "('a::finite,'b::linorder_stone_relation_algebra_expansion) square"
  assumes "\<forall>i . f (i,i) = top"
    shows "matrix_idempotent_semiring.reflexive f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_idempotent_semiring.reflexive f
[PROOF STEP]
proof (unfold less_eq_matrix_def, rule allI, rule prod_cases)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>e a b. mone (a, b) \<le> f (a, b)
[PROOF STEP]
fix i j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>e a b. mone (a, b) \<le> f (a, b)
[PROOF STEP]
show "mone (i,j) \<le> f (i,j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mone (i, j) \<le> f (i, j)
[PROOF STEP]
proof (cases "i = j")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i = j \<Longrightarrow> mone (i, j) \<le> f (i, j)
 2. i \<noteq> j \<Longrightarrow> mone (i, j) \<le> f (i, j)
[PROOF STEP]
assume "i = j"
[PROOF STATE]
proof (state)
this:
i = j

goal (2 subgoals):
 1. i = j \<Longrightarrow> mone (i, j) \<le> f (i, j)
 2. i \<noteq> j \<Longrightarrow> mone (i, j) \<le> f (i, j)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
i = j

goal (1 subgoal):
 1. mone (i, j) \<le> f (i, j)
[PROOF STEP]
by (simp add: assms)
[PROOF STATE]
proof (state)
this:
mone (i, j) \<le> f (i, j)

goal (1 subgoal):
 1. i \<noteq> j \<Longrightarrow> mone (i, j) \<le> f (i, j)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i \<noteq> j \<Longrightarrow> mone (i, j) \<le> f (i, j)
[PROOF STEP]
assume "i \<noteq> j"
[PROOF STATE]
proof (state)
this:
i \<noteq> j

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

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

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

goal (1 subgoal):
 1. mone (i, j) \<le> f (i, j)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
mone (i, j) \<le> f (i, j)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
mone (i, j) \<le> f (i, j)

goal:
No subgoals!
[PROOF STEP]
qed