[STATEMENT]
lemma sanity_check:
  "\<not>(entangled 2 (mat_of_cols_list 2 [[1/sqrt(2), 1/sqrt(2)]] \<Otimes> mat_of_cols_list 2 [[1/sqrt(2), 1/sqrt(2)]]))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> entangled 2 (Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]]) \<Otimes> Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]]))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> entangled 2 (Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]]) \<Otimes> Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]]))
[PROOF STEP]
define u where "u = mat_of_cols_list 2 [[1/sqrt(2), 1/sqrt(2)]]"
[PROOF STATE]
proof (state)
this:
u = Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]])

goal (1 subgoal):
 1. \<not> entangled 2 (Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]]) \<Otimes> Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]]))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
u = Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]])
[PROOF STEP]
have "state 1 u"
[PROOF STATE]
proof (prove)
using this:
u = Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]])

goal (1 subgoal):
 1. state 1 u
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. u = Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]]) \<Longrightarrow> state 1 u
[PROOF STEP]
have "dim_col u = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_col u = 1
[PROOF STEP]
using u_def mat_of_cols_list_def
[PROOF STATE]
proof (prove)
using this:
u = Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]])
Tensor.mat_of_cols_list ?nr ?cs = Matrix.mat ?nr (length ?cs) (\<lambda>(i, j). ?cs ! j ! i)

goal (1 subgoal):
 1. dim_col u = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
dim_col u = 1

goal (1 subgoal):
 1. u = Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]]) \<Longrightarrow> state 1 u
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
dim_col u = 1

goal (1 subgoal):
 1. u = Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]]) \<Longrightarrow> state 1 u
[PROOF STEP]
have f:"dim_row u = 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row u = 2
[PROOF STEP]
using u_def mat_of_cols_list_def
[PROOF STATE]
proof (prove)
using this:
u = Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]])
Tensor.mat_of_cols_list ?nr ?cs = Matrix.mat ?nr (length ?cs) (\<lambda>(i, j). ?cs ! j ! i)

goal (1 subgoal):
 1. dim_row u = 2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
dim_row u = 2

goal (1 subgoal):
 1. u = Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]]) \<Longrightarrow> state 1 u
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
dim_row u = 2

goal (1 subgoal):
 1. u = Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]]) \<Longrightarrow> state 1 u
[PROOF STEP]
have "\<parallel>Matrix.col u 0\<parallel> = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>Matrix.col u 0\<parallel> = 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<parallel>Matrix.col u 0\<parallel> = 1
[PROOF STEP]
have "(\<Sum>i<2. (cmod (u $$ (i, 0)))\<^sup>2) = (1/sqrt 2)\<^sup>2 + (1/sqrt 2)\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i<2. (cmod (u $$ (i, 0)))\<^sup>2) = (1 / sqrt 2)\<^sup>2 + (1 / sqrt 2)\<^sup>2
[PROOF STEP]
by(simp add: u_def cmod_def numeral_2_eq_2)
[PROOF STATE]
proof (state)
this:
(\<Sum>i<2. (cmod (u $$ (i, 0)))\<^sup>2) = (1 / sqrt 2)\<^sup>2 + (1 / sqrt 2)\<^sup>2

goal (1 subgoal):
 1. \<parallel>Matrix.col u 0\<parallel> = 1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>i<2. (cmod (u $$ (i, 0)))\<^sup>2) = (1 / sqrt 2)\<^sup>2 + (1 / sqrt 2)\<^sup>2
[PROOF STEP]
have "\<parallel>Matrix.col u 0\<parallel> = sqrt ((1/sqrt 2)\<^sup>2 + (1/sqrt 2)\<^sup>2)"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i<2. (cmod (u $$ (i, 0)))\<^sup>2) = (1 / sqrt 2)\<^sup>2 + (1 / sqrt 2)\<^sup>2

goal (1 subgoal):
 1. \<parallel>Matrix.col u 0\<parallel> = sqrt ((1 / sqrt 2)\<^sup>2 + (1 / sqrt 2)\<^sup>2)
[PROOF STEP]
using f
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i<2. (cmod (u $$ (i, 0)))\<^sup>2) = (1 / sqrt 2)\<^sup>2 + (1 / sqrt 2)\<^sup>2
dim_row u = 2

goal (1 subgoal):
 1. \<parallel>Matrix.col u 0\<parallel> = sqrt ((1 / sqrt 2)\<^sup>2 + (1 / sqrt 2)\<^sup>2)
[PROOF STEP]
by(auto simp: Matrix.col_def u_def cpx_vec_length_def)
[PROOF STATE]
proof (state)
this:
\<parallel>Matrix.col u 0\<parallel> = sqrt ((1 / sqrt 2)\<^sup>2 + (1 / sqrt 2)\<^sup>2)

goal (1 subgoal):
 1. \<parallel>Matrix.col u 0\<parallel> = 1
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<parallel>Matrix.col u 0\<parallel> = sqrt ((1 / sqrt 2)\<^sup>2 + (1 / sqrt 2)\<^sup>2)

goal (1 subgoal):
 1. \<parallel>Matrix.col u 0\<parallel> = 1
[PROOF STEP]
by(simp add: power_divide)
[PROOF STATE]
proof (state)
this:
\<parallel>Matrix.col u 0\<parallel> = 1

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<parallel>Matrix.col u 0\<parallel> = 1

goal (1 subgoal):
 1. u = Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]]) \<Longrightarrow> state 1 u
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
dim_col u = 1
dim_row u = 2
\<parallel>Matrix.col u 0\<parallel> = 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
dim_col u = 1
dim_row u = 2
\<parallel>Matrix.col u 0\<parallel> = 1

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

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

goal (1 subgoal):
 1. \<not> entangled 2 (Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]]) \<Otimes> Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]]))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
state 1 u
[PROOF STEP]
have "state 2 (u \<Otimes> u)"
[PROOF STATE]
proof (prove)
using this:
state 1 u

goal (1 subgoal):
 1. state 2 (u \<Otimes> u)
[PROOF STEP]
using tensor_state
[PROOF STATE]
proof (prove)
using this:
state 1 u
\<lbrakk>state ?m ?u; state ?n ?v\<rbrakk> \<Longrightarrow> state (?m + ?n) (?u \<Otimes> ?v)

goal (1 subgoal):
 1. state 2 (u \<Otimes> u)
[PROOF STEP]
by(metis one_add_one)
[PROOF STATE]
proof (state)
this:
state 2 (u \<Otimes> u)

goal (1 subgoal):
 1. \<not> entangled 2 (Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]]) \<Otimes> Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]]))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
state 2 (u \<Otimes> u)

goal (1 subgoal):
 1. \<not> entangled 2 (Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]]) \<Otimes> Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]]))
[PROOF STEP]
using entangled_def prod_state_def
[PROOF STATE]
proof (prove)
using this:
state 2 (u \<Otimes> u)
entangled ?n ?v \<equiv> \<not> prod_state ?n ?v
prod_state ?m ?u \<equiv> if state ?m ?u then \<exists>n p v w. state n v \<and> state p w \<and> n < ?m \<and> p < ?m \<and> ?u = v \<Otimes> w else undefined

goal (1 subgoal):
 1. \<not> entangled 2 (Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]]) \<Otimes> Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]]))
[PROOF STEP]
by(metis \<open>state 1 u\<close> one_less_numeral_iff semiring_norm(76) u_def)
[PROOF STATE]
proof (state)
this:
\<not> entangled 2 (Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]]) \<Otimes> Tensor.mat_of_cols_list 2 (map (map complex_of_real) [[1 / sqrt 2, 1 / sqrt 2]]))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma conj_idem: "((P::'\<alpha> predicate) \<and> P) = P"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (P \<and> P) = P
[PROOF STEP]
by (rule ext) blast


[STATEMENT]
lemma complex_norm_eq_1_exp: "norm z = 1 \<longleftrightarrow> exp(\<i> * of_real (Arg2pi z)) = z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cmod z = 1) = (exp (\<i> * complex_of_real (Arg2pi z)) = z)
[PROOF STEP]
by (metis Arg2pi_eq cis_conv_exp mult.left_neutral norm_cis of_real_1)


[STATEMENT]
lemma ratfps_nth_bigo_square_free_factorization:
  fixes p :: "complex poly"
  assumes "square_free_factorization q (b, cs)"
  assumes "q \<noteq> 0" and "R > 0"
  assumes roots1: "\<And>c l. (c, l) \<in> set cs \<Longrightarrow> \<forall>x\<in>ball 0 (1 / R). poly c x \<noteq> 0"
  assumes roots2: "\<And>c l. (c, l) \<in> set cs \<Longrightarrow> l > k \<Longrightarrow> \<forall>x\<in>sphere 0 (1 / R). poly c x \<noteq> 0"
  shows   "fps_nth (fps_of_poly p / fps_of_poly q) \<in> O(\<lambda>n. of_nat n ^ k * of_real R ^ n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ($) (fps_of_poly p / fps_of_poly q) \<in> O(\<lambda>n. of_nat n ^ k * complex_of_real R ^ n)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ($) (fps_of_poly p / fps_of_poly q) \<in> O(\<lambda>n. of_nat n ^ k * complex_of_real R ^ n)
[PROOF STEP]
from assms(1)
[PROOF STATE]
proof (chain)
picking this:
square_free_factorization q (b, cs)
[PROOF STEP]
have q: "q = smult b (\<Prod>(c, l)\<in>set cs. c ^ Suc l)"
[PROOF STATE]
proof (prove)
using this:
square_free_factorization q (b, cs)

goal (1 subgoal):
 1. q = smult b (\<Prod>(c, l)\<in>set cs. c ^ Suc l)
[PROOF STEP]
unfolding square_free_factorization_def prod.case
[PROOF STATE]
proof (prove)
using this:
q = smult b (\<Prod>(a, i)\<in>set cs. a ^ Suc i) \<and> (q = 0 \<longrightarrow> b = 0 \<and> cs = []) \<and> (\<forall>a i. (a, i) \<in> set cs \<longrightarrow> square_free a \<and> 0 < degree a) \<and> (\<forall>a i b j. (a, i) \<in> set cs \<longrightarrow> (b, j) \<in> set cs \<longrightarrow> (a, i) \<noteq> (b, j) \<longrightarrow> coprime a b) \<and> distinct cs

goal (1 subgoal):
 1. q = smult b (\<Prod>(c, l)\<in>set cs. c ^ Suc l)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
q = smult b (\<Prod>(c, l)\<in>set cs. c ^ Suc l)

goal (1 subgoal):
 1. ($) (fps_of_poly p / fps_of_poly q) \<in> O(\<lambda>n. of_nat n ^ k * complex_of_real R ^ n)
[PROOF STEP]
with \<open>q \<noteq> 0\<close>
[PROOF STATE]
proof (chain)
picking this:
q \<noteq> 0
q = smult b (\<Prod>(c, l)\<in>set cs. c ^ Suc l)
[PROOF STEP]
have [simp]: "b \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
q \<noteq> 0
q = smult b (\<Prod>(c, l)\<in>set cs. c ^ Suc l)

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

goal (1 subgoal):
 1. ($) (fps_of_poly p / fps_of_poly q) \<in> O(\<lambda>n. of_nat n ^ k * complex_of_real R ^ n)
[PROOF STEP]
from assms(1)
[PROOF STATE]
proof (chain)
picking this:
square_free_factorization q (b, cs)
[PROOF STEP]
have [simp]: "(0, x) \<notin> set cs" for x
[PROOF STATE]
proof (prove)
using this:
square_free_factorization q (b, cs)

goal (1 subgoal):
 1. (0, x) \<notin> set cs
[PROOF STEP]
by (auto simp: square_free_factorization_def)
[PROOF STATE]
proof (state)
this:
(0, ?x) \<notin> set cs

goal (1 subgoal):
 1. ($) (fps_of_poly p / fps_of_poly q) \<in> O(\<lambda>n. of_nat n ^ k * complex_of_real R ^ n)
[PROOF STEP]
from assms(1)
[PROOF STATE]
proof (chain)
picking this:
square_free_factorization q (b, cs)
[PROOF STEP]
have coprime: "c1 = c2" "m = n"
    if "\<not>coprime c1 c2" "(c1, m) \<in> set cs" "(c2, n) \<in> set cs" for c1 c2 m n
[PROOF STATE]
proof (prove)
using this:
square_free_factorization q (b, cs)

goal (1 subgoal):
 1. c1 = c2 &&& m = n
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
square_free_factorization q (b, cs)
\<not> coprime c1 c2
(c1, m) \<in> set cs
(c2, n) \<in> set cs

goal (1 subgoal):
 1. c1 = c2 &&& m = n
[PROOF STEP]
by (auto simp: square_free_factorization_def case_prod_unfold)
[PROOF STATE]
proof (state)
this:
\<lbrakk>\<not> coprime ?c1.0 ?c2.0; (?c1.0, ?m) \<in> set cs; (?c2.0, ?n) \<in> set cs\<rbrakk> \<Longrightarrow> ?c1.0 = ?c2.0
\<lbrakk>\<not> coprime ?c1.0 ?c2.0; (?c1.0, ?m) \<in> set cs; (?c2.0, ?n) \<in> set cs\<rbrakk> \<Longrightarrow> ?m = ?n

goal (1 subgoal):
 1. ($) (fps_of_poly p / fps_of_poly q) \<in> O(\<lambda>n. of_nat n ^ k * complex_of_real R ^ n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ($) (fps_of_poly p / fps_of_poly q) \<in> O(\<lambda>n. of_nat n ^ k * complex_of_real R ^ n)
[PROOF STEP]
proof (rule ratfps_nth_bigo)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. 0 < R
 2. \<And>z. z \<in> ball 0 (1 / R) \<Longrightarrow> poly q z \<noteq> 0
 3. \<And>z. \<lbrakk>z \<in> sphere 0 (1 / R); poly q z = 0\<rbrakk> \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
fix z :: complex
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. 0 < R
 2. \<And>z. z \<in> ball 0 (1 / R) \<Longrightarrow> poly q z \<noteq> 0
 3. \<And>z. \<lbrakk>z \<in> sphere 0 (1 / R); poly q z = 0\<rbrakk> \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
assume z: "z \<in> ball 0 (1 / R)"
[PROOF STATE]
proof (state)
this:
z \<in> ball 0 (1 / R)

goal (3 subgoals):
 1. 0 < R
 2. \<And>z. z \<in> ball 0 (1 / R) \<Longrightarrow> poly q z \<noteq> 0
 3. \<And>z. \<lbrakk>z \<in> sphere 0 (1 / R); poly q z = 0\<rbrakk> \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
show "poly q z \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly q z \<noteq> 0
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. poly q z = 0 \<Longrightarrow> False
[PROOF STEP]
assume "poly q z = 0"
[PROOF STATE]
proof (state)
this:
poly q z = 0

goal (1 subgoal):
 1. poly q z = 0 \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
poly q z = 0
[PROOF STEP]
obtain c l where cl: "(c, l) \<in> set cs" and "poly c z = 0"
[PROOF STATE]
proof (prove)
using this:
poly q z = 0

goal (1 subgoal):
 1. (\<And>c l. \<lbrakk>(c, l) \<in> set cs; poly c z = 0\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: q poly_prod image_iff)
[PROOF STATE]
proof (state)
this:
(c, l) \<in> set cs
poly c z = 0

goal (1 subgoal):
 1. poly q z = 0 \<Longrightarrow> False
[PROOF STEP]
with roots1[of c l] and z
[PROOF STATE]
proof (chain)
picking this:
(c, l) \<in> set cs \<Longrightarrow> \<forall>x\<in>ball 0 (1 / R). poly c x \<noteq> 0
z \<in> ball 0 (1 / R)
(c, l) \<in> set cs
poly c z = 0
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
(c, l) \<in> set cs \<Longrightarrow> \<forall>x\<in>ball 0 (1 / R). poly c x \<noteq> 0
z \<in> ball 0 (1 / R)
(c, l) \<in> set cs
poly c z = 0

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
poly q z \<noteq> 0

goal (2 subgoals):
 1. 0 < R
 2. \<And>z. \<lbrakk>z \<in> sphere 0 (1 / R); poly q z = 0\<rbrakk> \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 < R
 2. \<And>z. \<lbrakk>z \<in> sphere 0 (1 / R); poly q z = 0\<rbrakk> \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
fix z :: complex
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 < R
 2. \<And>z. \<lbrakk>z \<in> sphere 0 (1 / R); poly q z = 0\<rbrakk> \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
assume z: "z \<in> sphere 0 (1 / R)"
[PROOF STATE]
proof (state)
this:
z \<in> sphere 0 (1 / R)

goal (2 subgoals):
 1. 0 < R
 2. \<And>z. \<lbrakk>z \<in> sphere 0 (1 / R); poly q z = 0\<rbrakk> \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
have order: "order z q = order z (\<Prod>(c, l)\<in>set cs. c ^ Suc l)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. order z q = order z (\<Prod>(c, l)\<in>set cs. c ^ Suc l)
[PROOF STEP]
by (simp add: order_smult q)
[PROOF STATE]
proof (state)
this:
order z q = order z (\<Prod>(c, l)\<in>set cs. c ^ Suc l)

goal (2 subgoals):
 1. 0 < R
 2. \<And>z. \<lbrakk>z \<in> sphere 0 (1 / R); poly q z = 0\<rbrakk> \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
order z q = order z (\<Prod>(c, l)\<in>set cs. c ^ Suc l)

goal (2 subgoals):
 1. 0 < R
 2. \<And>z. \<lbrakk>z \<in> sphere 0 (1 / R); poly q z = 0\<rbrakk> \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
have "\<dots> = (\<Sum>x\<in>set cs. order z (case x of (c, l) \<Rightarrow> c ^ Suc l))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. order z (\<Prod>(c, l)\<in>set cs. c ^ Suc l) = (\<Sum>x\<in>set cs. order z (case x of (c, l) \<Rightarrow> c ^ Suc l))
[PROOF STEP]
by (subst order_prod) (auto dest: coprime)
[PROOF STATE]
proof (state)
this:
order z (\<Prod>(c, l)\<in>set cs. c ^ Suc l) = (\<Sum>x\<in>set cs. order z (case x of (c, l) \<Rightarrow> c ^ Suc l))

goal (2 subgoals):
 1. 0 < R
 2. \<And>z. \<lbrakk>z \<in> sphere 0 (1 / R); poly q z = 0\<rbrakk> \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
order z (\<Prod>(c, l)\<in>set cs. c ^ Suc l) = (\<Sum>x\<in>set cs. order z (case x of (c, l) \<Rightarrow> c ^ Suc l))

goal (2 subgoals):
 1. 0 < R
 2. \<And>z. \<lbrakk>z \<in> sphere 0 (1 / R); poly q z = 0\<rbrakk> \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
have "\<dots> = (\<Sum>(c, l)\<in>set cs. Suc l * order z c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>set cs. order z (case x of (c, l) \<Rightarrow> c ^ Suc l)) = (\<Sum>(c, l)\<in>set cs. Suc l * order z c)
[PROOF STEP]
unfolding case_prod_unfold
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>set cs. order z (fst x ^ Suc (snd x))) = (\<Sum>p\<in>set cs. Suc (snd p) * order z (fst p))
[PROOF STEP]
by (intro sum.cong refl, subst order_power) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>set cs. order z (case x of (c, l) \<Rightarrow> c ^ Suc l)) = (\<Sum>(c, l)\<in>set cs. Suc l * order z c)

goal (2 subgoals):
 1. 0 < R
 2. \<And>z. \<lbrakk>z \<in> sphere 0 (1 / R); poly q z = 0\<rbrakk> \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
order z q = (\<Sum>(c, l)\<in>set cs. Suc l * order z c)
[PROOF STEP]
have "order z q = \<dots>"
[PROOF STATE]
proof (prove)
using this:
order z q = (\<Sum>(c, l)\<in>set cs. Suc l * order z c)

goal (1 subgoal):
 1. order z q = (\<Sum>(c, l)\<in>set cs. Suc l * order z c)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
order z q = (\<Sum>(c, l)\<in>set cs. Suc l * order z c)

goal (2 subgoals):
 1. 0 < R
 2. \<And>z. \<lbrakk>z \<in> sphere 0 (1 / R); poly q z = 0\<rbrakk> \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
show "order z q \<le> Suc k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. order z q \<le> Suc k
[PROOF STEP]
proof (cases "\<exists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<exists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
 2. \<nexists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<nexists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0

goal (2 subgoals):
 1. \<exists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
 2. \<nexists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
have "order z q = (\<Sum>(c, l)\<in>set cs. Suc l * order z c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. order z q = (\<Sum>(c, l)\<in>set cs. Suc l * order z c)
[PROOF STEP]
by fact
[PROOF STATE]
proof (state)
this:
order z q = (\<Sum>(c, l)\<in>set cs. Suc l * order z c)

goal (2 subgoals):
 1. \<exists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
 2. \<nexists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
order z q = (\<Sum>(c, l)\<in>set cs. Suc l * order z c)

goal (2 subgoals):
 1. \<exists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
 2. \<nexists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
have "order z c = 0" if "(c, l) \<in> set cs" for c l
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. order z c = 0
[PROOF STEP]
using False that
[PROOF STATE]
proof (prove)
using this:
\<nexists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0
(c, l) \<in> set cs

goal (1 subgoal):
 1. order z c = 0
[PROOF STEP]
by (auto simp: order_root)
[PROOF STATE]
proof (state)
this:
(?c, ?l) \<in> set cs \<Longrightarrow> order z ?c = 0

goal (2 subgoals):
 1. \<exists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
 2. \<nexists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
hence "(\<Sum>(c, l)\<in>set cs. Suc l * order z c) = 0"
[PROOF STATE]
proof (prove)
using this:
(?c, ?l) \<in> set cs \<Longrightarrow> order z ?c = 0

goal (1 subgoal):
 1. (\<Sum>(c, l)\<in>set cs. Suc l * order z c) = 0
[PROOF STEP]
by (intro sum.neutral) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>(c, l)\<in>set cs. Suc l * order z c) = 0

goal (2 subgoals):
 1. \<exists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
 2. \<nexists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
order z q = 0
[PROOF STEP]
show "order z q \<le> Suc k"
[PROOF STATE]
proof (prove)
using this:
order z q = 0

goal (1 subgoal):
 1. order z q \<le> Suc k
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
order z q \<le> Suc k

goal (1 subgoal):
 1. \<exists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
case True \<comment>\<open>The order of a root is determined by the unique polynomial in the
                   square-free factorisation that contains it.\<close>
[PROOF STATE]
proof (state)
this:
\<exists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0

goal (1 subgoal):
 1. \<exists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0
[PROOF STEP]
obtain c0 l0 where cl0: "(c0, l0) \<in> set cs" "poly c0 z = 0"
[PROOF STATE]
proof (prove)
using this:
\<exists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0

goal (1 subgoal):
 1. (\<And>c0 l0. \<lbrakk>(c0, l0) \<in> set cs; poly c0 z = 0\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(c0, l0) \<in> set cs
poly c0 z = 0

goal (1 subgoal):
 1. \<exists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
have "order z q = (\<Sum>(c, l)\<in>set cs. Suc l * order z c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. order z q = (\<Sum>(c, l)\<in>set cs. Suc l * order z c)
[PROOF STEP]
by fact
[PROOF STATE]
proof (state)
this:
order z q = (\<Sum>(c, l)\<in>set cs. Suc l * order z c)

goal (1 subgoal):
 1. \<exists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
order z q = (\<Sum>(c, l)\<in>set cs. Suc l * order z c)

goal (1 subgoal):
 1. \<exists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
have "\<dots> = Suc l0 * order z c0 + (\<Sum>(c, l) \<in> set cs - {(c0, l0)}. Suc l * order z c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>(c, l)\<in>set cs. Suc l * order z c) = Suc l0 * order z c0 + (\<Sum>(c, l)\<in>set cs - {(c0, l0)}. Suc l * order z c)
[PROOF STEP]
using cl0
[PROOF STATE]
proof (prove)
using this:
(c0, l0) \<in> set cs
poly c0 z = 0

goal (1 subgoal):
 1. (\<Sum>(c, l)\<in>set cs. Suc l * order z c) = Suc l0 * order z c0 + (\<Sum>(c, l)\<in>set cs - {(c0, l0)}. Suc l * order z c)
[PROOF STEP]
by (subst sum.remove[of _ "(c0, l0)"]) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>(c, l)\<in>set cs. Suc l * order z c) = Suc l0 * order z c0 + (\<Sum>(c, l)\<in>set cs - {(c0, l0)}. Suc l * order z c)

goal (1 subgoal):
 1. \<exists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>(c, l)\<in>set cs. Suc l * order z c) = Suc l0 * order z c0 + (\<Sum>(c, l)\<in>set cs - {(c0, l0)}. Suc l * order z c)

goal (1 subgoal):
 1. \<exists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
have "(\<Sum>(c, l) \<in> set cs - {(c0, l0)}. Suc l * order z c) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>(c, l)\<in>set cs - {(c0, l0)}. Suc l * order z c) = 0
[PROOF STEP]
proof (intro sum.neutral ballI, goal_cases)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> set cs - {(c0, l0)} \<Longrightarrow> (case x of (c, l) \<Rightarrow> Suc l * order z c) = 0
[PROOF STEP]
case (1 cl)
[PROOF STATE]
proof (state)
this:
cl \<in> set cs - {(c0, l0)}

goal (1 subgoal):
 1. \<And>x. x \<in> set cs - {(c0, l0)} \<Longrightarrow> (case x of (c, l) \<Rightarrow> Suc l * order z c) = 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
cl \<in> set cs - {(c0, l0)}
[PROOF STEP]
obtain c l where [simp]: "cl = (c, l)" and cl: "(c, l) \<in> set cs" "(c0, l0) \<noteq> (c, l)"
[PROOF STATE]
proof (prove)
using this:
cl \<in> set cs - {(c0, l0)}

goal (1 subgoal):
 1. (\<And>c l. \<lbrakk>cl = (c, l); (c, l) \<in> set cs; (c0, l0) \<noteq> (c, l)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (cases cl) auto
[PROOF STATE]
proof (state)
this:
cl = (c, l)
(c, l) \<in> set cs
(c0, l0) \<noteq> (c, l)

goal (1 subgoal):
 1. \<And>x. x \<in> set cs - {(c0, l0)} \<Longrightarrow> (case x of (c, l) \<Rightarrow> Suc l * order z c) = 0
[PROOF STEP]
from cl and cl0 and coprime[of c c0 l l0]
[PROOF STATE]
proof (chain)
picking this:
(c, l) \<in> set cs
(c0, l0) \<noteq> (c, l)
(c0, l0) \<in> set cs
poly c0 z = 0
\<lbrakk>\<not> coprime c c0; (c, l) \<in> set cs; (c0, l0) \<in> set cs\<rbrakk> \<Longrightarrow> c = c0
\<lbrakk>\<not> coprime c c0; (c, l) \<in> set cs; (c0, l0) \<in> set cs\<rbrakk> \<Longrightarrow> l = l0
[PROOF STEP]
have "coprime c c0"
[PROOF STATE]
proof (prove)
using this:
(c, l) \<in> set cs
(c0, l0) \<noteq> (c, l)
(c0, l0) \<in> set cs
poly c0 z = 0
\<lbrakk>\<not> coprime c c0; (c, l) \<in> set cs; (c0, l0) \<in> set cs\<rbrakk> \<Longrightarrow> c = c0
\<lbrakk>\<not> coprime c c0; (c, l) \<in> set cs; (c0, l0) \<in> set cs\<rbrakk> \<Longrightarrow> l = l0

goal (1 subgoal):
 1. coprime c c0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
coprime c c0

goal (1 subgoal):
 1. \<And>x. x \<in> set cs - {(c0, l0)} \<Longrightarrow> (case x of (c, l) \<Rightarrow> Suc l * order z c) = 0
[PROOF STEP]
with same_root_imp_not_coprime[of c z c0] and cl0
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>poly c z = 0; poly c0 z = 0\<rbrakk> \<Longrightarrow> \<not> coprime c c0
(c0, l0) \<in> set cs
poly c0 z = 0
coprime c c0
[PROOF STEP]
have "poly c z \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>poly c z = 0; poly c0 z = 0\<rbrakk> \<Longrightarrow> \<not> coprime c c0
(c0, l0) \<in> set cs
poly c0 z = 0
coprime c c0

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

goal (1 subgoal):
 1. \<And>x. x \<in> set cs - {(c0, l0)} \<Longrightarrow> (case x of (c, l) \<Rightarrow> Suc l * order z c) = 0
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
poly c z \<noteq> 0

goal (1 subgoal):
 1. (case cl of (c, l) \<Rightarrow> Suc l * order z c) = 0
[PROOF STEP]
by (auto simp: order_root)
[PROOF STATE]
proof (state)
this:
(case cl of (c, l) \<Rightarrow> Suc l * order z c) = 0

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>(c, l)\<in>set cs - {(c0, l0)}. Suc l * order z c) = 0

goal (1 subgoal):
 1. \<exists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>(c, l)\<in>set cs - {(c0, l0)}. Suc l * order z c) = 0

goal (1 subgoal):
 1. \<exists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
have "square_free c0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. square_free c0
[PROOF STEP]
using cl0 assms(1)
[PROOF STATE]
proof (prove)
using this:
(c0, l0) \<in> set cs
poly c0 z = 0
square_free_factorization q (b, cs)

goal (1 subgoal):
 1. square_free c0
[PROOF STEP]
by (auto simp: square_free_factorization_def)
[PROOF STATE]
proof (state)
this:
square_free c0

goal (1 subgoal):
 1. \<exists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
hence "rsquarefree c0"
[PROOF STATE]
proof (prove)
using this:
square_free c0

goal (1 subgoal):
 1. rsquarefree c0
[PROOF STEP]
by (rule square_free_rsquarefree)
[PROOF STATE]
proof (state)
this:
rsquarefree c0

goal (1 subgoal):
 1. \<exists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
with cl0
[PROOF STATE]
proof (chain)
picking this:
(c0, l0) \<in> set cs
poly c0 z = 0
rsquarefree c0
[PROOF STEP]
have "order z c0 = 1"
[PROOF STATE]
proof (prove)
using this:
(c0, l0) \<in> set cs
poly c0 z = 0
rsquarefree c0

goal (1 subgoal):
 1. order z c0 = 1
[PROOF STEP]
by (auto simp: rsquarefree_def' order_root intro: antisym)
[PROOF STATE]
proof (state)
this:
order z c0 = 1

goal (1 subgoal):
 1. \<exists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
order z q = Suc l0 * 1 + 0
[PROOF STEP]
have "order z q = Suc l0"
[PROOF STATE]
proof (prove)
using this:
order z q = Suc l0 * 1 + 0

goal (1 subgoal):
 1. order z q = Suc l0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
order z q = Suc l0

goal (1 subgoal):
 1. \<exists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
order z q = Suc l0

goal (1 subgoal):
 1. \<exists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
from roots2[of c0 l0] cl0 z
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>(c0, l0) \<in> set cs; k < l0\<rbrakk> \<Longrightarrow> \<forall>x\<in>sphere 0 (1 / R). poly c0 x \<noteq> 0
(c0, l0) \<in> set cs
poly c0 z = 0
z \<in> sphere 0 (1 / R)
[PROOF STEP]
have "l0 \<le> k"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>(c0, l0) \<in> set cs; k < l0\<rbrakk> \<Longrightarrow> \<forall>x\<in>sphere 0 (1 / R). poly c0 x \<noteq> 0
(c0, l0) \<in> set cs
poly c0 z = 0
z \<in> sphere 0 (1 / R)

goal (1 subgoal):
 1. l0 \<le> k
[PROOF STEP]
by (cases l0 k rule: linorder_cases) auto
[PROOF STATE]
proof (state)
this:
l0 \<le> k

goal (1 subgoal):
 1. \<exists>c0 l0. (c0, l0) \<in> set cs \<and> poly c0 z = 0 \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<And>x y. x \<le> y \<Longrightarrow> Suc x \<le> Suc y) \<Longrightarrow> order z q \<le> Suc k
[PROOF STEP]
show "order z q \<le> Suc k"
[PROOF STATE]
proof (prove)
using this:
(\<And>x y. x \<le> y \<Longrightarrow> Suc x \<le> Suc y) \<Longrightarrow> order z q \<le> Suc k

goal (1 subgoal):
 1. order z q \<le> Suc k
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
order z q \<le> Suc k

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
order z q \<le> Suc k

goal (1 subgoal):
 1. 0 < R
[PROOF STEP]
qed fact+
[PROOF STATE]
proof (state)
this:
($) (fps_of_poly p / fps_of_poly q) \<in> O(\<lambda>n. of_nat n ^ k * complex_of_real R ^ n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma startsby_zero_sum_depends:
  assumes a0: "a $0 = 0"
    and kn: "n \<ge> k"
  shows "sum (\<lambda>i. (a ^ i)$k) {0 .. n} = sum (\<lambda>i. (a ^ i)$k) {0 .. k}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..n. a ^ i $ k) = (\<Sum>i = 0..k. a ^ i $ k)
[PROOF STEP]
proof (intro strip sum.mono_neutral_right)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. finite {0..n}
 2. {0..k} \<subseteq> {0..n}
 3. \<And>i. i \<in> {0..n} - {0..k} \<Longrightarrow> a ^ i $ k = (0::'a)
[PROOF STEP]
show "\<And>i. i \<in> {0..n} - {0..k} \<Longrightarrow> a ^ i $ k = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i \<in> {0..n} - {0..k} \<Longrightarrow> a ^ i $ k = (0::'a)
[PROOF STEP]
by (simp add: a0 startsby_zero_power_prefix)
[PROOF STATE]
proof (state)
this:
?i \<in> {0..n} - {0..k} \<Longrightarrow> a ^ ?i $ k = (0::'a)

goal (2 subgoals):
 1. finite {0..n}
 2. {0..k} \<subseteq> {0..n}
[PROOF STEP]
qed (use kn in auto)


[STATEMENT]
theorem Dirichlet:
  assumes "coprime h n"
  shows   "infinite {p. prime p \<and> [p = h] (mod n)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infinite {p. prime p \<and> [p = h] (mod n)}
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. finite {p. prime p \<and> [p = h] (mod n)} \<Longrightarrow> False
[PROOF STEP]
assume "finite {p. prime p \<and> [p = h] (mod n)}"
[PROOF STATE]
proof (state)
this:
finite {p. prime p \<and> [p = h] (mod n)}

goal (1 subgoal):
 1. finite {p. prime p \<and> [p = h] (mod n)} \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
finite {p. prime p \<and> [p = h] (mod n)}
[PROOF STEP]
obtain K where K: "{p. prime p \<and> [p = h] (mod n)} \<subseteq> {..<K}"
[PROOF STATE]
proof (prove)
using this:
finite {p. prime p \<and> [p = h] (mod n)}

goal (1 subgoal):
 1. (\<And>K. {p. prime p \<and> [p = h] (mod n)} \<subseteq> {..<K} \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: finite_nat_iff_bounded)
[PROOF STATE]
proof (state)
this:
{p. prime p \<and> [p = h] (mod n)} \<subseteq> {..<K}

goal (1 subgoal):
 1. finite {p. prime p \<and> [p = h] (mod n)} \<Longrightarrow> False
[PROOF STEP]
have "eventually (\<lambda>x. (\<Sum>p | prime p \<and> [p = h] (mod n) \<and> real p \<le> x. ln p / p) =
                        (\<Sum>p | prime p \<and> [p = h] (mod n). ln p / p)) at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_top. (\<Sum>p | prime p \<and> [p = h] (mod n) \<and> real p \<le> x. ln (real p) / real p) = (\<Sum>p | prime p \<and> [p = h] (mod n). ln (real p) / real p)
[PROOF STEP]
using eventually_ge_at_top[of "real K"]
[PROOF STATE]
proof (prove)
using this:
eventually ((\<le>) (real K)) at_top

goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_top. (\<Sum>p | prime p \<and> [p = h] (mod n) \<and> real p \<le> x. ln (real p) / real p) = (\<Sum>p | prime p \<and> [p = h] (mod n). ln (real p) / real p)
[PROOF STEP]
by eventually_elim (intro sum.cong, use K in auto)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in at_top. (\<Sum>p | prime p \<and> [p = h] (mod n) \<and> real p \<le> x. ln (real p) / real p) = (\<Sum>p | prime p \<and> [p = h] (mod n). ln (real p) / real p)

goal (1 subgoal):
 1. finite {p. prime p \<and> [p = h] (mod n)} \<Longrightarrow> False
[PROOF STEP]
hence "(\<lambda>x. (\<Sum>p | prime p \<and> [p = h] (mod n) \<and> real p \<le> x. ln p / p)) \<in>
            \<Theta>(\<lambda>_. (\<Sum>p | prime p \<and> [p = h] (mod n). ln p / p))"
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in at_top. (\<Sum>p | prime p \<and> [p = h] (mod n) \<and> real p \<le> x. ln (real p) / real p) = (\<Sum>p | prime p \<and> [p = h] (mod n). ln (real p) / real p)

goal (1 subgoal):
 1. (\<lambda>x. \<Sum>p | prime p \<and> [p = h] (mod n) \<and> real p \<le> x. ln (real p) / real p) \<in> \<Theta>(\<lambda>_. \<Sum>p | prime p \<and> [p = h] (mod n). ln (real p) / real p)
[PROOF STEP]
by (intro bigthetaI_cong) auto
[PROOF STATE]
proof (state)
this:
(\<lambda>x. \<Sum>p | prime p \<and> [p = h] (mod n) \<and> real p \<le> x. ln (real p) / real p) \<in> \<Theta>(\<lambda>_. \<Sum>p | prime p \<and> [p = h] (mod n). ln (real p) / real p)

goal (1 subgoal):
 1. finite {p. prime p \<and> [p = h] (mod n)} \<Longrightarrow> False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<lambda>x. \<Sum>p | prime p \<and> [p = h] (mod n) \<and> real p \<le> x. ln (real p) / real p) \<in> \<Theta>(\<lambda>_. \<Sum>p | prime p \<and> [p = h] (mod n). ln (real p) / real p)

goal (1 subgoal):
 1. finite {p. prime p \<and> [p = h] (mod n)} \<Longrightarrow> False
[PROOF STEP]
have "(\<lambda>_. (\<Sum>p | prime p \<and> [p = h] (mod n). ln p / p)) \<in> O(\<lambda>_. 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>_. \<Sum>p | prime p \<and> [p = h] (mod n). ln (real p) / real p) \<in> O(\<lambda>_. 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<lambda>_. \<Sum>p | prime p \<and> [p = h] (mod n). ln (real p) / real p) \<in> O(\<lambda>_. 1)

goal (1 subgoal):
 1. finite {p. prime p \<and> [p = h] (mod n)} \<Longrightarrow> False
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>x. \<Sum>p | prime p \<and> [p = h] (mod n) \<and> real p \<le> x. ln (real p) / real p) \<in> O(\<lambda>_. 1)
[PROOF STEP]
have "(\<lambda>x. (\<Sum>p | prime p \<and> [p = h] (mod n) \<and> real p \<le> x. ln p / p)) \<in> O(\<lambda>_. 1)"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. \<Sum>p | prime p \<and> [p = h] (mod n) \<and> real p \<le> x. ln (real p) / real p) \<in> O(\<lambda>_. 1)

goal (1 subgoal):
 1. (\<lambda>x. \<Sum>p | prime p \<and> [p = h] (mod n) \<and> real p \<le> x. ln (real p) / real p) \<in> O(\<lambda>_. 1)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<lambda>x. \<Sum>p | prime p \<and> [p = h] (mod n) \<and> real p \<le> x. ln (real p) / real p) \<in> O(\<lambda>_. 1)

goal (1 subgoal):
 1. finite {p. prime p \<and> [p = h] (mod n)} \<Longrightarrow> False
[PROOF STEP]
from sum_in_bigo(2)[OF this Dirichlet_strong[OF assms]] and n
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>x. (\<Sum>p | prime p \<and> [p = h] (mod n) \<and> real p \<le> x. ln (real p) / real p) - ((\<Sum>x\<in>{p. prime p \<and> [p = h] (mod n) \<and> real p \<le> x}. ln (real x) / real x) - ln x / real (totient n))) \<in> O(\<lambda>_. 1)
1 < n
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. (\<Sum>p | prime p \<and> [p = h] (mod n) \<and> real p \<le> x. ln (real p) / real p) - ((\<Sum>x\<in>{p. prime p \<and> [p = h] (mod n) \<and> real p \<le> x}. ln (real x) / real x) - ln x / real (totient n))) \<in> O(\<lambda>_. 1)
1 < n

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma moebius_rotation_preserve_cmod [simp]:
  assumes "u \<noteq> \<infinity>\<^sub>h"
  shows "cmod (to_complex (moebius_pt (moebius_rotation \<phi>) u)) = cmod (to_complex u)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cmod (to_complex (moebius_pt (moebius_rotation \<phi>) u)) = cmod (to_complex u)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
u \<noteq> \<infinity>\<^sub>h

goal (1 subgoal):
 1. cmod (to_complex (moebius_pt (moebius_rotation \<phi>) u)) = cmod (to_complex u)
[PROOF STEP]
using inf_or_of_complex[of u]
[PROOF STATE]
proof (prove)
using this:
u \<noteq> \<infinity>\<^sub>h
u = \<infinity>\<^sub>h \<or> (\<exists>x. u = of_complex x)

goal (1 subgoal):
 1. cmod (to_complex (moebius_pt (moebius_rotation \<phi>) u)) = cmod (to_complex u)
[PROOF STEP]
by (auto simp: norm_mult)


[STATEMENT]
lemma card_partition_on_size1_eq_iverson:
  assumes "finite A"
  shows "card {P. partition_on A P \<and> card P \<le> k \<and> (\<forall>X\<in>P. card X = 1)} = iverson (card A \<le> k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {P. partition_on A P \<and> card P \<le> k \<and> (\<forall>X\<in>P. card X = 1)} = iverson (card A \<le> k)
[PROOF STEP]
proof (cases "card A \<le> k")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. card A \<le> k \<Longrightarrow> card {P. partition_on A P \<and> card P \<le> k \<and> (\<forall>X\<in>P. card X = 1)} = iverson (card A \<le> k)
 2. \<not> card A \<le> k \<Longrightarrow> card {P. partition_on A P \<and> card P \<le> k \<and> (\<forall>X\<in>P. card X = 1)} = iverson (card A \<le> k)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
card A \<le> k

goal (2 subgoals):
 1. card A \<le> k \<Longrightarrow> card {P. partition_on A P \<and> card P \<le> k \<and> (\<forall>X\<in>P. card X = 1)} = iverson (card A \<le> k)
 2. \<not> card A \<le> k \<Longrightarrow> card {P. partition_on A P \<and> card P \<le> k \<and> (\<forall>X\<in>P. card X = 1)} = iverson (card A \<le> k)
[PROOF STEP]
from this \<open>finite A\<close>
[PROOF STATE]
proof (chain)
picking this:
card A \<le> k
finite A
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
card A \<le> k
finite A

goal (1 subgoal):
 1. card {P. partition_on A P \<and> card P \<le> k \<and> (\<forall>X\<in>P. card X = 1)} = iverson (card A \<le> k)
[PROOF STEP]
unfolding iverson_def
[PROOF STATE]
proof (prove)
using this:
card A \<le> k
finite A

goal (1 subgoal):
 1. card {P. partition_on A P \<and> card P \<le> k \<and> (\<forall>X\<in>P. card X = 1)} = (if card A \<le> k then 1 else 0)
[PROOF STEP]
using card_partition_on_size1_eq_1
[PROOF STATE]
proof (prove)
using this:
card A \<le> k
finite A
\<lbrakk>finite ?A; card ?A \<le> ?k\<rbrakk> \<Longrightarrow> card {P. partition_on ?A P \<and> card P \<le> ?k \<and> (\<forall>X\<in>P. card X = 1)} = 1

goal (1 subgoal):
 1. card {P. partition_on A P \<and> card P \<le> k \<and> (\<forall>X\<in>P. card X = 1)} = (if card A \<le> k then 1 else 0)
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
card {P. partition_on A P \<and> card P \<le> k \<and> (\<forall>X\<in>P. card X = 1)} = iverson (card A \<le> k)

goal (1 subgoal):
 1. \<not> card A \<le> k \<Longrightarrow> card {P. partition_on A P \<and> card P \<le> k \<and> (\<forall>X\<in>P. card X = 1)} = iverson (card A \<le> k)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> card A \<le> k \<Longrightarrow> card {P. partition_on A P \<and> card P \<le> k \<and> (\<forall>X\<in>P. card X = 1)} = iverson (card A \<le> k)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> card A \<le> k

goal (1 subgoal):
 1. \<not> card A \<le> k \<Longrightarrow> card {P. partition_on A P \<and> card P \<le> k \<and> (\<forall>X\<in>P. card X = 1)} = iverson (card A \<le> k)
[PROOF STEP]
from this \<open>finite A\<close>
[PROOF STATE]
proof (chain)
picking this:
\<not> card A \<le> k
finite A
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> card A \<le> k
finite A

goal (1 subgoal):
 1. card {P. partition_on A P \<and> card P \<le> k \<and> (\<forall>X\<in>P. card X = 1)} = iverson (card A \<le> k)
[PROOF STEP]
unfolding iverson_def
[PROOF STATE]
proof (prove)
using this:
\<not> card A \<le> k
finite A

goal (1 subgoal):
 1. card {P. partition_on A P \<and> card P \<le> k \<and> (\<forall>X\<in>P. card X = 1)} = (if card A \<le> k then 1 else 0)
[PROOF STEP]
using card_partition_on_size1_eq_0
[PROOF STATE]
proof (prove)
using this:
\<not> card A \<le> k
finite A
\<lbrakk>finite ?A; ?k < card ?A\<rbrakk> \<Longrightarrow> card {P. partition_on ?A P \<and> card P \<le> ?k \<and> (\<forall>X\<in>P. card X = 1)} = 0

goal (1 subgoal):
 1. card {P. partition_on A P \<and> card P \<le> k \<and> (\<forall>X\<in>P. card X = 1)} = (if card A \<le> k then 1 else 0)
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
card {P. partition_on A P \<and> card P \<le> k \<and> (\<forall>X\<in>P. card X = 1)} = iverson (card A \<le> k)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fls_mult_right_inverse_base_factor:
  fixes   f :: "'a::ring_1 fls"
  assumes "(f $$ fls_subdegree f) * y = 1"
  shows   "f * fls_right_inverse (fls_base_factor f) y = fls_X_intpow (fls_subdegree f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f * fls_right_inverse (fls_base_factor f) y = fls_X_intpow (fls_subdegree f)
[PROOF STEP]
using   assms fls_base_factor_to_fps_base_factor[of f] fls_base_factor_subdegree[of f]
          fls_shifted_times_simps(1)[of f "-fls_subdegree f" "fls_right_inverse f y"]
          fls_right_inverse[of f y]
[PROOF STATE]
proof (prove)
using this:
f $$ fls_subdegree f * y = (1::'a)
fls_base_factor_to_fps (fls_base_factor f) = fls_base_factor_to_fps f
fls_subdegree (fls_base_factor f) = 0
f * fls_shift (- fls_subdegree f) (fls_right_inverse f y) = fls_shift (- fls_subdegree f) (f * fls_right_inverse f y)
f $$ fls_subdegree f * y = (1::'a) \<Longrightarrow> f * fls_right_inverse f y = 1

goal (1 subgoal):
 1. f * fls_right_inverse (fls_base_factor f) y = fls_X_intpow (fls_subdegree f)
[PROOF STEP]
by      simp


[STATEMENT]
lemma cyclic_reduced_homology_group_nsphere:
   "cyclic_group(reduced_homology_group p (nsphere n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cyclic_group (reduced_homology_group p (nsphere n))
[PROOF STEP]
by (metis reduced_homology_group_nsphere trivial_imp_cyclic_group cyclic_integer_group
      group_integer_group group_reduced_homology_group isomorphic_group_cyclicity)


[STATEMENT]
lemma "(\<forall>x. p(a) \<and> (p(x) \<longrightarrow> (\<exists>y. p(y) \<and> r x y)) \<longrightarrow>
           (\<exists>z. \<exists>w. p(z) \<and> r x w \<and> r w z))  =
     (\<forall>x. (\<not>p(a) \<or> p(x) \<or> (\<exists>z. \<exists>w. p(z) \<and> r x w \<and> r w z)) \<and>
           (\<not>p(a) \<or> \<not>(\<exists>y. p(y) \<and> r x y) \<or>
            (\<exists>z. \<exists>w. p(z) \<and> r x w \<and> r w z)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x. p a \<and> (p x \<longrightarrow> (\<exists>y. p y \<and> r x y)) \<longrightarrow> (\<exists>z w. p z \<and> r x w \<and> r w z)) = (\<forall>x. (\<not> p a \<or> p x \<or> (\<exists>z w. p z \<and> r x w \<and> r w z)) \<and> (\<not> p a \<or> (\<nexists>y. p y \<and> r x y) \<or> (\<exists>z w. p z \<and> r x w \<and> r w z)))
[PROOF STEP]
by blast


[STATEMENT]
lemma lebesgue_measurable_imp_measurable_on_nnreal:
  fixes u :: "'a::euclidean_space \<Rightarrow> real"
  assumes "u \<in> borel_measurable lebesgue" "\<And>x. u x \<ge> 0""S \<in> sets lebesgue"
  shows "u measurable_on S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. u measurable_on S
[PROOF STEP]
unfolding measurable_on_UNIV [symmetric, of u]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. if x \<in> S then u x else 0) measurable_on UNIV
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
u \<in> borel_measurable lebesgue
0 \<le> u ?x
S \<in> sets lebesgue

goal (1 subgoal):
 1. (\<lambda>x. if x \<in> S then u x else 0) measurable_on UNIV
[PROOF STEP]
by (auto intro: lebesgue_measurable_imp_measurable_on_nnreal_UNIV)


[STATEMENT]
lemma unitary_gen_regular:
  assumes "unitary_gen M"
  shows "mat_det M \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_det M \<noteq> 0
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. mat_det M \<noteq> 0
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
unitary_gen M
[PROOF STEP]
obtain k where
    "k \<noteq> 0" "mat_adj M *\<^sub>m\<^sub>m M = k *\<^sub>s\<^sub>m eye"
[PROOF STATE]
proof (prove)
using this:
unitary_gen M

goal (1 subgoal):
 1. (\<And>k. \<lbrakk>k \<noteq> 0; mat_adj M *\<^sub>m\<^sub>m M = k *\<^sub>s\<^sub>m eye\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding unitary_gen_def
[PROOF STATE]
proof (prove)
using this:
\<exists>k. k \<noteq> 0 \<and> mat_adj M *\<^sub>m\<^sub>m M = k *\<^sub>s\<^sub>m eye

goal (1 subgoal):
 1. (\<And>k. \<lbrakk>k \<noteq> 0; mat_adj M *\<^sub>m\<^sub>m M = k *\<^sub>s\<^sub>m eye\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
k \<noteq> 0
mat_adj M *\<^sub>m\<^sub>m M = k *\<^sub>s\<^sub>m eye

goal (1 subgoal):
 1. mat_det M \<noteq> 0
[PROOF STEP]
hence "mat_det (mat_adj M *\<^sub>m\<^sub>m M) \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
k \<noteq> 0
mat_adj M *\<^sub>m\<^sub>m M = k *\<^sub>s\<^sub>m eye

goal (1 subgoal):
 1. mat_det (mat_adj M *\<^sub>m\<^sub>m M) \<noteq> 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
mat_det (mat_adj M *\<^sub>m\<^sub>m M) \<noteq> 0

goal (1 subgoal):
 1. mat_det M \<noteq> 0
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
mat_det (mat_adj M *\<^sub>m\<^sub>m M) \<noteq> 0

goal (1 subgoal):
 1. mat_det M \<noteq> 0
[PROOF STEP]
by (simp add: mat_det_adj)
[PROOF STATE]
proof (state)
this:
mat_det M \<noteq> 0

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma gen_akiyama_tanigawa_row_Suc [code]:
  "gen_akiyama_tanigawa_row f (Suc n) l u =
     akiyama_tanigawa_step_aux (Suc l) (gen_akiyama_tanigawa_row f n l (Suc u))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gen_akiyama_tanigawa_row f (Suc n) l u = akiyama_tanigawa_step_aux (Suc l) (gen_akiyama_tanigawa_row f n l (Suc u))
[PROOF STEP]
by (rule nth_equalityI) (auto simp: nth_gen_akiyama_tanigawa_row nth_akiyama_tanigawa_step_aux)


[STATEMENT]
lemma powreal_divide2:
  "0 \<le> a \<Longrightarrow> a pow\<^sub>\<real> (x - y) = (a pow\<^sub>\<real> x) / (a pow\<^sub>\<real> y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> a \<Longrightarrow> a pow\<^sub>\<real> (x - y) = a pow\<^sub>\<real> x / a pow\<^sub>\<real> y
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 0 \<le> a \<Longrightarrow> a pow\<^sub>\<real> (x - y) = a pow\<^sub>\<real> x / a pow\<^sub>\<real> y
[PROOF STEP]
assume a1: "0 \<le> a"
[PROOF STATE]
proof (state)
this:
0 \<le> a

goal (1 subgoal):
 1. 0 \<le> a \<Longrightarrow> a pow\<^sub>\<real> (x - y) = a pow\<^sub>\<real> x / a pow\<^sub>\<real> y
[PROOF STEP]
have f2: "\<forall>x0. - (x0::real) = - 1 * x0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x0. - x0 = - 1 * x0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>x0. - x0 = - 1 * x0

goal (1 subgoal):
 1. 0 \<le> a \<Longrightarrow> a pow\<^sub>\<real> (x - y) = a pow\<^sub>\<real> x / a pow\<^sub>\<real> y
[PROOF STEP]
have "x - y = x + - 1 * y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x - y = x + - 1 * y
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x - y = x + - 1 * y

goal (1 subgoal):
 1. 0 \<le> a \<Longrightarrow> a pow\<^sub>\<real> (x - y) = a pow\<^sub>\<real> x / a pow\<^sub>\<real> y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x - y = x + - 1 * y
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
x - y = x + - 1 * y

goal (1 subgoal):
 1. a pow\<^sub>\<real> (x - y) = a pow\<^sub>\<real> x / a pow\<^sub>\<real> y
[PROOF STEP]
using f2 a1
[PROOF STATE]
proof (prove)
using this:
x - y = x + - 1 * y
\<forall>x0. - x0 = - 1 * x0
0 \<le> a

goal (1 subgoal):
 1. a pow\<^sub>\<real> (x - y) = a pow\<^sub>\<real> x / a pow\<^sub>\<real> y
[PROOF STEP]
by (metis field_class.field_divide_inverse powreal_add powreal_minus)
[PROOF STATE]
proof (state)
this:
a pow\<^sub>\<real> (x - y) = a pow\<^sub>\<real> x / a pow\<^sub>\<real> y

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fps_mult_of_nat_nth [simp]:
  shows "(of_nat k * f) $ n = of_nat k * f$n"
  and   "(f * of_nat k ) $ n = f$n * of_nat k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (of_nat k * f) $ n = of_nat k * f $ n &&& (f * of_nat k) $ n = f $ n * of_nat k
[PROOF STEP]
by    (simp_all add: fps_of_nat[symmetric])


[STATEMENT]
lemma at_right_minus: "at_right a = filtermap (\<lambda>x. - x) (at_left (- a))"
  for a :: real
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. at_right a = filtermap uminus (at_left (- a))
[PROOF STEP]
by (simp add: filter_eq_iff eventually_filtermap eventually_at_filter filtermap_nhds_minus[symmetric])


[STATEMENT]
theorem descartes_roots_test:
  fixes p::"real poly"
  assumes "p\<noteq>0" "a<b"
  shows "proots_count p {x. a < x \<and> x <b} \<le> descartes_roots_test a b p  \<and>
          even (descartes_roots_test a b p - proots_count p {x. a < x \<and> x < b})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proots_count p {x. a < x \<and> x < b} \<le> descartes_roots_test a b p \<and> even (descartes_roots_test a b p - proots_count p {x. a < x \<and> x < b})
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. proots_count p {x. a < x \<and> x < b} \<le> descartes_roots_test a b p \<and> even (descartes_roots_test a b p - proots_count p {x. a < x \<and> x < b})
[PROOF STEP]
define q where "q=fcompose p [:a,b:] [:1,1:]"
[PROOF STATE]
proof (state)
this:
q = fcompose p [:a, b:] [:1, 1:]

goal (1 subgoal):
 1. proots_count p {x. a < x \<and> x < b} \<le> descartes_roots_test a b p \<and> even (descartes_roots_test a b p - proots_count p {x. a < x \<and> x < b})
[PROOF STEP]
have "q\<noteq>0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. q \<noteq> 0
[PROOF STEP]
unfolding q_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fcompose p [:a, b:] [:1, 1:] \<noteq> 0
[PROOF STEP]
apply (rule fcompose_nzero[OF \<open>p\<noteq>0\<close>])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. [:1, 1:] \<noteq> 0
 2. \<forall>c. [:a, b:] \<noteq> smult c [:1, 1:]
 3. infinite UNIV
[PROOF STEP]
using \<open>a<b\<close> infinite_UNIV_char_0
[PROOF STATE]
proof (prove)
using this:
a < b
infinite UNIV

goal (3 subgoals):
 1. [:1, 1:] \<noteq> 0
 2. \<forall>c. [:a, b:] \<noteq> smult c [:1, 1:]
 3. infinite UNIV
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
q \<noteq> 0

goal (1 subgoal):
 1. proots_count p {x. a < x \<and> x < b} \<le> descartes_roots_test a b p \<and> even (descartes_roots_test a b p - proots_count p {x. a < x \<and> x < b})
[PROOF STEP]
have "proots_count p {x. a < x \<and> x <b} = proots_count q {x. 0 < x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proots_count p {x. a < x \<and> x < b} = proots_count q {x. 0 < x}
[PROOF STEP]
using proots_sphere_pos_interval[OF \<open>p\<noteq>0\<close> \<open>a<b\<close>,folded q_def]
[PROOF STATE]
proof (prove)
using this:
proots_count p {x. a < x \<and> x < b} = proots_count q {x. 0 < x}

goal (1 subgoal):
 1. proots_count p {x. a < x \<and> x < b} = proots_count q {x. 0 < x}
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
proots_count p {x. a < x \<and> x < b} = proots_count q {x. 0 < x}

goal (1 subgoal):
 1. proots_count p {x. a < x \<and> x < b} \<le> descartes_roots_test a b p \<and> even (descartes_roots_test a b p - proots_count p {x. a < x \<and> x < b})
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
proots_count p {x. a < x \<and> x < b} = proots_count q {x. 0 < x}

goal (1 subgoal):
 1. proots_count p {x. a < x \<and> x < b} \<le> descartes_roots_test a b p \<and> even (descartes_roots_test a b p - proots_count p {x. a < x \<and> x < b})
[PROOF STEP]
have "int (proots_count q {x. 0 < x}) \<le> changes (coeffs q) \<and>
          even (changes (coeffs q) - int (proots_count q {x. 0 < x}))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int (proots_count q {x. 0 < x}) \<le> changes (coeffs q) \<and> even (changes (coeffs q) - int (proots_count q {x. 0 < x}))
[PROOF STEP]
by (rule descartes_sign[OF \<open>q\<noteq>0\<close>])
[PROOF STATE]
proof (state)
this:
int (proots_count q {x. 0 < x}) \<le> changes (coeffs q) \<and> even (changes (coeffs q) - int (proots_count q {x. 0 < x}))

goal (1 subgoal):
 1. proots_count p {x. a < x \<and> x < b} \<le> descartes_roots_test a b p \<and> even (descartes_roots_test a b p - proots_count p {x. a < x \<and> x < b})
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
int (proots_count q {x. 0 < x}) \<le> changes (coeffs q) \<and> even (changes (coeffs q) - int (proots_count q {x. 0 < x}))
[PROOF STEP]
have "proots_count q {x. 0 < x} \<le> nat (changes (coeffs q)) \<and>
          even (nat (changes (coeffs q)) - proots_count q {x. 0 < x})"
[PROOF STATE]
proof (prove)
using this:
int (proots_count q {x. 0 < x}) \<le> changes (coeffs q) \<and> even (changes (coeffs q) - int (proots_count q {x. 0 < x}))

goal (1 subgoal):
 1. proots_count q {x. 0 < x} \<le> nat (changes (coeffs q)) \<and> even (nat (changes (coeffs q)) - proots_count q {x. 0 < x})
[PROOF STEP]
using even_nat_iff
[PROOF STATE]
proof (prove)
using this:
int (proots_count q {x. 0 < x}) \<le> changes (coeffs q) \<and> even (changes (coeffs q) - int (proots_count q {x. 0 < x}))
0 \<le> ?k \<Longrightarrow> even (nat ?k) = even ?k

goal (1 subgoal):
 1. proots_count q {x. 0 < x} \<le> nat (changes (coeffs q)) \<and> even (nat (changes (coeffs q)) - proots_count q {x. 0 < x})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
proots_count q {x. 0 < x} \<le> nat (changes (coeffs q)) \<and> even (nat (changes (coeffs q)) - proots_count q {x. 0 < x})

goal (1 subgoal):
 1. proots_count p {x. a < x \<and> x < b} \<le> descartes_roots_test a b p \<and> even (descartes_roots_test a b p - proots_count p {x. a < x \<and> x < b})
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
proots_count p {x. a < x \<and> x < b} = proots_count q {x. 0 < x}
proots_count q {x. 0 < x} \<le> nat (changes (coeffs q)) \<and> even (nat (changes (coeffs q)) - proots_count q {x. 0 < x})
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
proots_count p {x. a < x \<and> x < b} = proots_count q {x. 0 < x}
proots_count q {x. 0 < x} \<le> nat (changes (coeffs q)) \<and> even (nat (changes (coeffs q)) - proots_count q {x. 0 < x})

goal (1 subgoal):
 1. proots_count p {x. a < x \<and> x < b} \<le> descartes_roots_test a b p \<and> even (descartes_roots_test a b p - proots_count p {x. a < x \<and> x < b})
[PROOF STEP]
unfolding descartes_roots_test_def
[PROOF STATE]
proof (prove)
using this:
proots_count p {x. a < x \<and> x < b} = proots_count q {x. 0 < x}
proots_count q {x. 0 < x} \<le> nat (changes (coeffs q)) \<and> even (nat (changes (coeffs q)) - proots_count q {x. 0 < x})

goal (1 subgoal):
 1. proots_count p {x. a < x \<and> x < b} \<le> nat (changes (coeffs (fcompose p [:a, b:] [:1, 1:]))) \<and> even (nat (changes (coeffs (fcompose p [:a, b:] [:1, 1:]))) - proots_count p {x. a < x \<and> x < b})
[PROOF STEP]
apply (fold q_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>proots_count p {x. a < x \<and> x < b} = proots_count q {x. 0 < x}; proots_count q {x. 0 < x} \<le> nat (changes (coeffs q)) \<and> even (nat (changes (coeffs q)) - proots_count q {x. 0 < x})\<rbrakk> \<Longrightarrow> proots_count p {x. a < x \<and> x < b} \<le> nat (changes (coeffs q)) \<and> even (nat (changes (coeffs q)) - proots_count p {x. a < x \<and> x < b})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
proots_count p {x. a < x \<and> x < b} \<le> descartes_roots_test a b p \<and> even (descartes_roots_test a b p - proots_count p {x. a < x \<and> x < b})

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma dependent_explicit_2:
  fixes v w :: "('a::{field,real_vector})^'n"
  assumes "v \<noteq> w"
  shows "dependent {v, w} \<longleftrightarrow> (\<exists> i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dependent {v, w} = (\<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. dependent {v, w} \<Longrightarrow> \<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0
 2. \<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0 \<Longrightarrow> dependent {v, w}
[PROOF STEP]
let ?S = "{v, w}"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. dependent {v, w} \<Longrightarrow> \<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0
 2. \<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0 \<Longrightarrow> dependent {v, w}
[PROOF STEP]
have "finite ?S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {v, w}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
finite {v, w}

goal (2 subgoals):
 1. dependent {v, w} \<Longrightarrow> \<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0
 2. \<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0 \<Longrightarrow> dependent {v, w}
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
finite {v, w}

goal (2 subgoals):
 1. dependent {v, w} \<Longrightarrow> \<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0
 2. \<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0 \<Longrightarrow> dependent {v, w}
[PROOF STEP]
assume "dependent ?S"
[PROOF STATE]
proof (state)
this:
dependent {v, w}

goal (2 subgoals):
 1. dependent {v, w} \<Longrightarrow> \<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0
 2. \<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0 \<Longrightarrow> dependent {v, w}
[PROOF STEP]
with dependent_explicit_finite [of ?S] and \<open>finite ?S\<close> and \<open>v \<noteq> w\<close>
[PROOF STATE]
proof (chain)
picking this:
finite {v, w} \<Longrightarrow> dependent {v, w} = (\<exists>u. (\<exists>v\<in>{v, w}. u v \<noteq> 0) \<and> (\<Sum>v\<in>{v, w}. u v *\<^sub>R v) = 0)
finite {v, w}
v \<noteq> w
dependent {v, w}
[PROOF STEP]
show "\<exists> i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0"
[PROOF STATE]
proof (prove)
using this:
finite {v, w} \<Longrightarrow> dependent {v, w} = (\<exists>u. (\<exists>v\<in>{v, w}. u v \<noteq> 0) \<and> (\<Sum>v\<in>{v, w}. u v *\<^sub>R v) = 0)
finite {v, w}
v \<noteq> w
dependent {v, w}

goal (1 subgoal):
 1. \<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0

goal (1 subgoal):
 1. \<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0 \<Longrightarrow> dependent {v, w}
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
dependent {v, w} \<Longrightarrow> \<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0

goal (1 subgoal):
 1. \<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0 \<Longrightarrow> dependent {v, w}
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
dependent {v, w} \<Longrightarrow> \<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0

goal (1 subgoal):
 1. \<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0 \<Longrightarrow> dependent {v, w}
[PROOF STEP]
assume "\<exists> i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0"
[PROOF STATE]
proof (state)
this:
\<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0

goal (1 subgoal):
 1. \<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0 \<Longrightarrow> dependent {v, w}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0
[PROOF STEP]
obtain i and j where "i \<noteq> 0 \<or> j \<noteq> 0" and "i *\<^sub>R v + j *\<^sub>R w = 0"
[PROOF STATE]
proof (prove)
using this:
\<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0

goal (1 subgoal):
 1. (\<And>i j. \<lbrakk>i \<noteq> 0 \<or> j \<noteq> 0; i *\<^sub>R v + j *\<^sub>R w = 0\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i \<noteq> 0 \<or> j \<noteq> 0
i *\<^sub>R v + j *\<^sub>R w = 0

goal (1 subgoal):
 1. \<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0 \<Longrightarrow> dependent {v, w}
[PROOF STEP]
let ?u = "\<lambda> x. if x = v then i else j"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0 \<Longrightarrow> dependent {v, w}
[PROOF STEP]
from \<open>i \<noteq> 0 \<or> j \<noteq> 0\<close> and \<open>v \<noteq> w\<close>
[PROOF STATE]
proof (chain)
picking this:
i \<noteq> 0 \<or> j \<noteq> 0
v \<noteq> w
[PROOF STEP]
have "\<exists> x\<in>?S. ?u x \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
i \<noteq> 0 \<or> j \<noteq> 0
v \<noteq> w

goal (1 subgoal):
 1. \<exists>x\<in>{v, w}. (if x = v then i else j) \<noteq> 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<exists>x\<in>{v, w}. (if x = v then i else j) \<noteq> 0

goal (1 subgoal):
 1. \<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0 \<Longrightarrow> dependent {v, w}
[PROOF STEP]
from \<open>i *\<^sub>R v + j *\<^sub>R w = 0\<close> and \<open>v \<noteq> w\<close>
[PROOF STATE]
proof (chain)
picking this:
i *\<^sub>R v + j *\<^sub>R w = 0
v \<noteq> w
[PROOF STEP]
have "(\<Sum> x\<in>?S. ?u x *\<^sub>R x) = 0"
[PROOF STATE]
proof (prove)
using this:
i *\<^sub>R v + j *\<^sub>R w = 0
v \<noteq> w

goal (1 subgoal):
 1. (\<Sum>x\<in>{v, w}. (if x = v then i else j) *\<^sub>R x) = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>{v, w}. (if x = v then i else j) *\<^sub>R x) = 0

goal (1 subgoal):
 1. \<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0 \<Longrightarrow> dependent {v, w}
[PROOF STEP]
with dependent_explicit_finite [of ?S]
      and \<open>finite ?S\<close> and \<open>\<exists> x\<in>?S. ?u x \<noteq> 0\<close>
[PROOF STATE]
proof (chain)
picking this:
finite {v, w} \<Longrightarrow> dependent {v, w} = (\<exists>u. (\<exists>v\<in>{v, w}. u v \<noteq> 0) \<and> (\<Sum>v\<in>{v, w}. u v *\<^sub>R v) = 0)
finite {v, w}
\<exists>x\<in>{v, w}. (if x = v then i else j) \<noteq> 0
(\<Sum>x\<in>{v, w}. (if x = v then i else j) *\<^sub>R x) = 0
[PROOF STEP]
show "dependent ?S"
[PROOF STATE]
proof (prove)
using this:
finite {v, w} \<Longrightarrow> dependent {v, w} = (\<exists>u. (\<exists>v\<in>{v, w}. u v \<noteq> 0) \<and> (\<Sum>v\<in>{v, w}. u v *\<^sub>R v) = 0)
finite {v, w}
\<exists>x\<in>{v, w}. (if x = v then i else j) \<noteq> 0
(\<Sum>x\<in>{v, w}. (if x = v then i else j) *\<^sub>R x) = 0

goal (1 subgoal):
 1. dependent {v, w}
[PROOF STEP]
by best
[PROOF STATE]
proof (state)
this:
dependent {v, w}

goal:
No subgoals!
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<exists>i j. (i \<noteq> 0 \<or> j \<noteq> 0) \<and> i *\<^sub>R v + j *\<^sub>R w = 0 \<Longrightarrow> dependent {v, w}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mult_inj_eq:
  assumes coprime: "coprime x (q::nat)"
    and y: "y < q"
    and y': "y' < q"
    and map: "x * y mod q = x * y' mod q"
  shows "y = y'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y = y'
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. y = y'
[PROOF STEP]
have "x*y mod q = x*y' mod q \<Longrightarrow> y mod q = y' mod q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x * y mod q = x * y' mod q \<Longrightarrow> y mod q = y' mod q
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x * y mod q = x * y' mod q \<Longrightarrow> y mod q = y' mod q
[PROOF STEP]
have "x*y mod q = x*y' mod q \<Longrightarrow> [x*y = x*y'] (mod q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x * y mod q = x * y' mod q \<Longrightarrow> [x * y = x * y'] (mod q)
[PROOF STEP]
by(simp add: cong_def)
[PROOF STATE]
proof (state)
this:
x * y mod q = x * y' mod q \<Longrightarrow> [x * y = x * y'] (mod q)

goal (1 subgoal):
 1. x * y mod q = x * y' mod q \<Longrightarrow> y mod q = y' mod q
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
x * y mod q = x * y' mod q \<Longrightarrow> [x * y = x * y'] (mod q)

goal (1 subgoal):
 1. x * y mod q = x * y' mod q \<Longrightarrow> y mod q = y' mod q
[PROOF STEP]
have "[x*y = x*y'] (mod q) = [y = y'] (mod q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x * y = x * y'] (mod q) = [y = y'] (mod q)
[PROOF STEP]
by(simp add: cong_mult_lcancel_nat coprime)
[PROOF STATE]
proof (state)
this:
[x * y = x * y'] (mod q) = [y = y'] (mod q)

goal (1 subgoal):
 1. x * y mod q = x * y' mod q \<Longrightarrow> y mod q = y' mod q
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
[x * y = x * y'] (mod q) = [y = y'] (mod q)

goal (1 subgoal):
 1. x * y mod q = x * y' mod q \<Longrightarrow> y mod q = y' mod q
[PROOF STEP]
have "[y = y'] (mod q) \<Longrightarrow> y mod q = y' mod q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [y = y'] (mod q) \<Longrightarrow> y mod q = y' mod q
[PROOF STEP]
by(simp add: cong_def)
[PROOF STATE]
proof (state)
this:
[y = y'] (mod q) \<Longrightarrow> y mod q = y' mod q

goal (1 subgoal):
 1. x * y mod q = x * y' mod q \<Longrightarrow> y mod q = y' mod q
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
x * y mod q = x * y' mod q \<Longrightarrow> [x * y = x * y'] (mod q)
[x * y = x * y'] (mod q) = [y = y'] (mod q)
[y = y'] (mod q) \<Longrightarrow> y mod q = y' mod q
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
x * y mod q = x * y' mod q \<Longrightarrow> [x * y = x * y'] (mod q)
[x * y = x * y'] (mod q) = [y = y'] (mod q)
[y = y'] (mod q) \<Longrightarrow> y mod q = y' mod q

goal (1 subgoal):
 1. y mod q = y' mod q
[PROOF STEP]
by(simp add: map)
[PROOF STATE]
proof (state)
this:
y mod q = y' mod q

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
x * y mod q = x * y' mod q \<Longrightarrow> y mod q = y' mod q

goal (1 subgoal):
 1. y = y'
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
x * y mod q = x * y' mod q \<Longrightarrow> y mod q = y' mod q

goal (1 subgoal):
 1. y = y'
[PROOF STEP]
have "y mod q = y' mod q \<Longrightarrow> y = y'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y mod q = y' mod q \<Longrightarrow> y = y'
[PROOF STEP]
by(simp add: y y')
[PROOF STATE]
proof (state)
this:
y mod q = y' mod q \<Longrightarrow> y = y'

goal (1 subgoal):
 1. y = y'
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
x * y mod q = x * y' mod q \<Longrightarrow> y mod q = y' mod q
y mod q = y' mod q \<Longrightarrow> y = y'
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
x * y mod q = x * y' mod q \<Longrightarrow> y mod q = y' mod q
y mod q = y' mod q \<Longrightarrow> y = y'

goal (1 subgoal):
 1. y = y'
[PROOF STEP]
by(simp add: map)
[PROOF STATE]
proof (state)
this:
y = y'

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma finite_nth_roots [intro]:
  assumes "n > 0"
  shows   "finite {z::complex. z ^ n = c}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {z. z ^ n = c}
[PROOF STEP]
proof (cases "c = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. c = 0 \<Longrightarrow> finite {z. z ^ n = c}
 2. c \<noteq> 0 \<Longrightarrow> finite {z. z ^ n = c}
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
c = 0

goal (2 subgoals):
 1. c = 0 \<Longrightarrow> finite {z. z ^ n = c}
 2. c \<noteq> 0 \<Longrightarrow> finite {z. z ^ n = c}
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
0 < n
c = 0
[PROOF STEP]
have "{z::complex. z ^ n = c} = {0}"
[PROOF STATE]
proof (prove)
using this:
0 < n
c = 0

goal (1 subgoal):
 1. {z. z ^ n = c} = {0}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{z. z ^ n = c} = {0}

goal (2 subgoals):
 1. c = 0 \<Longrightarrow> finite {z. z ^ n = c}
 2. c \<noteq> 0 \<Longrightarrow> finite {z. z ^ n = c}
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
{z. z ^ n = c} = {0}

goal (1 subgoal):
 1. finite {z. z ^ n = c}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
finite {z. z ^ n = c}

goal (1 subgoal):
 1. c \<noteq> 0 \<Longrightarrow> finite {z. z ^ n = c}
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. c \<noteq> 0 \<Longrightarrow> finite {z. z ^ n = c}
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
c \<noteq> 0

goal (1 subgoal):
 1. c \<noteq> 0 \<Longrightarrow> finite {z. z ^ n = c}
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
0 < n
[PROOF STEP]
have "finite {z::complex. z ^ n = 1}"
[PROOF STATE]
proof (prove)
using this:
0 < n

goal (1 subgoal):
 1. finite {z. z ^ n = 1}
[PROOF STEP]
by (intro finite_roots_unity) simp_all
[PROOF STATE]
proof (state)
this:
finite {z. z ^ n = 1}

goal (1 subgoal):
 1. c \<noteq> 0 \<Longrightarrow> finite {z. z ^ n = c}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
finite {z. z ^ n = 1}

goal (1 subgoal):
 1. c \<noteq> 0 \<Longrightarrow> finite {z. z ^ n = c}
[PROOF STEP]
have "?this \<longleftrightarrow> ?thesis"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {z. z ^ n = 1} = finite {z. z ^ n = c}
[PROOF STEP]
by (rule bij_betw_finite, rule bij_betw_nth_root_unity) fact+
[PROOF STATE]
proof (state)
this:
finite {z. z ^ n = 1} = finite {z. z ^ n = c}

goal (1 subgoal):
 1. c \<noteq> 0 \<Longrightarrow> finite {z. z ^ n = c}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
finite {z. z ^ n = c}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
finite {z. z ^ n = c}

goal (1 subgoal):
 1. finite {z. z ^ n = c}
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
finite {z. z ^ n = c}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma closure_of_subset_eq: "S \<subseteq> topspace X \<and> X closure_of S \<subseteq> S \<longleftrightarrow> closedin X S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (S \<subseteq> topspace X \<and> X closure_of S \<subseteq> S) = closedin X S
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (S \<subseteq> topspace X \<and> X closure_of S \<subseteq> S) = closedin X S
[PROOF STEP]
have "openin X (topspace X - S)"
    if "\<And>x. \<lbrakk>x \<in> topspace X; \<forall>T. x \<in> T \<and> openin X T \<longrightarrow> S \<inter> T \<noteq> {}\<rbrakk> \<Longrightarrow> x \<in> S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. openin X (topspace X - S)
[PROOF STEP]
apply (subst openin_subopen)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>topspace X - S. \<exists>T. openin X T \<and> x \<in> T \<and> T \<subseteq> topspace X - S
[PROOF STEP]
by (metis Diff_iff Diff_mono Diff_triv inf.commute openin_subset order_refl that)
[PROOF STATE]
proof (state)
this:
(\<And>x. \<lbrakk>x \<in> topspace X; \<forall>T. x \<in> T \<and> openin X T \<longrightarrow> S \<inter> T \<noteq> {}\<rbrakk> \<Longrightarrow> x \<in> S) \<Longrightarrow> openin X (topspace X - S)

goal (1 subgoal):
 1. (S \<subseteq> topspace X \<and> X closure_of S \<subseteq> S) = closedin X S
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<And>x. \<lbrakk>x \<in> topspace X; \<forall>T. x \<in> T \<and> openin X T \<longrightarrow> S \<inter> T \<noteq> {}\<rbrakk> \<Longrightarrow> x \<in> S) \<Longrightarrow> openin X (topspace X - S)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<And>x. \<lbrakk>x \<in> topspace X; \<forall>T. x \<in> T \<and> openin X T \<longrightarrow> S \<inter> T \<noteq> {}\<rbrakk> \<Longrightarrow> x \<in> S) \<Longrightarrow> openin X (topspace X - S)

goal (1 subgoal):
 1. (S \<subseteq> topspace X \<and> X closure_of S \<subseteq> S) = closedin X S
[PROOF STEP]
by (auto simp: closedin_def closure_of_def disjoint_iff_not_equal)
[PROOF STATE]
proof (state)
this:
(S \<subseteq> topspace X \<and> X closure_of S \<subseteq> S) = closedin X S

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma transcendental_sinh:
  assumes "algebraic z" "z \<noteq> 0"
  shows   "\<not>algebraic (sinh z :: complex)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> algebraic (sinh z)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> algebraic (sinh z)
[PROOF STEP]
have "\<not>algebraic (\<Sum>(a,b)\<leftarrow>[(1/2, z), (-1/2, -z)]. a * exp b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> algebraic (\<Sum>(a, b)\<leftarrow>[(1 / 2, z), (- 1 / 2, - z)]. a * exp b)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
algebraic z
z \<noteq> 0

goal (1 subgoal):
 1. \<not> algebraic (\<Sum>(a, b)\<leftarrow>[(1 / 2, z), (- 1 / 2, - z)]. a * exp b)
[PROOF STEP]
by (intro sum_of_exp_transcendentalI) auto
[PROOF STATE]
proof (state)
this:
\<not> algebraic (\<Sum>(a, b)\<leftarrow>[(1 / 2, z), (- 1 / 2, - z)]. a * exp b)

goal (1 subgoal):
 1. \<not> algebraic (sinh z)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<not> algebraic (\<Sum>(a, b)\<leftarrow>[(1 / 2, z), (- 1 / 2, - z)]. a * exp b)

goal (1 subgoal):
 1. \<not> algebraic (sinh z)
[PROOF STEP]
have "(\<Sum>(a,b)\<leftarrow>[(1/2, z), (-1/2, -z)]. a * exp b) = sinh z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>(a, b)\<leftarrow>[(1 / 2, z), (- 1 / 2, - z)]. a * exp b) = sinh z
[PROOF STEP]
by (simp add: sinh_def field_simps scaleR_conv_of_real)
[PROOF STATE]
proof (state)
this:
(\<Sum>(a, b)\<leftarrow>[(1 / 2, z), (- 1 / 2, - z)]. a * exp b) = sinh z

goal (1 subgoal):
 1. \<not> algebraic (sinh z)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<not> algebraic (sinh z)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> algebraic (sinh z)

goal (1 subgoal):
 1. \<not> algebraic (sinh z)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
\<not> algebraic (sinh z)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ncoplanar_perm_16:
  assumes "\<not> Coplanar A B C D"
  shows "\<not> Coplanar C D A B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> Coplanar C D A B
[PROOF STEP]
using assms coplanar_perm_16
[PROOF STATE]
proof (prove)
using this:
\<not> Coplanar A B C D
Coplanar ?A ?B ?C ?D \<Longrightarrow> Coplanar ?C ?D ?A ?B

goal (1 subgoal):
 1. \<not> Coplanar C D A B
[PROOF STEP]
by blast


[STATEMENT]
lemma vquot_fm_empty [simp]: fixes A::fm shows "\<lfloor>A\<rfloor>{} = \<guillemotleft>A\<guillemotright>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lfloor>A\<rfloor>{} = \<guillemotleft>A\<guillemotright>
[PROOF STEP]
by (simp add: vquot_fm_def quot_fm_def)


[STATEMENT]
lemma exp_approx':
  assumes "n > 0" "0 \<le> x" "x \<le> 1"
  shows   "\<bar>exp (x::real) - (\<Sum>k\<le>n. x^k / fact k)\<bar> \<le> x ^ n / fact n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>exp x - (\<Sum>k\<le>n. x ^ k / fact k)\<bar> \<le> x ^ n / fact n
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<bar>exp x - (\<Sum>k\<le>n. x ^ k / fact k)\<bar> \<le> x ^ n / fact n
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
0 < n
0 \<le> x
x \<le> 1
[PROOF STEP]
have "x^n / (2 - x) \<le> x^n / 1"
[PROOF STATE]
proof (prove)
using this:
0 < n
0 \<le> x
x \<le> 1

goal (1 subgoal):
 1. x ^ n / (2 - x) \<le> x ^ n / 1
[PROOF STEP]
by (intro frac_le) simp_all
[PROOF STATE]
proof (state)
this:
x ^ n / (2 - x) \<le> x ^ n / 1

goal (1 subgoal):
 1. \<bar>exp x - (\<Sum>k\<le>n. x ^ k / fact k)\<bar> \<le> x ^ n / fact n
[PROOF STEP]
hence "(2 * x^n / (2 - x)) / fact n \<le> 2 * x^n / fact n"
[PROOF STATE]
proof (prove)
using this:
x ^ n / (2 - x) \<le> x ^ n / 1

goal (1 subgoal):
 1. 2 * x ^ n / (2 - x) / fact n \<le> 2 * x ^ n / fact n
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
x ^ n / (2 - x) \<le> x ^ n / 1
0 < n
0 \<le> x
x \<le> 1

goal (1 subgoal):
 1. 2 * x ^ n / (2 - x) / fact n \<le> 2 * x ^ n / fact n
[PROOF STEP]
by (simp add: field_split_simps)
[PROOF STATE]
proof (state)
this:
2 * x ^ n / (2 - x) / fact n \<le> 2 * x ^ n / fact n

goal (1 subgoal):
 1. \<bar>exp x - (\<Sum>k\<le>n. x ^ k / fact k)\<bar> \<le> x ^ n / fact n
[PROOF STEP]
with exp_approx[of n x] assms
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>0 < n; 0 \<le> x; x < 2\<rbrakk> \<Longrightarrow> exp x - (\<Sum>k<n. x ^ k / fact k) \<in> {0..2 * x ^ n / (2 - x) / fact n}
0 < n
0 \<le> x
x \<le> 1
2 * x ^ n / (2 - x) / fact n \<le> 2 * x ^ n / fact n
[PROOF STEP]
have "exp (x::real) - (\<Sum>k<n. x^k / fact k) \<in> {0..2 * x^n / fact n}"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 < n; 0 \<le> x; x < 2\<rbrakk> \<Longrightarrow> exp x - (\<Sum>k<n. x ^ k / fact k) \<in> {0..2 * x ^ n / (2 - x) / fact n}
0 < n
0 \<le> x
x \<le> 1
2 * x ^ n / (2 - x) / fact n \<le> 2 * x ^ n / fact n

goal (1 subgoal):
 1. exp x - (\<Sum>k<n. x ^ k / fact k) \<in> {0..2 * x ^ n / fact n}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
exp x - (\<Sum>k<n. x ^ k / fact k) \<in> {0..2 * x ^ n / fact n}

goal (1 subgoal):
 1. \<bar>exp x - (\<Sum>k\<le>n. x ^ k / fact k)\<bar> \<le> x ^ n / fact n
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
exp x - (\<Sum>k<n. x ^ k / fact k) \<in> {0..2 * x ^ n / fact n}

goal (1 subgoal):
 1. \<bar>exp x - (\<Sum>k\<le>n. x ^ k / fact k)\<bar> \<le> x ^ n / fact n
[PROOF STEP]
have "(\<Sum>k\<le>n. x^k / fact k) = (\<Sum>k<n. x^k / fact k) + x ^ n / fact n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k\<le>n. x ^ k / fact k) = (\<Sum>k<n. x ^ k / fact k) + x ^ n / fact n
[PROOF STEP]
by (simp add: lessThan_Suc_atMost [symmetric])
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<le>n. x ^ k / fact k) = (\<Sum>k<n. x ^ k / fact k) + x ^ n / fact n

goal (1 subgoal):
 1. \<bar>exp x - (\<Sum>k\<le>n. x ^ k / fact k)\<bar> \<le> x ^ n / fact n
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
exp x - (\<Sum>k<n. x ^ k / fact k) \<in> {0..2 * x ^ n / fact n}
(\<Sum>k\<le>n. x ^ k / fact k) = (\<Sum>k<n. x ^ k / fact k) + x ^ n / fact n
[PROOF STEP]
show "\<bar>exp (x::real) - (\<Sum>k\<le>n. x^k / fact k)\<bar> \<le> x ^ n / fact n"
[PROOF STATE]
proof (prove)
using this:
exp x - (\<Sum>k<n. x ^ k / fact k) \<in> {0..2 * x ^ n / fact n}
(\<Sum>k\<le>n. x ^ k / fact k) = (\<Sum>k<n. x ^ k / fact k) + x ^ n / fact n

goal (1 subgoal):
 1. \<bar>exp x - (\<Sum>k\<le>n. x ^ k / fact k)\<bar> \<le> x ^ n / fact n
[PROOF STEP]
unfolding atLeastAtMost_iff
[PROOF STATE]
proof (prove)
using this:
0 \<le> exp x - (\<Sum>k<n. x ^ k / fact k) \<and> exp x - (\<Sum>k<n. x ^ k / fact k) \<le> 2 * x ^ n / fact n
(\<Sum>k\<le>n. x ^ k / fact k) = (\<Sum>k<n. x ^ k / fact k) + x ^ n / fact n

goal (1 subgoal):
 1. \<bar>exp x - (\<Sum>k\<le>n. x ^ k / fact k)\<bar> \<le> x ^ n / fact n
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
\<bar>exp x - (\<Sum>k\<le>n. x ^ k / fact k)\<bar> \<le> x ^ n / fact n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma divide_gt1:
  "\<lbrakk>c *R (a::'a) > b; (c::rat) < 0 \<rbrakk> \<Longrightarrow>  a < (1/c) *R b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>b < c *R a; c < 0\<rbrakk> \<Longrightarrow> a < (1 / c) *R b
[PROOF STEP]
using scaleRat_less2[of b "c *R a" "1/c"]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>b < c *R a; 1 / c < 0\<rbrakk> \<Longrightarrow> (1 / c) *R c *R a < (1 / c) *R b

goal (1 subgoal):
 1. \<lbrakk>b < c *R a; c < 0\<rbrakk> \<Longrightarrow> a < (1 / c) *R b
[PROOF STEP]
by (simp add: scaleRat_scaleRat scaleRat_one)


[STATEMENT]
lemma angular_component_unit:
  assumes "a \<in> nonzero Q\<^sub>p"
  shows "angular_component a \<in> Units Z\<^sub>p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. angular_component a \<in> Units Z\<^sub>p
[PROOF STEP]
using ac_fract[of a "numer a" "denom a"]  Q\<^sub>p_def Qp.nonzero_closed
    Qp.nonzero_memE(2) Zp.Units_inv_Units Zp.Units_m_closed
    Zp.nonzero_closed Zp.nonzero_memE(2) Z\<^sub>p_def ac_Zp_is_Unit
    angular_component_def assms local.numer_denom_facts(1)
    local.numer_denom_facts(2) padic_fields.numer_denom_facts(3)
    padic_fields_axioms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>a \<in> carrier Q\<^sub>p; numerator Z\<^sub>p a \<in> nonzero Z\<^sub>p; denominator Z\<^sub>p a \<in> nonzero Z\<^sub>p; a = fraction Z\<^sub>p (numerator Z\<^sub>p a) (denominator Z\<^sub>p a)\<rbrakk> \<Longrightarrow> angular_component a = ac_Zp (numerator Z\<^sub>p a) \<otimes>\<^bsub>Z\<^sub>p\<^esub> inv\<^bsub>Z\<^sub>p\<^esub> ac_Zp (denominator Z\<^sub>p a)
Q\<^sub>p \<equiv> Frac Z\<^sub>p
?a \<in> nonzero Q\<^sub>p \<Longrightarrow> ?a \<in> carrier Q\<^sub>p
?a \<in> nonzero Q\<^sub>p \<Longrightarrow> ?a \<noteq> \<zero>
?x \<in> Units Z\<^sub>p \<Longrightarrow> inv\<^bsub>Z\<^sub>p\<^esub> ?x \<in> Units Z\<^sub>p
\<lbrakk>?x \<in> Units Z\<^sub>p; ?y \<in> Units Z\<^sub>p\<rbrakk> \<Longrightarrow> ?x \<otimes>\<^bsub>Z\<^sub>p\<^esub> ?y \<in> Units Z\<^sub>p
?a \<in> nonzero Z\<^sub>p \<Longrightarrow> ?a \<in> carrier Z\<^sub>p
?a \<in> nonzero Z\<^sub>p \<Longrightarrow> ?a \<noteq> \<zero>\<^bsub>Z\<^sub>p\<^esub>
Z\<^sub>p \<equiv> padic_int p
\<lbrakk>?x \<in> carrier Z\<^sub>p; ?x \<noteq> \<zero>\<^bsub>Z\<^sub>p\<^esub>\<rbrakk> \<Longrightarrow> ac_Zp ?x \<in> Units Z\<^sub>p
angular_component ?a = ac_Zp (numerator Z\<^sub>p ?a) \<otimes>\<^bsub>Z\<^sub>p\<^esub> inv\<^bsub>Z\<^sub>p\<^esub> ac_Zp (denominator Z\<^sub>p ?a)
a \<in> nonzero Q\<^sub>p
?a \<in> carrier Q\<^sub>p \<Longrightarrow> numerator Z\<^sub>p ?a \<in> carrier Z\<^sub>p
?a \<in> carrier Q\<^sub>p \<Longrightarrow> denominator Z\<^sub>p ?a \<in> nonzero Z\<^sub>p
\<lbrakk>padic_fields ?p; ?a \<in> carrier (Frac (padic_int ?p)); ?a \<noteq> \<zero>\<^bsub>Frac (padic_int ?p)\<^esub>\<rbrakk> \<Longrightarrow> numerator (padic_int ?p) ?a \<noteq> \<zero>\<^bsub>padic_int ?p\<^esub>
padic_fields p

goal (1 subgoal):
 1. angular_component a \<in> Units Z\<^sub>p
[PROOF STEP]
by auto


[STATEMENT]
lemma column_add_code [code abstract]:
  "vec_nth (column_add_row A n m q i) =  (%j. if j = n then A $ i $ n + A $ i $ m * q else A $ i $ j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ($) (column_add_row A n m q i) = (\<lambda>j. if j = n then A $ i $ n + A $ i $ m * q else A $ i $ j)
[PROOF STEP]
unfolding column_add_row_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ($) (\<chi>j. if j = n then A $ i $ n + A $ i $ m * q else A $ i $ j) = (\<lambda>j. if j = n then A $ i $ n + A $ i $ m * q else A $ i $ j)
[PROOF STEP]
by auto


[STATEMENT]
lemma finite_set_to_list: "\<exists> xs :: 'a :: finite list. distinct xs \<and> set xs = Y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>xs. distinct xs \<and> set xs = Y
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>xs. distinct xs \<and> set xs = Y
[PROOF STEP]
have "finite Y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite Y
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
finite Y

goal (1 subgoal):
 1. \<exists>xs. distinct xs \<and> set xs = Y
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
finite Y

goal (1 subgoal):
 1. \<exists>xs. distinct xs \<and> set xs = Y
[PROOF STEP]
proof (induct Y rule: finite_induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<exists>xs. distinct xs \<and> set xs = {}
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>xs. distinct xs \<and> set xs = F\<rbrakk> \<Longrightarrow> \<exists>xs. distinct xs \<and> set xs = insert x F
[PROOF STEP]
case (insert y Y)
[PROOF STATE]
proof (state)
this:
finite Y
y \<notin> Y
\<exists>xs. distinct xs \<and> set xs = Y

goal (2 subgoals):
 1. \<exists>xs. distinct xs \<and> set xs = {}
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>xs. distinct xs \<and> set xs = F\<rbrakk> \<Longrightarrow> \<exists>xs. distinct xs \<and> set xs = insert x F
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
finite Y
y \<notin> Y
\<exists>xs. distinct xs \<and> set xs = Y
[PROOF STEP]
obtain xs where xs: "distinct xs" "set xs = Y"
[PROOF STATE]
proof (prove)
using this:
finite Y
y \<notin> Y
\<exists>xs. distinct xs \<and> set xs = Y

goal (1 subgoal):
 1. (\<And>xs. \<lbrakk>distinct xs; set xs = Y\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
distinct xs
set xs = Y

goal (2 subgoals):
 1. \<exists>xs. distinct xs \<and> set xs = {}
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; \<exists>xs. distinct xs \<and> set xs = F\<rbrakk> \<Longrightarrow> \<exists>xs. distinct xs \<and> set xs = insert x F
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>xs. distinct xs \<and> set xs = insert y Y
[PROOF STEP]
by (rule exI[of _ "y # xs"], insert xs insert(2), auto)
[PROOF STATE]
proof (state)
this:
\<exists>xs. distinct xs \<and> set xs = insert y Y

goal (1 subgoal):
 1. \<exists>xs. distinct xs \<and> set xs = {}
[PROOF STEP]
qed simp
[PROOF STATE]
proof (state)
this:
\<exists>xs. distinct xs \<and> set xs = Y

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma feasible_Sup_trans:
  fixes S::"'s trans set"
  assumes fS: "\<forall>t\<in>S. feasible t"
  shows "feasible (Sup_trans S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. feasible (Sup_trans S)
[PROOF STEP]
proof(cases "S={}", simp add:Sup_trans_def Sup_exp_def, blast, intro feasibleI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>b P. \<lbrakk>S \<noteq> {}; bounded_by b P; nneg P\<rbrakk> \<Longrightarrow> bounded_by b (Sup_trans S P)
 2. \<And>b P. \<lbrakk>S \<noteq> {}; bounded_by b P; nneg P\<rbrakk> \<Longrightarrow> nneg (Sup_trans S P)
[PROOF STEP]
fix b::real and P::"'s expect"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>b P. \<lbrakk>S \<noteq> {}; bounded_by b P; nneg P\<rbrakk> \<Longrightarrow> bounded_by b (Sup_trans S P)
 2. \<And>b P. \<lbrakk>S \<noteq> {}; bounded_by b P; nneg P\<rbrakk> \<Longrightarrow> nneg (Sup_trans S P)
[PROOF STEP]
assume bP: "bounded_by b P" and nP: "nneg P"
     and neS: "S \<noteq> {}"
[PROOF STATE]
proof (state)
this:
bounded_by b P
nneg P
S \<noteq> {}

goal (2 subgoals):
 1. \<And>b P. \<lbrakk>S \<noteq> {}; bounded_by b P; nneg P\<rbrakk> \<Longrightarrow> bounded_by b (Sup_trans S P)
 2. \<And>b P. \<lbrakk>S \<noteq> {}; bounded_by b P; nneg P\<rbrakk> \<Longrightarrow> nneg (Sup_trans S P)
[PROOF STEP]
from neS
[PROOF STATE]
proof (chain)
picking this:
S \<noteq> {}
[PROOF STEP]
obtain t where tin: "t \<in> S"
[PROOF STATE]
proof (prove)
using this:
S \<noteq> {}

goal (1 subgoal):
 1. (\<And>t. t \<in> S \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by(auto)
[PROOF STATE]
proof (state)
this:
t \<in> S

goal (2 subgoals):
 1. \<And>b P. \<lbrakk>S \<noteq> {}; bounded_by b P; nneg P\<rbrakk> \<Longrightarrow> bounded_by b (Sup_trans S P)
 2. \<And>b P. \<lbrakk>S \<noteq> {}; bounded_by b P; nneg P\<rbrakk> \<Longrightarrow> nneg (Sup_trans S P)
[PROOF STEP]
with fS
[PROOF STATE]
proof (chain)
picking this:
\<forall>t\<in>S. feasible t
t \<in> S
[PROOF STEP]
have ft: "feasible t"
[PROOF STATE]
proof (prove)
using this:
\<forall>t\<in>S. feasible t
t \<in> S

goal (1 subgoal):
 1. feasible t
[PROOF STEP]
by(auto)
[PROOF STATE]
proof (state)
this:
feasible t

goal (2 subgoals):
 1. \<And>b P. \<lbrakk>S \<noteq> {}; bounded_by b P; nneg P\<rbrakk> \<Longrightarrow> bounded_by b (Sup_trans S P)
 2. \<And>b P. \<lbrakk>S \<noteq> {}; bounded_by b P; nneg P\<rbrakk> \<Longrightarrow> nneg (Sup_trans S P)
[PROOF STEP]
with bP nP
[PROOF STATE]
proof (chain)
picking this:
bounded_by b P
nneg P
feasible t
[PROOF STEP]
have "\<lambda>s. 0 \<tturnstile> t P"
[PROOF STATE]
proof (prove)
using this:
bounded_by b P
nneg P
feasible t

goal (1 subgoal):
 1. \<lambda>s. 0 \<tturnstile> t P
[PROOF STEP]
by(auto)
[PROOF STATE]
proof (state)
this:
\<lambda>s. 0 \<tturnstile> t P

goal (2 subgoals):
 1. \<And>b P. \<lbrakk>S \<noteq> {}; bounded_by b P; nneg P\<rbrakk> \<Longrightarrow> bounded_by b (Sup_trans S P)
 2. \<And>b P. \<lbrakk>S \<noteq> {}; bounded_by b P; nneg P\<rbrakk> \<Longrightarrow> nneg (Sup_trans S P)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<lambda>s. 0 \<tturnstile> t P

goal (2 subgoals):
 1. \<And>b P. \<lbrakk>S \<noteq> {}; bounded_by b P; nneg P\<rbrakk> \<Longrightarrow> bounded_by b (Sup_trans S P)
 2. \<And>b P. \<lbrakk>S \<noteq> {}; bounded_by b P; nneg P\<rbrakk> \<Longrightarrow> nneg (Sup_trans S P)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
\<lambda>s. 0 \<tturnstile> t P

goal (2 subgoals):
 1. \<And>b P. \<lbrakk>S \<noteq> {}; bounded_by b P; nneg P\<rbrakk> \<Longrightarrow> bounded_by b (Sup_trans S P)
 2. \<And>b P. \<lbrakk>S \<noteq> {}; bounded_by b P; nneg P\<rbrakk> \<Longrightarrow> nneg (Sup_trans S P)
[PROOF STEP]
from bP nP
[PROOF STATE]
proof (chain)
picking this:
bounded_by b P
nneg P
[PROOF STEP]
have "sound P"
[PROOF STATE]
proof (prove)
using this:
bounded_by b P
nneg P

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

goal (2 subgoals):
 1. \<And>b P. \<lbrakk>S \<noteq> {}; bounded_by b P; nneg P\<rbrakk> \<Longrightarrow> bounded_by b (Sup_trans S P)
 2. \<And>b P. \<lbrakk>S \<noteq> {}; bounded_by b P; nneg P\<rbrakk> \<Longrightarrow> nneg (Sup_trans S P)
[PROOF STEP]
with tin fS
[PROOF STATE]
proof (chain)
picking this:
t \<in> S
\<forall>t\<in>S. feasible t
sound P
[PROOF STEP]
have "t P \<tturnstile> Sup_trans S P"
[PROOF STATE]
proof (prove)
using this:
t \<in> S
\<forall>t\<in>S. feasible t
sound P

goal (1 subgoal):
 1. t P \<tturnstile> Sup_trans S P
[PROOF STEP]
by(auto intro!:Sup_trans_upper2)
[PROOF STATE]
proof (state)
this:
t P \<tturnstile> Sup_trans S P

goal (2 subgoals):
 1. \<And>b P. \<lbrakk>S \<noteq> {}; bounded_by b P; nneg P\<rbrakk> \<Longrightarrow> bounded_by b (Sup_trans S P)
 2. \<And>b P. \<lbrakk>S \<noteq> {}; bounded_by b P; nneg P\<rbrakk> \<Longrightarrow> nneg (Sup_trans S P)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
t P \<tturnstile> Sup_trans S P

goal (2 subgoals):
 1. \<And>b P. \<lbrakk>S \<noteq> {}; bounded_by b P; nneg P\<rbrakk> \<Longrightarrow> bounded_by b (Sup_trans S P)
 2. \<And>b P. \<lbrakk>S \<noteq> {}; bounded_by b P; nneg P\<rbrakk> \<Longrightarrow> nneg (Sup_trans S P)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<lambda>s. 0 \<tturnstile> Sup_trans S P
[PROOF STEP]
show "nneg (Sup_trans S P)"
[PROOF STATE]
proof (prove)
using this:
\<lambda>s. 0 \<tturnstile> Sup_trans S P

goal (1 subgoal):
 1. nneg (Sup_trans S P)
[PROOF STEP]
by(auto)
[PROOF STATE]
proof (state)
this:
nneg (Sup_trans S P)

goal (1 subgoal):
 1. \<And>b P. \<lbrakk>S \<noteq> {}; bounded_by b P; nneg P\<rbrakk> \<Longrightarrow> bounded_by b (Sup_trans S P)
[PROOF STEP]
from fS bP nP
[PROOF STATE]
proof (chain)
picking this:
\<forall>t\<in>S. feasible t
bounded_by b P
nneg P
[PROOF STEP]
show "bounded_by b (Sup_trans S P)"
[PROOF STATE]
proof (prove)
using this:
\<forall>t\<in>S. feasible t
bounded_by b P
nneg P

goal (1 subgoal):
 1. bounded_by b (Sup_trans S P)
[PROOF STEP]
by(auto intro!:bounded_byI2[OF Sup_trans_least2])
[PROOF STATE]
proof (state)
this:
bounded_by b (Sup_trans S P)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma span_breakdown:
  assumes bS: "b \<in> S"
    and aS: "a \<in> span S"
  shows "\<exists>k. a - k *s b \<in> span (S - {b})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>k. a - k *s b \<in> span (S - {b})
[PROOF STEP]
using assms span_insert [of b "S - {b}"]
[PROOF STATE]
proof (prove)
using this:
b \<in> S
a \<in> span S
span (insert b (S - {b})) = {x. \<exists>k. x - k *s b \<in> span (S - {b})}

goal (1 subgoal):
 1. \<exists>k. a - k *s b \<in> span (S - {b})
[PROOF STEP]
by (simp add: insert_absorb)


[STATEMENT]
lemma arg_min_on_image_finite:
  fixes f :: "'b \<Rightarrow> 'c :: linorder"
  assumes "inj_on f (g ` B)" "finite B" "B \<noteq> {}"
  shows "arg_min_on f (g ` B) = g (arg_min_on (f \<circ> g) B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. arg_min_on f (g ` B) = g (arg_min_on (f \<circ> g) B)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. arg_min_on f (g ` B) = g (arg_min_on (f \<circ> g) B)
[PROOF STEP]
note * = arg_min_if_finite[OF \<open>finite B\<close> \<open>B \<noteq> {}\<close>, of \<open>f \<circ> g\<close>]
[PROOF STATE]
proof (state)
this:
arg_min_on (f \<circ> g) B \<in> B
\<not> (\<exists>x\<in>B. (f \<circ> g) x < (f \<circ> g) (arg_min_on (f \<circ> g) B))

goal (1 subgoal):
 1. arg_min_on f (g ` B) = g (arg_min_on (f \<circ> g) B)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. arg_min_on f (g ` B) = g (arg_min_on (f \<circ> g) B)
[PROOF STEP]
using assms * arg_min_inj_eq
[PROOF STATE]
proof (prove)
using this:
inj_on f (g ` B)
finite B
B \<noteq> {}
arg_min_on (f \<circ> g) B \<in> B
\<not> (\<exists>x\<in>B. (f \<circ> g) x < (f \<circ> g) (arg_min_on (f \<circ> g) B))
\<lbrakk>inj_on ?f {x. ?P x}; ?P ?a; \<forall>y. ?P y \<longrightarrow> ?f ?a \<le> ?f y\<rbrakk> \<Longrightarrow> arg_min ?f ?P = ?a

goal (1 subgoal):
 1. arg_min_on f (g ` B) = g (arg_min_on (f \<circ> g) B)
[PROOF STEP]
by (smt arg_min_if_finite(1) arg_min_least
        comp_apply finite_imageI imageE image_eqI image_is_empty inj_onD less_le)
[PROOF STATE]
proof (state)
this:
arg_min_on f (g ` B) = g (arg_min_on (f \<circ> g) B)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in domain) finite_extension_is_subring:
  assumes "subring K R" "set xs \<subseteq> carrier R" shows "subring (finite_extension K xs) R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. subring (finite_extension K xs) R
[PROOF STEP]
using assms simple_extension_is_subring
[PROOF STATE]
proof (prove)
using this:
subring K R
set xs \<subseteq> carrier R
\<lbrakk>subring ?K R; ?x \<in> carrier R\<rbrakk> \<Longrightarrow> subring (simple_extension ?K ?x) R

goal (1 subgoal):
 1. subring (finite_extension K xs) R
[PROOF STEP]
by (induct xs) (auto)