[STATEMENT]
lemma step_4_pop_big_size_ok_3:
    assumes
      "invar (States dir big small)"
      "0 < size big"
      "Big.pop big = (x, bigP) "
      "remaining_steps (States dir bigP small) \<ge> 4"
      "((step ^^ 4) (States dir bigP small)) = (States dir' big' small')"
      "size_new small + remaining_steps (States dir big small) + 2 \<le> 3 * size_new big"
    shows
      "size_new small' + remaining_steps (States dir' big' small') + 2 \<le> 3 * size_new big'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. size_new small' + remaining_steps (States dir' big' small') + 2 \<le> 3 * size_new big'
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. size_new small' + remaining_steps (States dir' big' small') + 2 \<le> 3 * size_new big'
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
invar (States dir big small)
0 < size big
Big.pop big = (x, bigP)
4 \<le> remaining_steps (States dir bigP small)
(step ^^ 4) (States dir bigP small) = States dir' big' small'
size_new small + remaining_steps (States dir big small) + 2 \<le> 3 * size_new big
[PROOF STEP]
have "size_new small + (remaining_steps (States dir big small) - 4) + 2 \<le> 3 * (size_new big - 1)"
[PROOF STATE]
proof (prove)
using this:
invar (States dir big small)
0 < size big
Big.pop big = (x, bigP)
4 \<le> remaining_steps (States dir bigP small)
(step ^^ 4) (States dir bigP small) = States dir' big' small'
size_new small + remaining_steps (States dir big small) + 2 \<le> 3 * size_new big

goal (1 subgoal):
 1. size_new small + (remaining_steps (States dir big small) - 4) + 2 \<le> 3 * (size_new big - 1)
[PROOF STEP]
by (meson dual_order.trans remaining_steps_pop_big step_4_pop_big_size_ok_3_aux)
[PROOF STATE]
proof (state)
this:
size_new small + (remaining_steps (States dir big small) - 4) + 2 \<le> 3 * (size_new big - 1)

goal (1 subgoal):
 1. size_new small' + remaining_steps (States dir' big' small') + 2 \<le> 3 * size_new big'
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
size_new small + (remaining_steps (States dir big small) - 4) + 2 \<le> 3 * (size_new big - 1)
[PROOF STEP]
have "size_new small + remaining_steps (States dir' big' small') + 2 \<le> 3 * (size_new big - 1)"
[PROOF STATE]
proof (prove)
using this:
size_new small + (remaining_steps (States dir big small) - 4) + 2 \<le> 3 * (size_new big - 1)

goal (1 subgoal):
 1. size_new small + remaining_steps (States dir' big' small') + 2 \<le> 3 * (size_new big - 1)
[PROOF STEP]
by (smt (verit, ccfv_SIG) add_le_mono assms(1) assms(2) assms(3) assms(4) assms(5) dual_order.trans le_antisym less_or_eq_imp_le nat_less_le step_4_remaining_steps_pop_big)
[PROOF STATE]
proof (state)
this:
size_new small + remaining_steps (States dir' big' small') + 2 \<le> 3 * (size_new big - 1)

goal (1 subgoal):
 1. size_new small' + remaining_steps (States dir' big' small') + 2 \<le> 3 * size_new big'
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
invar (States dir big small)
0 < size big
Big.pop big = (x, bigP)
4 \<le> remaining_steps (States dir bigP small)
(step ^^ 4) (States dir bigP small) = States dir' big' small'
size_new small + remaining_steps (States dir big small) + 2 \<le> 3 * size_new big
size_new small + remaining_steps (States dir' big' small') + 2 \<le> 3 * (size_new big - 1)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
invar (States dir big small)
0 < size big
Big.pop big = (x, bigP)
4 \<le> remaining_steps (States dir bigP small)
(step ^^ 4) (States dir bigP small) = States dir' big' small'
size_new small + remaining_steps (States dir big small) + 2 \<le> 3 * size_new big
size_new small + remaining_steps (States dir' big' small') + 2 \<le> 3 * (size_new big - 1)

goal (1 subgoal):
 1. size_new small' + remaining_steps (States dir' big' small') + 2 \<le> 3 * size_new big'
[PROOF STEP]
by (metis diff_Suc_1 invar_pop_big step_n_size_new_small step_n_pop_size_new_big)
[PROOF STATE]
proof (state)
this:
size_new small' + remaining_steps (States dir' big' small') + 2 \<le> 3 * size_new big'

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ang_vec_a_scale2:
  assumes "k \<noteq> 0"
  shows "\<angle>a z1 (cor k * z2) = \<angle>a z1 z2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<angle>a z1 (cor k * z2) = \<angle>a z1 z2
[PROOF STEP]
using ang_vec_a_sym[of z1 "complex_of_real k * z2"]
[PROOF STATE]
proof (prove)
using this:
\<angle>a z1 (cor k * z2) = \<angle>a (cor k * z2) z1

goal (1 subgoal):
 1. \<angle>a z1 (cor k * z2) = \<angle>a z1 z2
[PROOF STEP]
using ang_vec_a_scale1[OF assms, of z2 z1]
[PROOF STATE]
proof (prove)
using this:
\<angle>a z1 (cor k * z2) = \<angle>a (cor k * z2) z1
\<angle>a (cor k * z2) z1 = \<angle>a z2 z1

goal (1 subgoal):
 1. \<angle>a z1 (cor k * z2) = \<angle>a z1 z2
[PROOF STEP]
using ang_vec_a_sym[of z1 z2]
[PROOF STATE]
proof (prove)
using this:
\<angle>a z1 (cor k * z2) = \<angle>a (cor k * z2) z1
\<angle>a (cor k * z2) z1 = \<angle>a z2 z1
\<angle>a z1 z2 = \<angle>a z2 z1

goal (1 subgoal):
 1. \<angle>a z1 (cor k * z2) = \<angle>a z1 z2
[PROOF STEP]
by auto


[STATEMENT]
lemma extreme_point_not_in_interior:
  fixes S :: "'a::{real_normed_vector, perfect_space} set"
  assumes "x extreme_point_of S" shows "x \<notin> interior S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<notin> interior S
[PROOF STEP]
proof (cases "S = {x}")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. S = {x} \<Longrightarrow> x \<notin> interior S
 2. S \<noteq> {x} \<Longrightarrow> x \<notin> interior S
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
S \<noteq> {x}

goal (2 subgoals):
 1. S = {x} \<Longrightarrow> x \<notin> interior S
 2. S \<noteq> {x} \<Longrightarrow> x \<notin> interior S
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
S \<noteq> {x}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
S \<noteq> {x}

goal (1 subgoal):
 1. x \<notin> interior S
[PROOF STEP]
by (meson assms subsetD extreme_point_not_in_REL_INTERIOR interior_subset_rel_interior)
[PROOF STATE]
proof (state)
this:
x \<notin> interior S

goal (1 subgoal):
 1. S = {x} \<Longrightarrow> x \<notin> interior S
[PROOF STEP]
qed (simp add: empty_interior_finite)


[STATEMENT]
lemma facetrel_card: "y \<lhd> x \<Longrightarrow> card (x-y) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y \<lhd> x \<Longrightarrow> card (x - y) = 1
[PROOF STEP]
using insert_Diff_if[of _ y y]
[PROOF STATE]
proof (prove)
using this:
insert ?x y - y = (if ?x \<in> y then y - y else insert ?x (y - y))

goal (1 subgoal):
 1. y \<lhd> x \<Longrightarrow> card (x - y) = 1
[PROOF STEP]
unfolding facetrel_def
[PROOF STATE]
proof (prove)
using this:
insert ?x y - y = (if ?x \<in> y then y - y else insert ?x (y - y))

goal (1 subgoal):
 1. \<exists>v. v \<notin> y \<and> x = insert v y \<Longrightarrow> card (x - y) = 1
[PROOF STEP]
by fastforce


[STATEMENT]
lemma sets_le_imp_space_le: "sets A \<subseteq> sets B \<Longrightarrow> space A \<subseteq> space B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sets A \<subseteq> sets B \<Longrightarrow> space A \<subseteq> space B
[PROOF STEP]
by (auto dest: sets.sets_into_space)


[STATEMENT]
lemma abs_eq_content: "\<bar>y - x\<bar> = (if x\<le>y then content {x..y} else content {y..x})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>y - x\<bar> = (if x \<le> y then content {x..y} else content {y..x})
[PROOF STEP]
by (auto simp: content_real)


[STATEMENT]
lemma qbs_prob_var_bind_return:
  assumes "s \<in> monadP_qbs_Px Y"
          "f \<in> Z \<rightarrow>\<^sub>Q \<real>\<^sub>Q"
      and "g \<in> Y \<rightarrow>\<^sub>Q Z"
    shows "qbs_prob_var (s \<bind> (\<lambda>y. qbs_return Z (g y))) f = qbs_prob_var s (f \<circ> g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. qbs_prob_var (s \<bind> (\<lambda>y. qbs_return Z (g y))) f = qbs_prob_var s (f \<circ> g)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. qbs_prob_var (s \<bind> (\<lambda>y. qbs_return Z (g y))) f = qbs_prob_var s (f \<circ> g)
[PROOF STEP]
have 1:"(\<lambda>x. (f x - qbs_prob_integral s (f \<circ> g))\<^sup>2) \<in> Z \<rightarrow>\<^sub>Q \<real>\<^sub>Q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. (f x - qbs_prob_integral s (f \<circ> g))\<^sup>2) \<in> Z \<rightarrow>\<^sub>Q \<real>\<^sub>Q
[PROOF STEP]
using assms(2,3)
[PROOF STATE]
proof (prove)
using this:
f \<in> Z \<rightarrow>\<^sub>Q \<real>\<^sub>Q
g \<in> Y \<rightarrow>\<^sub>Q Z

goal (1 subgoal):
 1. (\<lambda>x. (f x - qbs_prob_integral s (f \<circ> g))\<^sup>2) \<in> Z \<rightarrow>\<^sub>Q \<real>\<^sub>Q
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>x. (f x - qbs_prob_integral s (f \<circ> g))\<^sup>2) \<in> Z \<rightarrow>\<^sub>Q \<real>\<^sub>Q

goal (1 subgoal):
 1. qbs_prob_var (s \<bind> (\<lambda>y. qbs_return Z (g y))) f = qbs_prob_var s (f \<circ> g)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. (f x - qbs_prob_integral s (f \<circ> g))\<^sup>2) \<in> Z \<rightarrow>\<^sub>Q \<real>\<^sub>Q

goal (1 subgoal):
 1. qbs_prob_var (s \<bind> (\<lambda>y. qbs_return Z (g y))) f = qbs_prob_var s (f \<circ> g)
[PROOF STEP]
using qbs_prob_integral_bind_return[OF assms(1) 1 assms(3)] qbs_prob_integral_bind_return[OF assms]
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. (f x - qbs_prob_integral s (f \<circ> g))\<^sup>2) \<in> Z \<rightarrow>\<^sub>Q \<real>\<^sub>Q
\<integral>\<^sub>Q x. (f x - qbs_prob_integral s (f \<circ> g))\<^sup>2 \<partial>s \<bind> (\<lambda>y. qbs_return Z (g y)) = qbs_prob_integral s ((\<lambda>x. (f x - qbs_prob_integral s (f \<circ> g))\<^sup>2) \<circ> g)
qbs_prob_integral (s \<bind> (\<lambda>y. qbs_return Z (g y))) f = qbs_prob_integral s (f \<circ> g)

goal (1 subgoal):
 1. qbs_prob_var (s \<bind> (\<lambda>y. qbs_return Z (g y))) f = qbs_prob_var s (f \<circ> g)
[PROOF STEP]
by(simp add: comp_def qbs_prob_var_def)
[PROOF STATE]
proof (state)
this:
qbs_prob_var (s \<bind> (\<lambda>y. qbs_return Z (g y))) f = qbs_prob_var s (f \<circ> g)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma additive_principal_times_omega:
"0 < x \<Longrightarrow> additive_principal (x * \<omega>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < x \<Longrightarrow> additive_principal (x * \<omega>)
[PROOF STEP]
apply (rule additive_principal.intro)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. 0 < x \<Longrightarrow> 0 < x * \<omega>
 2. \<And>b. \<lbrakk>0 < x; b < x * \<omega>\<rbrakk> \<Longrightarrow> b + x * \<omega> = x * \<omega>
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>b. \<lbrakk>0 < x; b < x * \<omega>\<rbrakk> \<Longrightarrow> b + x * \<omega> = x * \<omega>
[PROOF STEP]
apply (simp add: omega_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>b. \<lbrakk>0 < x; b < oLimit (\<lambda>n. x * ordinal_of_nat n)\<rbrakk> \<Longrightarrow> oLimit (\<lambda>n. b + x * ordinal_of_nat n) = oLimit (\<lambda>n. x * ordinal_of_nat n)
[PROOF STEP]
apply (drule less_oLimitD, clarify, rename_tac k)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>b k. \<lbrakk>0 < x; b < x * ordinal_of_nat k\<rbrakk> \<Longrightarrow> oLimit (\<lambda>n. b + x * ordinal_of_nat n) = oLimit (\<lambda>n. x * ordinal_of_nat n)
[PROOF STEP]
apply (drule_tac x=b in order_less_imp_le)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>b k. \<lbrakk>0 < x; b \<le> x * ordinal_of_nat k\<rbrakk> \<Longrightarrow> oLimit (\<lambda>n. b + x * ordinal_of_nat n) = oLimit (\<lambda>n. x * ordinal_of_nat n)
[PROOF STEP]
apply (rule oLimit_eqI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>b k n. \<lbrakk>0 < x; b \<le> x * ordinal_of_nat k\<rbrakk> \<Longrightarrow> \<exists>m. b + x * ordinal_of_nat n \<le> x * ordinal_of_nat m
 2. \<And>b k n. \<lbrakk>0 < x; b \<le> x * ordinal_of_nat k\<rbrakk> \<Longrightarrow> \<exists>m. x * ordinal_of_nat n \<le> b + x * ordinal_of_nat m
[PROOF STEP]
apply (rule_tac x="k + n" in exI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>b k n. \<lbrakk>0 < x; b \<le> x * ordinal_of_nat k\<rbrakk> \<Longrightarrow> b + x * ordinal_of_nat n \<le> x * ordinal_of_nat (k + n)
 2. \<And>b k n. \<lbrakk>0 < x; b \<le> x * ordinal_of_nat k\<rbrakk> \<Longrightarrow> \<exists>m. x * ordinal_of_nat n \<le> b + x * ordinal_of_nat m
[PROOF STEP]
apply (erule order_trans[OF ordinal_plus_monoL])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>b k n. 0 < x \<Longrightarrow> x * ordinal_of_nat k + x * ordinal_of_nat n \<le> x * ordinal_of_nat (k + n)
 2. \<And>b k n. \<lbrakk>0 < x; b \<le> x * ordinal_of_nat k\<rbrakk> \<Longrightarrow> \<exists>m. x * ordinal_of_nat n \<le> b + x * ordinal_of_nat m
[PROOF STEP]
apply (simp add: ordinal_times_distrib[symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>b k n. \<lbrakk>0 < x; b \<le> x * ordinal_of_nat k\<rbrakk> \<Longrightarrow> \<exists>m. x * ordinal_of_nat n \<le> b + x * ordinal_of_nat m
[PROOF STEP]
apply (rule_tac x=n in exI, simp)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma norm_of_real_diff [simp]:
  "norm (of_real b - of_real a :: 'a::real_normed_algebra_1) \<le> \<bar>b - a\<bar>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (of_real b - of_real a) \<le> \<bar>b - a\<bar>
[PROOF STEP]
by (metis norm_of_real of_real_diff order_refl)


[STATEMENT]
lemma curry_forall_eq:
  "(\<forall>f. P f) = (\<forall>f. P (case_prod f))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>f. P f) = (\<forall>f. P (\<lambda>(x, y). f x y))
[PROOF STEP]
by (metis case_prod_curry)


[STATEMENT]
lemma right_total_rel_converter:
  "\<lbrakk> right_unique A; left_total A; right_total B; right_total C; right_unique R; left_total R \<rbrakk>
   \<Longrightarrow> right_total (rel_converter A B C R)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>right_unique A; left_total A; right_total B; right_total C; right_unique R; left_total R\<rbrakk> \<Longrightarrow> right_total (rel_converter A B C R)
[PROOF STEP]
unfolding right_unique_alt_def right_total_alt_def rel_converter_conversep[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A\<inverse>\<inverse> OO A \<le> (=); left_total A; (=) \<le> B\<inverse>\<inverse> OO B; (=) \<le> C\<inverse>\<inverse> OO C; R\<inverse>\<inverse> OO R \<le> (=); left_total R\<rbrakk> \<Longrightarrow> (=) \<le> rel_converter A\<inverse>\<inverse> B\<inverse>\<inverse> C\<inverse>\<inverse> R\<inverse>\<inverse> OO rel_converter A B C R
[PROOF STEP]
apply(subst rel_converter_eq[symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A\<inverse>\<inverse> OO A \<le> (=); left_total A; (=) \<le> B\<inverse>\<inverse> OO B; (=) \<le> C\<inverse>\<inverse> OO C; R\<inverse>\<inverse> OO R \<le> (=); left_total R\<rbrakk> \<Longrightarrow> rel_converter (=) (=) (=) (=) \<le> rel_converter A\<inverse>\<inverse> B\<inverse>\<inverse> C\<inverse>\<inverse> R\<inverse>\<inverse> OO rel_converter A B C R
[PROOF STEP]
apply(rule order_trans[rotated])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>A\<inverse>\<inverse> OO A \<le> (=); left_total A; (=) \<le> B\<inverse>\<inverse> OO B; (=) \<le> C\<inverse>\<inverse> OO C; R\<inverse>\<inverse> OO R \<le> (=); left_total R\<rbrakk> \<Longrightarrow> ?y \<le> rel_converter A\<inverse>\<inverse> B\<inverse>\<inverse> C\<inverse>\<inverse> R\<inverse>\<inverse> OO rel_converter A B C R
 2. \<lbrakk>A\<inverse>\<inverse> OO A \<le> (=); left_total A; (=) \<le> B\<inverse>\<inverse> OO B; (=) \<le> C\<inverse>\<inverse> OO C; R\<inverse>\<inverse> OO R \<le> (=); left_total R\<rbrakk> \<Longrightarrow> rel_converter (=) (=) (=) (=) \<le> ?y
[PROOF STEP]
apply(rule rel_converter_neg_distr; simp add: right_unique_alt_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A\<inverse>\<inverse> OO A \<le> (=); left_total A; (=) \<le> B\<inverse>\<inverse> OO B; (=) \<le> C\<inverse>\<inverse> OO C; R\<inverse>\<inverse> OO R \<le> (=); left_total R\<rbrakk> \<Longrightarrow> rel_converter (=) (=) (=) (=) \<le> rel_converter (A\<inverse>\<inverse> OO A) (B\<inverse>\<inverse> OO B) (C\<inverse>\<inverse> OO C) (R\<inverse>\<inverse> OO R)
[PROOF STEP]
apply(rule rel_converter_mono; assumption)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma extend_set_subset_Compl_eq: "(extend_set h A \<subseteq> - extend_set h B) = (A \<subseteq> - B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (extend_set h A \<subseteq> - extend_set h B) = (A \<subseteq> - B)
[PROOF STEP]
by (auto simp: extend_set_def)


[STATEMENT]
lemma resr_subdist: "(x \<rightarrow> y) \<squnion> (x \<rightarrow> z) \<le> x \<rightarrow> (y \<squnion> z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x \<rightarrow> y) \<squnion> (x \<rightarrow> z) \<le> x \<rightarrow> y \<squnion> z
[PROOF STEP]
by (metis sup_commute sup_least resr_subdist_var)


[STATEMENT]
lemma b_gt1: "b>1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 < b
[PROOF STEP]
using c_gt0 b_def
[PROOF STATE]
proof (prove)
using this:
0 < c
b \<equiv> 2 ^ Suc c

goal (1 subgoal):
 1. 1 < b
[PROOF STEP]
using one_less_numeral_iff one_less_power semiring_norm(76)
[PROOF STATE]
proof (prove)
using this:
0 < c
b \<equiv> 2 ^ Suc c
((1::?'a) < numeral ?n) = (num.One < ?n)
\<lbrakk>(1::?'a) < ?a; 0 < ?n\<rbrakk> \<Longrightarrow> (1::?'a) < ?a ^ ?n
(num.One < num.Bit0 ?n) = True

goal (1 subgoal):
 1. 1 < b
[PROOF STEP]
by blast


[STATEMENT]
lemma maxne0_times_sum_list_gt_dotprod:
  assumes "length b = length ys"
  shows "maxne0 ys b * sum_list ys \<ge> b \<bullet> ys"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b \<bullet> ys \<le> maxne0 ys b * sum_list ys
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
length b = length ys

goal (1 subgoal):
 1. b \<bullet> ys \<le> maxne0 ys b * sum_list ys
[PROOF STEP]
apply (induct b ys rule: list_induct2)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. [] \<bullet> [] \<le> maxne0 [] [] * sum_list []
 2. \<And>x xs y ys. \<lbrakk>length xs = length ys; xs \<bullet> ys \<le> maxne0 ys xs * sum_list ys\<rbrakk> \<Longrightarrow> (x # xs) \<bullet> (y # ys) \<le> maxne0 (y # ys) (x # xs) * sum_list (y # ys)
[PROOF STEP]
apply (auto  simp: max_def ring_distribs add_mono_thms_linordered_semiring(1))
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x xs y ys. \<lbrakk>length xs = length ys; xs \<bullet> ys \<le> maxne0 ys xs * sum_list ys; \<not> x \<le> maxne0 ys xs; 0 < y\<rbrakk> \<Longrightarrow> xs \<bullet> ys \<le> x * sum_list ys
[PROOF STEP]
by (meson leI le_trans mult_less_cancel2 nat_less_le)


[STATEMENT]
lemma (in Module) linear_comb_eq:"\<lbrakk>H \<subseteq> carrier M;
       s \<in> {j. j \<le> (n::nat)} \<rightarrow> carrier R; f \<in> {j. j \<le> n} \<rightarrow> H;
       g \<in> {j. j \<le> n} \<rightarrow> H; \<forall>j\<in>{j. j \<le> n}. f j = g j\<rbrakk>  \<Longrightarrow>
  l_comb R M n s f = l_comb R M n s g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>H \<subseteq> carrier M; s \<in> {j. j \<le> n} \<rightarrow> carrier R; f \<in> {j. j \<le> n} \<rightarrow> H; g \<in> {j. j \<le> n} \<rightarrow> H; \<forall>j\<in>{j. j \<le> n}. f j = g j\<rbrakk> \<Longrightarrow> l_comb R M n s f = l_comb R M n s g
[PROOF STEP]
apply (simp add:linear_comb_eqTr)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma is_unit_div_div_commute: "is_unit b \<Longrightarrow> is_unit c \<Longrightarrow> a div b div c = a div c div b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>is_unit b; is_unit c\<rbrakk> \<Longrightarrow> a div b div c = a div c div b
[PROOF STEP]
by (metis is_unit_div_mult2_eq mult.commute)


[STATEMENT]
lemma lens_plus_assoc:
  "(X +\<^sub>L Y) +\<^sub>L Z \<approx>\<^sub>L X +\<^sub>L Y +\<^sub>L Z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (X +\<^sub>L Y) +\<^sub>L Z \<approx>\<^sub>L X +\<^sub>L Y +\<^sub>L Z
[PROOF STEP]
by (simp add: lens_equivI lens_plus_sub_assoc_1 lens_plus_sub_assoc_2)


[STATEMENT]
lemma countably_compact_eq_compact:
  "countably_compact U \<longleftrightarrow> compact (U :: 'a :: second_countable_topology set)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. countably_compact U = compact U
[PROOF STEP]
using countably_compact_imp_compact_second_countable compact_imp_countably_compact
[PROOF STATE]
proof (prove)
using this:
countably_compact ?U \<Longrightarrow> compact ?U
compact ?U \<Longrightarrow> countably_compact ?U

goal (1 subgoal):
 1. countably_compact U = compact U
[PROOF STEP]
by blast


[STATEMENT]
lemma complex_roots_of_int_poly:
  shows "p \<noteq> 0 \<Longrightarrow> set (complex_roots_of_int_poly p) = {x. ipoly p x = 0}" (is "_ \<Longrightarrow> ?l = ?r")
  and "distinct (complex_roots_of_int_poly p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (p \<noteq> 0 \<Longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) &&& distinct (complex_roots_of_int_poly p)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. p \<noteq> 0 \<Longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}
 2. distinct (complex_roots_of_int_poly p)
[PROOF STEP]
have "(p \<noteq> 0 \<longrightarrow> ?l = ?r) \<and> (distinct (complex_roots_of_int_poly p))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)
[PROOF STEP]
proof (cases "degree p \<ge> 3")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 3 \<le> degree p \<Longrightarrow> (p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)
 2. \<not> 3 \<le> degree p \<Longrightarrow> (p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> 3 \<le> degree p

goal (2 subgoals):
 1. 3 \<le> degree p \<Longrightarrow> (p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)
 2. \<not> 3 \<le> degree p \<Longrightarrow> (p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)
[PROOF STEP]
hence "complex_roots_of_int_poly p = complex_roots_of_int_poly_all p"
[PROOF STATE]
proof (prove)
using this:
\<not> 3 \<le> degree p

goal (1 subgoal):
 1. complex_roots_of_int_poly p = complex_roots_of_int_poly_all p
[PROOF STEP]
unfolding complex_roots_of_int_poly_def Let_def
[PROOF STATE]
proof (prove)
using this:
\<not> 3 \<le> degree p

goal (1 subgoal):
 1. concat (map complex_roots_of_int_poly_all (if 3 \<le> degree p then factors_of_int_poly p else [p])) = complex_roots_of_int_poly_all p
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
complex_roots_of_int_poly p = complex_roots_of_int_poly_all p

goal (2 subgoals):
 1. 3 \<le> degree p \<Longrightarrow> (p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)
 2. \<not> 3 \<le> degree p \<Longrightarrow> (p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)
[PROOF STEP]
with complex_roots_of_int_poly_all[of p] False
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>3 \<le> degree p \<Longrightarrow> square_free p; p \<noteq> 0\<rbrakk> \<Longrightarrow> set (complex_roots_of_int_poly_all p) = {x. poly (complex_of_int_poly p) x = 0}
(3 \<le> degree p \<Longrightarrow> square_free p) \<Longrightarrow> distinct (complex_roots_of_int_poly_all p)
\<not> 3 \<le> degree p
complex_roots_of_int_poly p = complex_roots_of_int_poly_all p
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>3 \<le> degree p \<Longrightarrow> square_free p; p \<noteq> 0\<rbrakk> \<Longrightarrow> set (complex_roots_of_int_poly_all p) = {x. poly (complex_of_int_poly p) x = 0}
(3 \<le> degree p \<Longrightarrow> square_free p) \<Longrightarrow> distinct (complex_roots_of_int_poly_all p)
\<not> 3 \<le> degree p
complex_roots_of_int_poly p = complex_roots_of_int_poly_all p

goal (1 subgoal):
 1. (p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)

goal (1 subgoal):
 1. 3 \<le> degree p \<Longrightarrow> (p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 3 \<le> degree p \<Longrightarrow> (p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
3 \<le> degree p

goal (1 subgoal):
 1. 3 \<le> degree p \<Longrightarrow> (p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
3 \<le> degree p

goal (1 subgoal):
 1. 3 \<le> degree p \<Longrightarrow> (p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)
[PROOF STEP]
fix q
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 3 \<le> degree p \<Longrightarrow> (p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)
[PROOF STEP]
assume "q \<in> set (factors_of_int_poly p)"
[PROOF STATE]
proof (state)
this:
q \<in> set (factors_of_int_poly p)

goal (1 subgoal):
 1. 3 \<le> degree p \<Longrightarrow> (p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)
[PROOF STEP]
from factors_of_int_poly(1)[OF refl this] irreducible_imp_square_free[of q]
[PROOF STATE]
proof (chain)
picking this:
irreducible q \<and> 0 < lead_coeff q \<and> degree q \<le> degree p \<and> degree q \<noteq> 0
irreducible q \<Longrightarrow> square_free q
[PROOF STEP]
have 0: "q \<noteq> 0" and sf: "square_free q"
[PROOF STATE]
proof (prove)
using this:
irreducible q \<and> 0 < lead_coeff q \<and> degree q \<le> degree p \<and> degree q \<noteq> 0
irreducible q \<Longrightarrow> square_free q

goal (1 subgoal):
 1. q \<noteq> 0 &&& square_free q
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
q \<noteq> 0
square_free q

goal (1 subgoal):
 1. 3 \<le> degree p \<Longrightarrow> (p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)
[PROOF STEP]
from complex_roots_of_int_poly_all(1)[OF sf 0] complex_roots_of_int_poly_all(2)[OF sf]
[PROOF STATE]
proof (chain)
picking this:
set (complex_roots_of_int_poly_all q) = {x. poly (complex_of_int_poly q) x = 0}
distinct (complex_roots_of_int_poly_all q)
[PROOF STEP]
have "set (complex_roots_of_int_poly_all q) = {x. ipoly q x = 0}"
        "distinct (complex_roots_of_int_poly_all q)"
[PROOF STATE]
proof (prove)
using this:
set (complex_roots_of_int_poly_all q) = {x. poly (complex_of_int_poly q) x = 0}
distinct (complex_roots_of_int_poly_all q)

goal (1 subgoal):
 1. set (complex_roots_of_int_poly_all q) = {x. poly (complex_of_int_poly q) x = 0} &&& distinct (complex_roots_of_int_poly_all q)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set (complex_roots_of_int_poly_all q) = {x. poly (complex_of_int_poly q) x = 0}
distinct (complex_roots_of_int_poly_all q)

goal (1 subgoal):
 1. 3 \<le> degree p \<Longrightarrow> (p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?q2 \<in> set (factors_of_int_poly p) \<Longrightarrow> set (complex_roots_of_int_poly_all ?q2) = {x. poly (complex_of_int_poly ?q2) x = 0}
?q2 \<in> set (factors_of_int_poly p) \<Longrightarrow> distinct (complex_roots_of_int_poly_all ?q2)

goal (1 subgoal):
 1. 3 \<le> degree p \<Longrightarrow> (p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)
[PROOF STEP]
note all = this
[PROOF STATE]
proof (state)
this:
?q2 \<in> set (factors_of_int_poly p) \<Longrightarrow> set (complex_roots_of_int_poly_all ?q2) = {x. poly (complex_of_int_poly ?q2) x = 0}
?q2 \<in> set (factors_of_int_poly p) \<Longrightarrow> distinct (complex_roots_of_int_poly_all ?q2)

goal (1 subgoal):
 1. 3 \<le> degree p \<Longrightarrow> (p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)
[PROOF STEP]
from True
[PROOF STATE]
proof (chain)
picking this:
3 \<le> degree p
[PROOF STEP]
have
      "?l = (\<Union> ((\<lambda> p. set (complex_roots_of_int_poly_all p)) ` set (factors_of_int_poly p)))"
[PROOF STATE]
proof (prove)
using this:
3 \<le> degree p

goal (1 subgoal):
 1. set (complex_roots_of_int_poly p) = (\<Union>p\<in>set (factors_of_int_poly p). set (complex_roots_of_int_poly_all p))
[PROOF STEP]
unfolding complex_roots_of_int_poly_def Let_def
[PROOF STATE]
proof (prove)
using this:
3 \<le> degree p

goal (1 subgoal):
 1. set (concat (map complex_roots_of_int_poly_all (if 3 \<le> degree p then factors_of_int_poly p else [p]))) = (\<Union>p\<in>set (factors_of_int_poly p). set (complex_roots_of_int_poly_all p))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set (complex_roots_of_int_poly p) = (\<Union>p\<in>set (factors_of_int_poly p). set (complex_roots_of_int_poly_all p))

goal (1 subgoal):
 1. 3 \<le> degree p \<Longrightarrow> (p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
set (complex_roots_of_int_poly p) = (\<Union>p\<in>set (factors_of_int_poly p). set (complex_roots_of_int_poly_all p))

goal (1 subgoal):
 1. 3 \<le> degree p \<Longrightarrow> (p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)
[PROOF STEP]
have "\<dots> = (\<Union> ((\<lambda> p. {x. ipoly p x = 0}) ` set (factors_of_int_poly p)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Union>p\<in>set (factors_of_int_poly p). set (complex_roots_of_int_poly_all p)) = (\<Union>p\<in>set (factors_of_int_poly p). {x. poly (complex_of_int_poly p) x = 0})
[PROOF STEP]
using all
[PROOF STATE]
proof (prove)
using this:
?q2 \<in> set (factors_of_int_poly p) \<Longrightarrow> set (complex_roots_of_int_poly_all ?q2) = {x. poly (complex_of_int_poly ?q2) x = 0}
?q2 \<in> set (factors_of_int_poly p) \<Longrightarrow> distinct (complex_roots_of_int_poly_all ?q2)

goal (1 subgoal):
 1. (\<Union>p\<in>set (factors_of_int_poly p). set (complex_roots_of_int_poly_all p)) = (\<Union>p\<in>set (factors_of_int_poly p). {x. poly (complex_of_int_poly p) x = 0})
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(\<Union>p\<in>set (factors_of_int_poly p). set (complex_roots_of_int_poly_all p)) = (\<Union>p\<in>set (factors_of_int_poly p). {x. poly (complex_of_int_poly p) x = 0})

goal (1 subgoal):
 1. 3 \<le> degree p \<Longrightarrow> (p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
set (complex_roots_of_int_poly p) = (\<Union>p\<in>set (factors_of_int_poly p). {x. poly (complex_of_int_poly p) x = 0})
[PROOF STEP]
have l: "?l = (\<Union> ((\<lambda> p. {x. ipoly p x = 0}) ` set (factors_of_int_poly p)))"
[PROOF STATE]
proof (prove)
using this:
set (complex_roots_of_int_poly p) = (\<Union>p\<in>set (factors_of_int_poly p). {x. poly (complex_of_int_poly p) x = 0})

goal (1 subgoal):
 1. set (complex_roots_of_int_poly p) = (\<Union>p\<in>set (factors_of_int_poly p). {x. poly (complex_of_int_poly p) x = 0})
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
set (complex_roots_of_int_poly p) = (\<Union>p\<in>set (factors_of_int_poly p). {x. poly (complex_of_int_poly p) x = 0})

goal (1 subgoal):
 1. 3 \<le> degree p \<Longrightarrow> (p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)
[PROOF STEP]
have lr: "p \<noteq> 0 \<longrightarrow> ?l = ?r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}
[PROOF STEP]
using l factors_of_int_poly(2)[OF refl, of p]
[PROOF STATE]
proof (prove)
using this:
set (complex_roots_of_int_poly p) = (\<Union>p\<in>set (factors_of_int_poly p). {x. poly (complex_of_int_poly p) x = 0})
p \<noteq> 0 \<Longrightarrow> (ipoly p ?x = (0::?'a)) = (\<exists>q\<in>set (factors_of_int_poly p). ipoly q ?x = (0::?'a))

goal (1 subgoal):
 1. p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}

goal (1 subgoal):
 1. 3 \<le> degree p \<Longrightarrow> (p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)
[PROOF STEP]
proof (rule conjI[OF lr])
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. distinct (complex_roots_of_int_poly p)
[PROOF STEP]
from True
[PROOF STATE]
proof (chain)
picking this:
3 \<le> degree p
[PROOF STEP]
have id: "complex_roots_of_int_poly p =
          concat (map complex_roots_of_int_poly_all (factors_of_int_poly p))"
[PROOF STATE]
proof (prove)
using this:
3 \<le> degree p

goal (1 subgoal):
 1. complex_roots_of_int_poly p = concat (map complex_roots_of_int_poly_all (factors_of_int_poly p))
[PROOF STEP]
unfolding complex_roots_of_int_poly_def Let_def
[PROOF STATE]
proof (prove)
using this:
3 \<le> degree p

goal (1 subgoal):
 1. concat (map complex_roots_of_int_poly_all (if 3 \<le> degree p then factors_of_int_poly p else [p])) = concat (map complex_roots_of_int_poly_all (factors_of_int_poly p))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
complex_roots_of_int_poly p = concat (map complex_roots_of_int_poly_all (factors_of_int_poly p))

goal (1 subgoal):
 1. distinct (complex_roots_of_int_poly p)
[PROOF STEP]
show "distinct (complex_roots_of_int_poly p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct (complex_roots_of_int_poly p)
[PROOF STEP]
unfolding id distinct_conv_nth
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i<length (concat (map complex_roots_of_int_poly_all (factors_of_int_poly p))). \<forall>j<length (concat (map complex_roots_of_int_poly_all (factors_of_int_poly p))). i \<noteq> j \<longrightarrow> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i \<noteq> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j
[PROOF STEP]
proof (intro allI impI, goal_cases)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length (concat (map complex_roots_of_int_poly_all (factors_of_int_poly p))); j < length (concat (map complex_roots_of_int_poly_all (factors_of_int_poly p))); i \<noteq> j\<rbrakk> \<Longrightarrow> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i \<noteq> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j
[PROOF STEP]
case (1 i j)
[PROOF STATE]
proof (state)
this:
i < length (concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)))
j < length (concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)))
i \<noteq> j

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length (concat (map complex_roots_of_int_poly_all (factors_of_int_poly p))); j < length (concat (map complex_roots_of_int_poly_all (factors_of_int_poly p))); i \<noteq> j\<rbrakk> \<Longrightarrow> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i \<noteq> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j
[PROOF STEP]
let ?fp = "factors_of_int_poly p"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length (concat (map complex_roots_of_int_poly_all (factors_of_int_poly p))); j < length (concat (map complex_roots_of_int_poly_all (factors_of_int_poly p))); i \<noteq> j\<rbrakk> \<Longrightarrow> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i \<noteq> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j
[PROOF STEP]
let ?rr = "complex_roots_of_int_poly_all"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length (concat (map complex_roots_of_int_poly_all (factors_of_int_poly p))); j < length (concat (map complex_roots_of_int_poly_all (factors_of_int_poly p))); i \<noteq> j\<rbrakk> \<Longrightarrow> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i \<noteq> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j
[PROOF STEP]
let ?cc = "concat (map ?rr (factors_of_int_poly p))"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length (concat (map complex_roots_of_int_poly_all (factors_of_int_poly p))); j < length (concat (map complex_roots_of_int_poly_all (factors_of_int_poly p))); i \<noteq> j\<rbrakk> \<Longrightarrow> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i \<noteq> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j
[PROOF STEP]
from nth_concat_diff[OF 1, unfolded length_map]
[PROOF STATE]
proof (chain)
picking this:
\<exists>j1 k1 j2 k2. (j1, k1) \<noteq> (j2, k2) \<and> j1 < length (factors_of_int_poly p) \<and> j2 < length (factors_of_int_poly p) \<and> k1 < length (map complex_roots_of_int_poly_all (factors_of_int_poly p) ! j1) \<and> k2 < length (map complex_roots_of_int_poly_all (factors_of_int_poly p) ! j2) \<and> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i = map complex_roots_of_int_poly_all (factors_of_int_poly p) ! j1 ! k1 \<and> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j = map complex_roots_of_int_poly_all (factors_of_int_poly p) ! j2 ! k2
[PROOF STEP]
obtain j1 k1 j2 k2 where
          *: "(j1,k1) \<noteq> (j2,k2)"
          "j1 < length ?fp" "j2 < length ?fp" and
          "k1 < length (map ?rr ?fp ! j1)"
          "k2 < length (map ?rr ?fp ! j2)"
          "?cc ! i = map ?rr ?fp ! j1 ! k1"
          "?cc ! j = map ?rr ?fp ! j2 ! k2"
[PROOF STATE]
proof (prove)
using this:
\<exists>j1 k1 j2 k2. (j1, k1) \<noteq> (j2, k2) \<and> j1 < length (factors_of_int_poly p) \<and> j2 < length (factors_of_int_poly p) \<and> k1 < length (map complex_roots_of_int_poly_all (factors_of_int_poly p) ! j1) \<and> k2 < length (map complex_roots_of_int_poly_all (factors_of_int_poly p) ! j2) \<and> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i = map complex_roots_of_int_poly_all (factors_of_int_poly p) ! j1 ! k1 \<and> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j = map complex_roots_of_int_poly_all (factors_of_int_poly p) ! j2 ! k2

goal (1 subgoal):
 1. (\<And>j1 k1 j2 k2. \<lbrakk>(j1, k1) \<noteq> (j2, k2); j1 < length (factors_of_int_poly p); j2 < length (factors_of_int_poly p); k1 < length (map complex_roots_of_int_poly_all (factors_of_int_poly p) ! j1); k2 < length (map complex_roots_of_int_poly_all (factors_of_int_poly p) ! j2); concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i = map complex_roots_of_int_poly_all (factors_of_int_poly p) ! j1 ! k1; concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j = map complex_roots_of_int_poly_all (factors_of_int_poly p) ! j2 ! k2\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(j1, k1) \<noteq> (j2, k2)
j1 < length (factors_of_int_poly p)
j2 < length (factors_of_int_poly p)
k1 < length (map complex_roots_of_int_poly_all (factors_of_int_poly p) ! j1)
k2 < length (map complex_roots_of_int_poly_all (factors_of_int_poly p) ! j2)
concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i = map complex_roots_of_int_poly_all (factors_of_int_poly p) ! j1 ! k1
concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j = map complex_roots_of_int_poly_all (factors_of_int_poly p) ! j2 ! k2

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length (concat (map complex_roots_of_int_poly_all (factors_of_int_poly p))); j < length (concat (map complex_roots_of_int_poly_all (factors_of_int_poly p))); i \<noteq> j\<rbrakk> \<Longrightarrow> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i \<noteq> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j
[PROOF STEP]
hence **: "k1 < length (?rr (?fp ! j1))"
          "k2 < length (?rr (?fp ! j2))"
          "?cc ! i = ?rr (?fp ! j1) ! k1"
          "?cc ! j = ?rr (?fp ! j2) ! k2"
[PROOF STATE]
proof (prove)
using this:
(j1, k1) \<noteq> (j2, k2)
j1 < length (factors_of_int_poly p)
j2 < length (factors_of_int_poly p)
k1 < length (map complex_roots_of_int_poly_all (factors_of_int_poly p) ! j1)
k2 < length (map complex_roots_of_int_poly_all (factors_of_int_poly p) ! j2)
concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i = map complex_roots_of_int_poly_all (factors_of_int_poly p) ! j1 ! k1
concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j = map complex_roots_of_int_poly_all (factors_of_int_poly p) ! j2 ! k2

goal (1 subgoal):
 1. (k1 < length (complex_roots_of_int_poly_all (factors_of_int_poly p ! j1)) &&& k2 < length (complex_roots_of_int_poly_all (factors_of_int_poly p ! j2))) &&& concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i = complex_roots_of_int_poly_all (factors_of_int_poly p ! j1) ! k1 &&& concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j = complex_roots_of_int_poly_all (factors_of_int_poly p ! j2) ! k2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
k1 < length (complex_roots_of_int_poly_all (factors_of_int_poly p ! j1))
k2 < length (complex_roots_of_int_poly_all (factors_of_int_poly p ! j2))
concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i = complex_roots_of_int_poly_all (factors_of_int_poly p ! j1) ! k1
concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j = complex_roots_of_int_poly_all (factors_of_int_poly p ! j2) ! k2

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length (concat (map complex_roots_of_int_poly_all (factors_of_int_poly p))); j < length (concat (map complex_roots_of_int_poly_all (factors_of_int_poly p))); i \<noteq> j\<rbrakk> \<Longrightarrow> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i \<noteq> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j
[PROOF STEP]
from *
[PROOF STATE]
proof (chain)
picking this:
(j1, k1) \<noteq> (j2, k2)
j1 < length (factors_of_int_poly p)
j2 < length (factors_of_int_poly p)
[PROOF STEP]
have mem: "?fp ! j1 \<in> set ?fp" "?fp ! j2 \<in> set ?fp"
[PROOF STATE]
proof (prove)
using this:
(j1, k1) \<noteq> (j2, k2)
j1 < length (factors_of_int_poly p)
j2 < length (factors_of_int_poly p)

goal (1 subgoal):
 1. factors_of_int_poly p ! j1 \<in> set (factors_of_int_poly p) &&& factors_of_int_poly p ! j2 \<in> set (factors_of_int_poly p)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
factors_of_int_poly p ! j1 \<in> set (factors_of_int_poly p)
factors_of_int_poly p ! j2 \<in> set (factors_of_int_poly p)

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < length (concat (map complex_roots_of_int_poly_all (factors_of_int_poly p))); j < length (concat (map complex_roots_of_int_poly_all (factors_of_int_poly p))); i \<noteq> j\<rbrakk> \<Longrightarrow> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i \<noteq> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j
[PROOF STEP]
show "?cc ! i \<noteq> ?cc ! j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i \<noteq> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j
[PROOF STEP]
proof (cases "j1 = j2")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. j1 = j2 \<Longrightarrow> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i \<noteq> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j
 2. j1 \<noteq> j2 \<Longrightarrow> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i \<noteq> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
j1 = j2

goal (2 subgoals):
 1. j1 = j2 \<Longrightarrow> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i \<noteq> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j
 2. j1 \<noteq> j2 \<Longrightarrow> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i \<noteq> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j
[PROOF STEP]
with *
[PROOF STATE]
proof (chain)
picking this:
(j1, k1) \<noteq> (j2, k2)
j1 < length (factors_of_int_poly p)
j2 < length (factors_of_int_poly p)
j1 = j2
[PROOF STEP]
have "k1 \<noteq> k2"
[PROOF STATE]
proof (prove)
using this:
(j1, k1) \<noteq> (j2, k2)
j1 < length (factors_of_int_poly p)
j2 < length (factors_of_int_poly p)
j1 = j2

goal (1 subgoal):
 1. k1 \<noteq> k2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
k1 \<noteq> k2

goal (2 subgoals):
 1. j1 = j2 \<Longrightarrow> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i \<noteq> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j
 2. j1 \<noteq> j2 \<Longrightarrow> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i \<noteq> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j
[PROOF STEP]
with all(2)[OF mem(2)] **(1-2)
[PROOF STATE]
proof (chain)
picking this:
distinct (complex_roots_of_int_poly_all (factors_of_int_poly p ! j2))
k1 < length (complex_roots_of_int_poly_all (factors_of_int_poly p ! j1))
k2 < length (complex_roots_of_int_poly_all (factors_of_int_poly p ! j2))
k1 \<noteq> k2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
distinct (complex_roots_of_int_poly_all (factors_of_int_poly p ! j2))
k1 < length (complex_roots_of_int_poly_all (factors_of_int_poly p ! j1))
k2 < length (complex_roots_of_int_poly_all (factors_of_int_poly p ! j2))
k1 \<noteq> k2

goal (1 subgoal):
 1. concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i \<noteq> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j
[PROOF STEP]
unfolding **(3-4)
[PROOF STATE]
proof (prove)
using this:
distinct (complex_roots_of_int_poly_all (factors_of_int_poly p ! j2))
k1 < length (complex_roots_of_int_poly_all (factors_of_int_poly p ! j1))
k2 < length (complex_roots_of_int_poly_all (factors_of_int_poly p ! j2))
k1 \<noteq> k2

goal (1 subgoal):
 1. complex_roots_of_int_poly_all (factors_of_int_poly p ! j1) ! k1 \<noteq> complex_roots_of_int_poly_all (factors_of_int_poly p ! j2) ! k2
[PROOF STEP]
unfolding True
            distinct_conv_nth
[PROOF STATE]
proof (prove)
using this:
\<forall>i<length (complex_roots_of_int_poly_all (factors_of_int_poly p ! j2)). \<forall>j<length (complex_roots_of_int_poly_all (factors_of_int_poly p ! j2)). i \<noteq> j \<longrightarrow> complex_roots_of_int_poly_all (factors_of_int_poly p ! j2) ! i \<noteq> complex_roots_of_int_poly_all (factors_of_int_poly p ! j2) ! j
k1 < length (complex_roots_of_int_poly_all (factors_of_int_poly p ! j2))
k2 < length (complex_roots_of_int_poly_all (factors_of_int_poly p ! j2))
k1 \<noteq> k2

goal (1 subgoal):
 1. complex_roots_of_int_poly_all (factors_of_int_poly p ! j2) ! k1 \<noteq> complex_roots_of_int_poly_all (factors_of_int_poly p ! j2) ! k2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i \<noteq> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j

goal (1 subgoal):
 1. j1 \<noteq> j2 \<Longrightarrow> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i \<noteq> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. j1 \<noteq> j2 \<Longrightarrow> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i \<noteq> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
j1 \<noteq> j2

goal (1 subgoal):
 1. j1 \<noteq> j2 \<Longrightarrow> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i \<noteq> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j
[PROOF STEP]
from \<open>degree p \<ge> 3\<close>
[PROOF STATE]
proof (chain)
picking this:
3 \<le> degree p
[PROOF STEP]
have p: "p \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
3 \<le> degree p

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

goal (1 subgoal):
 1. j1 \<noteq> j2 \<Longrightarrow> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i \<noteq> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j
[PROOF STEP]
note fip = factors_of_int_poly(2-3)[OF refl this]
[PROOF STATE]
proof (state)
this:
(ipoly p ?x = (0::?'a)) = (\<exists>q\<in>set (factors_of_int_poly p). ipoly q ?x = (0::?'a))
ipoly p ?x = (0::?'a) \<Longrightarrow> \<exists>!q. q \<in> set (factors_of_int_poly p) \<and> ipoly q ?x = (0::?'a)

goal (1 subgoal):
 1. j1 \<noteq> j2 \<Longrightarrow> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i \<noteq> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i \<noteq> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j
[PROOF STEP]
unfolding **(3-4)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. complex_roots_of_int_poly_all (factors_of_int_poly p ! j1) ! k1 \<noteq> complex_roots_of_int_poly_all (factors_of_int_poly p ! j2) ! k2
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. complex_roots_of_int_poly_all (factors_of_int_poly p ! j1) ! k1 = complex_roots_of_int_poly_all (factors_of_int_poly p ! j2) ! k2 \<Longrightarrow> False
[PROOF STEP]
define x where "x = ?rr (?fp ! j2) ! k2"
[PROOF STATE]
proof (state)
this:
x = complex_roots_of_int_poly_all (factors_of_int_poly p ! j2) ! k2

goal (1 subgoal):
 1. complex_roots_of_int_poly_all (factors_of_int_poly p ! j1) ! k1 = complex_roots_of_int_poly_all (factors_of_int_poly p ! j2) ! k2 \<Longrightarrow> False
[PROOF STEP]
assume id: "?rr (?fp ! j1) ! k1 = ?rr (?fp ! j2) ! k2"
[PROOF STATE]
proof (state)
this:
complex_roots_of_int_poly_all (factors_of_int_poly p ! j1) ! k1 = complex_roots_of_int_poly_all (factors_of_int_poly p ! j2) ! k2

goal (1 subgoal):
 1. complex_roots_of_int_poly_all (factors_of_int_poly p ! j1) ! k1 = complex_roots_of_int_poly_all (factors_of_int_poly p ! j2) ! k2 \<Longrightarrow> False
[PROOF STEP]
from **
[PROOF STATE]
proof (chain)
picking this:
k1 < length (complex_roots_of_int_poly_all (factors_of_int_poly p ! j1))
k2 < length (complex_roots_of_int_poly_all (factors_of_int_poly p ! j2))
concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i = complex_roots_of_int_poly_all (factors_of_int_poly p ! j1) ! k1
concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j = complex_roots_of_int_poly_all (factors_of_int_poly p ! j2) ! k2
[PROOF STEP]
have x1: "x \<in> set (?rr (?fp ! j1))"
[PROOF STATE]
proof (prove)
using this:
k1 < length (complex_roots_of_int_poly_all (factors_of_int_poly p ! j1))
k2 < length (complex_roots_of_int_poly_all (factors_of_int_poly p ! j2))
concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i = complex_roots_of_int_poly_all (factors_of_int_poly p ! j1) ! k1
concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j = complex_roots_of_int_poly_all (factors_of_int_poly p ! j2) ! k2

goal (1 subgoal):
 1. x \<in> set (complex_roots_of_int_poly_all (factors_of_int_poly p ! j1))
[PROOF STEP]
unfolding x_def id[symmetric]
[PROOF STATE]
proof (prove)
using this:
k1 < length (complex_roots_of_int_poly_all (factors_of_int_poly p ! j1))
k2 < length (complex_roots_of_int_poly_all (factors_of_int_poly p ! j2))
concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i = complex_roots_of_int_poly_all (factors_of_int_poly p ! j1) ! k1
concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j = complex_roots_of_int_poly_all (factors_of_int_poly p ! j1) ! k1

goal (1 subgoal):
 1. complex_roots_of_int_poly_all (factors_of_int_poly p ! j1) ! k1 \<in> set (complex_roots_of_int_poly_all (factors_of_int_poly p ! j1))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> set (complex_roots_of_int_poly_all (factors_of_int_poly p ! j1))

goal (1 subgoal):
 1. complex_roots_of_int_poly_all (factors_of_int_poly p ! j1) ! k1 = complex_roots_of_int_poly_all (factors_of_int_poly p ! j2) ! k2 \<Longrightarrow> False
[PROOF STEP]
from **
[PROOF STATE]
proof (chain)
picking this:
k1 < length (complex_roots_of_int_poly_all (factors_of_int_poly p ! j1))
k2 < length (complex_roots_of_int_poly_all (factors_of_int_poly p ! j2))
concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i = complex_roots_of_int_poly_all (factors_of_int_poly p ! j1) ! k1
concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j = complex_roots_of_int_poly_all (factors_of_int_poly p ! j2) ! k2
[PROOF STEP]
have x2: "x \<in> set (?rr (?fp ! j2))"
[PROOF STATE]
proof (prove)
using this:
k1 < length (complex_roots_of_int_poly_all (factors_of_int_poly p ! j1))
k2 < length (complex_roots_of_int_poly_all (factors_of_int_poly p ! j2))
concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i = complex_roots_of_int_poly_all (factors_of_int_poly p ! j1) ! k1
concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j = complex_roots_of_int_poly_all (factors_of_int_poly p ! j2) ! k2

goal (1 subgoal):
 1. x \<in> set (complex_roots_of_int_poly_all (factors_of_int_poly p ! j2))
[PROOF STEP]
unfolding x_def
[PROOF STATE]
proof (prove)
using this:
k1 < length (complex_roots_of_int_poly_all (factors_of_int_poly p ! j1))
k2 < length (complex_roots_of_int_poly_all (factors_of_int_poly p ! j2))
concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i = complex_roots_of_int_poly_all (factors_of_int_poly p ! j1) ! k1
concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j = complex_roots_of_int_poly_all (factors_of_int_poly p ! j2) ! k2

goal (1 subgoal):
 1. complex_roots_of_int_poly_all (factors_of_int_poly p ! j2) ! k2 \<in> set (complex_roots_of_int_poly_all (factors_of_int_poly p ! j2))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> set (complex_roots_of_int_poly_all (factors_of_int_poly p ! j2))

goal (1 subgoal):
 1. complex_roots_of_int_poly_all (factors_of_int_poly p ! j1) ! k1 = complex_roots_of_int_poly_all (factors_of_int_poly p ! j2) ! k2 \<Longrightarrow> False
[PROOF STEP]
from all(1)[OF mem(1)] x1
[PROOF STATE]
proof (chain)
picking this:
set (complex_roots_of_int_poly_all (factors_of_int_poly p ! j1)) = {x. poly (complex_of_int_poly (factors_of_int_poly p ! j1)) x = 0}
x \<in> set (complex_roots_of_int_poly_all (factors_of_int_poly p ! j1))
[PROOF STEP]
have x1: "ipoly (?fp ! j1) x = 0"
[PROOF STATE]
proof (prove)
using this:
set (complex_roots_of_int_poly_all (factors_of_int_poly p ! j1)) = {x. poly (complex_of_int_poly (factors_of_int_poly p ! j1)) x = 0}
x \<in> set (complex_roots_of_int_poly_all (factors_of_int_poly p ! j1))

goal (1 subgoal):
 1. poly (complex_of_int_poly (factors_of_int_poly p ! j1)) x = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
poly (complex_of_int_poly (factors_of_int_poly p ! j1)) x = 0

goal (1 subgoal):
 1. complex_roots_of_int_poly_all (factors_of_int_poly p ! j1) ! k1 = complex_roots_of_int_poly_all (factors_of_int_poly p ! j2) ! k2 \<Longrightarrow> False
[PROOF STEP]
from all(1)[OF mem(2)] x2
[PROOF STATE]
proof (chain)
picking this:
set (complex_roots_of_int_poly_all (factors_of_int_poly p ! j2)) = {x. poly (complex_of_int_poly (factors_of_int_poly p ! j2)) x = 0}
x \<in> set (complex_roots_of_int_poly_all (factors_of_int_poly p ! j2))
[PROOF STEP]
have x2: "ipoly (?fp ! j2) x = 0"
[PROOF STATE]
proof (prove)
using this:
set (complex_roots_of_int_poly_all (factors_of_int_poly p ! j2)) = {x. poly (complex_of_int_poly (factors_of_int_poly p ! j2)) x = 0}
x \<in> set (complex_roots_of_int_poly_all (factors_of_int_poly p ! j2))

goal (1 subgoal):
 1. poly (complex_of_int_poly (factors_of_int_poly p ! j2)) x = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
poly (complex_of_int_poly (factors_of_int_poly p ! j2)) x = 0

goal (1 subgoal):
 1. complex_roots_of_int_poly_all (factors_of_int_poly p ! j1) ! k1 = complex_roots_of_int_poly_all (factors_of_int_poly p ! j2) ! k2 \<Longrightarrow> False
[PROOF STEP]
from False factors_of_int_poly(4)[OF refl, of p]
[PROOF STATE]
proof (chain)
picking this:
j1 \<noteq> j2
distinct (factors_of_int_poly p)
[PROOF STEP]
have neq: "?fp ! j1 \<noteq> ?fp ! j2"
[PROOF STATE]
proof (prove)
using this:
j1 \<noteq> j2
distinct (factors_of_int_poly p)

goal (1 subgoal):
 1. factors_of_int_poly p ! j1 \<noteq> factors_of_int_poly p ! j2
[PROOF STEP]
using *
[PROOF STATE]
proof (prove)
using this:
j1 \<noteq> j2
distinct (factors_of_int_poly p)
(j1, k1) \<noteq> (j2, k2)
j1 < length (factors_of_int_poly p)
j2 < length (factors_of_int_poly p)

goal (1 subgoal):
 1. factors_of_int_poly p ! j1 \<noteq> factors_of_int_poly p ! j2
[PROOF STEP]
unfolding distinct_conv_nth
[PROOF STATE]
proof (prove)
using this:
j1 \<noteq> j2
\<forall>i<length (factors_of_int_poly p). \<forall>j<length (factors_of_int_poly p). i \<noteq> j \<longrightarrow> factors_of_int_poly p ! i \<noteq> factors_of_int_poly p ! j
(j1, k1) \<noteq> (j2, k2)
j1 < length (factors_of_int_poly p)
j2 < length (factors_of_int_poly p)

goal (1 subgoal):
 1. factors_of_int_poly p ! j1 \<noteq> factors_of_int_poly p ! j2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
factors_of_int_poly p ! j1 \<noteq> factors_of_int_poly p ! j2

goal (1 subgoal):
 1. complex_roots_of_int_poly_all (factors_of_int_poly p ! j1) ! k1 = complex_roots_of_int_poly_all (factors_of_int_poly p ! j2) ! k2 \<Longrightarrow> False
[PROOF STEP]
have "poly (complex_of_int_poly p) x = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly (complex_of_int_poly p) x = 0
[PROOF STEP]
by (meson fip(1) mem(2) x2)
[PROOF STATE]
proof (state)
this:
poly (complex_of_int_poly p) x = 0

goal (1 subgoal):
 1. complex_roots_of_int_poly_all (factors_of_int_poly p ! j1) ! k1 = complex_roots_of_int_poly_all (factors_of_int_poly p ! j2) ! k2 \<Longrightarrow> False
[PROOF STEP]
from fip(2)[OF this] mem x1 x2 neq
[PROOF STATE]
proof (chain)
picking this:
\<exists>!q. q \<in> set (factors_of_int_poly p) \<and> poly (complex_of_int_poly q) x = 0
factors_of_int_poly p ! j1 \<in> set (factors_of_int_poly p)
factors_of_int_poly p ! j2 \<in> set (factors_of_int_poly p)
poly (complex_of_int_poly (factors_of_int_poly p ! j1)) x = 0
poly (complex_of_int_poly (factors_of_int_poly p ! j2)) x = 0
factors_of_int_poly p ! j1 \<noteq> factors_of_int_poly p ! j2
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
\<exists>!q. q \<in> set (factors_of_int_poly p) \<and> poly (complex_of_int_poly q) x = 0
factors_of_int_poly p ! j1 \<in> set (factors_of_int_poly p)
factors_of_int_poly p ! j2 \<in> set (factors_of_int_poly p)
poly (complex_of_int_poly (factors_of_int_poly p ! j1)) x = 0
poly (complex_of_int_poly (factors_of_int_poly p ! j2)) x = 0
factors_of_int_poly p ! j1 \<noteq> factors_of_int_poly p ! j2

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i \<noteq> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! i \<noteq> concat (map complex_roots_of_int_poly_all (factors_of_int_poly p)) ! j

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
distinct (complex_roots_of_int_poly p)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)

goal (2 subgoals):
 1. p \<noteq> 0 \<Longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}
 2. distinct (complex_roots_of_int_poly p)
[PROOF STEP]
thus "p \<noteq> 0 \<Longrightarrow> ?l = ?r" "distinct (complex_roots_of_int_poly p)"
[PROOF STATE]
proof (prove)
using this:
(p \<noteq> 0 \<longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) \<and> distinct (complex_roots_of_int_poly p)

goal (1 subgoal):
 1. (p \<noteq> 0 \<Longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}) &&& distinct (complex_roots_of_int_poly p)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
p \<noteq> 0 \<Longrightarrow> set (complex_roots_of_int_poly p) = {x. poly (complex_of_int_poly p) x = 0}
distinct (complex_roots_of_int_poly p)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma up_V: "Z \<subseteq> V \<Longrightarrow> Z\<^sup>\<up> \<subseteq> V"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Z \<subseteq> V \<Longrightarrow> Z\<^sup>\<up> \<subseteq> V
[PROOF STEP]
unfolding V_def zone_delay_def cval_add_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Z \<subseteq> {v. \<forall>x\<in>X. 0 \<le> v x} \<Longrightarrow> {\<lambda>x. u x + d |u d. u \<in> Z \<and> 0 \<le> d} \<subseteq> {v. \<forall>x\<in>X. 0 \<le> v x}
[PROOF STEP]
by auto


[STATEMENT]
theorem mertens_second_theorem:
  defines "f \<equiv> prime_sum_upto (\<lambda>p. 1 / p)"
  shows   "\<And>x. x \<ge> 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x"
    and   "(\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>x. 2 \<le> x \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x) &&& (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>x. 2 \<le> x \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
define r where "r = (\<lambda>t. (\<MM> t - ln t) / (t * ln t ^ 2))"
[PROOF STATE]
proof (state)
this:
r = (\<lambda>t. (\<MM> t - ln t) / (t * (ln t)\<^sup>2))

goal (2 subgoals):
 1. \<And>x. 2 \<le> x \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
r = (\<lambda>t. (\<MM> t - ln t) / (t * (ln t)\<^sup>2))

goal (2 subgoals):
 1. \<And>x. 2 \<le> x \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
fix x :: real
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>x. 2 \<le> x \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
assume x: "x > 2"
[PROOF STATE]
proof (state)
this:
2 < x

goal (2 subgoals):
 1. \<And>x. 2 \<le> x \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
have "((\<lambda>t. \<MM> t * (-1 / (t * ln t ^ 2))) has_integral \<MM> x * (1 / ln x) - \<MM> 2 * (1 / ln 2) -
            (\<Sum>n\<in>real -` {2<..x}. ind prime n * (ln n / real n) * (1 / ln n))) {2..x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>t. \<MM> t * (- 1 / (t * (ln t)\<^sup>2))) has_integral \<MM> x * (1 / ln x) - \<MM> 2 * (1 / ln 2) - (\<Sum>n\<in>real -` {2<..x}. ind prime n * (ln (real n) / real n) * (1 / ln (real n)))) {2..x}
[PROOF STEP]
unfolding primes_M_def prime_sum_upto_altdef1
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>t. sum_upto (\<lambda>p. ind prime p * (ln (real p) / real p)) t * (- 1 / (t * (ln t)\<^sup>2))) has_integral sum_upto (\<lambda>p. ind prime p * (ln (real p) / real p)) x * (1 / ln x) - sum_upto (\<lambda>p. ind prime p * (ln (real p) / real p)) 2 * (1 / ln 2) - (\<Sum>n\<in>real -` {2<..x}. ind prime n * (ln (real n) / real n) * (1 / ln (real n)))) {2..x}
[PROOF STEP]
using x
[PROOF STATE]
proof (prove)
using this:
2 < x

goal (1 subgoal):
 1. ((\<lambda>t. sum_upto (\<lambda>p. ind prime p * (ln (real p) / real p)) t * (- 1 / (t * (ln t)\<^sup>2))) has_integral sum_upto (\<lambda>p. ind prime p * (ln (real p) / real p)) x * (1 / ln x) - sum_upto (\<lambda>p. ind prime p * (ln (real p) / real p)) 2 * (1 / ln 2) - (\<Sum>n\<in>real -` {2<..x}. ind prime n * (ln (real n) / real n) * (1 / ln (real n)))) {2..x}
[PROOF STEP]
by (intro partial_summation_strong[of "{}"])
         (auto intro!: continuous_intros derivative_eq_intros simp: power2_eq_square
               simp flip: has_real_derivative_iff_has_vector_derivative)
[PROOF STATE]
proof (state)
this:
((\<lambda>t. \<MM> t * (- 1 / (t * (ln t)\<^sup>2))) has_integral \<MM> x * (1 / ln x) - \<MM> 2 * (1 / ln 2) - (\<Sum>n\<in>real -` {2<..x}. ind prime n * (ln (real n) / real n) * (1 / ln (real n)))) {2..x}

goal (2 subgoals):
 1. \<And>x. 2 \<le> x \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
((\<lambda>t. \<MM> t * (- 1 / (t * (ln t)\<^sup>2))) has_integral \<MM> x * (1 / ln x) - \<MM> 2 * (1 / ln 2) - (\<Sum>n\<in>real -` {2<..x}. ind prime n * (ln (real n) / real n) * (1 / ln (real n)))) {2..x}

goal (2 subgoals):
 1. \<And>x. 2 \<le> x \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
have "\<MM> x * (1 / ln x) - \<MM> 2 * (1 / ln 2) -
                 (\<Sum>n\<in>real -` {2<..x}. ind prime n * (ln n / n) * (1 / ln n)) =
               \<MM> x / ln x - (\<Sum>n\<in>insert 2 (real -` {2<..x}). ind prime n * (ln n / n) * (1 / ln n))"
      (is "_ = _ - ?S")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<MM> x * (1 / ln x) - \<MM> 2 * (1 / ln 2) - (\<Sum>n\<in>real -` {2<..x}. ind prime n * (ln (real n) / real n) * (1 / ln (real n))) = \<MM> x / ln x - (\<Sum>n\<in>insert 2 (real -` {2<..x}). ind prime n * (ln (real n) / real n) * (1 / ln (real n)))
[PROOF STEP]
by (subst sum.insert)
         (auto simp: primes_M_def finite_vimage_real_of_nat_greaterThanAtMost eval_prime_sum_upto)
[PROOF STATE]
proof (state)
this:
\<MM> x * (1 / ln x) - \<MM> 2 * (1 / ln 2) - (\<Sum>n\<in>real -` {2<..x}. ind prime n * (ln (real n) / real n) * (1 / ln (real n))) = \<MM> x / ln x - (\<Sum>n\<in>insert 2 (real -` {2<..x}). ind prime n * (ln (real n) / real n) * (1 / ln (real n)))

goal (2 subgoals):
 1. \<And>x. 2 \<le> x \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<MM> x * (1 / ln x) - \<MM> 2 * (1 / ln 2) - (\<Sum>n\<in>real -` {2<..x}. ind prime n * (ln (real n) / real n) * (1 / ln (real n))) = \<MM> x / ln x - (\<Sum>n\<in>insert 2 (real -` {2<..x}). ind prime n * (ln (real n) / real n) * (1 / ln (real n)))

goal (2 subgoals):
 1. \<And>x. 2 \<le> x \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
have "?S = f x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>n\<in>insert 2 (real -` {2<..x}). ind prime n * (ln (real n) / real n) * (1 / ln (real n))) = f x
[PROOF STEP]
unfolding f_def prime_sum_upto_altdef1 sum_upto_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>n\<in>insert 2 (real -` {2<..x}). ind prime n * (ln (real n) / real n) * (1 / ln (real n))) = (\<Sum>p\<in>{i. 0 < i \<and> real i \<le> x}. ind prime p * (1 / real p))
[PROOF STEP]
using x
[PROOF STATE]
proof (prove)
using this:
2 < x

goal (1 subgoal):
 1. (\<Sum>n\<in>insert 2 (real -` {2<..x}). ind prime n * (ln (real n) / real n) * (1 / ln (real n))) = (\<Sum>p\<in>{i. 0 < i \<and> real i \<le> x}. ind prime p * (1 / real p))
[PROOF STEP]
by (intro sum.mono_neutral_cong_left) (auto simp: not_less numeral_2_eq_2 le_Suc_eq)
[PROOF STATE]
proof (state)
this:
(\<Sum>n\<in>insert 2 (real -` {2<..x}). ind prime n * (ln (real n) / real n) * (1 / ln (real n))) = f x

goal (2 subgoals):
 1. \<And>x. 2 \<le> x \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
((\<lambda>t. \<MM> t * (- 1 / (t * (ln t)\<^sup>2))) has_integral \<MM> x / ln x - f x) {2..x}
[PROOF STEP]
have "((\<lambda>t. -\<MM> t / (t * ln t ^ 2)) has_integral (\<MM> x / ln x - f x)) {2..x}"
[PROOF STATE]
proof (prove)
using this:
((\<lambda>t. \<MM> t * (- 1 / (t * (ln t)\<^sup>2))) has_integral \<MM> x / ln x - f x) {2..x}

goal (1 subgoal):
 1. ((\<lambda>t. - \<MM> t / (t * (ln t)\<^sup>2)) has_integral \<MM> x / ln x - f x) {2..x}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
((\<lambda>t. - \<MM> t / (t * (ln t)\<^sup>2)) has_integral \<MM> x / ln x - f x) {2..x}

goal (2 subgoals):
 1. \<And>x. 2 \<le> x \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
from has_integral_neg[OF this]
[PROOF STATE]
proof (chain)
picking this:
((\<lambda>x. - (- \<MM> x / (x * (ln x)\<^sup>2))) has_integral - (\<MM> x / ln x - f x)) {2..x}
[PROOF STEP]
have "((\<lambda>t. \<MM> t / (t * ln t ^ 2)) has_integral (f x - \<MM> x / ln x)) {2..x}"
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. - (- \<MM> x / (x * (ln x)\<^sup>2))) has_integral - (\<MM> x / ln x - f x)) {2..x}

goal (1 subgoal):
 1. ((\<lambda>t. \<MM> t / (t * (ln t)\<^sup>2)) has_integral f x - \<MM> x / ln x) {2..x}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
((\<lambda>t. \<MM> t / (t * (ln t)\<^sup>2)) has_integral f x - \<MM> x / ln x) {2..x}

goal (2 subgoals):
 1. \<And>x. 2 \<le> x \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
hence "((\<lambda>t. \<MM> t / (t * ln t ^ 2) - 1 / (t * ln t)) has_integral
             (f x - \<MM> x / ln x - (ln (ln x) - ln (ln 2)))) {2..x}"
[PROOF STATE]
proof (prove)
using this:
((\<lambda>t. \<MM> t / (t * (ln t)\<^sup>2)) has_integral f x - \<MM> x / ln x) {2..x}

goal (1 subgoal):
 1. ((\<lambda>t. \<MM> t / (t * (ln t)\<^sup>2) - 1 / (t * ln t)) has_integral f x - \<MM> x / ln x - (ln (ln x) - ln (ln 2))) {2..x}
[PROOF STEP]
using x
[PROOF STATE]
proof (prove)
using this:
((\<lambda>t. \<MM> t / (t * (ln t)\<^sup>2)) has_integral f x - \<MM> x / ln x) {2..x}
2 < x

goal (1 subgoal):
 1. ((\<lambda>t. \<MM> t / (t * (ln t)\<^sup>2) - 1 / (t * ln t)) has_integral f x - \<MM> x / ln x - (ln (ln x) - ln (ln 2))) {2..x}
[PROOF STEP]
by (intro has_integral_diff fundamental_theorem_of_calculus)
         (auto simp flip: has_real_derivative_iff_has_vector_derivative
               intro!: derivative_eq_intros)
[PROOF STATE]
proof (state)
this:
((\<lambda>t. \<MM> t / (t * (ln t)\<^sup>2) - 1 / (t * ln t)) has_integral f x - \<MM> x / ln x - (ln (ln x) - ln (ln 2))) {2..x}

goal (2 subgoals):
 1. \<And>x. 2 \<le> x \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
((\<lambda>t. \<MM> t / (t * (ln t)\<^sup>2) - 1 / (t * ln t)) has_integral f x - \<MM> x / ln x - (ln (ln x) - ln (ln 2))) {2..x}

goal (2 subgoals):
 1. \<And>x. 2 \<le> x \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
have "?this \<longleftrightarrow> (r has_integral (f x - \<MM> x / ln x - (ln (ln x) - ln (ln 2)))) {2..x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>t. \<MM> t / (t * (ln t)\<^sup>2) - 1 / (t * ln t)) has_integral f x - \<MM> x / ln x - (ln (ln x) - ln (ln 2))) {2..x} = (r has_integral f x - \<MM> x / ln x - (ln (ln x) - ln (ln 2))) {2..x}
[PROOF STEP]
by (intro has_integral_cong) (auto simp: r_def field_simps power2_eq_square)
[PROOF STATE]
proof (state)
this:
((\<lambda>t. \<MM> t / (t * (ln t)\<^sup>2) - 1 / (t * ln t)) has_integral f x - \<MM> x / ln x - (ln (ln x) - ln (ln 2))) {2..x} = (r has_integral f x - \<MM> x / ln x - (ln (ln x) - ln (ln 2))) {2..x}

goal (2 subgoals):
 1. \<And>x. 2 \<le> x \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(r has_integral f x - \<MM> x / ln x - (ln (ln x) - ln (ln 2))) {2..x}
[PROOF STEP]
have \<dots>
[PROOF STATE]
proof (prove)
using this:
(r has_integral f x - \<MM> x / ln x - (ln (ln x) - ln (ln 2))) {2..x}

goal (1 subgoal):
 1. (r has_integral f x - \<MM> x / ln x - (ln (ln x) - ln (ln 2))) {2..x}
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(r has_integral f x - \<MM> x / ln x - (ln (ln x) - ln (ln 2))) {2..x}

goal (2 subgoals):
 1. \<And>x. 2 \<le> x \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
2 < ?x2 \<Longrightarrow> (r has_integral f ?x2 - \<MM> ?x2 / ln ?x2 - (ln (ln ?x2) - ln (ln 2))) {2..?x2}

goal (2 subgoals):
 1. \<And>x. 2 \<le> x \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
note integral = this
[PROOF STATE]
proof (state)
this:
2 < ?x2 \<Longrightarrow> (r has_integral f ?x2 - \<MM> ?x2 / ln ?x2 - (ln (ln ?x2) - ln (ln 2))) {2..?x2}

goal (2 subgoals):
 1. \<And>x. 2 \<le> x \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
define R\<^sub>\<MM> where "R\<^sub>\<MM> = (\<lambda>x. \<MM> x - ln x)"
[PROOF STATE]
proof (state)
this:
R\<^sub>\<MM> = (\<lambda>x. \<MM> x - ln x)

goal (2 subgoals):
 1. \<And>x. 2 \<le> x \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
have \<MM>: "\<MM> x = ln x + R\<^sub>\<MM> x" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<MM> x = ln x + R\<^sub>\<MM> x
[PROOF STEP]
by (simp add: R\<^sub>\<MM>_def)
[PROOF STATE]
proof (state)
this:
\<MM> ?x = ln ?x + R\<^sub>\<MM> ?x

goal (2 subgoals):
 1. \<And>x. 2 \<le> x \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
define I where "I = (\<lambda>x. integral {x..} r)"
[PROOF STATE]
proof (state)
this:
I = (\<lambda>x. integral {x..} r)

goal (2 subgoals):
 1. \<And>x. 2 \<le> x \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
define C where "C = (1 - ln (ln 2) + I 2)"
[PROOF STATE]
proof (state)
this:
C = 1 - ln (ln 2) + I 2

goal (2 subgoals):
 1. \<And>x. 2 \<le> x \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
have C_altdef: "C = meissel_mertens"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. C = meissel_mertens
[PROOF STEP]
by (simp add: I_def r_def C_def meissel_mertens_def)
[PROOF STATE]
proof (state)
this:
C = meissel_mertens

goal (2 subgoals):
 1. \<And>x. 2 \<le> x \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
show bound: " \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x" if x: "x \<ge> 2" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
proof (cases "x = 2")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x = 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. x \<noteq> 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
x = 2

goal (2 subgoals):
 1. x = 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. x \<noteq> 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
hence "\<bar>f x - ln (ln x) - meissel_mertens\<bar> = \<bar>1 / 2 - ln (ln 2) - meissel_mertens\<bar>"
[PROOF STATE]
proof (prove)
using this:
x = 2

goal (1 subgoal):
 1. \<bar>f x - ln (ln x) - meissel_mertens\<bar> = \<bar>1 / 2 - ln (ln 2) - meissel_mertens\<bar>
[PROOF STEP]
by (simp add: f_def eval_prime_sum_upto )
[PROOF STATE]
proof (state)
this:
\<bar>f x - ln (ln x) - meissel_mertens\<bar> = \<bar>1 / 2 - ln (ln 2) - meissel_mertens\<bar>

goal (2 subgoals):
 1. x = 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. x \<noteq> 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<bar>f x - ln (ln x) - meissel_mertens\<bar> = \<bar>1 / 2 - ln (ln 2) - meissel_mertens\<bar>

goal (2 subgoals):
 1. x = 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. x \<noteq> 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
have "\<dots> \<le> 2 / ln 2 + 1 / 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>1 / 2 - ln (ln 2) - meissel_mertens\<bar> \<le> 2 / ln 2 + 1 / 2
[PROOF STEP]
using meissel_mertens_bounds
[PROOF STATE]
proof (prove)
using this:
\<bar>meissel_mertens - 1 + ln (ln 2)\<bar> \<le> 2 / ln 2

goal (1 subgoal):
 1. \<bar>1 / 2 - ln (ln 2) - meissel_mertens\<bar> \<le> 2 / ln 2 + 1 / 2
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
\<bar>1 / 2 - ln (ln 2) - meissel_mertens\<bar> \<le> 2 / ln 2 + 1 / 2

goal (2 subgoals):
 1. x = 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. x \<noteq> 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<bar>1 / 2 - ln (ln 2) - meissel_mertens\<bar> \<le> 2 / ln 2 + 1 / 2

goal (2 subgoals):
 1. x = 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. x \<noteq> 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
have "\<dots> \<le> 2 / ln 2 + 2 / ln 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 / ln 2 + 1 / 2 \<le> 2 / ln 2 + 2 / ln 2
[PROOF STEP]
using ln2_le_25_over_36
[PROOF STATE]
proof (prove)
using this:
ln 2 \<le> 25 / 36

goal (1 subgoal):
 1. 2 / ln 2 + 1 / 2 \<le> 2 / ln 2 + 2 / ln 2
[PROOF STEP]
by (intro add_mono divide_left_mono) auto
[PROOF STATE]
proof (state)
this:
2 / ln 2 + 1 / 2 \<le> 2 / ln 2 + 2 / ln 2

goal (2 subgoals):
 1. x = 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
 2. x \<noteq> 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 2 / ln 2 + 2 / ln 2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 2 / ln 2 + 2 / ln 2

goal (1 subgoal):
 1. \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
\<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 2 / ln 2 + 2 / ln 2
x = 2

goal (1 subgoal):
 1. \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x

goal (1 subgoal):
 1. x \<noteq> 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x \<noteq> 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
x \<noteq> 2

goal (1 subgoal):
 1. x \<noteq> 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
hence x: "x > 2"
[PROOF STATE]
proof (prove)
using this:
x \<noteq> 2

goal (1 subgoal):
 1. 2 < x
[PROOF STEP]
using x
[PROOF STATE]
proof (prove)
using this:
x \<noteq> 2
2 \<le> x

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

goal (1 subgoal):
 1. x \<noteq> 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
have "integral {2..x} r + I x = integral ({2..x} \<union> {x..}) r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integral {2..x} r + I x = integral ({2..x} \<union> {x..}) r
[PROOF STEP]
unfolding I_def r_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integral {2..x} (\<lambda>t. (\<MM> t - ln t) / (t * (ln t)\<^sup>2)) + integral {x..} (\<lambda>t. (\<MM> t - ln t) / (t * (ln t)\<^sup>2)) = integral ({2..x} \<union> {x..}) (\<lambda>t. (\<MM> t - ln t) / (t * (ln t)\<^sup>2))
[PROOF STEP]
using x
[PROOF STATE]
proof (prove)
using this:
2 < x

goal (1 subgoal):
 1. integral {2..x} (\<lambda>t. (\<MM> t - ln t) / (t * (ln t)\<^sup>2)) + integral {x..} (\<lambda>t. (\<MM> t - ln t) / (t * (ln t)\<^sup>2)) = integral ({2..x} \<union> {x..}) (\<lambda>t. (\<MM> t - ln t) / (t * (ln t)\<^sup>2))
[PROOF STEP]
by (intro integral_Un [symmetric] integrable_on_meissel_mertens) (auto simp: max_def r_def)
[PROOF STATE]
proof (state)
this:
integral {2..x} r + I x = integral ({2..x} \<union> {x..}) r

goal (1 subgoal):
 1. x \<noteq> 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
integral {2..x} r + I x = integral ({2..x} \<union> {x..}) r

goal (1 subgoal):
 1. x \<noteq> 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
have "{2..x} \<union> {x..} = {2..}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {2..x} \<union> {x..} = {2..}
[PROOF STEP]
using x
[PROOF STATE]
proof (prove)
using this:
2 < x

goal (1 subgoal):
 1. {2..x} \<union> {x..} = {2..}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{2..x} \<union> {x..} = {2..}

goal (1 subgoal):
 1. x \<noteq> 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
integral {2..x} r + I x = integral {2..} r
[PROOF STEP]
have *: "integral {2..x} r = I 2 - I x"
[PROOF STATE]
proof (prove)
using this:
integral {2..x} r + I x = integral {2..} r

goal (1 subgoal):
 1. integral {2..x} r = I 2 - I x
[PROOF STEP]
unfolding I_def
[PROOF STATE]
proof (prove)
using this:
integral {2..x} r + integral {x..} r = integral {2..} r

goal (1 subgoal):
 1. integral {2..x} r = integral {2..} r - integral {x..} r
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
integral {2..x} r = I 2 - I x

goal (1 subgoal):
 1. x \<noteq> 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
have eq: "f x - ln (ln x) - C = R\<^sub>\<MM> x / ln x - I x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f x - ln (ln x) - C = R\<^sub>\<MM> x / ln x - I x
[PROOF STEP]
using integral[OF x] x
[PROOF STATE]
proof (prove)
using this:
(r has_integral f x - \<MM> x / ln x - (ln (ln x) - ln (ln 2))) {2..x}
2 < x

goal (1 subgoal):
 1. f x - ln (ln x) - C = R\<^sub>\<MM> x / ln x - I x
[PROOF STEP]
by (auto simp: C_def field_simps \<MM> has_integral_iff *)
[PROOF STATE]
proof (state)
this:
f x - ln (ln x) - C = R\<^sub>\<MM> x / ln x - I x

goal (1 subgoal):
 1. x \<noteq> 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
f x - ln (ln x) - C = R\<^sub>\<MM> x / ln x - I x

goal (1 subgoal):
 1. x \<noteq> 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
have "\<bar>\<dots>\<bar> \<le> \<bar>R\<^sub>\<MM> x / ln x\<bar> + norm (I x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>R\<^sub>\<MM> x / ln x - I x\<bar> \<le> \<bar>R\<^sub>\<MM> x / ln x\<bar> + norm (I x)
[PROOF STEP]
unfolding real_norm_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>R\<^sub>\<MM> x / ln x - I x\<bar> \<le> \<bar>R\<^sub>\<MM> x / ln x\<bar> + \<bar>I x\<bar>
[PROOF STEP]
by (rule abs_triangle_ineq4)
[PROOF STATE]
proof (state)
this:
\<bar>R\<^sub>\<MM> x / ln x - I x\<bar> \<le> \<bar>R\<^sub>\<MM> x / ln x\<bar> + norm (I x)

goal (1 subgoal):
 1. x \<noteq> 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<bar>R\<^sub>\<MM> x / ln x - I x\<bar> \<le> \<bar>R\<^sub>\<MM> x / ln x\<bar> + norm (I x)

goal (1 subgoal):
 1. x \<noteq> 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
have "\<bar>R\<^sub>\<MM> x / ln x\<bar> \<le> 2 / \<bar>ln x\<bar>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>R\<^sub>\<MM> x / ln x\<bar> \<le> 2 / \<bar>ln x\<bar>
[PROOF STEP]
unfolding R\<^sub>\<MM>_def abs_divide
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>\<MM> x - ln x\<bar> / \<bar>ln x\<bar> \<le> 2 / \<bar>ln x\<bar>
[PROOF STEP]
using mertens_first_theorem[of x] x
[PROOF STATE]
proof (prove)
using this:
1 \<le> x \<Longrightarrow> \<bar>\<MM> x - ln x\<bar> < 2
2 < x

goal (1 subgoal):
 1. \<bar>\<MM> x - ln x\<bar> / \<bar>ln x\<bar> \<le> 2 / \<bar>ln x\<bar>
[PROOF STEP]
by (intro divide_right_mono) auto
[PROOF STATE]
proof (state)
this:
\<bar>R\<^sub>\<MM> x / ln x\<bar> \<le> 2 / \<bar>ln x\<bar>

goal (1 subgoal):
 1. x \<noteq> 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<bar>R\<^sub>\<MM> x / ln x\<bar> \<le> 2 / \<bar>ln x\<bar>

goal (1 subgoal):
 1. x \<noteq> 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
have "{x..} - {x<..} = {x}" and "{x<..} \<subseteq> {x..}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x..} - {x<..} = {x} &&& {x<..} \<subseteq> {x..}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{x..} - {x<..} = {x}
{x<..} \<subseteq> {x..}

goal (1 subgoal):
 1. x \<noteq> 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
hence "I x = integral {x<..} r"
[PROOF STATE]
proof (prove)
using this:
{x..} - {x<..} = {x}
{x<..} \<subseteq> {x..}

goal (1 subgoal):
 1. I x = integral {x<..} r
[PROOF STEP]
unfolding I_def
[PROOF STATE]
proof (prove)
using this:
{x..} - {x<..} = {x}
{x<..} \<subseteq> {x..}

goal (1 subgoal):
 1. integral {x..} r = integral {x<..} r
[PROOF STEP]
by (intro integral_subset_negligible [symmetric]) simp_all
[PROOF STATE]
proof (state)
this:
I x = integral {x<..} r

goal (1 subgoal):
 1. x \<noteq> 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
I x = integral {x<..} r

goal (1 subgoal):
 1. x \<noteq> 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
have "norm \<dots> \<le> 2 / ln x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (integral {x<..} r) \<le> 2 / ln x
[PROOF STEP]
using meissel_mertens_integral_le[of x] x
[PROOF STATE]
proof (prove)
using this:
1 < x \<Longrightarrow> norm (integral {x<..} (\<lambda>t. (\<MM> t - ln t) / (t * (ln t)\<^sup>2))) \<le> 2 / ln x
2 < x

goal (1 subgoal):
 1. norm (integral {x<..} r) \<le> 2 / ln x
[PROOF STEP]
by (simp add: r_def)
[PROOF STATE]
proof (state)
this:
norm (integral {x<..} r) \<le> 2 / ln x

goal (1 subgoal):
 1. x \<noteq> 2 \<Longrightarrow> \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>\<And>xa y. xa \<le> y \<Longrightarrow> xa + norm (I x) \<le> y + norm (I x); \<And>xa y. xa \<le> y \<Longrightarrow> 2 / \<bar>ln x\<bar> + xa \<le> 2 / \<bar>ln x\<bar> + y\<rbrakk> \<Longrightarrow> \<bar>f x - ln (ln x) - C\<bar> \<le> 2 / \<bar>ln x\<bar> + 2 / ln x
[PROOF STEP]
show "\<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>xa y. xa \<le> y \<Longrightarrow> xa + norm (I x) \<le> y + norm (I x); \<And>xa y. xa \<le> y \<Longrightarrow> 2 / \<bar>ln x\<bar> + xa \<le> 2 / \<bar>ln x\<bar> + y\<rbrakk> \<Longrightarrow> \<bar>f x - ln (ln x) - C\<bar> \<le> 2 / \<bar>ln x\<bar> + 2 / ln x

goal (1 subgoal):
 1. \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
using x
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>xa y. xa \<le> y \<Longrightarrow> xa + norm (I x) \<le> y + norm (I x); \<And>xa y. xa \<le> y \<Longrightarrow> 2 / \<bar>ln x\<bar> + xa \<le> 2 / \<bar>ln x\<bar> + y\<rbrakk> \<Longrightarrow> \<bar>f x - ln (ln x) - C\<bar> \<le> 2 / \<bar>ln x\<bar> + 2 / ln x
2 < x

goal (1 subgoal):
 1. \<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
[PROOF STEP]
by (simp add: C_altdef)
[PROOF STATE]
proof (state)
this:
\<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
2 \<le> ?x \<Longrightarrow> \<bar>f ?x - ln (ln ?x) - meissel_mertens\<bar> \<le> 4 / ln ?x

goal (1 subgoal):
 1. (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
have "(\<lambda>x. f x - ln (ln x) - C) \<in> O(\<lambda>x. 1 / ln x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. f x - ln (ln x) - C) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
proof (intro landau_o.bigI[of 4] eventually_mono[OF eventually_ge_at_top[of 2]])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 < 4
 2. \<And>x. 2 \<le> x \<Longrightarrow> norm (f x - ln (ln x) - C) \<le> 4 * norm (1 / ln x)
[PROOF STEP]
fix x :: real
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 < 4
 2. \<And>x. 2 \<le> x \<Longrightarrow> norm (f x - ln (ln x) - C) \<le> 4 * norm (1 / ln x)
[PROOF STEP]
assume x: "x \<ge> 2"
[PROOF STATE]
proof (state)
this:
2 \<le> x

goal (2 subgoals):
 1. 0 < 4
 2. \<And>x. 2 \<le> x \<Longrightarrow> norm (f x - ln (ln x) - C) \<le> 4 * norm (1 / ln x)
[PROOF STEP]
with bound[OF x]
[PROOF STATE]
proof (chain)
picking this:
\<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
2 \<le> x
[PROOF STEP]
show "norm (f x - ln (ln x) - C) \<le> 4 * norm (1 / ln x)"
[PROOF STATE]
proof (prove)
using this:
\<bar>f x - ln (ln x) - meissel_mertens\<bar> \<le> 4 / ln x
2 \<le> x

goal (1 subgoal):
 1. norm (f x - ln (ln x) - C) \<le> 4 * norm (1 / ln x)
[PROOF STEP]
by (simp add: C_altdef)
[PROOF STATE]
proof (state)
this:
norm (f x - ln (ln x) - C) \<le> 4 * norm (1 / ln x)

goal (1 subgoal):
 1. 0 < 4
[PROOF STEP]
qed (auto intro!: add_pos_nonneg)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. f x - ln (ln x) - C) \<in> O(\<lambda>x. 1 / ln x)

goal (1 subgoal):
 1. (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
thus "(\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. f x - ln (ln x) - C) \<in> O(\<lambda>x. 1 / ln x)

goal (1 subgoal):
 1. (\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
by (simp add: C_altdef)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. f x - ln (ln x) - meissel_mertens) \<in> O(\<lambda>x. 1 / ln x)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Infinitesimal_minus_iff [simp]: "- x \<in> Infinitesimal \<longleftrightarrow> x \<in> Infinitesimal"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (- x \<in> Infinitesimal) = (x \<in> Infinitesimal)
[PROOF STEP]
by (simp add: Infinitesimal_def)


[STATEMENT]
lemma of_nat_div_real [real_asymp_nat_reify]:
  "of_nat (a div b) = max 0 (rfloor (of_nat a / of_nat b))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (a div b) = max 0 (rfloor (real a / real b))
[PROOF STEP]
by (simp add: rfloor_def floor_divide_of_nat_eq)


[STATEMENT]
lemma pre_post_compose:
  "-q \<le> -r \<Longrightarrow> (-p\<stileturn>-q)*(-r\<stileturn>-s) \<le> -p\<stileturn>-s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. - q \<le> - r \<Longrightarrow> (- p \<stileturn> - q) * (- r \<stileturn> - s) \<le> - p \<stileturn> - s
[PROOF STEP]
using order_lesseq_imp pre_compose pre_post_galois
[PROOF STATE]
proof (prove)
using this:
(\<forall>z\<ge>?x. ?y \<le> z) = (?y \<le> ?x)
\<lbrakk>- ?p \<le> ?x \<guillemotleft> - ?q; - ?q \<le> ?y \<guillemotleft> - ?r\<rbrakk> \<Longrightarrow> - ?p \<le> ?x * ?y \<guillemotleft> - ?r
(- ?p \<le> ?x \<guillemotleft> - ?q) = (?x \<le> - ?p \<stileturn> - ?q)

goal (1 subgoal):
 1. - q \<le> - r \<Longrightarrow> (- p \<stileturn> - q) * (- r \<stileturn> - s) \<le> - p \<stileturn> - s
[PROOF STEP]
by blast


[STATEMENT]
lemma min_lp_in_sat_dual: "x \<in> min_lp A b c \<Longrightarrow> x \<in> sat_dual A c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> optimal_set (\<lambda>x y. x \<bullet> c \<le> y \<bullet> c) (sat_dual A c) \<Longrightarrow> x \<in> sat_dual A c
[PROOF STEP]
unfolding optimal_set_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> {x \<in> sat_dual A c. \<forall>y\<in>sat_dual A c. x \<bullet> c \<le> y \<bullet> c} \<Longrightarrow> x \<in> sat_dual A c
[PROOF STEP]
using sol_dim_in_sat_dual[of x A]
[PROOF STATE]
proof (prove)
using this:
x \<in> sat_dual A ?c \<Longrightarrow> dim_vec x = dim_row A

goal (1 subgoal):
 1. x \<in> {x \<in> sat_dual A c. \<forall>y\<in>sat_dual A c. x \<bullet> c \<le> y \<bullet> c} \<Longrightarrow> x \<in> sat_dual A c
[PROOF STEP]
by blast


[STATEMENT]
lemma transitive_star:
  "x * x \<le> x \<Longrightarrow> x\<^sup>\<star> = 1 \<squnion> x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. transitive x \<Longrightarrow> x\<^sup>\<star> = (1::'a) \<squnion> x
[PROOF STEP]
by (metis order.antisym star.circ_mult_increasing_2 star.circ_plus_same star_left_induct_mult star_left_unfold_equal)


[STATEMENT]
lemma drec_bind_mono_pfun[partial_function_mono]:
  fixes C :: "'a \<Rightarrow> ('b \<Rightarrow> 'c dres) \<Rightarrow> ('d dres)"
  shows
  "\<lbrakk> monotone (fun_ord (\<le>)) (\<le>) B;
    \<And>y. monotone (fun_ord (\<le>)) (\<le>) (\<lambda>f. C y f) \<rbrakk> \<Longrightarrow>
     monotone (fun_ord (\<le>)) (\<le>) (\<lambda>f. dbind (B f) (\<lambda>y. C y f))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>monotone drec.le_fun (\<le>) B; \<And>y. monotone drec.le_fun (\<le>) (C y)\<rbrakk> \<Longrightarrow> monotone drec.le_fun (\<le>) (\<lambda>f. B f \<bind> (\<lambda>y. C y f))
[PROOF STEP]
apply rule
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>monotone drec.le_fun (\<le>) B; \<And>y. monotone drec.le_fun (\<le>) (C y); drec.le_fun x y\<rbrakk> \<Longrightarrow> B x \<bind> (\<lambda>y. C y x) \<le> B y \<bind> (\<lambda>ya. C ya y)
[PROOF STEP]
apply (rule dbind_mono)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x y. \<lbrakk>monotone drec.le_fun (\<le>) B; \<And>y. monotone drec.le_fun (\<le>) (C y); drec.le_fun x y\<rbrakk> \<Longrightarrow> B x \<le> B y
 2. \<And>x y xa. \<lbrakk>monotone drec.le_fun (\<le>) B; \<And>y. monotone drec.le_fun (\<le>) (C y); drec.le_fun x y; dRETURN xa \<le> B x\<rbrakk> \<Longrightarrow> C xa x \<le> C xa y
[PROOF STEP]
apply (blast dest: monotoneD)+
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done