[STATEMENT]
theorem unity_root_sum:
  fixes k :: nat and n :: int
  assumes gr: "k \<ge> 1"
  shows "k dvd n \<Longrightarrow> unity_root_sum k n = k"
    and "\<not>k dvd n \<Longrightarrow> unity_root_sum k n = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (int k dvd n \<Longrightarrow> unity_root_sum k n = of_nat k) &&& (\<not> int k dvd n \<Longrightarrow> unity_root_sum k n = 0)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. int k dvd n \<Longrightarrow> unity_root_sum k n = of_nat k
 2. \<not> int k dvd n \<Longrightarrow> unity_root_sum k n = 0
[PROOF STEP]
assume dvd: "k dvd n"
[PROOF STATE]
proof (state)
this:
int k dvd n

goal (2 subgoals):
 1. int k dvd n \<Longrightarrow> unity_root_sum k n = of_nat k
 2. \<not> int k dvd n \<Longrightarrow> unity_root_sum k n = 0
[PROOF STEP]
let ?x = "unity_root k n"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. int k dvd n \<Longrightarrow> unity_root_sum k n = of_nat k
 2. \<not> int k dvd n \<Longrightarrow> unity_root_sum k n = 0
[PROOF STEP]
have unit: "?x = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unity_root k n = 1
[PROOF STEP]
using dvd gr unity_root_eq_1_iff_int
[PROOF STATE]
proof (prove)
using this:
int k dvd n
1 \<le> k
0 < ?k \<Longrightarrow> (unity_root ?k ?n = 1) = (int ?k dvd ?n)

goal (1 subgoal):
 1. unity_root k n = 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
unity_root k n = 1

goal (2 subgoals):
 1. int k dvd n \<Longrightarrow> unity_root_sum k n = of_nat k
 2. \<not> int k dvd n \<Longrightarrow> unity_root_sum k n = 0
[PROOF STEP]
have exp: "?x^m = unity_root k (n*m)" for m
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unity_root k n ^ m = unity_root k (n * int m)
[PROOF STEP]
using unity_root_pow
[PROOF STATE]
proof (prove)
using this:
unity_root ?k ?n ^ ?m = unity_root ?k (?n * int ?m)

goal (1 subgoal):
 1. unity_root k n ^ m = unity_root k (n * int m)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
unity_root k n ^ ?m = unity_root k (n * int ?m)

goal (2 subgoals):
 1. int k dvd n \<Longrightarrow> unity_root_sum k n = of_nat k
 2. \<not> int k dvd n \<Longrightarrow> unity_root_sum k n = 0
[PROOF STEP]
have "unity_root_sum k n = (\<Sum>m<k. unity_root k (n*m))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unity_root_sum k n = (\<Sum>m<k. unity_root k (n * int m))
[PROOF STEP]
using unity_root_sum_def
[PROOF STATE]
proof (prove)
using this:
unity_root_sum ?k ?n = (\<Sum>m<?k. unity_root ?k (?n * int m))

goal (1 subgoal):
 1. unity_root_sum k n = (\<Sum>m<k. unity_root k (n * int m))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
unity_root_sum k n = (\<Sum>m<k. unity_root k (n * int m))

goal (2 subgoals):
 1. int k dvd n \<Longrightarrow> unity_root_sum k n = of_nat k
 2. \<not> int k dvd n \<Longrightarrow> unity_root_sum k n = 0
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
unity_root_sum k n = (\<Sum>m<k. unity_root k (n * int m))

goal (2 subgoals):
 1. int k dvd n \<Longrightarrow> unity_root_sum k n = of_nat k
 2. \<not> int k dvd n \<Longrightarrow> unity_root_sum k n = 0
[PROOF STEP]
have "\<dots> = (\<Sum>m<k. ?x^m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m<k. unity_root k (n * int m)) = sum ((^) (unity_root k n)) {..<k}
[PROOF STEP]
using exp
[PROOF STATE]
proof (prove)
using this:
unity_root k n ^ ?m = unity_root k (n * int ?m)

goal (1 subgoal):
 1. (\<Sum>m<k. unity_root k (n * int m)) = sum ((^) (unity_root k n)) {..<k}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>m<k. unity_root k (n * int m)) = sum ((^) (unity_root k n)) {..<k}

goal (2 subgoals):
 1. int k dvd n \<Longrightarrow> unity_root_sum k n = of_nat k
 2. \<not> int k dvd n \<Longrightarrow> unity_root_sum k n = 0
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>m<k. unity_root k (n * int m)) = sum ((^) (unity_root k n)) {..<k}

goal (2 subgoals):
 1. int k dvd n \<Longrightarrow> unity_root_sum k n = of_nat k
 2. \<not> int k dvd n \<Longrightarrow> unity_root_sum k n = 0
[PROOF STEP]
have "\<dots> = (\<Sum>m<k. 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum ((^) (unity_root k n)) {..<k} = (\<Sum>m<k. 1)
[PROOF STEP]
using unit
[PROOF STATE]
proof (prove)
using this:
unity_root k n = 1

goal (1 subgoal):
 1. sum ((^) (unity_root k n)) {..<k} = (\<Sum>m<k. 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sum ((^) (unity_root k n)) {..<k} = (\<Sum>m<k. 1)

goal (2 subgoals):
 1. int k dvd n \<Longrightarrow> unity_root_sum k n = of_nat k
 2. \<not> int k dvd n \<Longrightarrow> unity_root_sum k n = 0
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum ((^) (unity_root k n)) {..<k} = (\<Sum>m<k. 1)

goal (2 subgoals):
 1. int k dvd n \<Longrightarrow> unity_root_sum k n = of_nat k
 2. \<not> int k dvd n \<Longrightarrow> unity_root_sum k n = 0
[PROOF STEP]
have "\<dots> = k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m<k. 1) = of_nat k
[PROOF STEP]
using gr
[PROOF STATE]
proof (prove)
using this:
1 \<le> k

goal (1 subgoal):
 1. (\<Sum>m<k. 1) = of_nat k
[PROOF STEP]
by (induction k, auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>m<k. 1) = of_nat k

goal (2 subgoals):
 1. int k dvd n \<Longrightarrow> unity_root_sum k n = of_nat k
 2. \<not> int k dvd n \<Longrightarrow> unity_root_sum k n = 0
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
unity_root_sum k n = of_nat k
[PROOF STEP]
show "unity_root_sum k n = k"
[PROOF STATE]
proof (prove)
using this:
unity_root_sum k n = of_nat k

goal (1 subgoal):
 1. unity_root_sum k n = of_nat k
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
unity_root_sum k n = of_nat k

goal (1 subgoal):
 1. \<not> int k dvd n \<Longrightarrow> unity_root_sum k n = 0
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> int k dvd n \<Longrightarrow> unity_root_sum k n = 0
[PROOF STEP]
assume dvd: "\<not>k dvd n"
[PROOF STATE]
proof (state)
this:
\<not> int k dvd n

goal (1 subgoal):
 1. \<not> int k dvd n \<Longrightarrow> unity_root_sum k n = 0
[PROOF STEP]
let ?x = "unity_root k n"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> int k dvd n \<Longrightarrow> unity_root_sum k n = 0
[PROOF STEP]
have "?x \<noteq> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unity_root k n \<noteq> 1
[PROOF STEP]
using dvd gr unity_root_eq_1_iff_int
[PROOF STATE]
proof (prove)
using this:
\<not> int k dvd n
1 \<le> k
0 < ?k \<Longrightarrow> (unity_root ?k ?n = 1) = (int ?k dvd ?n)

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

goal (1 subgoal):
 1. \<not> int k dvd n \<Longrightarrow> unity_root_sum k n = 0
[PROOF STEP]
have "(?x^k - 1)/(?x - 1) = (\<Sum>m<k. ?x^m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (unity_root k n ^ k - 1) / (unity_root k n - 1) = sum ((^) (unity_root k n)) {..<k}
[PROOF STEP]
using geometric_sum[of ?x k, OF \<open>?x \<noteq> 1\<close>]
[PROOF STATE]
proof (prove)
using this:
sum ((^) (unity_root k n)) {..<k} = (unity_root k n ^ k - 1) / (unity_root k n - 1)

goal (1 subgoal):
 1. (unity_root k n ^ k - 1) / (unity_root k n - 1) = sum ((^) (unity_root k n)) {..<k}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(unity_root k n ^ k - 1) / (unity_root k n - 1) = sum ((^) (unity_root k n)) {..<k}

goal (1 subgoal):
 1. \<not> int k dvd n \<Longrightarrow> unity_root_sum k n = 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(unity_root k n ^ k - 1) / (unity_root k n - 1) = sum ((^) (unity_root k n)) {..<k}
[PROOF STEP]
have sum: "unity_root_sum k n = (?x^k - 1)/(?x - 1)"
[PROOF STATE]
proof (prove)
using this:
(unity_root k n ^ k - 1) / (unity_root k n - 1) = sum ((^) (unity_root k n)) {..<k}

goal (1 subgoal):
 1. unity_root_sum k n = (unity_root k n ^ k - 1) / (unity_root k n - 1)
[PROOF STEP]
using unity_root_sum_def unity_root_pow
[PROOF STATE]
proof (prove)
using this:
(unity_root k n ^ k - 1) / (unity_root k n - 1) = sum ((^) (unity_root k n)) {..<k}
unity_root_sum ?k ?n = (\<Sum>m<?k. unity_root ?k (?n * int m))
unity_root ?k ?n ^ ?m = unity_root ?k (?n * int ?m)

goal (1 subgoal):
 1. unity_root_sum k n = (unity_root k n ^ k - 1) / (unity_root k n - 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
unity_root_sum k n = (unity_root k n ^ k - 1) / (unity_root k n - 1)

goal (1 subgoal):
 1. \<not> int k dvd n \<Longrightarrow> unity_root_sum k n = 0
[PROOF STEP]
have "?x^k = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unity_root k n ^ k = 1
[PROOF STEP]
using gr unity_root_eq_1_iff_int unity_root_pow
[PROOF STATE]
proof (prove)
using this:
1 \<le> k
0 < ?k \<Longrightarrow> (unity_root ?k ?n = 1) = (int ?k dvd ?n)
unity_root ?k ?n ^ ?m = unity_root ?k (?n * int ?m)

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

goal (1 subgoal):
 1. \<not> int k dvd n \<Longrightarrow> unity_root_sum k n = 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
unity_root k n ^ k = 1
[PROOF STEP]
show "unity_root_sum k n = 0"
[PROOF STATE]
proof (prove)
using this:
unity_root k n ^ k = 1

goal (1 subgoal):
 1. unity_root_sum k n = 0
[PROOF STEP]
using sum
[PROOF STATE]
proof (prove)
using this:
unity_root k n ^ k = 1
unity_root_sum k n = (unity_root k n ^ k - 1) / (unity_root k n - 1)

goal (1 subgoal):
 1. unity_root_sum k n = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
unity_root_sum k n = 0

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma measure_uniform_measure[simp]:
  assumes A: "emeasure M A \<noteq> 0" "emeasure M A \<noteq> \<infinity>" and B: "B \<in> sets M"
  shows "measure (uniform_measure M A) B = measure M (A \<inter> B) / measure M A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Sigma_Algebra.measure (uniform_measure M A) B = Sigma_Algebra.measure M (A \<inter> B) / Sigma_Algebra.measure M A
[PROOF STEP]
using emeasure_uniform_measure[OF emeasure_neq_0_sets[OF A(1)] B] A
[PROOF STATE]
proof (prove)
using this:
emeasure (uniform_measure M A) B = emeasure M (A \<inter> B) / emeasure M A
emeasure M A \<noteq> 0
emeasure M A \<noteq> \<infinity>

goal (1 subgoal):
 1. Sigma_Algebra.measure (uniform_measure M A) B = Sigma_Algebra.measure M (A \<inter> B) / Sigma_Algebra.measure M A
[PROOF STEP]
by (cases "emeasure M A" "emeasure M (A \<inter> B)" rule: ennreal2_cases)
     (simp_all add: measure_def divide_ennreal top_ennreal.rep_eq top_ereal_def ennreal_top_divide)


[STATEMENT]
lemma resultant_le_prod_sq_norm:
  fixes f g::"int poly"
  defines "n \<equiv> degree f" and "k \<equiv> degree g"
  shows "\<bar>resultant f g\<bar> \<le> sqrt (of_int (\<parallel>f\<parallel>\<^sup>2^k * \<parallel>g\<parallel>\<^sup>2^n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_of_int \<bar>resultant f g\<bar> \<le> sqrt (real_of_int (\<parallel>f\<parallel>\<^sup>2 ^ k * \<parallel>g\<parallel>\<^sup>2 ^ n))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. real_of_int \<bar>resultant f g\<bar> \<le> sqrt (real_of_int (\<parallel>f\<parallel>\<^sup>2 ^ k * \<parallel>g\<parallel>\<^sup>2 ^ n))
[PROOF STEP]
let ?S = "sylvester_mat f g"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. real_of_int \<bar>resultant f g\<bar> \<le> sqrt (real_of_int (\<parallel>f\<parallel>\<^sup>2 ^ k * \<parallel>g\<parallel>\<^sup>2 ^ n))
[PROOF STEP]
let ?f = "sq_norm \<circ> row ?S"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. real_of_int \<bar>resultant f g\<bar> \<le> sqrt (real_of_int (\<parallel>f\<parallel>\<^sup>2 ^ k * \<parallel>g\<parallel>\<^sup>2 ^ n))
[PROOF STEP]
have map_rw1: "map ?f [0..<degree g] = replicate k \<parallel>f\<parallel>\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g] = replicate k \<parallel>f\<parallel>\<^sup>2
[PROOF STEP]
proof (rule nth_equalityI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. length (map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g]) = length (replicate k \<parallel>f\<parallel>\<^sup>2)
 2. \<And>i. i < length (map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g]) \<Longrightarrow> map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g] ! i = replicate k \<parallel>f\<parallel>\<^sup>2 ! i
[PROOF STEP]
let ?M = "map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g]"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. length (map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g]) = length (replicate k \<parallel>f\<parallel>\<^sup>2)
 2. \<And>i. i < length (map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g]) \<Longrightarrow> map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g] ! i = replicate k \<parallel>f\<parallel>\<^sup>2 ! i
[PROOF STEP]
show "length ?M = length (replicate k \<parallel>f\<parallel>\<^sup>2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g]) = length (replicate k \<parallel>f\<parallel>\<^sup>2)
[PROOF STEP]
using k_def
[PROOF STATE]
proof (prove)
using this:
k \<equiv> degree g

goal (1 subgoal):
 1. length (map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g]) = length (replicate k \<parallel>f\<parallel>\<^sup>2)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g]) = length (replicate k \<parallel>f\<parallel>\<^sup>2)

goal (1 subgoal):
 1. \<And>i. i < length (map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g]) \<Longrightarrow> map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g] ! i = replicate k \<parallel>f\<parallel>\<^sup>2 ! i
[PROOF STEP]
show "?M ! i = replicate k \<parallel>f\<parallel>\<^sup>2 ! i" if i: "i < length ?M" for i
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g] ! i = replicate k \<parallel>f\<parallel>\<^sup>2 ! i
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g] ! i = replicate k \<parallel>f\<parallel>\<^sup>2 ! i
[PROOF STEP]
have ik: "i<k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i < k
[PROOF STEP]
using i k_def
[PROOF STATE]
proof (prove)
using this:
i < length (map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g])
k \<equiv> degree g

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

goal (1 subgoal):
 1. map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g] ! i = replicate k \<parallel>f\<parallel>\<^sup>2 ! i
[PROOF STEP]
hence i_deg_g: "i < degree g"
[PROOF STATE]
proof (prove)
using this:
i < k

goal (1 subgoal):
 1. i < degree g
[PROOF STEP]
using k_def
[PROOF STATE]
proof (prove)
using this:
i < k
k \<equiv> degree g

goal (1 subgoal):
 1. i < degree g
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i < degree g

goal (1 subgoal):
 1. map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g] ! i = replicate k \<parallel>f\<parallel>\<^sup>2 ! i
[PROOF STEP]
have "replicate k \<parallel>f\<parallel>\<^sup>2 ! i = \<parallel>f\<parallel>\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. replicate k \<parallel>f\<parallel>\<^sup>2 ! i = \<parallel>f\<parallel>\<^sup>2
[PROOF STEP]
by (rule nth_replicate[OF ik])
[PROOF STATE]
proof (state)
this:
replicate k \<parallel>f\<parallel>\<^sup>2 ! i = \<parallel>f\<parallel>\<^sup>2

goal (1 subgoal):
 1. map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g] ! i = replicate k \<parallel>f\<parallel>\<^sup>2 ! i
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
replicate k \<parallel>f\<parallel>\<^sup>2 ! i = \<parallel>f\<parallel>\<^sup>2

goal (1 subgoal):
 1. map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g] ! i = replicate k \<parallel>f\<parallel>\<^sup>2 ! i
[PROOF STEP]
have "... = (sq_norm \<circ> row (sylvester_mat f g)) (0 + i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>f\<parallel>\<^sup>2 = (sq_norm \<circ> row (sylvester_mat f g)) (0 + i)
[PROOF STEP]
using sq_norm_row_sylvester_mat1 ik k_def
[PROOF STATE]
proof (prove)
using this:
?i < degree ?g \<Longrightarrow> \<parallel>row (sylvester_mat ?f ?g) ?i\<parallel>\<^sup>2 = \<parallel>?f\<parallel>\<^sup>2
i < k
k \<equiv> degree g

goal (1 subgoal):
 1. \<parallel>f\<parallel>\<^sup>2 = (sq_norm \<circ> row (sylvester_mat f g)) (0 + i)
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
\<parallel>f\<parallel>\<^sup>2 = (sq_norm \<circ> row (sylvester_mat f g)) (0 + i)

goal (1 subgoal):
 1. map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g] ! i = replicate k \<parallel>f\<parallel>\<^sup>2 ! i
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<parallel>f\<parallel>\<^sup>2 = (sq_norm \<circ> row (sylvester_mat f g)) (0 + i)

goal (1 subgoal):
 1. map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g] ! i = replicate k \<parallel>f\<parallel>\<^sup>2 ! i
[PROOF STEP]
have "... = ?M ! i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (sq_norm \<circ> row (sylvester_mat f g)) (0 + i) = map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g] ! i
[PROOF STEP]
by (rule nth_map_upt[symmetric], simp add: i_deg_g)
[PROOF STATE]
proof (state)
this:
(sq_norm \<circ> row (sylvester_mat f g)) (0 + i) = map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g] ! i

goal (1 subgoal):
 1. map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g] ! i = replicate k \<parallel>f\<parallel>\<^sup>2 ! i
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
replicate k \<parallel>f\<parallel>\<^sup>2 ! i = map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g] ! i
[PROOF STEP]
show "?M ! i = replicate k \<parallel>f\<parallel>\<^sup>2 ! i"
[PROOF STATE]
proof (prove)
using this:
replicate k \<parallel>f\<parallel>\<^sup>2 ! i = map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g] ! i

goal (1 subgoal):
 1. map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g] ! i = replicate k \<parallel>f\<parallel>\<^sup>2 ! i
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g] ! i = replicate k \<parallel>f\<parallel>\<^sup>2 ! i

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?i < length (map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g]) \<Longrightarrow> map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g] ! ?i = replicate k \<parallel>f\<parallel>\<^sup>2 ! ?i

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g] = replicate k \<parallel>f\<parallel>\<^sup>2

goal (1 subgoal):
 1. real_of_int \<bar>resultant f g\<bar> \<le> sqrt (real_of_int (\<parallel>f\<parallel>\<^sup>2 ^ k * \<parallel>g\<parallel>\<^sup>2 ^ n))
[PROOF STEP]
have map_rw2: "map ?f [degree g..<degree f + degree g] = replicate n \<parallel>g\<parallel>\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g] = replicate n \<parallel>g\<parallel>\<^sup>2
[PROOF STEP]
proof (rule nth_equalityI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. length (map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g]) = length (replicate n \<parallel>g\<parallel>\<^sup>2)
 2. \<And>i. i < length (map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g]) \<Longrightarrow> map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g] ! i = replicate n \<parallel>g\<parallel>\<^sup>2 ! i
[PROOF STEP]
let ?M = "map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g]"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. length (map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g]) = length (replicate n \<parallel>g\<parallel>\<^sup>2)
 2. \<And>i. i < length (map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g]) \<Longrightarrow> map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g] ! i = replicate n \<parallel>g\<parallel>\<^sup>2 ! i
[PROOF STEP]
show "length ?M = length (replicate n \<parallel>g\<parallel>\<^sup>2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g]) = length (replicate n \<parallel>g\<parallel>\<^sup>2)
[PROOF STEP]
by (simp add: n_def)
[PROOF STATE]
proof (state)
this:
length (map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g]) = length (replicate n \<parallel>g\<parallel>\<^sup>2)

goal (1 subgoal):
 1. \<And>i. i < length (map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g]) \<Longrightarrow> map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g] ! i = replicate n \<parallel>g\<parallel>\<^sup>2 ! i
[PROOF STEP]
show "?M ! i = replicate n \<parallel>g\<parallel>\<^sup>2 ! i" if "i<length ?M" for i
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g] ! i = replicate n \<parallel>g\<parallel>\<^sup>2 ! i
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g] ! i = replicate n \<parallel>g\<parallel>\<^sup>2 ! i
[PROOF STEP]
have i_n: "i<n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i < n
[PROOF STEP]
using n_def that
[PROOF STATE]
proof (prove)
using this:
n \<equiv> degree f
i < length (map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g])

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

goal (1 subgoal):
 1. map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g] ! i = replicate n \<parallel>g\<parallel>\<^sup>2 ! i
[PROOF STEP]
hence i_deg_f: "i < degree f"
[PROOF STATE]
proof (prove)
using this:
i < n

goal (1 subgoal):
 1. i < degree f
[PROOF STEP]
using n_def
[PROOF STATE]
proof (prove)
using this:
i < n
n \<equiv> degree f

goal (1 subgoal):
 1. i < degree f
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i < degree f

goal (1 subgoal):
 1. map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g] ! i = replicate n \<parallel>g\<parallel>\<^sup>2 ! i
[PROOF STEP]
have "replicate n \<parallel>g\<parallel>\<^sup>2 ! i = \<parallel>g\<parallel>\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. replicate n \<parallel>g\<parallel>\<^sup>2 ! i = \<parallel>g\<parallel>\<^sup>2
[PROOF STEP]
by (rule nth_replicate[OF i_n])
[PROOF STATE]
proof (state)
this:
replicate n \<parallel>g\<parallel>\<^sup>2 ! i = \<parallel>g\<parallel>\<^sup>2

goal (1 subgoal):
 1. map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g] ! i = replicate n \<parallel>g\<parallel>\<^sup>2 ! i
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
replicate n \<parallel>g\<parallel>\<^sup>2 ! i = \<parallel>g\<parallel>\<^sup>2

goal (1 subgoal):
 1. map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g] ! i = replicate n \<parallel>g\<parallel>\<^sup>2 ! i
[PROOF STEP]
have "... = (sq_norm \<circ> row (sylvester_mat f g)) (degree g + i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>g\<parallel>\<^sup>2 = (sq_norm \<circ> row (sylvester_mat f g)) (degree g + i)
[PROOF STEP]
using i_n n_def
[PROOF STATE]
proof (prove)
using this:
i < n
n \<equiv> degree f

goal (1 subgoal):
 1. \<parallel>g\<parallel>\<^sup>2 = (sq_norm \<circ> row (sylvester_mat f g)) (degree g + i)
[PROOF STEP]
by (simp add: sq_norm_row_sylvester_mat2)
[PROOF STATE]
proof (state)
this:
\<parallel>g\<parallel>\<^sup>2 = (sq_norm \<circ> row (sylvester_mat f g)) (degree g + i)

goal (1 subgoal):
 1. map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g] ! i = replicate n \<parallel>g\<parallel>\<^sup>2 ! i
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<parallel>g\<parallel>\<^sup>2 = (sq_norm \<circ> row (sylvester_mat f g)) (degree g + i)

goal (1 subgoal):
 1. map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g] ! i = replicate n \<parallel>g\<parallel>\<^sup>2 ! i
[PROOF STEP]
have "... = ?M ! i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (sq_norm \<circ> row (sylvester_mat f g)) (degree g + i) = map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g] ! i
[PROOF STEP]
by (simp add: i_deg_f)
[PROOF STATE]
proof (state)
this:
(sq_norm \<circ> row (sylvester_mat f g)) (degree g + i) = map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g] ! i

goal (1 subgoal):
 1. map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g] ! i = replicate n \<parallel>g\<parallel>\<^sup>2 ! i
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
replicate n \<parallel>g\<parallel>\<^sup>2 ! i = map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g] ! i
[PROOF STEP]
show "?M ! i = replicate n \<parallel>g\<parallel>\<^sup>2 ! i"
[PROOF STATE]
proof (prove)
using this:
replicate n \<parallel>g\<parallel>\<^sup>2 ! i = map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g] ! i

goal (1 subgoal):
 1. map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g] ! i = replicate n \<parallel>g\<parallel>\<^sup>2 ! i
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g] ! i = replicate n \<parallel>g\<parallel>\<^sup>2 ! i

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?i < length (map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g]) \<Longrightarrow> map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g] ! ?i = replicate n \<parallel>g\<parallel>\<^sup>2 ! ?i

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g] = replicate n \<parallel>g\<parallel>\<^sup>2

goal (1 subgoal):
 1. real_of_int \<bar>resultant f g\<bar> \<le> sqrt (real_of_int (\<parallel>f\<parallel>\<^sup>2 ^ k * \<parallel>g\<parallel>\<^sup>2 ^ n))
[PROOF STEP]
have p1: "prod_list (map ?f [0..<degree g]) = \<parallel>f\<parallel>\<^sup>2^k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prod_list (map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g]) = \<parallel>f\<parallel>\<^sup>2 ^ k
[PROOF STEP]
unfolding map_rw1
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prod_list (replicate k \<parallel>f\<parallel>\<^sup>2) = \<parallel>f\<parallel>\<^sup>2 ^ k
[PROOF STEP]
by (rule prod_list_replicate)
[PROOF STATE]
proof (state)
this:
prod_list (map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g]) = \<parallel>f\<parallel>\<^sup>2 ^ k

goal (1 subgoal):
 1. real_of_int \<bar>resultant f g\<bar> \<le> sqrt (real_of_int (\<parallel>f\<parallel>\<^sup>2 ^ k * \<parallel>g\<parallel>\<^sup>2 ^ n))
[PROOF STEP]
have p2: "prod_list (map ?f [degree g..<degree f + degree g]) = \<parallel>g\<parallel>\<^sup>2^n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prod_list (map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g]) = \<parallel>g\<parallel>\<^sup>2 ^ n
[PROOF STEP]
unfolding map_rw2
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prod_list (replicate n \<parallel>g\<parallel>\<^sup>2) = \<parallel>g\<parallel>\<^sup>2 ^ n
[PROOF STEP]
by (rule prod_list_replicate)
[PROOF STATE]
proof (state)
this:
prod_list (map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g]) = \<parallel>g\<parallel>\<^sup>2 ^ n

goal (1 subgoal):
 1. real_of_int \<bar>resultant f g\<bar> \<le> sqrt (real_of_int (\<parallel>f\<parallel>\<^sup>2 ^ k * \<parallel>g\<parallel>\<^sup>2 ^ n))
[PROOF STEP]
have list_rw: "[0..<degree f + degree g] = [0..<degree g] @ [degree g..<degree f + degree g]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [0..<degree f + degree g] = [0..<degree g] @ [degree g..<degree f + degree g]
[PROOF STEP]
by (metis add.commute upt_add_eq_append zero_le)
[PROOF STATE]
proof (state)
this:
[0..<degree f + degree g] = [0..<degree g] @ [degree g..<degree f + degree g]

goal (1 subgoal):
 1. real_of_int \<bar>resultant f g\<bar> \<le> sqrt (real_of_int (\<parallel>f\<parallel>\<^sup>2 ^ k * \<parallel>g\<parallel>\<^sup>2 ^ n))
[PROOF STEP]
have "\<bar>resultant f g\<bar> = \<bar>det ?S\<bar>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>resultant f g\<bar> = \<bar>det (sylvester_mat f g)\<bar>
[PROOF STEP]
unfolding resultant_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>det (sylvester_mat f g)\<bar> = \<bar>det (sylvester_mat f g)\<bar>
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
\<bar>resultant f g\<bar> = \<bar>det (sylvester_mat f g)\<bar>

goal (1 subgoal):
 1. real_of_int \<bar>resultant f g\<bar> \<le> sqrt (real_of_int (\<parallel>f\<parallel>\<^sup>2 ^ k * \<parallel>g\<parallel>\<^sup>2 ^ n))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<bar>resultant f g\<bar> = \<bar>det (sylvester_mat f g)\<bar>

goal (1 subgoal):
 1. real_of_int \<bar>resultant f g\<bar> \<le> sqrt (real_of_int (\<parallel>f\<parallel>\<^sup>2 ^ k * \<parallel>g\<parallel>\<^sup>2 ^ n))
[PROOF STEP]
have "... \<le> sqrt (of_int (prod_list (map sq_norm (rows ?S))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_of_int \<bar>det (sylvester_mat f g)\<bar> \<le> sqrt (real_of_int (prod_list (map sq_norm (rows (sylvester_mat f g)))))
[PROOF STEP]
by (rule Hadamard's_inequality_int, auto)
[PROOF STATE]
proof (state)
this:
real_of_int \<bar>det (sylvester_mat f g)\<bar> \<le> sqrt (real_of_int (prod_list (map sq_norm (rows (sylvester_mat f g)))))

goal (1 subgoal):
 1. real_of_int \<bar>resultant f g\<bar> \<le> sqrt (real_of_int (\<parallel>f\<parallel>\<^sup>2 ^ k * \<parallel>g\<parallel>\<^sup>2 ^ n))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real_of_int \<bar>det (sylvester_mat f g)\<bar> \<le> sqrt (real_of_int (prod_list (map sq_norm (rows (sylvester_mat f g)))))

goal (1 subgoal):
 1. real_of_int \<bar>resultant f g\<bar> \<le> sqrt (real_of_int (\<parallel>f\<parallel>\<^sup>2 ^ k * \<parallel>g\<parallel>\<^sup>2 ^ n))
[PROOF STEP]
have "map sq_norm (rows ?S) = map ?f [0..<degree f + degree g]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map sq_norm (rows (sylvester_mat f g)) = map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree f + degree g]
[PROOF STEP]
unfolding Matrix.rows_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map sq_norm (map (row (sylvester_mat f g)) [0..<dim_row (sylvester_mat f g)]) = map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree f + degree g]
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
map sq_norm (rows (sylvester_mat f g)) = map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree f + degree g]

goal (1 subgoal):
 1. real_of_int \<bar>resultant f g\<bar> \<le> sqrt (real_of_int (\<parallel>f\<parallel>\<^sup>2 ^ k * \<parallel>g\<parallel>\<^sup>2 ^ n))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map sq_norm (rows (sylvester_mat f g)) = map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree f + degree g]

goal (1 subgoal):
 1. real_of_int \<bar>resultant f g\<bar> \<le> sqrt (real_of_int (\<parallel>f\<parallel>\<^sup>2 ^ k * \<parallel>g\<parallel>\<^sup>2 ^ n))
[PROOF STEP]
have "... =  map ?f ([0..<degree g] @ [degree g..<degree f + degree g])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree f + degree g] = map (sq_norm \<circ> row (sylvester_mat f g)) ([0..<degree g] @ [degree g..<degree f + degree g])
[PROOF STEP]
by (simp add: list_rw)
[PROOF STATE]
proof (state)
this:
map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree f + degree g] = map (sq_norm \<circ> row (sylvester_mat f g)) ([0..<degree g] @ [degree g..<degree f + degree g])

goal (1 subgoal):
 1. real_of_int \<bar>resultant f g\<bar> \<le> sqrt (real_of_int (\<parallel>f\<parallel>\<^sup>2 ^ k * \<parallel>g\<parallel>\<^sup>2 ^ n))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree f + degree g] = map (sq_norm \<circ> row (sylvester_mat f g)) ([0..<degree g] @ [degree g..<degree f + degree g])

goal (1 subgoal):
 1. real_of_int \<bar>resultant f g\<bar> \<le> sqrt (real_of_int (\<parallel>f\<parallel>\<^sup>2 ^ k * \<parallel>g\<parallel>\<^sup>2 ^ n))
[PROOF STEP]
have "prod_list ... = prod_list (map ?f [0..<degree g])
    * prod_list (map ?f [degree g..<degree f + degree g])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prod_list (map (sq_norm \<circ> row (sylvester_mat f g)) ([0..<degree g] @ [degree g..<degree f + degree g])) = prod_list (map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g]) * prod_list (map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g])
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
prod_list (map (sq_norm \<circ> row (sylvester_mat f g)) ([0..<degree g] @ [degree g..<degree f + degree g])) = prod_list (map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g]) * prod_list (map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g])

goal (1 subgoal):
 1. real_of_int \<bar>resultant f g\<bar> \<le> sqrt (real_of_int (\<parallel>f\<parallel>\<^sup>2 ^ k * \<parallel>g\<parallel>\<^sup>2 ^ n))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
real_of_int \<bar>resultant f g\<bar> \<le> sqrt (real_of_int (prod_list (map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g]) * prod_list (map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g])))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
real_of_int \<bar>resultant f g\<bar> \<le> sqrt (real_of_int (prod_list (map (sq_norm \<circ> row (sylvester_mat f g)) [0..<degree g]) * prod_list (map (sq_norm \<circ> row (sylvester_mat f g)) [degree g..<degree f + degree g])))

goal (1 subgoal):
 1. real_of_int \<bar>resultant f g\<bar> \<le> sqrt (real_of_int (\<parallel>f\<parallel>\<^sup>2 ^ k * \<parallel>g\<parallel>\<^sup>2 ^ n))
[PROOF STEP]
unfolding p1 p2
[PROOF STATE]
proof (prove)
using this:
real_of_int \<bar>resultant f g\<bar> \<le> sqrt (real_of_int (\<parallel>f\<parallel>\<^sup>2 ^ k * \<parallel>g\<parallel>\<^sup>2 ^ n))

goal (1 subgoal):
 1. real_of_int \<bar>resultant f g\<bar> \<le> sqrt (real_of_int (\<parallel>f\<parallel>\<^sup>2 ^ k * \<parallel>g\<parallel>\<^sup>2 ^ n))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
real_of_int \<bar>resultant f g\<bar> \<le> sqrt (real_of_int (\<parallel>f\<parallel>\<^sup>2 ^ k * \<parallel>g\<parallel>\<^sup>2 ^ n))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma prod_rel_range[relator_props]: "\<lbrakk>Range Ra=UNIV; Range Rb=UNIV\<rbrakk>
  \<Longrightarrow> Range (\<langle>Ra,Rb\<rangle>prod_rel) = UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Range Ra = UNIV; Range Rb = UNIV\<rbrakk> \<Longrightarrow> Range (Ra \<times>\<^sub>r Rb) = UNIV
[PROOF STEP]
apply (auto simp: prod_rel_def)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>a. \<lbrakk>Range Ra = UNIV; Range Rb = UNIV\<rbrakk> \<Longrightarrow> \<exists>aa. (aa, a) \<in> Ra
 2. \<And>b. \<lbrakk>Range Ra = UNIV; Range Rb = UNIV\<rbrakk> \<Longrightarrow> \<exists>ba. (ba, b) \<in> Rb
[PROOF STEP]
by (metis Range_iff UNIV_I)+


[STATEMENT]
lemma lang_flatten_INTERSECT_finite[simp]:
  "finite X \<Longrightarrow> w \<in> lang n (flatten INTERSECT X) =
    (if X = {} then w \<in> lists (\<Sigma> n) else (\<forall>r \<in> X. w \<in> lang n r))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite X \<Longrightarrow> (w \<in> lang n (INTERSECT (sorted_list_of_set X))) = (if X = {} then w \<in> lists (\<Sigma> n) else \<forall>r\<in>X. w \<in> lang n r)
[PROOF STEP]
unfolding lang_INTERSECT
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite X \<Longrightarrow> (w \<in> (if sorted_list_of_set X = [] then lists (\<Sigma> n) else \<Inter> (lang n ` set (sorted_list_of_set X)))) = (if X = {} then w \<in> lists (\<Sigma> n) else \<forall>r\<in>X. w \<in> lang n r)
[PROOF STEP]
by auto


[STATEMENT]
lemma ratio_of_consecutive_primes:
  "(\<lambda>n. nth_prime (n+1)/nth_prime n) \<longlonglongrightarrow>1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. real (nth_prime (n + 1)) / real (nth_prime n)) \<longlonglongrightarrow> 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>n. real (nth_prime (n + 1)) / real (nth_prime n)) \<longlonglongrightarrow> 1
[PROOF STEP]
define f where "f=(\<lambda>x. real (nth_prime (Suc x)) /real (nth_prime x))"
[PROOF STATE]
proof (state)
this:
f = (\<lambda>x. real (nth_prime (Suc x)) / real (nth_prime x))

goal (1 subgoal):
 1. (\<lambda>n. real (nth_prime (n + 1)) / real (nth_prime n)) \<longlonglongrightarrow> 1
[PROOF STEP]
define g where "g=(\<lambda>x. (real x * ln (real x))
                              / (real (Suc x) * ln (real (Suc x))))"
[PROOF STATE]
proof (state)
this:
g = (\<lambda>x. real x * ln (real x) / (real (Suc x) * ln (real (Suc x))))

goal (1 subgoal):
 1. (\<lambda>n. real (nth_prime (n + 1)) / real (nth_prime n)) \<longlonglongrightarrow> 1
[PROOF STEP]
have p_n:"(\<lambda>x. real (nth_prime x) / (real x * ln (real x))) \<longlonglongrightarrow> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. real (nth_prime x) / (real x * ln (real x))) \<longlonglongrightarrow> 1
[PROOF STEP]
using nth_prime_asymptotics[unfolded asymp_equiv_def,simplified]
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. real (nth_prime x) / (real x * ln (real x))) \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. (\<lambda>x. real (nth_prime x) / (real x * ln (real x))) \<longlonglongrightarrow> 1
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<lambda>x. real (nth_prime x) / (real x * ln (real x))) \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. (\<lambda>n. real (nth_prime (n + 1)) / real (nth_prime n)) \<longlonglongrightarrow> 1
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<lambda>x. real (nth_prime x) / (real x * ln (real x))) \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. (\<lambda>n. real (nth_prime (n + 1)) / real (nth_prime n)) \<longlonglongrightarrow> 1
[PROOF STEP]
have p_sn:"(\<lambda>n. real (nth_prime (Suc n))
                        / (real (Suc n) * ln (real (Suc n)))) \<longlonglongrightarrow> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. real (nth_prime (Suc n)) / (real (Suc n) * ln (real (Suc n)))) \<longlonglongrightarrow> 1
[PROOF STEP]
using nth_prime_asymptotics[unfolded asymp_equiv_def,simplified
        ,THEN LIMSEQ_Suc]
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. real (nth_prime (Suc n)) / (real (Suc n) * ln (real (Suc n)))) \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. (\<lambda>n. real (nth_prime (Suc n)) / (real (Suc n) * ln (real (Suc n)))) \<longlonglongrightarrow> 1
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<lambda>n. real (nth_prime (Suc n)) / (real (Suc n) * ln (real (Suc n)))) \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. (\<lambda>n. real (nth_prime (n + 1)) / real (nth_prime n)) \<longlonglongrightarrow> 1
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>x. real (nth_prime x) / (real x * ln (real x))) \<longlonglongrightarrow> 1
(\<lambda>n. real (nth_prime (Suc n)) / (real (Suc n) * ln (real (Suc n)))) \<longlonglongrightarrow> 1
[PROOF STEP]
have "(\<lambda>x. f x * g x) \<longlonglongrightarrow> 1"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. real (nth_prime x) / (real x * ln (real x))) \<longlonglongrightarrow> 1
(\<lambda>n. real (nth_prime (Suc n)) / (real (Suc n) * ln (real (Suc n)))) \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. (\<lambda>x. f x * g x) \<longlonglongrightarrow> 1
[PROOF STEP]
using tendsto_divide[OF p_sn p_n]
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. real (nth_prime x) / (real x * ln (real x))) \<longlonglongrightarrow> 1
(\<lambda>n. real (nth_prime (Suc n)) / (real (Suc n) * ln (real (Suc n)))) \<longlonglongrightarrow> 1
1 \<noteq> 0 \<Longrightarrow> (\<lambda>x. real (nth_prime (Suc x)) / (real (Suc x) * ln (real (Suc x))) / (real (nth_prime x) / (real x * ln (real x)))) \<longlonglongrightarrow> 1 / 1

goal (1 subgoal):
 1. (\<lambda>x. f x * g x) \<longlonglongrightarrow> 1
[PROOF STEP]
unfolding f_def g_def
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. real (nth_prime x) / (real x * ln (real x))) \<longlonglongrightarrow> 1
(\<lambda>n. real (nth_prime (Suc n)) / (real (Suc n) * ln (real (Suc n)))) \<longlonglongrightarrow> 1
1 \<noteq> 0 \<Longrightarrow> (\<lambda>x. real (nth_prime (Suc x)) / (real (Suc x) * ln (real (Suc x))) / (real (nth_prime x) / (real x * ln (real x)))) \<longlonglongrightarrow> 1 / 1

goal (1 subgoal):
 1. (\<lambda>x. real (nth_prime (Suc x)) / real (nth_prime x) * (real x * ln (real x) / (real (Suc x) * ln (real (Suc x))))) \<longlonglongrightarrow> 1
[PROOF STEP]
by (auto simp:algebra_simps)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. f x * g x) \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. (\<lambda>n. real (nth_prime (n + 1)) / real (nth_prime n)) \<longlonglongrightarrow> 1
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<lambda>x. f x * g x) \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. (\<lambda>n. real (nth_prime (n + 1)) / real (nth_prime n)) \<longlonglongrightarrow> 1
[PROOF STEP]
have "g \<longlonglongrightarrow> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g \<longlonglongrightarrow> 1
[PROOF STEP]
unfolding g_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. real x * ln (real x) / (real (Suc x) * ln (real (Suc x)))) \<longlonglongrightarrow> 1
[PROOF STEP]
by real_asymp
[PROOF STATE]
proof (state)
this:
g \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. (\<lambda>n. real (nth_prime (n + 1)) / real (nth_prime n)) \<longlonglongrightarrow> 1
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>x. f x * g x) \<longlonglongrightarrow> 1
g \<longlonglongrightarrow> 1
[PROOF STEP]
have "(\<lambda>x. if g x = 0 then 0 else f x) \<longlonglongrightarrow> 1"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. f x * g x) \<longlonglongrightarrow> 1
g \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. (\<lambda>x. if g x = 0 then 0 else f x) \<longlonglongrightarrow> 1
[PROOF STEP]
apply (drule_tac tendsto_divide[OF _ \<open>g \<longlonglongrightarrow> 1\<close>])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. g \<longlonglongrightarrow> 1 \<Longrightarrow> 1 \<noteq> 0
 2. \<lbrakk>g \<longlonglongrightarrow> 1; (\<lambda>x. f x * g x / g x) \<longlonglongrightarrow> 1 / 1\<rbrakk> \<Longrightarrow> (\<lambda>x. if g x = 0 then 0 else f x) \<longlonglongrightarrow> 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>x. if g x = 0 then 0 else f x) \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. (\<lambda>n. real (nth_prime (n + 1)) / real (nth_prime n)) \<longlonglongrightarrow> 1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>x. if g x = 0 then 0 else f x) \<longlonglongrightarrow> 1
[PROOF STEP]
have "f \<longlonglongrightarrow> 1"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. if g x = 0 then 0 else f x) \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. f \<longlonglongrightarrow> 1
[PROOF STEP]
proof (elim filterlim_mono_eventually)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. nhds 1 \<le> nhds 1
 2. sequentially \<le> sequentially
 3. \<forall>\<^sub>F x in sequentially. (if g x = 0 then 0 else f x) = f x
[PROOF STEP]
have "\<forall>\<^sub>F x in sequentially. (if g (x+3) = 0 then 0
                else f (x+3)) = f (x+3)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in sequentially. (if g (x + 3) = 0 then 0 else f (x + 3)) = f (x + 3)
[PROOF STEP]
unfolding g_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in sequentially. (if real (x + 3) * ln (real (x + 3)) / (real (Suc (x + 3)) * ln (real (Suc (x + 3)))) = 0 then 0 else f (x + 3)) = f (x + 3)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in sequentially. (if g (x + 3) = 0 then 0 else f (x + 3)) = f (x + 3)

goal (3 subgoals):
 1. nhds 1 \<le> nhds 1
 2. sequentially \<le> sequentially
 3. \<forall>\<^sub>F x in sequentially. (if g x = 0 then 0 else f x) = f x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>\<^sub>F x in sequentially. (if g (x + 3) = 0 then 0 else f (x + 3)) = f (x + 3)
[PROOF STEP]
show "\<forall>\<^sub>F x in sequentially. (if g x = 0 then 0 else f x) = f x"
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in sequentially. (if g (x + 3) = 0 then 0 else f (x + 3)) = f (x + 3)

goal (1 subgoal):
 1. \<forall>\<^sub>F x in sequentially. (if g x = 0 then 0 else f x) = f x
[PROOF STEP]
apply (subst (asm) eventually_sequentially_seg)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F a in sequentially. (if g a = 0 then 0 else f a) = f a \<Longrightarrow> \<forall>\<^sub>F x in sequentially. (if g x = 0 then 0 else f x) = f x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in sequentially. (if g x = 0 then 0 else f x) = f x

goal (2 subgoals):
 1. nhds 1 \<le> nhds 1
 2. sequentially \<le> sequentially
[PROOF STEP]
qed auto
[PROOF STATE]
proof (state)
this:
f \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. (\<lambda>n. real (nth_prime (n + 1)) / real (nth_prime n)) \<longlonglongrightarrow> 1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f \<longlonglongrightarrow> 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
f \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. (\<lambda>n. real (nth_prime (n + 1)) / real (nth_prime n)) \<longlonglongrightarrow> 1
[PROOF STEP]
unfolding f_def
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. real (nth_prime (Suc x)) / real (nth_prime x)) \<longlonglongrightarrow> 1

goal (1 subgoal):
 1. (\<lambda>n. real (nth_prime (n + 1)) / real (nth_prime n)) \<longlonglongrightarrow> 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>n. real (nth_prime (n + 1)) / real (nth_prime n)) \<longlonglongrightarrow> 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem problem_plan_bound_S_bound_thesis:
  assumes "finite (PROB :: 'a problem)" "(sspace_DAG (prob_proj PROB vs) lss)"
  shows "(
    problem_plan_bound PROB
    \<le> Sup {S vs lss PROB s' | s'. s' \<in> valid_states (prob_proj PROB vs)}
  )"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. problem_plan_bound PROB \<le> Sup {S vs lss PROB s' |s'. s' \<in> valid_states (prob_proj PROB vs)}
[PROOF STEP]
using assms problem_plan_bound_S_bound sspace_DAG_def
[PROOF STATE]
proof (prove)
using this:
finite PROB
sspace_DAG (prob_proj PROB vs) lss
\<lbrakk>finite ?PROB; top_sorted_abs (\<lambda>x y. y \<in> state_successors (prob_proj ?PROB ?vs) x) ?lss; set ?lss = valid_states (prob_proj ?PROB ?vs)\<rbrakk> \<Longrightarrow> problem_plan_bound ?PROB \<le> Sup {S ?vs ?lss ?PROB s' |s'. s' \<in> valid_states (prob_proj ?PROB ?vs)}
sspace_DAG ?PROB ?lss \<equiv> set ?lss = valid_states ?PROB \<and> top_sorted_abs (\<lambda>x y. y \<in> state_successors ?PROB x) ?lss

goal (1 subgoal):
 1. problem_plan_bound PROB \<le> Sup {S vs lss PROB s' |s'. s' \<in> valid_states (prob_proj PROB vs)}
[PROOF STEP]
by fast


[STATEMENT]
lemma emeasure_exponential_Ioi:
  "0 < l \<Longrightarrow> 0 \<le> x \<Longrightarrow> emeasure (exponential l) {x <..} = exp (- x * l)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < l; 0 \<le> x\<rbrakk> \<Longrightarrow> emeasure (exponential l) {x<..} = ennreal (exp (- x * l))
[PROOF STEP]
using emeasure_exponential_Ioi_cutoff[of l x]
[PROOF STATE]
proof (prove)
using this:
0 < l \<Longrightarrow> emeasure (exponential l) {x<..} = ennreal (exp (- max 0 x * l))

goal (1 subgoal):
 1. \<lbrakk>0 < l; 0 \<le> x\<rbrakk> \<Longrightarrow> emeasure (exponential l) {x<..} = ennreal (exp (- x * l))
[PROOF STEP]
by simp


[STATEMENT]
lemma mult_mat_vec_nth: "(X *v x) $ i = scalar_product (row i X) x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (X *v x) $ i = scalar_product (row i X) x
[PROOF STEP]
by (simp add: matrix_vector_mult_def row_def scalar_product_def)


[STATEMENT]
lemma det_code_equation[code_unfold]:
fixes A::"'a::{field}^'n::{mod_type}^'n::{mod_type}"
shows "det A = (let A' = Gauss_Jordan_det_P A in prod (\<lambda>i. (snd (A'))$i$i) (UNIV::'n set)/(fst (A')))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det A = (let A' = Gauss_Jordan_det_P A in (\<Prod>i\<in>UNIV. snd A' $ i $ i) / fst A')
[PROOF STEP]
unfolding Let_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det A = (\<Prod>i\<in>UNIV. snd (Gauss_Jordan_det_P A) $ i $ i) / fst (Gauss_Jordan_det_P A)
[PROOF STEP]
using det_Gauss_Jordan_det_P[of A]
[PROOF STATE]
proof (prove)
using this:
fst (Gauss_Jordan_det_P A) * det A = det (snd (Gauss_Jordan_det_P A))

goal (1 subgoal):
 1. det A = (\<Prod>i\<in>UNIV. snd (Gauss_Jordan_det_P A) $ i $ i) / fst (Gauss_Jordan_det_P A)
[PROOF STEP]
unfolding det_snd_Gauss_Jordan_det_P
[PROOF STATE]
proof (prove)
using this:
fst (Gauss_Jordan_det_P A) * det A = (\<Prod>i\<in>UNIV. snd (Gauss_Jordan_det_P A) $ i $ i)

goal (1 subgoal):
 1. det A = (\<Prod>i\<in>UNIV. snd (Gauss_Jordan_det_P A) $ i $ i) / fst (Gauss_Jordan_det_P A)
[PROOF STEP]
by (simp add: fst_Gauss_Jordan_det_P_not_0 nonzero_eq_divide_eq ac_simps)


[STATEMENT]
lemma sorted_splay:
  "sorted1(inorder t) \<Longrightarrow> splay x t = Node l a r \<Longrightarrow>
  sorted(map fst (inorder l) @ x # map fst (inorder r))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>sorted1 (inorder t); Splay_Map.splay x t = \<langle>l, a, r\<rangle>\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (map fst (inorder l) @ x # map fst (inorder r))
[PROOF STEP]
unfolding inorder_splay[of x t, symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>sorted1 (inorder (Splay_Map.splay x t)); Splay_Map.splay x t = \<langle>l, a, r\<rangle>\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (map fst (inorder l) @ x # map fst (inorder r))
[PROOF STEP]
by(induction x t arbitrary: l a r rule: splay.induct)
  (auto simp: sorted_lems sorted_Cons_le sorted_snoc_le splay_Leaf_iff split: tree.splits)


[STATEMENT]
lemma of_nat_sum_of_fourth_powers:
  "30 * of_nat (\<Sum>i=0..<m. i * i * i * i) =
    of_nat m * (of_nat m - 1) * (of_nat (2 * m) - 1) *
    (of_nat (3 * m * m) - of_nat (3 * m) - (1::int))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 30 * int (\<Sum>i = 0..<m. i * i * i * i) = int m * (int m - 1) * (int (2 * m) - 1) * (int (3 * m * m) - int (3 * m) - 1)
[PROOF STEP]
by (induct m) simp_all


[STATEMENT]
lemma eventually_at_top_to_right:
  "eventually P at_top \<longleftrightarrow> eventually (\<lambda>x. P (inverse x)) (at_right (0::real))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eventually P at_top = (\<forall>\<^sub>F x in at_right 0. P (inverse x))
[PROOF STEP]
unfolding at_top_to_right eventually_filtermap
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>\<^sub>F x in at_right 0. P (inverse x)) = (\<forall>\<^sub>F x in at_right 0. P (inverse x))
[PROOF STEP]
..


[STATEMENT]
lemma sin_zero [simp]: "sin 0 = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin (0::'a) = (0::'a)
[PROOF STEP]
by (simp add: sin_def sin_coeff_def scaleR_conv_of_real)


[STATEMENT]
lemma hom_compose:
  "\<lbrakk> f \<in> hom G H; g \<in> hom H I \<rbrakk> \<Longrightarrow> g \<circ> f \<in> hom G I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f \<in> hom G H; g \<in> hom H I\<rbrakk> \<Longrightarrow> g \<circ> f \<in> hom G I
[PROOF STEP]
unfolding hom_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f \<in> {h \<in> carrier G \<rightarrow> carrier H. \<forall>x\<in>carrier G. \<forall>y\<in>carrier G. h (x \<otimes>\<^bsub>G\<^esub> y) = h x \<otimes>\<^bsub>H\<^esub> h y}; g \<in> {h \<in> carrier H \<rightarrow> carrier I. \<forall>x\<in>carrier H. \<forall>y\<in>carrier H. h (x \<otimes>\<^bsub>H\<^esub> y) = h x \<otimes>\<^bsub>I\<^esub> h y}\<rbrakk> \<Longrightarrow> g \<circ> f \<in> {h \<in> carrier G \<rightarrow> carrier I. \<forall>x\<in>carrier G. \<forall>y\<in>carrier G. h (x \<otimes>\<^bsub>G\<^esub> y) = h x \<otimes>\<^bsub>I\<^esub> h y}
[PROOF STEP]
by (auto simp add: Pi_iff)


[STATEMENT]
lemma drop_mess:
  "\<lbrakk>Suc (length xs\<^sub>0) \<le> length xs; drop (length xs - Suc (length xs\<^sub>0)) xs = x # xs\<^sub>0\<rbrakk>
  \<Longrightarrow> drop (length xs - length xs\<^sub>0) xs = xs\<^sub>0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Suc (length xs\<^sub>0) \<le> length xs; drop (length xs - Suc (length xs\<^sub>0)) xs = x # xs\<^sub>0\<rbrakk> \<Longrightarrow> drop (length xs - length xs\<^sub>0) xs = xs\<^sub>0
[PROOF STEP]
apply (cases xs)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>Suc (length xs\<^sub>0) \<le> length xs; drop (length xs - Suc (length xs\<^sub>0)) xs = x # xs\<^sub>0; xs = []\<rbrakk> \<Longrightarrow> drop (length xs - length xs\<^sub>0) xs = xs\<^sub>0
 2. \<And>a list. \<lbrakk>Suc (length xs\<^sub>0) \<le> length xs; drop (length xs - Suc (length xs\<^sub>0)) xs = x # xs\<^sub>0; xs = a # list\<rbrakk> \<Longrightarrow> drop (length xs - length xs\<^sub>0) xs = xs\<^sub>0
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a list. \<lbrakk>Suc (length xs\<^sub>0) \<le> length xs; drop (length xs - Suc (length xs\<^sub>0)) xs = x # xs\<^sub>0; xs = a # list\<rbrakk> \<Longrightarrow> drop (length xs - length xs\<^sub>0) xs = xs\<^sub>0
[PROOF STEP]
apply (simp add: Suc_diff_le)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a list. \<lbrakk>length xs\<^sub>0 \<le> length list; drop (length list - length xs\<^sub>0) (a # list) = x # xs\<^sub>0; xs = a # list\<rbrakk> \<Longrightarrow> drop (length list - length xs\<^sub>0) list = xs\<^sub>0
[PROOF STEP]
apply (case_tac "length list - length xs\<^sub>0")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>a list. \<lbrakk>length xs\<^sub>0 \<le> length list; drop (length list - length xs\<^sub>0) (a # list) = x # xs\<^sub>0; xs = a # list; length list - length xs\<^sub>0 = 0\<rbrakk> \<Longrightarrow> drop (length list - length xs\<^sub>0) list = xs\<^sub>0
 2. \<And>a list nat. \<lbrakk>length xs\<^sub>0 \<le> length list; drop (length list - length xs\<^sub>0) (a # list) = x # xs\<^sub>0; xs = a # list; length list - length xs\<^sub>0 = Suc nat\<rbrakk> \<Longrightarrow> drop (length list - length xs\<^sub>0) list = xs\<^sub>0
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a list nat. \<lbrakk>length xs\<^sub>0 \<le> length list; drop (length list - length xs\<^sub>0) (a # list) = x # xs\<^sub>0; xs = a # list; length list - length xs\<^sub>0 = Suc nat\<rbrakk> \<Longrightarrow> drop (length list - length xs\<^sub>0) list = xs\<^sub>0
[PROOF STEP]
apply (simp add: drop_Cons_Suc)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
theorem Digamma_LIMSEQ:
  fixes z :: "'a :: {banach,real_normed_field}"
  assumes z: "z \<noteq> 0"
  shows   "(\<lambda>m. of_real (ln (real m)) - (\<Sum>n<m. inverse (z + of_nat n))) \<longlonglongrightarrow> Digamma z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>m. of_real (ln (real m)) - (\<Sum>n<m. inverse (z + of_nat n))) \<longlonglongrightarrow> Digamma z
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>m. of_real (ln (real m)) - (\<Sum>n<m. inverse (z + of_nat n))) \<longlonglongrightarrow> Digamma z
[PROOF STEP]
have "(\<lambda>n. of_real (ln (real n / (real (Suc n))))) \<longlonglongrightarrow> (of_real (ln 1) :: 'a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. of_real (ln (real n / real (Suc n)))) \<longlonglongrightarrow> of_real (ln 1)
[PROOF STEP]
by (intro tendsto_intros LIMSEQ_n_over_Suc_n) simp_all
[PROOF STATE]
proof (state)
this:
(\<lambda>n. of_real (ln (real n / real (Suc n)))) \<longlonglongrightarrow> of_real (ln 1)

goal (1 subgoal):
 1. (\<lambda>m. of_real (ln (real m)) - (\<Sum>n<m. inverse (z + of_nat n))) \<longlonglongrightarrow> Digamma z
[PROOF STEP]
hence "(\<lambda>n. of_real (ln (real n / (real n + 1)))) \<longlonglongrightarrow> (0 :: 'a)"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. of_real (ln (real n / real (Suc n)))) \<longlonglongrightarrow> of_real (ln 1)

goal (1 subgoal):
 1. (\<lambda>n. of_real (ln (real n / (real n + 1)))) \<longlonglongrightarrow> (0::'a)
[PROOF STEP]
by (simp add: add_ac)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. of_real (ln (real n / (real n + 1)))) \<longlonglongrightarrow> (0::'a)

goal (1 subgoal):
 1. (\<lambda>m. of_real (ln (real m)) - (\<Sum>n<m. inverse (z + of_nat n))) \<longlonglongrightarrow> Digamma z
[PROOF STEP]
hence lim: "(\<lambda>n. of_real (ln (real n)) - of_real (ln (real n + 1))) \<longlonglongrightarrow> (0::'a)"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. of_real (ln (real n / (real n + 1)))) \<longlonglongrightarrow> (0::'a)

goal (1 subgoal):
 1. (\<lambda>n. of_real (ln (real n)) - of_real (ln (real n + 1))) \<longlonglongrightarrow> (0::'a)
[PROOF STEP]
proof (rule Lim_transform_eventually)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in sequentially. of_real (ln (real x / (real x + 1))) = of_real (ln (real x)) - of_real (ln (real x + 1))
[PROOF STEP]
show "eventually (\<lambda>n. of_real (ln (real n / (real n + 1))) =
            of_real (ln (real n)) - (of_real (ln (real n + 1)) :: 'a)) at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. of_real (ln (real n / (real n + 1))) = of_real (ln (real n)) - of_real (ln (real n + 1))
[PROOF STEP]
using eventually_gt_at_top[of "0::nat"]
[PROOF STATE]
proof (prove)
using this:
eventually ((<) 0) sequentially

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. of_real (ln (real n / (real n + 1))) = of_real (ln (real n)) - of_real (ln (real n + 1))
[PROOF STEP]
by eventually_elim (simp add: ln_div)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F n in sequentially. of_real (ln (real n / (real n + 1))) = of_real (ln (real n)) - of_real (ln (real n + 1))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<lambda>n. of_real (ln (real n)) - of_real (ln (real n + 1))) \<longlonglongrightarrow> (0::'a)

goal (1 subgoal):
 1. (\<lambda>m. of_real (ln (real m)) - (\<Sum>n<m. inverse (z + of_nat n))) \<longlonglongrightarrow> Digamma z
[PROOF STEP]
from summable_Digamma[OF z]
[PROOF STATE]
proof (chain)
picking this:
summable (\<lambda>n. inverse (of_nat (Suc n)) - inverse (z + of_nat n))
[PROOF STEP]
have "(\<lambda>n. inverse (of_nat (n+1)) - inverse (z + of_nat n))
              sums (Digamma z + euler_mascheroni)"
[PROOF STATE]
proof (prove)
using this:
summable (\<lambda>n. inverse (of_nat (Suc n)) - inverse (z + of_nat n))

goal (1 subgoal):
 1. (\<lambda>n. inverse (of_nat (n + 1)) - inverse (z + of_nat n)) sums (Digamma z + euler_mascheroni)
[PROOF STEP]
by (simp add: Digamma_def summable_sums)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. inverse (of_nat (n + 1)) - inverse (z + of_nat n)) sums (Digamma z + euler_mascheroni)

goal (1 subgoal):
 1. (\<lambda>m. of_real (ln (real m)) - (\<Sum>n<m. inverse (z + of_nat n))) \<longlonglongrightarrow> Digamma z
[PROOF STEP]
from sums_diff[OF this euler_mascheroni_sum]
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>n. inverse (of_nat (n + 1)) - inverse (z + of_nat n) - (inverse (of_nat (n + 1)) + of_real (ln (real (n + 1))) - of_real (ln (real (n + 2))))) sums (Digamma z + euler_mascheroni - euler_mascheroni)
[PROOF STEP]
have "(\<lambda>n. of_real (ln (real (Suc n) + 1)) - of_real (ln (real n + 1)) - inverse (z + of_nat n))
            sums Digamma z"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. inverse (of_nat (n + 1)) - inverse (z + of_nat n) - (inverse (of_nat (n + 1)) + of_real (ln (real (n + 1))) - of_real (ln (real (n + 2))))) sums (Digamma z + euler_mascheroni - euler_mascheroni)

goal (1 subgoal):
 1. (\<lambda>n. of_real (ln (real (Suc n) + 1)) - of_real (ln (real n + 1)) - inverse (z + of_nat n)) sums Digamma z
[PROOF STEP]
by (simp add: add_ac)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. of_real (ln (real (Suc n) + 1)) - of_real (ln (real n + 1)) - inverse (z + of_nat n)) sums Digamma z

goal (1 subgoal):
 1. (\<lambda>m. of_real (ln (real m)) - (\<Sum>n<m. inverse (z + of_nat n))) \<longlonglongrightarrow> Digamma z
[PROOF STEP]
hence "(\<lambda>m. (\<Sum>n<m. of_real (ln (real (Suc n) + 1)) - of_real (ln (real n + 1))) -
              (\<Sum>n<m. inverse (z + of_nat n))) \<longlonglongrightarrow> Digamma z"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. of_real (ln (real (Suc n) + 1)) - of_real (ln (real n + 1)) - inverse (z + of_nat n)) sums Digamma z

goal (1 subgoal):
 1. (\<lambda>m. (\<Sum>n<m. of_real (ln (real (Suc n) + 1)) - of_real (ln (real n + 1))) - (\<Sum>n<m. inverse (z + of_nat n))) \<longlonglongrightarrow> Digamma z
[PROOF STEP]
by (simp add: sums_def sum_subtractf)
[PROOF STATE]
proof (state)
this:
(\<lambda>m. (\<Sum>n<m. of_real (ln (real (Suc n) + 1)) - of_real (ln (real n + 1))) - (\<Sum>n<m. inverse (z + of_nat n))) \<longlonglongrightarrow> Digamma z

goal (1 subgoal):
 1. (\<lambda>m. of_real (ln (real m)) - (\<Sum>n<m. inverse (z + of_nat n))) \<longlonglongrightarrow> Digamma z
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<lambda>m. (\<Sum>n<m. of_real (ln (real (Suc n) + 1)) - of_real (ln (real n + 1))) - (\<Sum>n<m. inverse (z + of_nat n))) \<longlonglongrightarrow> Digamma z

goal (1 subgoal):
 1. (\<lambda>m. of_real (ln (real m)) - (\<Sum>n<m. inverse (z + of_nat n))) \<longlonglongrightarrow> Digamma z
[PROOF STEP]
have "(\<lambda>m. (\<Sum>n<m. of_real (ln (real (Suc n) + 1)) - of_real (ln (real n + 1)))) =
                 (\<lambda>m. of_real (ln (m + 1)) :: 'a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>m. \<Sum>n<m. of_real (ln (real (Suc n) + 1)) - of_real (ln (real n + 1))) = (\<lambda>x. of_real (ln (real x + 1)))
[PROOF STEP]
by (subst sum_lessThan_telescope) simp_all
[PROOF STATE]
proof (state)
this:
(\<lambda>m. \<Sum>n<m. of_real (ln (real (Suc n) + 1)) - of_real (ln (real n + 1))) = (\<lambda>x. of_real (ln (real x + 1)))

goal (1 subgoal):
 1. (\<lambda>m. of_real (ln (real m)) - (\<Sum>n<m. inverse (z + of_nat n))) \<longlonglongrightarrow> Digamma z
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>m. of_real (ln (real m + 1)) - (\<Sum>n<m. inverse (z + of_nat n))) \<longlonglongrightarrow> Digamma z
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<lambda>m. of_real (ln (real m + 1)) - (\<Sum>n<m. inverse (z + of_nat n))) \<longlonglongrightarrow> Digamma z

goal (1 subgoal):
 1. (\<lambda>m. of_real (ln (real m)) - (\<Sum>n<m. inverse (z + of_nat n))) \<longlonglongrightarrow> Digamma z
[PROOF STEP]
by (rule Lim_transform) (insert lim, simp)
[PROOF STATE]
proof (state)
this:
(\<lambda>m. of_real (ln (real m)) - (\<Sum>n<m. inverse (z + of_nat n))) \<longlonglongrightarrow> Digamma z

goal:
No subgoals!
[PROOF STEP]
qed