[STATEMENT]
theorem integral_swap_continuous:
  fixes f :: "['a::euclidean_space, 'b::euclidean_space] \<Rightarrow> 'c::banach"
  assumes "continuous_on (cbox (a,c) (b,d)) (\<lambda>(x,y). f x y)"
    shows "integral (cbox a b) (\<lambda>x. integral (cbox c d) (f x)) =
           integral (cbox c d) (\<lambda>y. integral (cbox a b) (\<lambda>x. f x y))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integral (cbox a b) (\<lambda>x. integral (cbox c d) (f x)) = integral (cbox c d) (\<lambda>y. integral (cbox a b) (\<lambda>x. f x y))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. integral (cbox a b) (\<lambda>x. integral (cbox c d) (f x)) = integral (cbox c d) (\<lambda>y. integral (cbox a b) (\<lambda>x. f x y))
[PROOF STEP]
have "integral (cbox a b) (\<lambda>x. integral (cbox c d) (f x)) = integral (cbox (a, c) (b, d)) (\<lambda>(x, y). f x y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integral (cbox a b) (\<lambda>x. integral (cbox c d) (f x)) = integral (cbox (a, c) (b, d)) (\<lambda>(x, y). f x y)
[PROOF STEP]
using integral_prod_continuous [OF assms]
[PROOF STATE]
proof (prove)
using this:
integral (cbox (a, c) (b, d)) (\<lambda>(x, y). f x y) = integral (cbox a b) (\<lambda>x. integral (cbox c d) (\<lambda>y. case (x, y) of (x, y) \<Rightarrow> f x y))

goal (1 subgoal):
 1. integral (cbox a b) (\<lambda>x. integral (cbox c d) (f x)) = integral (cbox (a, c) (b, d)) (\<lambda>(x, y). f x y)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
integral (cbox a b) (\<lambda>x. integral (cbox c d) (f x)) = integral (cbox (a, c) (b, d)) (\<lambda>(x, y). f x y)

goal (1 subgoal):
 1. integral (cbox a b) (\<lambda>x. integral (cbox c d) (f x)) = integral (cbox c d) (\<lambda>y. integral (cbox a b) (\<lambda>x. f x y))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
integral (cbox a b) (\<lambda>x. integral (cbox c d) (f x)) = integral (cbox (a, c) (b, d)) (\<lambda>(x, y). f x y)

goal (1 subgoal):
 1. integral (cbox a b) (\<lambda>x. integral (cbox c d) (f x)) = integral (cbox c d) (\<lambda>y. integral (cbox a b) (\<lambda>x. f x y))
[PROOF STEP]
have "... = integral (cbox (c, a) (d, b)) (\<lambda>(x, y). f y x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integral (cbox (a, c) (b, d)) (\<lambda>(x, y). f x y) = integral (cbox (c, a) (d, b)) (\<lambda>(x, y). f y x)
[PROOF STEP]
by (rule integral_swap_2dim [OF assms])
[PROOF STATE]
proof (state)
this:
integral (cbox (a, c) (b, d)) (\<lambda>(x, y). f x y) = integral (cbox (c, a) (d, b)) (\<lambda>(x, y). f y x)

goal (1 subgoal):
 1. integral (cbox a b) (\<lambda>x. integral (cbox c d) (f x)) = integral (cbox c d) (\<lambda>y. integral (cbox a b) (\<lambda>x. f x y))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
integral (cbox (a, c) (b, d)) (\<lambda>(x, y). f x y) = integral (cbox (c, a) (d, b)) (\<lambda>(x, y). f y x)

goal (1 subgoal):
 1. integral (cbox a b) (\<lambda>x. integral (cbox c d) (f x)) = integral (cbox c d) (\<lambda>y. integral (cbox a b) (\<lambda>x. f x y))
[PROOF STEP]
have "... = integral (cbox c d) (\<lambda>y. integral (cbox a b) (\<lambda>x. f x y))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integral (cbox (c, a) (d, b)) (\<lambda>(x, y). f y x) = integral (cbox c d) (\<lambda>y. integral (cbox a b) (\<lambda>x. f x y))
[PROOF STEP]
using integral_prod_continuous [OF swap_continuous] assms
[PROOF STATE]
proof (prove)
using this:
continuous_on (cbox (?c, ?a) (?d, ?b)) (\<lambda>(x, y). ?f1 x y) \<Longrightarrow> integral (cbox (?a, ?c) (?b, ?d)) (\<lambda>(x, y). ?f1 y x) = integral (cbox ?a ?b) (\<lambda>x. integral (cbox ?c ?d) (\<lambda>y. case (x, y) of (x, y) \<Rightarrow> ?f1 y x))
continuous_on (cbox (a, c) (b, d)) (\<lambda>(x, y). f x y)

goal (1 subgoal):
 1. integral (cbox (c, a) (d, b)) (\<lambda>(x, y). f y x) = integral (cbox c d) (\<lambda>y. integral (cbox a b) (\<lambda>x. f x y))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
integral (cbox (c, a) (d, b)) (\<lambda>(x, y). f y x) = integral (cbox c d) (\<lambda>y. integral (cbox a b) (\<lambda>x. f x y))

goal (1 subgoal):
 1. integral (cbox a b) (\<lambda>x. integral (cbox c d) (f x)) = integral (cbox c d) (\<lambda>y. integral (cbox a b) (\<lambda>x. f x y))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
integral (cbox a b) (\<lambda>x. integral (cbox c d) (f x)) = integral (cbox c d) (\<lambda>y. integral (cbox a b) (\<lambda>x. f x y))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
integral (cbox a b) (\<lambda>x. integral (cbox c d) (f x)) = integral (cbox c d) (\<lambda>y. integral (cbox a b) (\<lambda>x. f x y))

goal (1 subgoal):
 1. integral (cbox a b) (\<lambda>x. integral (cbox c d) (f x)) = integral (cbox c d) (\<lambda>y. integral (cbox a b) (\<lambda>x. f x y))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
integral (cbox a b) (\<lambda>x. integral (cbox c d) (f x)) = integral (cbox c d) (\<lambda>y. integral (cbox a b) (\<lambda>x. f x y))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma system_U_implies_vNM_utility:
  assumes fnt: "finite outcomes" and "outcomes \<noteq> {}"
  assumes rpr: "rational_preference (lotteries_on outcomes) \<R>"
  assumes ind: "independent_vnm (lotteries_on outcomes) \<R>"
  assumes cnt: "continuous_vnm (lotteries_on outcomes) \<R>"
  shows "\<exists>u. ordinal_utility (lotteries_on outcomes) \<R> (\<lambda>x. measure_pmf.expectation x u)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>u. ordinal_utility (\<P> outcomes) \<R> (\<lambda>x. measure_pmf.expectation x u)
[PROOF STEP]
using ordinal_utility_expected_value'[of outcomes \<R>] assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>rational_preference (\<P> outcomes) \<R>; independent_vnm (\<P> outcomes) \<R>; finite outcomes; outcomes \<noteq> {}; continuous_vnm (\<P> outcomes) \<R>\<rbrakk> \<Longrightarrow> \<exists>u. ordinal_utility (\<P> outcomes) \<R> (\<lambda>x. measure_pmf.expectation x u)
finite outcomes
outcomes \<noteq> {}
rational_preference (\<P> outcomes) \<R>
independent_vnm (\<P> outcomes) \<R>
continuous_vnm (\<P> outcomes) \<R>

goal (1 subgoal):
 1. \<exists>u. ordinal_utility (\<P> outcomes) \<R> (\<lambda>x. measure_pmf.expectation x u)
[PROOF STEP]
by blast


[STATEMENT]
lemma homotopy_eqv_contractibility:
  fixes S :: "'a::real_normed_vector set" and T :: "'b::real_normed_vector set"
  shows "S homotopy_eqv T \<Longrightarrow> (contractible S \<longleftrightarrow> contractible T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S homotopy_eqv T \<Longrightarrow> contractible S = contractible T
[PROOF STEP]
by (meson contractible_space_top_of_set homotopy_equivalent_space_contractibility)


[STATEMENT]
lemma orthogonal_complement_of_cspan: \<open>orthogonal_complement A = orthogonal_complement (cspan A)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. orthogonal_complement A = orthogonal_complement (cspan A)
[PROOF STEP]
by (metis (no_types, opaque_lifting) closed_csubspace.subspace complex_vector.span_minimal complex_vector.span_superset double_orthogonal_complement_increasing orthogonal_complement_antimono orthogonal_complement_closed_subspace subset_antisym)


[STATEMENT]
theorem p32: "\<forall>x. (F(x) \<and> (G(x) \<or> H(x))) \<longrightarrow> I(x) \<Longrightarrow> \<forall>x. I(x) \<and> H(x) \<longrightarrow> J(x) \<Longrightarrow>
  \<forall>x. K(x) \<longrightarrow> H(x) \<Longrightarrow> \<forall>x. F(x) \<and> K(x) \<longrightarrow> J(x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>x. F x \<and> (G x \<or> H x) \<longrightarrow> I x; \<forall>x. I x \<and> H x \<longrightarrow> J x; \<forall>x. K x \<longrightarrow> H x\<rbrakk> \<Longrightarrow> \<forall>x. F x \<and> K x \<longrightarrow> J x
[PROOF STEP]
by auto2


[STATEMENT]
lemma "(y \<le> x + y) = ((0::real) \<le> x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (y \<le> x + y) = (0 \<le> x)
[PROOF STEP]
by arith


[STATEMENT]
lemma eNorm_triangular_ineq:
  "eNorm N (x + y) \<le> defect N * eNorm N x + defect N * eNorm N y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eNorm N (x + y) \<le> ennreal (defect N) * eNorm N x + ennreal (defect N) * eNorm N y
[PROOF STEP]
unfolding eNorm_def defect_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. snd (Rep_quasinorm N) (x + y) \<le> ennreal (fst (Rep_quasinorm N)) * snd (Rep_quasinorm N) x + ennreal (fst (Rep_quasinorm N)) * snd (Rep_quasinorm N) y
[PROOF STEP]
using Rep_quasinorm[of N]
[PROOF STATE]
proof (prove)
using this:
Rep_quasinorm N \<in> {(x, N). 1 \<le> ennreal x \<and> (\<forall>x c. N (c *\<^sub>R x) = ennreal \<bar>c\<bar> * N x) \<and> (\<forall>xa y. N (xa + y) \<le> ennreal x * N xa + ennreal x * N y)}

goal (1 subgoal):
 1. snd (Rep_quasinorm N) (x + y) \<le> ennreal (fst (Rep_quasinorm N)) * snd (Rep_quasinorm N) x + ennreal (fst (Rep_quasinorm N)) * snd (Rep_quasinorm N) y
[PROOF STEP]
by auto


[STATEMENT]
lemma setEqualityAsDifference:
  "{x}-{y} = {}  =  (x = y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ({x} - {y} = {}) = (x = y)
[PROOF STEP]
by auto


[STATEMENT]
theorem residue_primroot_odd_prime_power_exists:
  assumes p: "prime p" "odd p"
  obtains g where "\<forall>k>0. residue_primroot (p ^ k) g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>g. \<forall>k>0. residue_primroot (p ^ k) g \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>g. \<forall>k>0. residue_primroot (p ^ k) g \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
obtain g where g: "residue_primroot p g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>g. residue_primroot p g \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using prime_primitive_root_exists[of p] assms prime_gt_1_nat[of p]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>1 < p; prime p\<rbrakk> \<Longrightarrow> \<exists>x. residue_primroot p x
prime p
odd p
prime p \<Longrightarrow> 1 < p

goal (1 subgoal):
 1. (\<And>g. residue_primroot p g \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
residue_primroot p g

goal (1 subgoal):
 1. (\<And>g. \<forall>k>0. residue_primroot (p ^ k) g \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "\<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
proof (cases "[g ^ (p - 1) = 1] (mod p\<^sup>2)")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. [g ^ (p - 1) = 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
 2. [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
[g ^ (p - 1) = 1] (mod p\<^sup>2)

goal (2 subgoals):
 1. [g ^ (p - 1) = 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
 2. [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
define g' where "g' = p + g"
[PROOF STATE]
proof (state)
this:
g' = p + g

goal (2 subgoals):
 1. [g ^ (p - 1) = 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
 2. [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
note g
[PROOF STATE]
proof (state)
this:
residue_primroot p g

goal (2 subgoals):
 1. [g ^ (p - 1) = 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
 2. [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
residue_primroot p g

goal (2 subgoals):
 1. [g ^ (p - 1) = 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
 2. [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
have "residue_primroot p g \<longleftrightarrow> residue_primroot p g'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. residue_primroot p g = residue_primroot p g'
[PROOF STEP]
unfolding g'_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. residue_primroot p g = residue_primroot p (p + g)
[PROOF STEP]
by (rule residue_primroot_cong) (auto simp: cong_def)
[PROOF STATE]
proof (state)
this:
residue_primroot p g = residue_primroot p g'

goal (2 subgoals):
 1. [g ^ (p - 1) = 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
 2. [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
residue_primroot p g'
[PROOF STEP]
have g': "residue_primroot p g'"
[PROOF STATE]
proof (prove)
using this:
residue_primroot p g'

goal (1 subgoal):
 1. residue_primroot p g'
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
residue_primroot p g'

goal (2 subgoals):
 1. [g ^ (p - 1) = 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
 2. [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
have "[g' ^ (p - 1) = (\<Sum>k\<le>p-1. ((p-1) choose k) * g ^ (p - Suc k) * p ^ k)] (mod p\<^sup>2)"
      (is "[_ = ?rhs] (mod _)")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [g' ^ (p - 1) = \<Sum>k\<le>p - 1. (p - 1 choose k) * g ^ (p - Suc k) * p ^ k] (mod p\<^sup>2)
[PROOF STEP]
by (simp add: g'_def binomial mult_ac)
[PROOF STATE]
proof (state)
this:
[g' ^ (p - 1) = \<Sum>k\<le>p - 1. (p - 1 choose k) * g ^ (p - Suc k) * p ^ k] (mod p\<^sup>2)

goal (2 subgoals):
 1. [g ^ (p - 1) = 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
 2. [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
[g' ^ (p - 1) = \<Sum>k\<le>p - 1. (p - 1 choose k) * g ^ (p - Suc k) * p ^ k] (mod p\<^sup>2)

goal (2 subgoals):
 1. [g ^ (p - 1) = 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
 2. [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
have "[?rhs = (\<Sum>k\<le>p-1. if k \<le> 1 then ((p-1) choose k) *
                                   g ^ (p - Suc k) * p ^ k else 0)] (mod p\<^sup>2)"
      (is "[sum ?f _ = sum ?g _] (mod _)")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [\<Sum>k\<le>p - 1. (p - 1 choose k) * g ^ (p - Suc k) * p ^ k = \<Sum>k\<le>p - 1. if k \<le> 1 then (p - 1 choose k) * g ^ (p - Suc k) * p ^ k else 0] (mod p\<^sup>2)
[PROOF STEP]
proof (intro cong_sum)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {..p - 1} \<Longrightarrow> [(p - 1 choose x) * g ^ (p - Suc x) * p ^ x = if x \<le> 1 then (p - 1 choose x) * g ^ (p - Suc x) * p ^ x else 0] (mod p\<^sup>2)
[PROOF STEP]
fix k
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {..p - 1} \<Longrightarrow> [(p - 1 choose x) * g ^ (p - Suc x) * p ^ x = if x \<le> 1 then (p - 1 choose x) * g ^ (p - Suc x) * p ^ x else 0] (mod p\<^sup>2)
[PROOF STEP]
assume "k \<in> {..p-1}"
[PROOF STATE]
proof (state)
this:
k \<in> {..p - 1}

goal (1 subgoal):
 1. \<And>x. x \<in> {..p - 1} \<Longrightarrow> [(p - 1 choose x) * g ^ (p - Suc x) * p ^ x = if x \<le> 1 then (p - 1 choose x) * g ^ (p - Suc x) * p ^ x else 0] (mod p\<^sup>2)
[PROOF STEP]
show "[?f k = ?g k] (mod p\<^sup>2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [(p - 1 choose k) * g ^ (p - Suc k) * p ^ k = if k \<le> 1 then (p - 1 choose k) * g ^ (p - Suc k) * p ^ k else 0] (mod p\<^sup>2)
[PROOF STEP]
proof (cases "k \<le> 1")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. k \<le> 1 \<Longrightarrow> [(p - 1 choose k) * g ^ (p - Suc k) * p ^ k = if k \<le> 1 then (p - 1 choose k) * g ^ (p - Suc k) * p ^ k else 0] (mod p\<^sup>2)
 2. \<not> k \<le> 1 \<Longrightarrow> [(p - 1 choose k) * g ^ (p - Suc k) * p ^ k = if k \<le> 1 then (p - 1 choose k) * g ^ (p - Suc k) * p ^ k else 0] (mod p\<^sup>2)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> k \<le> 1

goal (2 subgoals):
 1. k \<le> 1 \<Longrightarrow> [(p - 1 choose k) * g ^ (p - Suc k) * p ^ k = if k \<le> 1 then (p - 1 choose k) * g ^ (p - Suc k) * p ^ k else 0] (mod p\<^sup>2)
 2. \<not> k \<le> 1 \<Longrightarrow> [(p - 1 choose k) * g ^ (p - Suc k) * p ^ k = if k \<le> 1 then (p - 1 choose k) * g ^ (p - Suc k) * p ^ k else 0] (mod p\<^sup>2)
[PROOF STEP]
have "p\<^sup>2 dvd ?f k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p\<^sup>2 dvd (p - 1 choose k) * g ^ (p - Suc k) * p ^ k
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
\<not> k \<le> 1

goal (1 subgoal):
 1. p\<^sup>2 dvd (p - 1 choose k) * g ^ (p - Suc k) * p ^ k
[PROOF STEP]
by (intro dvd_mult le_imp_power_dvd) auto
[PROOF STATE]
proof (state)
this:
p\<^sup>2 dvd (p - 1 choose k) * g ^ (p - Suc k) * p ^ k

goal (2 subgoals):
 1. k \<le> 1 \<Longrightarrow> [(p - 1 choose k) * g ^ (p - Suc k) * p ^ k = if k \<le> 1 then (p - 1 choose k) * g ^ (p - Suc k) * p ^ k else 0] (mod p\<^sup>2)
 2. \<not> k \<le> 1 \<Longrightarrow> [(p - 1 choose k) * g ^ (p - Suc k) * p ^ k = if k \<le> 1 then (p - 1 choose k) * g ^ (p - Suc k) * p ^ k else 0] (mod p\<^sup>2)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
p\<^sup>2 dvd (p - 1 choose k) * g ^ (p - Suc k) * p ^ k

goal (1 subgoal):
 1. [(p - 1 choose k) * g ^ (p - Suc k) * p ^ k = if k \<le> 1 then (p - 1 choose k) * g ^ (p - Suc k) * p ^ k else 0] (mod p\<^sup>2)
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
p\<^sup>2 dvd (p - 1 choose k) * g ^ (p - Suc k) * p ^ k
\<not> k \<le> 1

goal (1 subgoal):
 1. [(p - 1 choose k) * g ^ (p - Suc k) * p ^ k = if k \<le> 1 then (p - 1 choose k) * g ^ (p - Suc k) * p ^ k else 0] (mod p\<^sup>2)
[PROOF STEP]
by (simp add: cong_0_iff)
[PROOF STATE]
proof (state)
this:
[(p - 1 choose k) * g ^ (p - Suc k) * p ^ k = if k \<le> 1 then (p - 1 choose k) * g ^ (p - Suc k) * p ^ k else 0] (mod p\<^sup>2)

goal (1 subgoal):
 1. k \<le> 1 \<Longrightarrow> [(p - 1 choose k) * g ^ (p - Suc k) * p ^ k = if k \<le> 1 then (p - 1 choose k) * g ^ (p - Suc k) * p ^ k else 0] (mod p\<^sup>2)
[PROOF STEP]
qed auto
[PROOF STATE]
proof (state)
this:
[(p - 1 choose k) * g ^ (p - Suc k) * p ^ k = if k \<le> 1 then (p - 1 choose k) * g ^ (p - Suc k) * p ^ k else 0] (mod p\<^sup>2)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
[\<Sum>k\<le>p - 1. (p - 1 choose k) * g ^ (p - Suc k) * p ^ k = \<Sum>k\<le>p - 1. if k \<le> 1 then (p - 1 choose k) * g ^ (p - Suc k) * p ^ k else 0] (mod p\<^sup>2)

goal (2 subgoals):
 1. [g ^ (p - 1) = 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
 2. [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
[\<Sum>k\<le>p - 1. (p - 1 choose k) * g ^ (p - Suc k) * p ^ k = \<Sum>k\<le>p - 1. if k \<le> 1 then (p - 1 choose k) * g ^ (p - Suc k) * p ^ k else 0] (mod p\<^sup>2)

goal (2 subgoals):
 1. [g ^ (p - 1) = 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
 2. [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
have "sum ?g {..p-1} = sum ?f {0, 1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k\<le>p - 1. if k \<le> 1 then (p - 1 choose k) * g ^ (p - Suc k) * p ^ k else 0) = (\<Sum>k\<in>{0, 1}. (p - 1 choose k) * g ^ (p - Suc k) * p ^ k)
[PROOF STEP]
using prime_gt_1_nat[of p] p
[PROOF STATE]
proof (prove)
using this:
prime p \<Longrightarrow> 1 < p
prime p
odd p

goal (1 subgoal):
 1. (\<Sum>k\<le>p - 1. if k \<le> 1 then (p - 1 choose k) * g ^ (p - Suc k) * p ^ k else 0) = (\<Sum>k\<in>{0, 1}. (p - 1 choose k) * g ^ (p - Suc k) * p ^ k)
[PROOF STEP]
by (intro sum.mono_neutral_cong_right) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<le>p - 1. if k \<le> 1 then (p - 1 choose k) * g ^ (p - Suc k) * p ^ k else 0) = (\<Sum>k\<in>{0, 1}. (p - 1 choose k) * g ^ (p - Suc k) * p ^ k)

goal (2 subgoals):
 1. [g ^ (p - 1) = 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
 2. [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<le>p - 1. if k \<le> 1 then (p - 1 choose k) * g ^ (p - Suc k) * p ^ k else 0) = (\<Sum>k\<in>{0, 1}. (p - 1 choose k) * g ^ (p - Suc k) * p ^ k)

goal (2 subgoals):
 1. [g ^ (p - 1) = 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
 2. [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
have "\<dots> = g ^ (p - 1) + p * (p - 1) * g ^ (p - 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k\<in>{0, 1}. (p - 1 choose k) * g ^ (p - Suc k) * p ^ k) = g ^ (p - 1) + p * (p - 1) * g ^ (p - 2)
[PROOF STEP]
using p
[PROOF STATE]
proof (prove)
using this:
prime p
odd p

goal (1 subgoal):
 1. (\<Sum>k\<in>{0, 1}. (p - 1 choose k) * g ^ (p - Suc k) * p ^ k) = g ^ (p - 1) + p * (p - 1) * g ^ (p - 2)
[PROOF STEP]
by (simp add: numeral_2_eq_2)
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<in>{0, 1}. (p - 1 choose k) * g ^ (p - Suc k) * p ^ k) = g ^ (p - 1) + p * (p - 1) * g ^ (p - 2)

goal (2 subgoals):
 1. [g ^ (p - 1) = 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
 2. [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<in>{0, 1}. (p - 1 choose k) * g ^ (p - Suc k) * p ^ k) = g ^ (p - 1) + p * (p - 1) * g ^ (p - 2)

goal (2 subgoals):
 1. [g ^ (p - 1) = 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
 2. [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
have "[g ^ (p - 1) + p * (p - 1) * g ^ (p - 2) = 1 + p * (p - 1) * g ^ (p - 2)] (mod p\<^sup>2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [g ^ (p - 1) + p * (p - 1) * g ^ (p - 2) = 1 + p * (p - 1) * g ^ (p - 2)] (mod p\<^sup>2)
[PROOF STEP]
by (intro cong_add True) auto
[PROOF STATE]
proof (state)
this:
[g ^ (p - 1) + p * (p - 1) * g ^ (p - 2) = 1 + p * (p - 1) * g ^ (p - 2)] (mod p\<^sup>2)

goal (2 subgoals):
 1. [g ^ (p - 1) = 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
 2. [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
[g' ^ (p - 1) = 1 + p * (p - 1) * g ^ (p - 2)] (mod p\<^sup>2)
[PROOF STEP]
have "[g' ^ (p - 1) = 1 + p * (p - 1) * g ^ (p - 2)] (mod p\<^sup>2)"
[PROOF STATE]
proof (prove)
using this:
[g' ^ (p - 1) = 1 + p * (p - 1) * g ^ (p - 2)] (mod p\<^sup>2)

goal (1 subgoal):
 1. [g' ^ (p - 1) = 1 + p * (p - 1) * g ^ (p - 2)] (mod p\<^sup>2)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
[g' ^ (p - 1) = 1 + p * (p - 1) * g ^ (p - 2)] (mod p\<^sup>2)

goal (2 subgoals):
 1. [g ^ (p - 1) = 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
 2. [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
[g' ^ (p - 1) = 1 + p * (p - 1) * g ^ (p - 2)] (mod p\<^sup>2)

goal (2 subgoals):
 1. [g ^ (p - 1) = 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
 2. [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
have "[1 + p * (p - 1) * g ^ (p - 2) \<noteq> 1] (mod p\<^sup>2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [1 + p * (p - 1) * g ^ (p - 2) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. [1 + p * (p - 1) * g ^ (p - 2) = 1] (mod p\<^sup>2) \<Longrightarrow> False
[PROOF STEP]
assume "[1 + p * (p - 1) * g ^ (p - 2) = 1] (mod p\<^sup>2)"
[PROOF STATE]
proof (state)
this:
[1 + p * (p - 1) * g ^ (p - 2) = 1] (mod p\<^sup>2)

goal (1 subgoal):
 1. [1 + p * (p - 1) * g ^ (p - 2) = 1] (mod p\<^sup>2) \<Longrightarrow> False
[PROOF STEP]
hence "[1 + p * (p - 1) * g ^ (p - 2) - 1 = 1 - 1] (mod p\<^sup>2)"
[PROOF STATE]
proof (prove)
using this:
[1 + p * (p - 1) * g ^ (p - 2) = 1] (mod p\<^sup>2)

goal (1 subgoal):
 1. [1 + p * (p - 1) * g ^ (p - 2) - 1 = 1 - 1] (mod p\<^sup>2)
[PROOF STEP]
by (intro cong_diff_nat) auto
[PROOF STATE]
proof (state)
this:
[1 + p * (p - 1) * g ^ (p - 2) - 1 = 1 - 1] (mod p\<^sup>2)

goal (1 subgoal):
 1. [1 + p * (p - 1) * g ^ (p - 2) = 1] (mod p\<^sup>2) \<Longrightarrow> False
[PROOF STEP]
hence "p * p dvd p * ((p - 1) * g ^ (p - 2))"
[PROOF STATE]
proof (prove)
using this:
[1 + p * (p - 1) * g ^ (p - 2) - 1 = 1 - 1] (mod p\<^sup>2)

goal (1 subgoal):
 1. p * p dvd p * ((p - 1) * g ^ (p - 2))
[PROOF STEP]
by (auto simp: cong_0_iff power2_eq_square)
[PROOF STATE]
proof (state)
this:
p * p dvd p * ((p - 1) * g ^ (p - 2))

goal (1 subgoal):
 1. [1 + p * (p - 1) * g ^ (p - 2) = 1] (mod p\<^sup>2) \<Longrightarrow> False
[PROOF STEP]
hence "p dvd (p - 1) * g ^ (p - 2)"
[PROOF STATE]
proof (prove)
using this:
p * p dvd p * ((p - 1) * g ^ (p - 2))

goal (1 subgoal):
 1. p dvd (p - 1) * g ^ (p - 2)
[PROOF STEP]
using p
[PROOF STATE]
proof (prove)
using this:
p * p dvd p * ((p - 1) * g ^ (p - 2))
prime p
odd p

goal (1 subgoal):
 1. p dvd (p - 1) * g ^ (p - 2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
p dvd (p - 1) * g ^ (p - 2)

goal (1 subgoal):
 1. [1 + p * (p - 1) * g ^ (p - 2) = 1] (mod p\<^sup>2) \<Longrightarrow> False
[PROOF STEP]
hence "p dvd g ^ (p - 2)"
[PROOF STATE]
proof (prove)
using this:
p dvd (p - 1) * g ^ (p - 2)

goal (1 subgoal):
 1. p dvd g ^ (p - 2)
[PROOF STEP]
using p dvd_imp_le[of p "p - Suc 0"] prime_gt_1_nat[of p]
[PROOF STATE]
proof (prove)
using this:
p dvd (p - 1) * g ^ (p - 2)
prime p
odd p
\<lbrakk>p dvd p - Suc 0; 0 < p - Suc 0\<rbrakk> \<Longrightarrow> p \<le> p - Suc 0
prime p \<Longrightarrow> 1 < p

goal (1 subgoal):
 1. p dvd g ^ (p - 2)
[PROOF STEP]
by (auto simp: prime_dvd_mult_iff)
[PROOF STATE]
proof (state)
this:
p dvd g ^ (p - 2)

goal (1 subgoal):
 1. [1 + p * (p - 1) * g ^ (p - 2) = 1] (mod p\<^sup>2) \<Longrightarrow> False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
p dvd g ^ (p - 2)

goal (1 subgoal):
 1. [1 + p * (p - 1) * g ^ (p - 2) = 1] (mod p\<^sup>2) \<Longrightarrow> False
[PROOF STEP]
have "\<dots> dvd g ^ (p - 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g ^ (p - 2) dvd g ^ (p - 1)
[PROOF STEP]
by (intro le_imp_power_dvd) auto
[PROOF STATE]
proof (state)
this:
g ^ (p - 2) dvd g ^ (p - 1)

goal (1 subgoal):
 1. [1 + p * (p - 1) * g ^ (p - 2) = 1] (mod p\<^sup>2) \<Longrightarrow> False
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
p dvd g ^ (p - 1)
[PROOF STEP]
have "[g ^ (p - 1) = 0] (mod p)"
[PROOF STATE]
proof (prove)
using this:
p dvd g ^ (p - 1)

goal (1 subgoal):
 1. [g ^ (p - 1) = 0] (mod p)
[PROOF STEP]
by (simp add: cong_0_iff)
[PROOF STATE]
proof (state)
this:
[g ^ (p - 1) = 0] (mod p)

goal (1 subgoal):
 1. [1 + p * (p - 1) * g ^ (p - 2) = 1] (mod p\<^sup>2) \<Longrightarrow> False
[PROOF STEP]
hence "[0 = g ^ (p - 1)] (mod p)"
[PROOF STATE]
proof (prove)
using this:
[g ^ (p - 1) = 0] (mod p)

goal (1 subgoal):
 1. [0 = g ^ (p - 1)] (mod p)
[PROOF STEP]
by (simp add: cong_sym_eq)
[PROOF STATE]
proof (state)
this:
[0 = g ^ (p - 1)] (mod p)

goal (1 subgoal):
 1. [1 + p * (p - 1) * g ^ (p - 2) = 1] (mod p\<^sup>2) \<Longrightarrow> False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
[0 = g ^ (p - 1)] (mod p)

goal (1 subgoal):
 1. [1 + p * (p - 1) * g ^ (p - 2) = 1] (mod p\<^sup>2) \<Longrightarrow> False
[PROOF STEP]
from \<open>residue_primroot p g\<close>
[PROOF STATE]
proof (chain)
picking this:
residue_primroot p g
[PROOF STEP]
have "[g ^ (p - 1) = 1] (mod p)"
[PROOF STATE]
proof (prove)
using this:
residue_primroot p g

goal (1 subgoal):
 1. [g ^ (p - 1) = 1] (mod p)
[PROOF STEP]
using p
[PROOF STATE]
proof (prove)
using this:
residue_primroot p g
prime p
odd p

goal (1 subgoal):
 1. [g ^ (p - 1) = 1] (mod p)
[PROOF STEP]
by (auto simp: residue_primroot_def ord_divides' totient_prime)
[PROOF STATE]
proof (state)
this:
[g ^ (p - 1) = 1] (mod p)

goal (1 subgoal):
 1. [1 + p * (p - 1) * g ^ (p - 2) = 1] (mod p\<^sup>2) \<Longrightarrow> False
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
[0 = 1] (mod p)
[PROOF STEP]
have "[0 = 1] (mod p)"
[PROOF STATE]
proof (prove)
using this:
[0 = 1] (mod p)

goal (1 subgoal):
 1. [0 = 1] (mod p)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
[0 = 1] (mod p)

goal (1 subgoal):
 1. [1 + p * (p - 1) * g ^ (p - 2) = 1] (mod p\<^sup>2) \<Longrightarrow> False
[PROOF STEP]
thus False
[PROOF STATE]
proof (prove)
using this:
[0 = 1] (mod p)

goal (1 subgoal):
 1. False
[PROOF STEP]
using prime_gt_1_nat[of p] p
[PROOF STATE]
proof (prove)
using this:
[0 = 1] (mod p)
prime p \<Longrightarrow> 1 < p
prime p
odd p

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
[1 + p * (p - 1) * g ^ (p - 2) \<noteq> 1] (mod p\<^sup>2)

goal (2 subgoals):
 1. [g ^ (p - 1) = 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
 2. [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
[g' ^ (p - 1) = 1 + p * (p - 1) * g ^ (p - 2)] (mod p\<^sup>2)
[1 + p * (p - 1) * g ^ (p - 2) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
have "[g' ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)"
[PROOF STATE]
proof (prove)
using this:
[g' ^ (p - 1) = 1 + p * (p - 1) * g ^ (p - 2)] (mod p\<^sup>2)
[1 + p * (p - 1) * g ^ (p - 2) \<noteq> 1] (mod p\<^sup>2)

goal (1 subgoal):
 1. [g' ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
by (simp add: cong_def)
[PROOF STATE]
proof (state)
this:
[g' ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)

goal (2 subgoals):
 1. [g ^ (p - 1) = 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
 2. [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
thus "\<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)"
[PROOF STATE]
proof (prove)
using this:
[g' ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)

goal (1 subgoal):
 1. \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
using g'
[PROOF STATE]
proof (prove)
using this:
[g' ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
residue_primroot p g'

goal (1 subgoal):
 1. \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)

goal (1 subgoal):
 1. [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2) \<Longrightarrow> \<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
[PROOF STEP]
qed (use g in auto)
[PROOF STATE]
proof (state)
this:
\<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)

goal (1 subgoal):
 1. (\<And>g. \<forall>k>0. residue_primroot (p ^ k) g \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)

goal (1 subgoal):
 1. thesis
[PROOF STEP]
using residue_primroot_prime_lift_iff[OF assms] that
[PROOF STATE]
proof (prove)
using this:
\<exists>g. residue_primroot p g \<and> [g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
residue_primroot p ?g \<Longrightarrow> (\<forall>k>0. residue_primroot (p ^ k) ?g) = [?g ^ (p - 1) \<noteq> 1] (mod p\<^sup>2)
\<forall>k>0. residue_primroot (p ^ k) ?g \<Longrightarrow> thesis

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma lead_coeff_mult: "lead_coeff (p * q) = lead_coeff p * lead_coeff q"
  for p q :: "'a::{comm_semiring_0, semiring_no_zero_divisors} poly"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lead_coeff (p * q) = lead_coeff p * lead_coeff q
[PROOF STEP]
by (cases "p = 0 \<or> q = 0") (auto simp: coeff_mult_degree_sum degree_mult_eq)


[STATEMENT]
lemma i_set0_mult_0_eq_i_set0_cont: "i_set0_mult 0 = i_set0_cont"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i_set0_mult 0 = i_set0_cont
[PROOF STEP]
by (simp add: i_set0_mult_def i_set0_cont_def i_set_mult_0_eq_i_set_cont)


[STATEMENT]
lemma emb_hsize: "t \<unrhd>\<^sub>e\<^sub>m\<^sub>b s \<Longrightarrow> hsize t \<ge> hsize s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. t \<unrhd>\<^sub>e\<^sub>m\<^sub>b s \<Longrightarrow> hsize s \<le> hsize t
[PROOF STEP]
apply (induction rule: emb.induct)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>t. hsize t \<le> hsize t
 2. \<And>t u s. \<lbrakk>t \<unrhd>\<^sub>e\<^sub>m\<^sub>b u; hsize u \<le> hsize t; u \<rightarrow>\<^sub>e\<^sub>m\<^sub>b s\<rbrakk> \<Longrightarrow> hsize s \<le> hsize t
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>t u s. \<lbrakk>t \<unrhd>\<^sub>e\<^sub>m\<^sub>b u; hsize u \<le> hsize t; u \<rightarrow>\<^sub>e\<^sub>m\<^sub>b s\<rbrakk> \<Longrightarrow> hsize s \<le> hsize t
[PROOF STEP]
using emb_step_hsize
[PROOF STATE]
proof (prove)
using this:
?t \<rightarrow>\<^sub>e\<^sub>m\<^sub>b ?s \<Longrightarrow> hsize ?s < hsize ?t

goal (1 subgoal):
 1. \<And>t u s. \<lbrakk>t \<unrhd>\<^sub>e\<^sub>m\<^sub>b u; hsize u \<le> hsize t; u \<rightarrow>\<^sub>e\<^sub>m\<^sub>b s\<rbrakk> \<Longrightarrow> hsize s \<le> hsize t
[PROOF STEP]
by fastforce


[STATEMENT]
lemma infiter_inf_top: "c\<^sup>\<infinity> = c\<^sup>\<omega> ; \<top>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c\<^sup>\<infinity> = c\<^sup>\<omega> ; \<top>
variables:
c, nil :: 'a
(;) :: 'a \<Rightarrow> 'a \<Rightarrow> 'a
type variables:
'a :: refinement_lattice
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. c\<^sup>\<infinity> = c\<^sup>\<omega> ; \<top>
variables:
c, nil :: 'a
(;) :: 'a \<Rightarrow> 'a \<Rightarrow> 'a
type variables:
'a :: refinement_lattice
[PROOF STEP]
have lr: "c\<^sup>\<infinity> \<sqsubseteq> c\<^sup>\<omega> ; \<top>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c\<^sup>\<infinity> \<sqsubseteq> c\<^sup>\<omega> ; \<top>
variables:
c, nil :: 'a
(;) :: 'a \<Rightarrow> 'a \<Rightarrow> 'a
type variables:
'a :: refinement_lattice
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. c\<^sup>\<infinity> \<sqsubseteq> c\<^sup>\<omega> ; \<top>
variables:
c, nil :: 'a
(;) :: 'a \<Rightarrow> 'a \<Rightarrow> 'a
type variables:
'a :: refinement_lattice
[PROOF STEP]
have "c ; (c\<^sup>\<omega> ; \<top>) = nil ; \<top> \<sqinter> c ; c\<^sup>\<omega> ; \<top>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c ; (c\<^sup>\<omega> ; \<top>) = nil ; \<top> \<sqinter> c ; c\<^sup>\<omega> ; \<top>
variables:
c, nil :: 'a
(;) :: 'a \<Rightarrow> 'a \<Rightarrow> 'a
type variables:
'a :: refinement_lattice
[PROOF STEP]
using semigroup.assoc seq.semigroup_axioms
[PROOF STATE]
proof (prove)
using this:
semigroup (?f::?'a::type \<Rightarrow> ?'a::type \<Rightarrow> ?'a::type) \<Longrightarrow> ?f (?f (?a::?'a::type) (?b::?'a::type)) (?c::?'a::type) = ?f ?a (?f ?b ?c)
semigroup (;)

goal (1 subgoal):
 1. c ; (c\<^sup>\<omega> ; \<top>) = nil ; \<top> \<sqinter> c ; c\<^sup>\<omega> ; \<top>
variables:
c, nil :: 'a
(;) :: 'a \<Rightarrow> 'a \<Rightarrow> 'a
type variables:
'a :: refinement_lattice
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
(c::'a::refinement_lattice) ; (c\<^sup>\<omega> ; \<top>) = nil ; \<top> \<sqinter> c ; c\<^sup>\<omega> ; \<top>

goal (1 subgoal):
 1. c\<^sup>\<infinity> \<sqsubseteq> c\<^sup>\<omega> ; \<top>
variables:
c, nil :: 'a
(;) :: 'a \<Rightarrow> 'a \<Rightarrow> 'a
type variables:
'a :: refinement_lattice
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(c::'a::refinement_lattice) ; (c\<^sup>\<omega> ; \<top>) = nil ; \<top> \<sqinter> c ; c\<^sup>\<omega> ; \<top>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(c::'a::refinement_lattice) ; (c\<^sup>\<omega> ; \<top>) = nil ; \<top> \<sqinter> c ; c\<^sup>\<omega> ; \<top>

goal (1 subgoal):
 1. c\<^sup>\<infinity> \<sqsubseteq> c\<^sup>\<omega> ; \<top>
variables:
c, nil :: 'a
(;) :: 'a \<Rightarrow> 'a \<Rightarrow> 'a
type variables:
'a :: refinement_lattice
[PROOF STEP]
by (metis (no_types) eq_refl finite_or_infinite_iteration.iter_unfold
         finite_or_infinite_iteration_axioms infiter_induct
         seq_distrib_right.inf_seq_distrib seq_distrib_right_axioms)
[PROOF STATE]
proof (state)
this:
(c::'a::refinement_lattice)\<^sup>\<infinity> \<sqsubseteq> c\<^sup>\<omega> ; \<top>

goal:
No subgoals!
variables:
c, nil :: 'a
(;) :: 'a \<Rightarrow> 'a \<Rightarrow> 'a
type variables:
'a :: refinement_lattice
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(c::'a::refinement_lattice)\<^sup>\<infinity> \<sqsubseteq> c\<^sup>\<omega> ; \<top>

goal (1 subgoal):
 1. c\<^sup>\<infinity> = c\<^sup>\<omega> ; \<top>
variables:
c, nil :: 'a
(;) :: 'a \<Rightarrow> 'a \<Rightarrow> 'a
type variables:
'a :: refinement_lattice
[PROOF STEP]
have rl: "c\<^sup>\<omega> ; \<top> \<sqsubseteq> c\<^sup>\<infinity>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c\<^sup>\<omega> ; \<top> \<sqsubseteq> c\<^sup>\<infinity>
variables:
c, nil :: 'a
(;) :: 'a \<Rightarrow> 'a \<Rightarrow> 'a
type variables:
'a :: refinement_lattice
[PROOF STEP]
by (metis inf_le2 infiter_annil infiter_unfold iter_induct_nil seq_mono_left)
[PROOF STATE]
proof (state)
this:
(c::'a::refinement_lattice)\<^sup>\<omega> ; \<top> \<sqsubseteq> c\<^sup>\<infinity>

goal (1 subgoal):
 1. c\<^sup>\<infinity> = c\<^sup>\<omega> ; \<top>
variables:
c, nil :: 'a
(;) :: 'a \<Rightarrow> 'a \<Rightarrow> 'a
type variables:
'a :: refinement_lattice
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(c::'a::refinement_lattice)\<^sup>\<omega> ; \<top> \<sqsubseteq> c\<^sup>\<infinity>

goal (1 subgoal):
 1. c\<^sup>\<infinity> = c\<^sup>\<omega> ; \<top>
variables:
c, nil :: 'a
(;) :: 'a \<Rightarrow> 'a \<Rightarrow> 'a
type variables:
'a :: refinement_lattice
[PROOF STEP]
using antisym_conv lr
[PROOF STATE]
proof (prove)
using this:
(c::'a::refinement_lattice)\<^sup>\<omega> ; \<top> \<sqsubseteq> c\<^sup>\<infinity>
(?y::?'a::order) \<le> (?x::?'a::order) \<Longrightarrow> (?x \<le> ?y) = (?x = ?y)
(c::'a::refinement_lattice)\<^sup>\<infinity> \<sqsubseteq> c\<^sup>\<omega> ; \<top>

goal (1 subgoal):
 1. c\<^sup>\<infinity> = c\<^sup>\<omega> ; \<top>
variables:
c, nil :: 'a
(;) :: 'a \<Rightarrow> 'a \<Rightarrow> 'a
type variables:
'a :: refinement_lattice
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(c::'a::refinement_lattice)\<^sup>\<infinity> = c\<^sup>\<omega> ; \<top>

goal:
No subgoals!
variables:
c, nil :: 'a
(;) :: 'a \<Rightarrow> 'a \<Rightarrow> 'a
type variables:
'a :: refinement_lattice
[PROOF STEP]
qed


[STATEMENT]
lemma cnj_transpose[simp]: "(\<chi> i j. cnj (transpose A $ i $ j)) = transpose (\<chi> i j. cnj (A $ i $ j))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i j. cnj_class.cnj (Finite_Cartesian_Product.transpose A $ i $ j)) = Finite_Cartesian_Product.transpose (\<chi>i j. cnj_class.cnj (A $ i $ j))
[PROOF STEP]
unfolding vec_eq_iff transpose_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i ia. (\<chi>i j. cnj_class.cnj ((\<chi>i j. A $ j $ i) $ i $ j)) $ i $ ia = (\<chi>i j. (\<chi>i j. cnj_class.cnj (A $ i $ j)) $ j $ i) $ i $ ia
[PROOF STEP]
by auto


[STATEMENT]
lemma filter_replicate_mset:
  "filter_mset P (replicate_mset n x) = (if P x then replicate_mset n x else {#})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. filter_mset P (replicate_mset n x) = (if P x then replicate_mset n x else {#})
[PROOF STEP]
by (induction n) auto


[STATEMENT]
lemma proj_fst_k_is_projection:
  "proj_fst_k k * proj_fst_k k = proj_fst_k k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proj_fst_k k * proj_fst_k k = proj_fst_k k
[PROOF STEP]
by (auto simp add: proj_fst_k_def scalar_prod_def sum_only_one_neq_0)


[STATEMENT]
lemma sqrt_exists:
  "0 \<le> (x::int) \<Longrightarrow> \<exists>r' . r'*r' \<le> x \<and> x < (r'+1)*(r'+1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> x \<Longrightarrow> \<exists>r'. r' * r' \<le> x \<and> x < (r' + 1) * (r' + 1)
[PROOF STEP]
using tc_extract_function sqrt_tc
[PROOF STATE]
proof (prove)
using this:
[?p]
?c
[?q] \<Longrightarrow> \<exists>f. \<forall>s. s \<in> ?p \<longrightarrow> f s \<in> ?q
[0 \<le> ?x]
r := 0; WHILE (r + 1) * (r + 1) \<le> ?x INV {r * r \<le> ?x}  VAR {nat (?x - r)}
DO r := r + 1 OD
[r * r \<le> ?x \<and> ?x < (r + 1) * (r + 1)]

goal (1 subgoal):
 1. 0 \<le> x \<Longrightarrow> \<exists>r'. r' * r' \<le> x \<and> x < (r' + 1) * (r' + 1)
[PROOF STEP]
by blast


[STATEMENT]
lemma list_of_lappend:
  assumes "lfinite xs" "lfinite ys"
  shows "list_of (lappend xs ys) = list_of xs @ list_of ys"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. list_of (lappend xs ys) = list_of xs @ list_of ys
[PROOF STEP]
using \<open>lfinite xs\<close>
[PROOF STATE]
proof (prove)
using this:
lfinite xs

goal (1 subgoal):
 1. list_of (lappend xs ys) = list_of xs @ list_of ys
[PROOF STEP]
by induct(simp_all add: \<open>lfinite ys\<close>)


[STATEMENT]
lemma properfactor_nz:
    shows "(y :: 'a) \<noteq> 0 \<Longrightarrow> properfactor x y \<longleftrightarrow> x dvd y \<and> \<not> y dvd x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y \<noteq> (0::'a) \<Longrightarrow> comm_semiring_1_class.properfactor x y = (x dvd y \<and> \<not> y dvd x)
[PROOF STEP]
by (auto simp: properfactor_def factor_def dvd_def)


[STATEMENT]
lemma sum_moebius_mu_divisors:
  assumes "n > 1"
  shows   "(\<Sum>d | d dvd n. moebius_mu d) = (0 :: 'a :: comm_ring_1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (0::'a)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (0::'a)
[PROOF STEP]
have "(\<Sum>d | d dvd n. moebius_mu d :: int) =
          (\<Sum>d \<in> Prod ` {P. P \<subseteq> prime_factors n}. moebius_mu d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = sum moebius_mu (Prod ` {P. P \<subseteq> prime_factors n})
[PROOF STEP]
proof (rule sum.mono_neutral_right; safe?)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. finite {d. d dvd n}
 2. \<And>x A. A \<subseteq> prime_factors n \<Longrightarrow> \<Prod>A dvd n
 3. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
fix A
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. finite {d. d dvd n}
 2. \<And>x A. A \<subseteq> prime_factors n \<Longrightarrow> \<Prod>A dvd n
 3. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
assume A: "A \<subseteq> prime_factors n"
[PROOF STATE]
proof (state)
this:
A \<subseteq> prime_factors n

goal (3 subgoals):
 1. finite {d. d dvd n}
 2. \<And>x A. A \<subseteq> prime_factors n \<Longrightarrow> \<Prod>A dvd n
 3. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
from A
[PROOF STATE]
proof (chain)
picking this:
A \<subseteq> prime_factors n
[PROOF STEP]
have [simp]: "finite A"
[PROOF STATE]
proof (prove)
using this:
A \<subseteq> prime_factors n

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

goal (3 subgoals):
 1. finite {d. d dvd n}
 2. \<And>x A. A \<subseteq> prime_factors n \<Longrightarrow> \<Prod>A dvd n
 3. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
from A
[PROOF STATE]
proof (chain)
picking this:
A \<subseteq> prime_factors n
[PROOF STEP]
have A': "x > 0" "prime x" if "x \<in> A" for x
[PROOF STATE]
proof (prove)
using this:
A \<subseteq> prime_factors n

goal (1 subgoal):
 1. 0 < x &&& prime x
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
A \<subseteq> prime_factors n
x \<in> A

goal (1 subgoal):
 1. 0 < x &&& prime x
[PROOF STEP]
by (auto simp: prime_factors_multiplicity prime_gt_0_nat)
[PROOF STATE]
proof (state)
this:
?x \<in> A \<Longrightarrow> 0 < ?x
?x \<in> A \<Longrightarrow> prime ?x

goal (3 subgoals):
 1. finite {d. d dvd n}
 2. \<And>x A. A \<subseteq> prime_factors n \<Longrightarrow> \<Prod>A dvd n
 3. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
from A'
[PROOF STATE]
proof (chain)
picking this:
?x \<in> A \<Longrightarrow> 0 < ?x
?x \<in> A \<Longrightarrow> prime ?x
[PROOF STEP]
have A_nz: "\<Prod>A \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
?x \<in> A \<Longrightarrow> 0 < ?x
?x \<in> A \<Longrightarrow> prime ?x

goal (1 subgoal):
 1. \<Prod>A \<noteq> 0
[PROOF STEP]
by (intro notI) auto
[PROOF STATE]
proof (state)
this:
\<Prod>A \<noteq> 0

goal (3 subgoals):
 1. finite {d. d dvd n}
 2. \<And>x A. A \<subseteq> prime_factors n \<Longrightarrow> \<Prod>A dvd n
 3. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
from A'
[PROOF STATE]
proof (chain)
picking this:
?x \<in> A \<Longrightarrow> 0 < ?x
?x \<in> A \<Longrightarrow> prime ?x
[PROOF STEP]
have "prime_factorization (\<Prod>A) = sum prime_factorization A"
[PROOF STATE]
proof (prove)
using this:
?x \<in> A \<Longrightarrow> 0 < ?x
?x \<in> A \<Longrightarrow> prime ?x

goal (1 subgoal):
 1. prime_factorization (\<Prod>A) = sum prime_factorization A
[PROOF STEP]
by (subst prime_factorization_prod) (auto dest: finite_subset)
[PROOF STATE]
proof (state)
this:
prime_factorization (\<Prod>A) = sum prime_factorization A

goal (3 subgoals):
 1. finite {d. d dvd n}
 2. \<And>x A. A \<subseteq> prime_factors n \<Longrightarrow> \<Prod>A dvd n
 3. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
prime_factorization (\<Prod>A) = sum prime_factorization A

goal (3 subgoals):
 1. finite {d. d dvd n}
 2. \<And>x A. A \<subseteq> prime_factors n \<Longrightarrow> \<Prod>A dvd n
 3. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
from A'
[PROOF STATE]
proof (chain)
picking this:
?x \<in> A \<Longrightarrow> 0 < ?x
?x \<in> A \<Longrightarrow> prime ?x
[PROOF STEP]
have "\<dots> = sum (\<lambda>x. {#x#}) A"
[PROOF STATE]
proof (prove)
using this:
?x \<in> A \<Longrightarrow> 0 < ?x
?x \<in> A \<Longrightarrow> prime ?x

goal (1 subgoal):
 1. sum prime_factorization A = (\<Sum>x\<in>A. {#x#})
[PROOF STEP]
by (intro sum.cong refl) (auto simp: prime_factorization_prime)
[PROOF STATE]
proof (state)
this:
sum prime_factorization A = (\<Sum>x\<in>A. {#x#})

goal (3 subgoals):
 1. finite {d. d dvd n}
 2. \<And>x A. A \<subseteq> prime_factors n \<Longrightarrow> \<Prod>A dvd n
 3. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum prime_factorization A = (\<Sum>x\<in>A. {#x#})

goal (3 subgoals):
 1. finite {d. d dvd n}
 2. \<And>x A. A \<subseteq> prime_factors n \<Longrightarrow> \<Prod>A dvd n
 3. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
have "\<dots> = mset_set A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>A. {#x#}) = mset_set A
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>A. {#x#}) = mset_set A

goal (3 subgoals):
 1. finite {d. d dvd n}
 2. \<And>x A. A \<subseteq> prime_factors n \<Longrightarrow> \<Prod>A dvd n
 3. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>A. {#x#}) = mset_set A

goal (3 subgoals):
 1. finite {d. d dvd n}
 2. \<And>x A. A \<subseteq> prime_factors n \<Longrightarrow> \<Prod>A dvd n
 3. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
from A
[PROOF STATE]
proof (chain)
picking this:
A \<subseteq> prime_factors n
[PROOF STEP]
have "\<dots> \<subseteq># mset_set (prime_factors n)"
[PROOF STATE]
proof (prove)
using this:
A \<subseteq> prime_factors n

goal (1 subgoal):
 1. mset_set A \<subseteq># mset_set (prime_factors n)
[PROOF STEP]
by (rule subset_imp_msubset_mset_set) simp_all
[PROOF STATE]
proof (state)
this:
mset_set A \<subseteq># mset_set (prime_factors n)

goal (3 subgoals):
 1. finite {d. d dvd n}
 2. \<And>x A. A \<subseteq> prime_factors n \<Longrightarrow> \<Prod>A dvd n
 3. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
mset_set A \<subseteq># mset_set (prime_factors n)

goal (3 subgoals):
 1. finite {d. d dvd n}
 2. \<And>x A. A \<subseteq> prime_factors n \<Longrightarrow> \<Prod>A dvd n
 3. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
have "\<dots> \<subseteq># prime_factorization n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mset_set (prime_factors n) \<subseteq># prime_factorization n
[PROOF STEP]
by (rule mset_set_set_mset_msubset)
[PROOF STATE]
proof (state)
this:
mset_set (prime_factors n) \<subseteq># prime_factorization n

goal (3 subgoals):
 1. finite {d. d dvd n}
 2. \<And>x A. A \<subseteq> prime_factors n \<Longrightarrow> \<Prod>A dvd n
 3. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
prime_factorization (\<Prod>A) \<subseteq># prime_factorization n
[PROOF STEP]
show "\<Prod>A dvd n"
[PROOF STATE]
proof (prove)
using this:
prime_factorization (\<Prod>A) \<subseteq># prime_factorization n

goal (1 subgoal):
 1. \<Prod>A dvd n
[PROOF STEP]
using A_nz
[PROOF STATE]
proof (prove)
using this:
prime_factorization (\<Prod>A) \<subseteq># prime_factorization n
\<Prod>A \<noteq> 0

goal (1 subgoal):
 1. \<Prod>A dvd n
[PROOF STEP]
by (intro prime_factorization_subset_imp_dvd) auto
[PROOF STATE]
proof (state)
this:
\<Prod>A dvd n

goal (2 subgoals):
 1. finite {d. d dvd n}
 2. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. finite {d. d dvd n}
 2. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. finite {d. d dvd n}
 2. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
assume x: "x \<notin> Prod ` {P. P \<subseteq> prime_factors n}" "x dvd n"
[PROOF STATE]
proof (state)
this:
x \<notin> Prod ` {P. P \<subseteq> prime_factors n}
x dvd n

goal (2 subgoals):
 1. finite {d. d dvd n}
 2. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
from x assms
[PROOF STATE]
proof (chain)
picking this:
x \<notin> Prod ` {P. P \<subseteq> prime_factors n}
x dvd n
1 < n
[PROOF STEP]
have [simp]: "x > 0"
[PROOF STATE]
proof (prove)
using this:
x \<notin> Prod ` {P. P \<subseteq> prime_factors n}
x dvd n
1 < n

goal (1 subgoal):
 1. 0 < x
[PROOF STEP]
by (auto intro!: Nat.gr0I)
[PROOF STATE]
proof (state)
this:
0 < x

goal (2 subgoals):
 1. finite {d. d dvd n}
 2. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
0 < x

goal (2 subgoals):
 1. finite {d. d dvd n}
 2. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
assume nz: "moebius_mu x \<noteq> 0"
[PROOF STATE]
proof (state)
this:
moebius_mu x \<noteq> (0::'b)

goal (2 subgoals):
 1. finite {d. d dvd n}
 2. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
have "(\<Prod>(set_mset (prime_factorization x))) = (\<Prod>p\<in>prime_factors x. p ^ multiplicity p x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Prod>(prime_factors x) = (\<Prod>p\<in>prime_factors x. p ^ multiplicity p x)
[PROOF STEP]
using nz
[PROOF STATE]
proof (prove)
using this:
moebius_mu x \<noteq> (0::'b)

goal (1 subgoal):
 1. \<Prod>(prime_factors x) = (\<Prod>p\<in>prime_factors x. p ^ multiplicity p x)
[PROOF STEP]
by (intro prod.cong refl)
                    (auto simp: moebius_mu_eq_zero_iff squarefree_factorial_semiring')
[PROOF STATE]
proof (state)
this:
\<Prod>(prime_factors x) = (\<Prod>p\<in>prime_factors x. p ^ multiplicity p x)

goal (2 subgoals):
 1. finite {d. d dvd n}
 2. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<Prod>(prime_factors x) = (\<Prod>p\<in>prime_factors x. p ^ multiplicity p x)

goal (2 subgoals):
 1. finite {d. d dvd n}
 2. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
have "\<dots> = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>p\<in>prime_factors x. p ^ multiplicity p x) = x
[PROOF STEP]
by (intro Primes.prime_factorization_nat [symmetric]) auto
[PROOF STATE]
proof (state)
this:
(\<Prod>p\<in>prime_factors x. p ^ multiplicity p x) = x

goal (2 subgoals):
 1. finite {d. d dvd n}
 2. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<Prod>(prime_factors x) = x
[PROOF STEP]
have "x = \<Prod>(prime_factors x)" "prime_factors x \<subseteq> prime_factors n"
[PROOF STATE]
proof (prove)
using this:
\<Prod>(prime_factors x) = x

goal (1 subgoal):
 1. x = \<Prod>(prime_factors x) &&& prime_factors x \<subseteq> prime_factors n
[PROOF STEP]
using dvd_prime_factors[of n x] assms \<open>x dvd n\<close>
[PROOF STATE]
proof (prove)
using this:
\<Prod>(prime_factors x) = x
\<lbrakk>n \<noteq> 0; x dvd n\<rbrakk> \<Longrightarrow> prime_factors x \<subseteq> prime_factors n
1 < n
x dvd n

goal (1 subgoal):
 1. x = \<Prod>(prime_factors x) &&& prime_factors x \<subseteq> prime_factors n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x = \<Prod>(prime_factors x)
prime_factors x \<subseteq> prime_factors n

goal (2 subgoals):
 1. finite {d. d dvd n}
 2. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
hence "x \<in> Prod ` {P. P \<subseteq> prime_factors n}"
[PROOF STATE]
proof (prove)
using this:
x = \<Prod>(prime_factors x)
prime_factors x \<subseteq> prime_factors n

goal (1 subgoal):
 1. x \<in> Prod ` {P. P \<subseteq> prime_factors n}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
x \<in> Prod ` {P. P \<subseteq> prime_factors n}

goal (2 subgoals):
 1. finite {d. d dvd n}
 2. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
with x(1)
[PROOF STATE]
proof (chain)
picking this:
x \<notin> Prod ` {P. P \<subseteq> prime_factors n}
x \<in> Prod ` {P. P \<subseteq> prime_factors n}
[PROOF STEP]
have False
[PROOF STATE]
proof (prove)
using this:
x \<notin> Prod ` {P. P \<subseteq> prime_factors n}
x \<in> Prod ` {P. P \<subseteq> prime_factors n}

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

goal (2 subgoals):
 1. finite {d. d dvd n}
 2. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
moebius_mu x \<noteq> (0::?'b) \<Longrightarrow> False

goal (2 subgoals):
 1. finite {d. d dvd n}
 2. \<And>i. \<lbrakk>i \<notin> Prod ` {P. P \<subseteq> prime_factors n}; i dvd n\<rbrakk> \<Longrightarrow> moebius_mu i = 0
[PROOF STEP]
thus "moebius_mu x = 0"
[PROOF STATE]
proof (prove)
using this:
moebius_mu x \<noteq> (0::?'b) \<Longrightarrow> False

goal (1 subgoal):
 1. moebius_mu x = (0::'b)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
moebius_mu x = (0::?'b1)

goal (1 subgoal):
 1. finite {d. d dvd n}
[PROOF STEP]
qed (insert assms, auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd n. moebius_mu d) = sum moebius_mu (Prod ` {P. P \<subseteq> prime_factors n})

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (0::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd n. moebius_mu d) = sum moebius_mu (Prod ` {P. P \<subseteq> prime_factors n})

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (0::'a)
[PROOF STEP]
have "\<dots> = (\<Sum>P | P \<subseteq> prime_factors n. moebius_mu (\<Prod>P))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum moebius_mu (Prod ` {P. P \<subseteq> prime_factors n}) = (\<Sum>P | P \<subseteq> prime_factors n. moebius_mu (\<Prod>P))
[PROOF STEP]
by (subst sum.reindex) (auto intro!: inj_on_Prod_primes dest: finite_subset)
[PROOF STATE]
proof (state)
this:
sum moebius_mu (Prod ` {P. P \<subseteq> prime_factors n}) = (\<Sum>P | P \<subseteq> prime_factors n. moebius_mu (\<Prod>P))

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (0::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum moebius_mu (Prod ` {P. P \<subseteq> prime_factors n}) = (\<Sum>P | P \<subseteq> prime_factors n. moebius_mu (\<Prod>P))

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (0::'a)
[PROOF STEP]
have "\<dots> = (\<Sum>P | P \<subseteq> prime_factors n. (-1) ^ card P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>P | P \<subseteq> prime_factors n. moebius_mu (\<Prod>P)) = (\<Sum>P | P \<subseteq> prime_factors n. (- 1) ^ card P)
[PROOF STEP]
proof (intro sum.cong refl)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {P. P \<subseteq> prime_factors n} \<Longrightarrow> moebius_mu (\<Prod>x) = (- 1) ^ card x
[PROOF STEP]
fix P
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {P. P \<subseteq> prime_factors n} \<Longrightarrow> moebius_mu (\<Prod>x) = (- 1) ^ card x
[PROOF STEP]
assume P: "P \<in> {P. P \<subseteq> prime_factors n}"
[PROOF STATE]
proof (state)
this:
P \<in> {P. P \<subseteq> prime_factors n}

goal (1 subgoal):
 1. \<And>x. x \<in> {P. P \<subseteq> prime_factors n} \<Longrightarrow> moebius_mu (\<Prod>x) = (- 1) ^ card x
[PROOF STEP]
hence [simp]: "finite P"
[PROOF STATE]
proof (prove)
using this:
P \<in> {P. P \<subseteq> prime_factors n}

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

goal (1 subgoal):
 1. \<And>x. x \<in> {P. P \<subseteq> prime_factors n} \<Longrightarrow> moebius_mu (\<Prod>x) = (- 1) ^ card x
[PROOF STEP]
from P
[PROOF STATE]
proof (chain)
picking this:
P \<in> {P. P \<subseteq> prime_factors n}
[PROOF STEP]
have prime: "prime p" if "p \<in> P" for p
[PROOF STATE]
proof (prove)
using this:
P \<in> {P. P \<subseteq> prime_factors n}

goal (1 subgoal):
 1. prime p
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
P \<in> {P. P \<subseteq> prime_factors n}
p \<in> P

goal (1 subgoal):
 1. prime p
[PROOF STEP]
by (auto simp: prime_factors_dvd)
[PROOF STATE]
proof (state)
this:
?p \<in> P \<Longrightarrow> prime ?p

goal (1 subgoal):
 1. \<And>x. x \<in> {P. P \<subseteq> prime_factors n} \<Longrightarrow> moebius_mu (\<Prod>x) = (- 1) ^ card x
[PROOF STEP]
hence "squarefree (\<Prod>P)"
[PROOF STATE]
proof (prove)
using this:
?p \<in> P \<Longrightarrow> prime ?p

goal (1 subgoal):
 1. squarefree (\<Prod>P)
[PROOF STEP]
by (intro squarefree_prod_coprime prime_imp_coprime squarefree_prime)
         (auto simp: primes_dvd_imp_eq)
[PROOF STATE]
proof (state)
this:
squarefree (\<Prod>P)

goal (1 subgoal):
 1. \<And>x. x \<in> {P. P \<subseteq> prime_factors n} \<Longrightarrow> moebius_mu (\<Prod>x) = (- 1) ^ card x
[PROOF STEP]
hence "moebius_mu (\<Prod>P) = (-1) ^ card (prime_factors (\<Prod>P))"
[PROOF STATE]
proof (prove)
using this:
squarefree (\<Prod>P)

goal (1 subgoal):
 1. moebius_mu (\<Prod>P) = (- (1::'b)) ^ card (prime_factors (\<Prod>P))
[PROOF STEP]
by (rule moebius_mu_squarefree_eq)
[PROOF STATE]
proof (state)
this:
moebius_mu (\<Prod>P) = (- (1::?'b1)) ^ card (prime_factors (\<Prod>P))

goal (1 subgoal):
 1. \<And>x. x \<in> {P. P \<subseteq> prime_factors n} \<Longrightarrow> moebius_mu (\<Prod>x) = (- 1) ^ card x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
moebius_mu (\<Prod>P) = (- (1::?'b1)) ^ card (prime_factors (\<Prod>P))

goal (1 subgoal):
 1. \<And>x. x \<in> {P. P \<subseteq> prime_factors n} \<Longrightarrow> moebius_mu (\<Prod>x) = (- 1) ^ card x
[PROOF STEP]
from P
[PROOF STATE]
proof (chain)
picking this:
P \<in> {P. P \<subseteq> prime_factors n}
[PROOF STEP]
have "prime_factors (\<Prod>P) = P"
[PROOF STATE]
proof (prove)
using this:
P \<in> {P. P \<subseteq> prime_factors n}

goal (1 subgoal):
 1. prime_factors (\<Prod>P) = P
[PROOF STEP]
by (subst prime_factors_prod) (auto simp: prime_factorization_prime prime)
[PROOF STATE]
proof (state)
this:
prime_factors (\<Prod>P) = P

goal (1 subgoal):
 1. \<And>x. x \<in> {P. P \<subseteq> prime_factors n} \<Longrightarrow> moebius_mu (\<Prod>x) = (- 1) ^ card x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
moebius_mu (\<Prod>P) = (- (1::?'b2)) ^ card P
[PROOF STEP]
show  "moebius_mu (\<Prod>P) = (-1) ^ card P"
[PROOF STATE]
proof (prove)
using this:
moebius_mu (\<Prod>P) = (- (1::?'b2)) ^ card P

goal (1 subgoal):
 1. moebius_mu (\<Prod>P) = (- (1::'b)) ^ card P
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
moebius_mu (\<Prod>P) = (- (1::?'b2)) ^ card P

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>P | P \<subseteq> prime_factors n. moebius_mu (\<Prod>P)) = (\<Sum>P | P \<subseteq> prime_factors n. (- 1) ^ card P)

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (0::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>P | P \<subseteq> prime_factors n. moebius_mu (\<Prod>P)) = (\<Sum>P | P \<subseteq> prime_factors n. (- 1) ^ card P)

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (0::'a)
[PROOF STEP]
have "{P. P \<subseteq> prime_factors n} =
               {P. P \<subseteq> prime_factors n \<and> even (card P)} \<union> {P. P \<subseteq> prime_factors n \<and> odd (card P)}"
    (is "_ = ?A \<union> ?B")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {P. P \<subseteq> prime_factors n} = {P. P \<subseteq> prime_factors n \<and> even (card P)} \<union> {P. P \<subseteq> prime_factors n \<and> odd (card P)}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
{P. P \<subseteq> prime_factors n} = {P. P \<subseteq> prime_factors n \<and> even (card P)} \<union> {P. P \<subseteq> prime_factors n \<and> odd (card P)}

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (0::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
{P. P \<subseteq> prime_factors n} = {P. P \<subseteq> prime_factors n \<and> even (card P)} \<union> {P. P \<subseteq> prime_factors n \<and> odd (card P)}

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (0::'a)
[PROOF STEP]
have "(\<Sum>P \<in> \<dots>. (-1) ^ card P) = (\<Sum>P \<in> ?A. (-1) ^ card P) + (\<Sum>P \<in> ?B. (-1) ^ card P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>P\<in>{P. P \<subseteq> prime_factors n \<and> even (card P)} \<union> {P. P \<subseteq> prime_factors n \<and> odd (card P)}. (- (1::'b)) ^ card P) = (\<Sum>P | P \<subseteq> prime_factors n \<and> even (card P). (- (1::'b)) ^ card P) + (\<Sum>P | P \<subseteq> prime_factors n \<and> odd (card P). (- (1::'b)) ^ card P)
[PROOF STEP]
by (intro sum.union_disjoint) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>P\<in>{P. P \<subseteq> prime_factors n \<and> even (card P)} \<union> {P. P \<subseteq> prime_factors n \<and> odd (card P)}. (- (1::?'b1)) ^ card P) = (\<Sum>P | P \<subseteq> prime_factors n \<and> even (card P). (- (1::?'b1)) ^ card P) + (\<Sum>P | P \<subseteq> prime_factors n \<and> odd (card P). (- (1::?'b1)) ^ card P)

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (0::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>P\<in>{P. P \<subseteq> prime_factors n \<and> even (card P)} \<union> {P. P \<subseteq> prime_factors n \<and> odd (card P)}. (- (1::?'b1)) ^ card P) = (\<Sum>P | P \<subseteq> prime_factors n \<and> even (card P). (- (1::?'b1)) ^ card P) + (\<Sum>P | P \<subseteq> prime_factors n \<and> odd (card P). (- (1::?'b1)) ^ card P)

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (0::'a)
[PROOF STEP]
have "(\<Sum>P \<in> ?A. (-1) ^ card P :: int) = (\<Sum>P \<in> ?A. 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>P | P \<subseteq> prime_factors n \<and> even (card P). (- 1) ^ card P) = (\<Sum>P | P \<subseteq> prime_factors n \<and> even (card P). 1)
[PROOF STEP]
by (intro sum.cong refl) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>P | P \<subseteq> prime_factors n \<and> even (card P). (- 1) ^ card P) = (\<Sum>P | P \<subseteq> prime_factors n \<and> even (card P). 1)

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (0::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>P | P \<subseteq> prime_factors n \<and> even (card P). (- 1) ^ card P) = (\<Sum>P | P \<subseteq> prime_factors n \<and> even (card P). 1)

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (0::'a)
[PROOF STEP]
have "\<dots> = int (card ?A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>P | P \<subseteq> prime_factors n \<and> even (card P). 1) = int (card {P. P \<subseteq> prime_factors n \<and> even (card P)})
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>P | P \<subseteq> prime_factors n \<and> even (card P). 1) = int (card {P. P \<subseteq> prime_factors n \<and> even (card P)})

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (0::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>P | P \<subseteq> prime_factors n \<and> even (card P). 1) = int (card {P. P \<subseteq> prime_factors n \<and> even (card P)})

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (0::'a)
[PROOF STEP]
have "(\<Sum>P \<in> ?B. (-1) ^ card P :: int) = (\<Sum>P \<in> ?B. -1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>P | P \<subseteq> prime_factors n \<and> odd (card P). (- 1) ^ card P) = (\<Sum>P | P \<subseteq> prime_factors n \<and> odd (card P). - 1)
[PROOF STEP]
by (intro sum.cong refl) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>P | P \<subseteq> prime_factors n \<and> odd (card P). (- 1) ^ card P) = (\<Sum>P | P \<subseteq> prime_factors n \<and> odd (card P). - 1)

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (0::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>P | P \<subseteq> prime_factors n \<and> odd (card P). (- 1) ^ card P) = (\<Sum>P | P \<subseteq> prime_factors n \<and> odd (card P). - 1)

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (0::'a)
[PROOF STEP]
have "\<dots> = -int (card ?B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>P | P \<subseteq> prime_factors n \<and> odd (card P). - 1) = - int (card {P. P \<subseteq> prime_factors n \<and> odd (card P)})
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>P | P \<subseteq> prime_factors n \<and> odd (card P). - 1) = - int (card {P. P \<subseteq> prime_factors n \<and> odd (card P)})

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (0::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>P | P \<subseteq> prime_factors n \<and> odd (card P). - 1) = - int (card {P. P \<subseteq> prime_factors n \<and> odd (card P)})

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (0::'a)
[PROOF STEP]
have "card ?B = card ?A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {P. P \<subseteq> prime_factors n \<and> odd (card P)} = card {P. P \<subseteq> prime_factors n \<and> even (card P)}
[PROOF STEP]
by (rule card_even_odd_subset [symmetric])
       (insert assms, auto simp: prime_factorization_empty_iff)
[PROOF STATE]
proof (state)
this:
card {P. P \<subseteq> prime_factors n \<and> odd (card P)} = card {P. P \<subseteq> prime_factors n \<and> even (card P)}

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (0::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card {P. P \<subseteq> prime_factors n \<and> odd (card P)} = card {P. P \<subseteq> prime_factors n \<and> even (card P)}

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (0::'a)
[PROOF STEP]
have "int (card ?A) + (- int (card ?A)) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int (card {P. P \<subseteq> prime_factors n \<and> even (card P)}) + - int (card {P. P \<subseteq> prime_factors n \<and> even (card P)}) = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
int (card {P. P \<subseteq> prime_factors n \<and> even (card P)}) + - int (card {P. P \<subseteq> prime_factors n \<and> even (card P)}) = 0

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (0::'a)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>d | d dvd n. moebius_mu d) = 0
[PROOF STEP]
have "(\<Sum>d | d dvd n. of_int (moebius_mu d) :: 'a) = 0"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>d | d dvd n. moebius_mu d) = 0

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. of_int (moebius_mu d)) = (0::'a)
[PROOF STEP]
unfolding of_int_sum [symmetric]
[PROOF STATE]
proof (prove)
using this:
(\<Sum>d | d dvd n. moebius_mu d) = 0

goal (1 subgoal):
 1. of_int (\<Sum>d | d dvd n. moebius_mu d) = (0::'a)
[PROOF STEP]
by (simp only: of_int_0)
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd n. of_int (moebius_mu d)) = (0::'a)

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (0::'a)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>d | d dvd n. of_int (moebius_mu d)) = (0::'a)

goal (1 subgoal):
 1. (\<Sum>d | d dvd n. moebius_mu d) = (0::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>d | d dvd n. moebius_mu d) = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem rinss_random_bst:
  "distr (rinss xs \<langle>\<rangle> A) (tree_sigma (count_space A)) (map_tree fst) =
     restrict_space (measure_pmf (random_bst (set xs))) (trees A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distr (rinss xs \<langle>\<rangle> A) (tree_sigma (count_space A)) (map_tree fst) = restrict_space (measure_pmf (random_bst (set xs))) (trees A)
[PROOF STEP]
by (simp only: rinss_bst_of_list lborel_permutations_of_set_bst_of_list
                 distr_bst_of_list_tree_sigma_count_space distr_bst_of_list_random_bst)


[STATEMENT]
lemma times_fun_prod_canc: "(f * g) (x, y) = \<Squnion>{f (x, z) * g (x, rquot y z) | z. z \<preceq>\<^sub>R y}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f \<oplus> g) (x, y) = \<Squnion>{f (x, z) \<oplus> g (x, rquot y z) |z. z \<preceq>\<^sub>R y}
[PROOF STEP]
apply (simp add: times_fun_prod)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Squnion>{f (x, y1) \<oplus> g (x, y2) |y1 y2. D y1 y2 \<and> y = y1 \<oplus> y2} = \<Squnion>{f (x, z) \<oplus> g (x, rquot y z) |z. z \<preceq>\<^sub>R y}
[PROOF STEP]
by (metis (no_types, lifting) gR_rel_defined gR_rel_mult add_canc1 add_canc2)


[STATEMENT]
lemma AR_eq_absolute_extensor:
  fixes S :: "'a::euclidean_space set"
  shows "AR S \<longleftrightarrow>
       (\<forall>f :: 'a * real \<Rightarrow> 'a.
        \<forall>U T. continuous_on T f \<longrightarrow> f ` T \<subseteq> S \<longrightarrow>
               closedin (top_of_set U) T \<longrightarrow>
                (\<exists>g. continuous_on U g \<and> g ` U \<subseteq> S \<and> (\<forall>x \<in> T. g x = f x)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. AR S = (\<forall>f U T. continuous_on T f \<longrightarrow> f ` T \<subseteq> S \<longrightarrow> closedin (top_of_set U) T \<longrightarrow> (\<exists>g. continuous_on U g \<and> g ` U \<subseteq> S \<and> (\<forall>x\<in>T. g x = f x)))
[PROOF STEP]
by (metis (mono_tags, opaque_lifting) AR_imp_absolute_extensor absolute_extensor_imp_AR)


[STATEMENT]
lemma K2_imp_M_neg:
  assumes "v \<noteq> 0" and "proj2_abs v \<in> K2"
  shows "v \<bullet> (M *v v) < 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v \<bullet> (M *v v) < 0
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
v \<noteq> 0
proj2_abs v \<in> K2

goal (1 subgoal):
 1. v \<bullet> (M *v v) < 0
[PROOF STEP]
by (simp add: K2_abs)


[STATEMENT]
lemma list_ord_append: "\<And>ys.
  list_ord ord (xs @ ys) =
  (list_ord ord xs \<and>
  (ys = [] \<or> (list_ord ord ys \<and> (xs = [] \<or> ord (last xs) (hd ys)))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>ys. list_ord ord (xs @ ys) = (list_ord ord xs \<and> (ys = [] \<or> list_ord ord ys \<and> (xs = [] \<or> ord (last xs) (hd ys))))
[PROOF STEP]
apply (induct xs, fastforce)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a xs ys. (\<And>ys. list_ord ord (xs @ ys) = (list_ord ord xs \<and> (ys = [] \<or> list_ord ord ys \<and> (xs = [] \<or> ord (last xs) (hd ys))))) \<Longrightarrow> list_ord ord ((a # xs) @ ys) = (list_ord ord (a # xs) \<and> (ys = [] \<or> list_ord ord ys \<and> (a # xs = [] \<or> ord (last (a # xs)) (hd ys))))
[PROOF STEP]
apply (case_tac xs, case_tac ys, fastforce+)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma inv_prod_rel_eq[simp]: "(P \<times>\<^sub>r Q)\<inverse> = P\<inverse> \<times>\<^sub>r Q\<inverse>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (P \<times>\<^sub>r Q)\<inverse> = P\<inverse> \<times>\<^sub>r Q\<inverse>
[PROOF STEP]
by (auto)


[STATEMENT]
lemma eSuc_le_iff: "eSuc x \<le> y \<longleftrightarrow> (\<exists>y'. y = eSuc y' \<and> x \<le> y')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (eSuc x \<le> y) = (\<exists>y'. y = eSuc y' \<and> x \<le> y')
[PROOF STEP]
by(cases y rule: co.enat.exhaust) simp_all


[STATEMENT]
lemma gauss_int_norm_mod_less_aux:
  assumes [simp]: "b \<noteq> 0"
  shows   "2 * gauss_int_norm (a mod b) \<le> gauss_int_norm b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * gauss_int_norm (a mod b) \<le> gauss_int_norm b
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 2 * gauss_int_norm (a mod b) \<le> gauss_int_norm b
[PROOF STEP]
define a' b' where "a' = gauss2complex a" and "b' = gauss2complex b"
[PROOF STATE]
proof (state)
this:
a' = gauss2complex a
b' = gauss2complex b

goal (1 subgoal):
 1. 2 * gauss_int_norm (a mod b) \<le> gauss_int_norm b
[PROOF STEP]
have [simp]: "b' \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b' \<noteq> 0
[PROOF STEP]
by (simp add: b'_def)
[PROOF STATE]
proof (state)
this:
b' \<noteq> 0

goal (1 subgoal):
 1. 2 * gauss_int_norm (a mod b) \<le> gauss_int_norm b
[PROOF STEP]
have "gauss_int_norm (a mod b) =
          norm (gauss2complex (a - round_complex (a' / b') * b)) ^ 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (gauss_int_norm (a mod b)) = (cmod (gauss2complex (a - round_complex (a' / b') * b)))\<^sup>2
[PROOF STEP]
unfolding modulo_gauss_int_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (gauss_int_norm (a - a div b * b)) = (cmod (gauss2complex (a - round_complex (a' / b') * b)))\<^sup>2
[PROOF STEP]
by (subst real_gauss_int_norm [symmetric]) (auto simp add: divide_gauss_int_def a'_def b'_def)
[PROOF STATE]
proof (state)
this:
real (gauss_int_norm (a mod b)) = (cmod (gauss2complex (a - round_complex (a' / b') * b)))\<^sup>2

goal (1 subgoal):
 1. 2 * gauss_int_norm (a mod b) \<le> gauss_int_norm b
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real (gauss_int_norm (a mod b)) = (cmod (gauss2complex (a - round_complex (a' / b') * b)))\<^sup>2

goal (1 subgoal):
 1. 2 * gauss_int_norm (a mod b) \<le> gauss_int_norm b
[PROOF STEP]
have "gauss2complex (a - round_complex (a' / b') * b) =
               a' - gauss2complex (round_complex (a' / b')) * b'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gauss2complex (a - round_complex (a' / b') * b) = a' - gauss2complex (round_complex (a' / b')) * b'
[PROOF STEP]
by (simp add: a'_def b'_def)
[PROOF STATE]
proof (state)
this:
gauss2complex (a - round_complex (a' / b') * b) = a' - gauss2complex (round_complex (a' / b')) * b'

goal (1 subgoal):
 1. 2 * gauss_int_norm (a mod b) \<le> gauss_int_norm b
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
gauss2complex (a - round_complex (a' / b') * b) = a' - gauss2complex (round_complex (a' / b')) * b'

goal (1 subgoal):
 1. 2 * gauss_int_norm (a mod b) \<le> gauss_int_norm b
[PROOF STEP]
have "\<dots> = (a' / b' - gauss2complex (round_complex (a' / b'))) * b'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a' - gauss2complex (round_complex (a' / b')) * b' = (a' / b' - gauss2complex (round_complex (a' / b'))) * b'
[PROOF STEP]
by (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
a' - gauss2complex (round_complex (a' / b')) * b' = (a' / b' - gauss2complex (round_complex (a' / b'))) * b'

goal (1 subgoal):
 1. 2 * gauss_int_norm (a mod b) \<le> gauss_int_norm b
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
a' - gauss2complex (round_complex (a' / b')) * b' = (a' / b' - gauss2complex (round_complex (a' / b'))) * b'

goal (1 subgoal):
 1. 2 * gauss_int_norm (a mod b) \<le> gauss_int_norm b
[PROOF STEP]
have "norm \<dots> ^ 2 = norm (a' / b' - gauss2complex (round_complex (a' / b'))) ^ 2 * norm b' ^ 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cmod ((a' / b' - gauss2complex (round_complex (a' / b'))) * b'))\<^sup>2 = (cmod (a' / b' - gauss2complex (round_complex (a' / b'))))\<^sup>2 * (cmod b')\<^sup>2
[PROOF STEP]
by (simp add: norm_mult power_mult_distrib)
[PROOF STATE]
proof (state)
this:
(cmod ((a' / b' - gauss2complex (round_complex (a' / b'))) * b'))\<^sup>2 = (cmod (a' / b' - gauss2complex (round_complex (a' / b'))))\<^sup>2 * (cmod b')\<^sup>2

goal (1 subgoal):
 1. 2 * gauss_int_norm (a mod b) \<le> gauss_int_norm b
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(cmod ((a' / b' - gauss2complex (round_complex (a' / b'))) * b'))\<^sup>2 = (cmod (a' / b' - gauss2complex (round_complex (a' / b'))))\<^sup>2 * (cmod b')\<^sup>2

goal (1 subgoal):
 1. 2 * gauss_int_norm (a mod b) \<le> gauss_int_norm b
[PROOF STEP]
have "\<dots> \<le> 1 / 2 * norm b' ^ 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cmod (a' / b' - gauss2complex (round_complex (a' / b'))))\<^sup>2 * (cmod b')\<^sup>2 \<le> 1 / 2 * (cmod b')\<^sup>2
[PROOF STEP]
by (intro mult_right_mono norm_round_complex_le) auto
[PROOF STATE]
proof (state)
this:
(cmod (a' / b' - gauss2complex (round_complex (a' / b'))))\<^sup>2 * (cmod b')\<^sup>2 \<le> 1 / 2 * (cmod b')\<^sup>2

goal (1 subgoal):
 1. 2 * gauss_int_norm (a mod b) \<le> gauss_int_norm b
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(cmod (a' / b' - gauss2complex (round_complex (a' / b'))))\<^sup>2 * (cmod b')\<^sup>2 \<le> 1 / 2 * (cmod b')\<^sup>2

goal (1 subgoal):
 1. 2 * gauss_int_norm (a mod b) \<le> gauss_int_norm b
[PROOF STEP]
have "norm b' ^ 2 = gauss_int_norm b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cmod b')\<^sup>2 = real (gauss_int_norm b)
[PROOF STEP]
by (simp add: b'_def real_gauss_int_norm)
[PROOF STATE]
proof (state)
this:
(cmod b')\<^sup>2 = real (gauss_int_norm b)

goal (1 subgoal):
 1. 2 * gauss_int_norm (a mod b) \<le> gauss_int_norm b
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
real (gauss_int_norm (a mod b)) \<le> 1 / 2 * real (gauss_int_norm b)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
real (gauss_int_norm (a mod b)) \<le> 1 / 2 * real (gauss_int_norm b)

goal (1 subgoal):
 1. 2 * gauss_int_norm (a mod b) \<le> gauss_int_norm b
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
2 * gauss_int_norm (a mod b) \<le> gauss_int_norm b

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma octo_of_real_sum[simp]: "octo_of_real (sum f s) = (\<Sum>x\<in>s. octo_of_real (f x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. octo_of_real (sum f s) = (\<Sum>x\<in>s. octo_of_real (f x))
[PROOF STEP]
by (induct s rule: infinite_finite_induct) auto


[STATEMENT]
lemma monotone_onD: "monotone_on X r s f \<Longrightarrow> r x y \<Longrightarrow> x \<in> X \<Longrightarrow> y \<in> X \<Longrightarrow> s (f x) (f y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Binary_Relations.monotone_on X r s f; r x y; x \<in> X; y \<in> X\<rbrakk> \<Longrightarrow> s (f x) (f y)
[PROOF STEP]
by (auto simp: monotone_on_def)


[STATEMENT]
lemma contD:
  "\<lbrakk> cont luba orda lubb ordb f; Complete_Partial_Order.chain orda Y; Y \<noteq> {} \<rbrakk>
  \<Longrightarrow> f (luba Y) = lubb (f ` Y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>cont luba orda lubb ordb f; Complete_Partial_Order.chain orda Y; Y \<noteq> {}\<rbrakk> \<Longrightarrow> f (luba Y) = lubb (f ` Y)
[PROOF STEP]
unfolding cont_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>Y. Complete_Partial_Order.chain orda Y \<longrightarrow> Y \<noteq> {} \<longrightarrow> f (luba Y) = lubb (f ` Y); Complete_Partial_Order.chain orda Y; Y \<noteq> {}\<rbrakk> \<Longrightarrow> f (luba Y) = lubb (f ` Y)
[PROOF STEP]
by blast


[STATEMENT]
lemma card_M1: "card M1 = p^a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card M1 = p ^ a
[PROOF STEP]
using M1_in_M M_subset_calM calM_def
[PROOF STATE]
proof (prove)
using this:
M1 \<in> M
M \<subseteq> calM
calM \<equiv> {s. s \<subseteq> carrier G \<and> card s = p ^ a}

goal (1 subgoal):
 1. card M1 = p ^ a
[PROOF STEP]
by blast


[STATEMENT]
lemma zmult_zle_mono:"\<lbrakk>i \<le> (j::int); 0 < k\<rbrakk> \<Longrightarrow> k * i \<le>  k * j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>i \<le> j; 0 < k\<rbrakk> \<Longrightarrow> k * i \<le> k * j
[PROOF STEP]
apply (case_tac "i = j")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>i \<le> j; 0 < k; i = j\<rbrakk> \<Longrightarrow> k * i \<le> k * j
 2. \<lbrakk>i \<le> j; 0 < k; i \<noteq> j\<rbrakk> \<Longrightarrow> k * i \<le> k * j
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>i \<le> j; 0 < k; i \<noteq> j\<rbrakk> \<Longrightarrow> k * i \<le> k * j
[PROOF STEP]
apply (frule zle_imp_zless_or_eq[of "i" "j"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>i \<le> j; 0 < k; i \<noteq> j; i < j \<or> i = j\<rbrakk> \<Longrightarrow> k * i \<le> k * j
[PROOF STEP]
apply (thin_tac "i \<le> j")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < k; i \<noteq> j; i < j \<or> i = j\<rbrakk> \<Longrightarrow> k * i \<le> k * j
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma unit_vecs_length[simp]: "length (unit_vecs n) = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (unit_vecs n) = n
[PROOF STEP]
unfolding unit_vecs_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (map (unit_vec n) [0..<n]) = n
[PROOF STEP]
by auto


[STATEMENT]
lemma insertion_smult [simp]: "insertion f (smult c p) = c * insertion f p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. insertion f (MPoly_Type.smult c p) = c * insertion f p
[PROOF STEP]
unfolding insertion_altdef
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m. MPoly_Type.coeff (MPoly_Type.smult c p) m * (\<Prod>i. f i ^ lookup m i)) = c * (\<Sum>m. MPoly_Type.coeff p m * (\<Prod>i. f i ^ lookup m i))
[PROOF STEP]
by (subst Sum_any_right_distrib)
     (auto intro: finite_subset[OF _ finite_coeff_support[of p]] simp: mult.assoc)


[STATEMENT]
lemma mod_mod_power:
  fixes k :: nat
  shows "k mod 2 ^ m mod 2 ^ n = k mod 2 ^ (min m n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
[PROOF STEP]
proof (cases "m \<le> n")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
 2. \<not> m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
m \<le> n

goal (2 subgoals):
 1. m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
 2. \<not> m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
m \<le> n
[PROOF STEP]
have "k mod 2 ^ m mod 2 ^ n = k mod 2 ^ m"
[PROOF STATE]
proof (prove)
using this:
m \<le> n

goal (1 subgoal):
 1. k mod 2 ^ m mod 2 ^ n = k mod 2 ^ m
[PROOF STEP]
apply -
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ m
[PROOF STEP]
apply (subst mod_less [where n = "2 ^ n"])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. m \<le> n \<Longrightarrow> k mod 2 ^ m < 2 ^ n
 2. m \<le> n \<Longrightarrow> k mod 2 ^ m = k mod 2 ^ m
[PROOF STEP]
apply (rule order_less_le_trans [OF mod_less_divisor])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. m \<le> n \<Longrightarrow> 0 < 2 ^ m
 2. m \<le> n \<Longrightarrow> 2 ^ m \<le> 2 ^ n
 3. m \<le> n \<Longrightarrow> k mod 2 ^ m = k mod 2 ^ m
[PROOF STEP]
apply simp+
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
k mod 2 ^ m mod 2 ^ n = k mod 2 ^ m

goal (2 subgoals):
 1. m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
 2. \<not> m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
k mod 2 ^ m mod 2 ^ n = k mod 2 ^ m

goal (2 subgoals):
 1. m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
 2. \<not> m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
[PROOF STEP]
have "\<dots> = k mod  2 ^ (min m n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k mod 2 ^ m = k mod 2 ^ min m n
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
m \<le> n

goal (1 subgoal):
 1. k mod 2 ^ m = k mod 2 ^ min m n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
k mod 2 ^ m = k mod 2 ^ min m n

goal (2 subgoals):
 1. m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
 2. \<not> m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n

goal (1 subgoal):
 1. k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n

goal (1 subgoal):
 1. \<not> m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> m \<le> n

goal (1 subgoal):
 1. \<not> m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> m \<le> n
[PROOF STEP]
have "n < m"
[PROOF STATE]
proof (prove)
using this:
\<not> m \<le> n

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

goal (1 subgoal):
 1. \<not> m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n < m
[PROOF STEP]
obtain d where md: "m = n + d"
[PROOF STATE]
proof (prove)
using this:
n < m

goal (1 subgoal):
 1. (\<And>d. m = n + d \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto dest: less_imp_add_positive)
[PROOF STATE]
proof (state)
this:
m = n + d

goal (1 subgoal):
 1. \<not> m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
m = n + d
[PROOF STEP]
have "k mod 2 ^ m = 2 ^ n * (k div 2 ^ n mod 2 ^ d) + k mod 2 ^ n"
[PROOF STATE]
proof (prove)
using this:
m = n + d

goal (1 subgoal):
 1. k mod 2 ^ m = 2 ^ n * (k div 2 ^ n mod 2 ^ d) + k mod 2 ^ n
[PROOF STEP]
by (simp add: mod_mult2_eq power_add)
[PROOF STATE]
proof (state)
this:
k mod 2 ^ m = 2 ^ n * (k div 2 ^ n mod 2 ^ d) + k mod 2 ^ n

goal (1 subgoal):
 1. \<not> m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
k mod 2 ^ m = 2 ^ n * (k div 2 ^ n mod 2 ^ d) + k mod 2 ^ n
[PROOF STEP]
have "k mod 2 ^ m mod 2 ^ n = k mod 2 ^ n"
[PROOF STATE]
proof (prove)
using this:
k mod 2 ^ m = 2 ^ n * (k div 2 ^ n mod 2 ^ d) + k mod 2 ^ n

goal (1 subgoal):
 1. k mod 2 ^ m mod 2 ^ n = k mod 2 ^ n
[PROOF STEP]
by (simp add: mod_add_left_eq)
[PROOF STATE]
proof (state)
this:
k mod 2 ^ m mod 2 ^ n = k mod 2 ^ n

goal (1 subgoal):
 1. \<not> m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
k mod 2 ^ m mod 2 ^ n = k mod 2 ^ n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
k mod 2 ^ m mod 2 ^ n = k mod 2 ^ n

goal (1 subgoal):
 1. k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
k mod 2 ^ m mod 2 ^ n = k mod 2 ^ n
\<not> m \<le> n

goal (1 subgoal):
 1. k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma atLeastLessThan_empty[simp]:
  assumes "b \<le>\<^sub>a a"
  shows "{a\<le>\<^sub>a..<\<^sub>ab} = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {a\<le>\<^sub>a..<\<^sub>ab} = {}
[PROOF STEP]
unfolding interval_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {a\<le>\<^sub>a..} \<inter> {..<\<^sub>ab} = {}
[PROOF STEP]
using assms less_le_not_le
[PROOF STATE]
proof (prove)
using this:
b \<le>\<^sub>a a
(?x <\<^sub>a ?y) = (?x \<le>\<^sub>a ?y \<and> \<not> ?y \<le>\<^sub>a ?x)

goal (1 subgoal):
 1. {a\<le>\<^sub>a..} \<inter> {..<\<^sub>ab} = {}
[PROOF STEP]
by (blast intro: order_trans)


[STATEMENT]
lemma filterlim_weak_subseq:
  fixes u::"nat \<Rightarrow> nat"
  assumes "(\<lambda>n. real(u n)) \<longlonglongrightarrow> \<infinity>"
  shows "LIM n sequentially. u n:> at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. filterlim u sequentially sequentially
[PROOF STEP]
unfolding filterlim_iff
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>P. eventually P sequentially \<longrightarrow> (\<forall>\<^sub>F x in sequentially. P (u x))
[PROOF STEP]
by (metis assms eventually_weak_subseq)