[STATEMENT]
lemma connected_iff_eq_connected_component_set:
  "connected S \<longleftrightarrow> (\<forall>x \<in> S. connected_component_set S x = S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. connected S = (\<forall>x\<in>S. connected_component_set S x = S)
[PROOF STEP]
proof (cases "S = {}")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. S = {} \<Longrightarrow> connected S = (\<forall>x\<in>S. connected_component_set S x = S)
 2. S \<noteq> {} \<Longrightarrow> connected S = (\<forall>x\<in>S. connected_component_set S x = S)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
S = {}

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

goal (1 subgoal):
 1. connected S = (\<forall>x\<in>S. connected_component_set S x = S)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
connected S = (\<forall>x\<in>S. connected_component_set S x = S)

goal (1 subgoal):
 1. S \<noteq> {} \<Longrightarrow> connected S = (\<forall>x\<in>S. connected_component_set S x = S)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. S \<noteq> {} \<Longrightarrow> connected S = (\<forall>x\<in>S. connected_component_set S x = S)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
S \<noteq> {}

goal (1 subgoal):
 1. S \<noteq> {} \<Longrightarrow> connected S = (\<forall>x\<in>S. connected_component_set S x = S)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
S \<noteq> {}
[PROOF STEP]
obtain x where "x \<in> S"
[PROOF STATE]
proof (prove)
using this:
S \<noteq> {}

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

goal (1 subgoal):
 1. S \<noteq> {} \<Longrightarrow> connected S = (\<forall>x\<in>S. connected_component_set S x = S)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. connected S = (\<forall>x\<in>S. connected_component_set S x = S)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. connected S \<Longrightarrow> \<forall>x\<in>S. connected_component_set S x = S
 2. \<forall>x\<in>S. connected_component_set S x = S \<Longrightarrow> connected S
[PROOF STEP]
assume "connected S"
[PROOF STATE]
proof (state)
this:
connected S

goal (2 subgoals):
 1. connected S \<Longrightarrow> \<forall>x\<in>S. connected_component_set S x = S
 2. \<forall>x\<in>S. connected_component_set S x = S \<Longrightarrow> connected S
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
connected S
[PROOF STEP]
show "\<forall>x \<in> S. connected_component_set S x = S"
[PROOF STATE]
proof (prove)
using this:
connected S

goal (1 subgoal):
 1. \<forall>x\<in>S. connected_component_set S x = S
[PROOF STEP]
by (force simp: connected_component_def)
[PROOF STATE]
proof (state)
this:
\<forall>x\<in>S. connected_component_set S x = S

goal (1 subgoal):
 1. \<forall>x\<in>S. connected_component_set S x = S \<Longrightarrow> connected S
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<forall>x\<in>S. connected_component_set S x = S \<Longrightarrow> connected S
[PROOF STEP]
assume "\<forall>x \<in> S. connected_component_set S x = S"
[PROOF STATE]
proof (state)
this:
\<forall>x\<in>S. connected_component_set S x = S

goal (1 subgoal):
 1. \<forall>x\<in>S. connected_component_set S x = S \<Longrightarrow> connected S
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>x\<in>S. connected_component_set S x = S
[PROOF STEP]
show "connected S"
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>S. connected_component_set S x = S

goal (1 subgoal):
 1. connected S
[PROOF STEP]
by (metis \<open>x \<in> S\<close> connected_connected_component)
[PROOF STATE]
proof (state)
this:
connected S

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
connected S = (\<forall>x\<in>S. connected_component_set S x = S)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma set_filter_diff_card: "card ({a \<in> A . P a } - {x}) = card {a \<in> (A - {x}) . (P a )}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card ({a \<in> A. P a} - {x}) = card {a \<in> A - {x}. P a}
[PROOF STEP]
by (simp add: set_filter_diff)


[STATEMENT]
lemma tensor_unpack_fstsnd: \<open>fst (tensor_unpack B C (snd (tensor_unpack A (B * C) i)))
     = snd (tensor_unpack A B (fst (tensor_unpack (A * B) C i)))\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fst (tensor_unpack B C (snd (tensor_unpack A (B * C) i))) = snd (tensor_unpack A B (fst (tensor_unpack (A * B) C i)))
[PROOF STEP]
unfolding tensor_unpack_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fst (snd (i div (B * C), i mod (B * C)) div C, snd (i div (B * C), i mod (B * C)) mod C) = snd (fst (i div C, i mod C) div B, fst (i div C, i mod C) mod B)
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i mod (B * C) div C = i div C mod B
[PROOF STEP]
by (metis (no_types, lifting) Euclidean_Division.div_eq_0_iff add_0_iff bits_mod_div_trivial div_mult_self4 mod_mult2_eq mod_mult_self1_is_0 mult.commute)


[STATEMENT]
theorem coprime_probability_tendsto:
  "(\<lambda>N. card (A N) / card ({1..N} \<times> {1..N})) \<longlonglongrightarrow> 6 / pi\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>N. real (card (A N)) / real (card ({1..N} \<times> {1..N}))) \<longlonglongrightarrow> 6 / pi\<^sup>2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>N. real (card (A N)) / real (card ({1..N} \<times> {1..N}))) \<longlonglongrightarrow> 6 / pi\<^sup>2
[PROOF STEP]
have "(\<lambda>N. 6 / pi ^ 2) \<sim>[at_top] (\<lambda>N. 6 / pi ^ 2 * real N ^ 2 / real N ^ 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>N. 6 / pi\<^sup>2) \<sim>[sequentially] (\<lambda>N. 6 / pi\<^sup>2 * (real N)\<^sup>2 / (real N)\<^sup>2)
[PROOF STEP]
using eventually_gt_at_top[of "0::nat"]
[PROOF STATE]
proof (prove)
using this:
eventually ((<) 0) sequentially

goal (1 subgoal):
 1. (\<lambda>N. 6 / pi\<^sup>2) \<sim>[sequentially] (\<lambda>N. 6 / pi\<^sup>2 * (real N)\<^sup>2 / (real N)\<^sup>2)
[PROOF STEP]
by (intro asymp_equiv_refl_ev) (auto elim!: eventually_mono)
[PROOF STATE]
proof (state)
this:
(\<lambda>N. 6 / pi\<^sup>2) \<sim>[sequentially] (\<lambda>N. 6 / pi\<^sup>2 * (real N)\<^sup>2 / (real N)\<^sup>2)

goal (1 subgoal):
 1. (\<lambda>N. real (card (A N)) / real (card ({1..N} \<times> {1..N}))) \<longlonglongrightarrow> 6 / pi\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<lambda>N. 6 / pi\<^sup>2) \<sim>[sequentially] (\<lambda>N. 6 / pi\<^sup>2 * (real N)\<^sup>2 / (real N)\<^sup>2)

goal (1 subgoal):
 1. (\<lambda>N. real (card (A N)) / real (card ({1..N} \<times> {1..N}))) \<longlonglongrightarrow> 6 / pi\<^sup>2
[PROOF STEP]
have "\<dots> \<sim>[at_top] (\<lambda>N. real (card (A N)) / real N ^ 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>N. 6 / pi\<^sup>2 * (real N)\<^sup>2 / (real N)\<^sup>2) \<sim>[sequentially] (\<lambda>N. real (card (A N)) / (real N)\<^sup>2)
[PROOF STEP]
by (intro asymp_equiv_intros asymp_equiv_symI[OF coprime_pairs_asymptotics''])
[PROOF STATE]
proof (state)
this:
(\<lambda>N. 6 / pi\<^sup>2 * (real N)\<^sup>2 / (real N)\<^sup>2) \<sim>[sequentially] (\<lambda>N. real (card (A N)) / (real N)\<^sup>2)

goal (1 subgoal):
 1. (\<lambda>N. real (card (A N)) / real (card ({1..N} \<times> {1..N}))) \<longlonglongrightarrow> 6 / pi\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<lambda>N. 6 / pi\<^sup>2 * (real N)\<^sup>2 / (real N)\<^sup>2) \<sim>[sequentially] (\<lambda>N. real (card (A N)) / (real N)\<^sup>2)

goal (1 subgoal):
 1. (\<lambda>N. real (card (A N)) / real (card ({1..N} \<times> {1..N}))) \<longlonglongrightarrow> 6 / pi\<^sup>2
[PROOF STEP]
have "\<dots> \<sim>[at_top] (\<lambda>N. real (card (A N)) / real (card ({1..N} \<times> {1..N})))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>N. real (card (A N)) / (real N)\<^sup>2) \<sim>[sequentially] (\<lambda>N. real (card (A N)) / real (card ({1..N} \<times> {1..N})))
[PROOF STEP]
by (simp add: power2_eq_square)
[PROOF STATE]
proof (state)
this:
(\<lambda>N. real (card (A N)) / (real N)\<^sup>2) \<sim>[sequentially] (\<lambda>N. real (card (A N)) / real (card ({1..N} \<times> {1..N})))

goal (1 subgoal):
 1. (\<lambda>N. real (card (A N)) / real (card ({1..N} \<times> {1..N}))) \<longlonglongrightarrow> 6 / pi\<^sup>2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>\<And>c d. c \<sim>[sequentially] d \<Longrightarrow> c \<sim>[sequentially] d; \<And>c d. c \<sim>[sequentially] d \<Longrightarrow> c \<sim>[sequentially] d\<rbrakk> \<Longrightarrow> (\<lambda>N. 6 / pi\<^sup>2) \<sim>[sequentially] (\<lambda>a. real (card (A a)) / real (card ({1..a} \<times> {1..a})))
[PROOF STEP]
have "\<dots> \<sim>[at_top] (\<lambda>_. 6 / pi ^ 2)"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>c d. c \<sim>[sequentially] d \<Longrightarrow> c \<sim>[sequentially] d; \<And>c d. c \<sim>[sequentially] d \<Longrightarrow> c \<sim>[sequentially] d\<rbrakk> \<Longrightarrow> (\<lambda>N. 6 / pi\<^sup>2) \<sim>[sequentially] (\<lambda>a. real (card (A a)) / real (card ({1..a} \<times> {1..a})))

goal (1 subgoal):
 1. (\<lambda>N. real (card (A N)) / real (card ({1..N} \<times> {1..N}))) \<sim>[sequentially] (\<lambda>_. 6 / pi\<^sup>2)
[PROOF STEP]
by (simp add: asymp_equiv_sym)
[PROOF STATE]
proof (state)
this:
(\<lambda>N. real (card (A N)) / real (card ({1..N} \<times> {1..N}))) \<sim>[sequentially] (\<lambda>_. 6 / pi\<^sup>2)

goal (1 subgoal):
 1. (\<lambda>N. real (card (A N)) / real (card ({1..N} \<times> {1..N}))) \<longlonglongrightarrow> 6 / pi\<^sup>2
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<lambda>N. real (card (A N)) / real (card ({1..N} \<times> {1..N}))) \<sim>[sequentially] (\<lambda>_. 6 / pi\<^sup>2)

goal (1 subgoal):
 1. (\<lambda>N. real (card (A N)) / real (card ({1..N} \<times> {1..N}))) \<longlonglongrightarrow> 6 / pi\<^sup>2
[PROOF STEP]
by (rule asymp_equivD_const)
[PROOF STATE]
proof (state)
this:
(\<lambda>N. real (card (A N)) / real (card ({1..N} \<times> {1..N}))) \<longlonglongrightarrow> 6 / pi\<^sup>2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma continuous_map_preimage_topspace [intro]:
  assumes "continuous_map T1 T2 f"
  shows "f-`(topspace T2) \<inter> topspace T1 = topspace T1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f -` topspace T2 \<inter> topspace T1 = topspace T1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
continuous_map T1 T2 f

goal (1 subgoal):
 1. f -` topspace T2 \<inter> topspace T1 = topspace T1
[PROOF STEP]
unfolding continuous_map_def
[PROOF STATE]
proof (prove)
using this:
(\<forall>x\<in>topspace T1. f x \<in> topspace T2) \<and> (\<forall>U. openin T2 U \<longrightarrow> openin T1 {x \<in> topspace T1. f x \<in> U})

goal (1 subgoal):
 1. f -` topspace T2 \<inter> topspace T1 = topspace T1
[PROOF STEP]
by auto


[STATEMENT]
theorem char_std_normal_distribution:
  "char std_normal_distribution = (\<lambda>t. complex_of_real (exp (- (t^2) / 2)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. char std_normal_distribution = (\<lambda>t. complex_of_real (exp (- t\<^sup>2 / 2)))
[PROOF STEP]
proof (intro ext LIMSEQ_unique)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>t. ?X1 t \<longlonglongrightarrow> char std_normal_distribution t
 2. \<And>t. ?X1 t \<longlonglongrightarrow> complex_of_real (exp (- t\<^sup>2 / 2))
[PROOF STEP]
fix t :: real
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>t. ?X1 t \<longlonglongrightarrow> char std_normal_distribution t
 2. \<And>t. ?X1 t \<longlonglongrightarrow> complex_of_real (exp (- t\<^sup>2 / 2))
[PROOF STEP]
let ?f' = "\<lambda>k. (\<i> * t)^k / fact k * (LINT x | std_normal_distribution. x^k)"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>t. ?X1 t \<longlonglongrightarrow> char std_normal_distribution t
 2. \<And>t. ?X1 t \<longlonglongrightarrow> complex_of_real (exp (- t\<^sup>2 / 2))
[PROOF STEP]
let ?f = "\<lambda>n. (\<Sum>k \<le> n. ?f' k)"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>t. ?X1 t \<longlonglongrightarrow> char std_normal_distribution t
 2. \<And>t. ?X1 t \<longlonglongrightarrow> complex_of_real (exp (- t\<^sup>2 / 2))
[PROOF STEP]
show "?f \<longlonglongrightarrow> exp (-(t^2) / 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. \<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) \<longlonglongrightarrow> complex_of_real (exp (- t\<^sup>2 / 2))
[PROOF STEP]
proof (rule limseq_even_odd)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (\<lambda>n. \<Sum>k\<le>2 * n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) \<longlonglongrightarrow> complex_of_real (exp (- t\<^sup>2 / 2))
 2. (\<lambda>n. \<Sum>k\<le>2 * n + 1. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) \<longlonglongrightarrow> complex_of_real (exp (- t\<^sup>2 / 2))
[PROOF STEP]
have "(\<i> * complex_of_real t) ^ (2 * a) / (2 ^ a * fact a) = (- ((complex_of_real t)\<^sup>2 / 2)) ^ a / fact a" for a
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<i> * complex_of_real t) ^ (2 * a) / (2 ^ a * fact a) = (- ((complex_of_real t)\<^sup>2 / 2)) ^ a / fact a
[PROOF STEP]
by (subst power_mult) (simp add: field_simps uminus_power_if power_mult)
[PROOF STATE]
proof (state)
this:
(\<i> * complex_of_real t) ^ (2 * ?a) / (2 ^ ?a * fact ?a) = (- ((complex_of_real t)\<^sup>2 / 2)) ^ ?a / fact ?a

goal (2 subgoals):
 1. (\<lambda>n. \<Sum>k\<le>2 * n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) \<longlonglongrightarrow> complex_of_real (exp (- t\<^sup>2 / 2))
 2. (\<lambda>n. \<Sum>k\<le>2 * n + 1. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) \<longlonglongrightarrow> complex_of_real (exp (- t\<^sup>2 / 2))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<i> * complex_of_real t) ^ (2 * ?a) / (2 ^ ?a * fact ?a) = (- ((complex_of_real t)\<^sup>2 / 2)) ^ ?a / fact ?a
[PROOF STEP]
have *: "?f (2 * n) = complex_of_real (\<Sum>k < Suc n. (1 / fact k) * (- (t^2) / 2)^k)" for n :: nat
[PROOF STATE]
proof (prove)
using this:
(\<i> * complex_of_real t) ^ (2 * ?a) / (2 ^ ?a * fact ?a) = (- ((complex_of_real t)\<^sup>2 / 2)) ^ ?a / fact ?a

goal (1 subgoal):
 1. (\<Sum>k\<le>2 * n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) = complex_of_real (\<Sum>k<Suc n. 1 / fact k * (- t\<^sup>2 / 2) ^ k)
[PROOF STEP]
unfolding of_real_sum
[PROOF STATE]
proof (prove)
using this:
(\<i> * complex_of_real t) ^ (2 * ?a) / (2 ^ ?a * fact ?a) = (- ((complex_of_real t)\<^sup>2 / 2)) ^ ?a / fact ?a

goal (1 subgoal):
 1. (\<Sum>k\<le>2 * n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) = (\<Sum>x<Suc n. complex_of_real (1 / fact x * (- t\<^sup>2 / 2) ^ x))
[PROOF STEP]
by (intro sum.reindex_bij_witness_not_neutral[symmetric, where
           i="\<lambda>n. n div 2" and j="\<lambda>n. 2 * n" and T'="{i. i \<le> 2 * n \<and> odd i}" and S'="{}"])
         (auto simp: integral_std_normal_distribution_moment_odd std_normal_distribution_even_moments)
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<le>2 * ?n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) = complex_of_real (\<Sum>k<Suc ?n. 1 / fact k * (- t\<^sup>2 / 2) ^ k)

goal (2 subgoals):
 1. (\<lambda>n. \<Sum>k\<le>2 * n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) \<longlonglongrightarrow> complex_of_real (exp (- t\<^sup>2 / 2))
 2. (\<lambda>n. \<Sum>k\<le>2 * n + 1. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) \<longlonglongrightarrow> complex_of_real (exp (- t\<^sup>2 / 2))
[PROOF STEP]
show "(\<lambda>n. ?f (2 * n)) \<longlonglongrightarrow> exp (-(t^2) / 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. \<Sum>k\<le>2 * n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) \<longlonglongrightarrow> complex_of_real (exp (- t\<^sup>2 / 2))
[PROOF STEP]
unfolding *
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. complex_of_real (\<Sum>k<Suc n. 1 / fact k * (- t\<^sup>2 / 2) ^ k)) \<longlonglongrightarrow> complex_of_real (exp (- t\<^sup>2 / 2))
[PROOF STEP]
using exp_converges[where 'a=real]
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. ?x ^ n /\<^sub>R fact n) sums exp ?x

goal (1 subgoal):
 1. (\<lambda>n. complex_of_real (\<Sum>k<Suc n. 1 / fact k * (- t\<^sup>2 / 2) ^ k)) \<longlonglongrightarrow> complex_of_real (exp (- t\<^sup>2 / 2))
[PROOF STEP]
by (intro tendsto_of_real LIMSEQ_Suc) (auto simp: inverse_eq_divide sums_def [symmetric])
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<Sum>k\<le>2 * n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) \<longlonglongrightarrow> complex_of_real (exp (- t\<^sup>2 / 2))

goal (1 subgoal):
 1. (\<lambda>n. \<Sum>k\<le>2 * n + 1. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) \<longlonglongrightarrow> complex_of_real (exp (- t\<^sup>2 / 2))
[PROOF STEP]
have **: "?f (2 * n + 1) = ?f (2 * n)" for n
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k\<le>2 * n + 1. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) = (\<Sum>k\<le>2 * n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>k\<le>2 * n + 1. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) = (\<Sum>k\<le>2 * n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k))
[PROOF STEP]
have "?f (2 * n + 1) = ?f (2 * n) + ?f' (2 * n + 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k\<le>2 * n + 1. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) = (\<Sum>k\<le>2 * n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) + (\<i> * complex_of_real t) ^ (2 * n + 1) / fact (2 * n + 1) * complex_of_real (LINT x|std_normal_distribution. x ^ (2 * n + 1))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<le>2 * n + 1. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) = (\<Sum>k\<le>2 * n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) + (\<i> * complex_of_real t) ^ (2 * n + 1) / fact (2 * n + 1) * complex_of_real (LINT x|std_normal_distribution. x ^ (2 * n + 1))

goal (1 subgoal):
 1. (\<Sum>k\<le>2 * n + 1. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) = (\<Sum>k\<le>2 * n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<le>2 * n + 1. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) = (\<Sum>k\<le>2 * n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) + (\<i> * complex_of_real t) ^ (2 * n + 1) / fact (2 * n + 1) * complex_of_real (LINT x|std_normal_distribution. x ^ (2 * n + 1))

goal (1 subgoal):
 1. (\<Sum>k\<le>2 * n + 1. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) = (\<Sum>k\<le>2 * n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k))
[PROOF STEP]
have "?f' (2 * n + 1) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<i> * complex_of_real t) ^ (2 * n + 1) / fact (2 * n + 1) * complex_of_real (LINT x|std_normal_distribution. x ^ (2 * n + 1)) = 0
[PROOF STEP]
by (subst integral_std_normal_distribution_moment_odd) simp_all
[PROOF STATE]
proof (state)
this:
(\<i> * complex_of_real t) ^ (2 * n + 1) / fact (2 * n + 1) * complex_of_real (LINT x|std_normal_distribution. x ^ (2 * n + 1)) = 0

goal (1 subgoal):
 1. (\<Sum>k\<le>2 * n + 1. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) = (\<Sum>k\<le>2 * n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>k\<le>2 * n + 1. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) = (\<Sum>k\<le>2 * n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) + 0
[PROOF STEP]
show "?f (2 * n + 1) = ?f (2 * n)"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>k\<le>2 * n + 1. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) = (\<Sum>k\<le>2 * n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) + 0

goal (1 subgoal):
 1. (\<Sum>k\<le>2 * n + 1. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) = (\<Sum>k\<le>2 * n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<le>2 * n + 1. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) = (\<Sum>k\<le>2 * n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<le>2 * ?n + 1. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) = (\<Sum>k\<le>2 * ?n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k))

goal (1 subgoal):
 1. (\<lambda>n. \<Sum>k\<le>2 * n + 1. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) \<longlonglongrightarrow> complex_of_real (exp (- t\<^sup>2 / 2))
[PROOF STEP]
show "(\<lambda>n. ?f (2 * n + 1)) \<longlonglongrightarrow> exp (-(t^2) / 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. \<Sum>k\<le>2 * n + 1. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) \<longlonglongrightarrow> complex_of_real (exp (- t\<^sup>2 / 2))
[PROOF STEP]
unfolding **
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. \<Sum>k\<le>2 * n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) \<longlonglongrightarrow> complex_of_real (exp (- t\<^sup>2 / 2))
[PROOF STEP]
by fact
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<Sum>k\<le>2 * n + 1. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) \<longlonglongrightarrow> complex_of_real (exp (- t\<^sup>2 / 2))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) \<longlonglongrightarrow> complex_of_real (exp (- t\<^sup>2 / 2))

goal (1 subgoal):
 1. \<And>t. (\<lambda>n. \<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) \<longlonglongrightarrow> char std_normal_distribution t
[PROOF STEP]
have **: "(\<lambda>n. x ^ n / fact n) \<longlonglongrightarrow> 0" for x :: real
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. x ^ n / fact n) \<longlonglongrightarrow> 0
[PROOF STEP]
using summable_LIMSEQ_zero [OF summable_exp]
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. inverse (fact n) * ?x1 ^ n) \<longlonglongrightarrow> (0::?'a1)

goal (1 subgoal):
 1. (\<lambda>n. x ^ n / fact n) \<longlonglongrightarrow> 0
[PROOF STEP]
by (auto simp add: inverse_eq_divide)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. ?x ^ n / fact n) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. \<And>t. (\<lambda>n. \<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) \<longlonglongrightarrow> char std_normal_distribution t
[PROOF STEP]
let ?F = "\<lambda>n. 2 * \<bar>t\<bar> ^ n / fact n * (LINT x|std_normal_distribution. \<bar>x\<bar> ^ n)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>t. (\<lambda>n. \<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) \<longlonglongrightarrow> char std_normal_distribution t
[PROOF STEP]
show "?f \<longlonglongrightarrow> char std_normal_distribution t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. \<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) \<longlonglongrightarrow> char std_normal_distribution t
[PROOF STEP]
proof (rule metric_tendsto_imp_tendsto[OF limseq_even_odd])
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. (\<lambda>n. ?f (2 * n)) \<longlonglongrightarrow> ?a
 2. (\<lambda>n. ?f (2 * n + 1)) \<longlonglongrightarrow> ?a
 3. \<forall>\<^sub>F x in sequentially. dist (\<Sum>k\<le>x. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) (char std_normal_distribution t) \<le> dist (?f x) ?a
[PROOF STEP]
show "(\<lambda>n. ?F (2 * n)) \<longlonglongrightarrow> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. 2 * \<bar>t\<bar> ^ (2 * n) / fact (2 * n) * (LINT x|std_normal_distribution. \<bar>x\<bar> ^ (2 * n))) \<longlonglongrightarrow> 0
[PROOF STEP]
proof (rule Lim_transform_eventually)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ?f \<longlonglongrightarrow> 0
 2. \<forall>\<^sub>F x in sequentially. ?f x = 2 * \<bar>t\<bar> ^ (2 * x) / fact (2 * x) * (LINT xa|std_normal_distribution. \<bar>xa\<bar> ^ (2 * x))
[PROOF STEP]
show "\<forall>\<^sub>F n in sequentially. 2 * ((t^2 / 2)^n / fact n) = ?F (2 * n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. 2 * ((t\<^sup>2 / 2) ^ n / fact n) = 2 * \<bar>t\<bar> ^ (2 * n) / fact (2 * n) * (LINT x|std_normal_distribution. \<bar>x\<bar> ^ (2 * n))
[PROOF STEP]
unfolding std_normal_distribution_even_moments_abs
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. 2 * ((t\<^sup>2 / 2) ^ n / fact n) = 2 * \<bar>t\<bar> ^ (2 * n) / fact (2 * n) * (fact (2 * n) / (2 ^ n * fact n))
[PROOF STEP]
by (simp add: power_mult power_divide)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F n in sequentially. 2 * ((t\<^sup>2 / 2) ^ n / fact n) = 2 * \<bar>t\<bar> ^ (2 * n) / fact (2 * n) * (LINT x|std_normal_distribution. \<bar>x\<bar> ^ (2 * n))

goal (1 subgoal):
 1. (\<lambda>n. 2 * ((t\<^sup>2 / 2) ^ n / fact n)) \<longlonglongrightarrow> 0
[PROOF STEP]
qed (intro tendsto_mult_right_zero **)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. 2 * \<bar>t\<bar> ^ (2 * n) / fact (2 * n) * (LINT x|std_normal_distribution. \<bar>x\<bar> ^ (2 * n))) \<longlonglongrightarrow> 0

goal (2 subgoals):
 1. (\<lambda>n. 2 * \<bar>t\<bar> ^ (2 * n + 1) / fact (2 * n + 1) * (LINT x|std_normal_distribution. \<bar>x\<bar> ^ (2 * n + 1))) \<longlonglongrightarrow> 0
 2. \<forall>\<^sub>F x in sequentially. dist (\<Sum>k\<le>x. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) (char std_normal_distribution t) \<le> dist (2 * \<bar>t\<bar> ^ x / fact x * (LINT xa|std_normal_distribution. \<bar>xa\<bar> ^ x)) 0
[PROOF STEP]
have *: "?F (2 * n + 1) = (2 * \<bar>t\<bar> * sqrt (2 / pi)) * ((2 * t^2)^n * fact n / fact (2 * n + 1))" for n
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * \<bar>t\<bar> ^ (2 * n + 1) / fact (2 * n + 1) * (LINT x|std_normal_distribution. \<bar>x\<bar> ^ (2 * n + 1)) = 2 * \<bar>t\<bar> * sqrt (2 / pi) * ((2 * t\<^sup>2) ^ n * fact n / fact (2 * n + 1))
[PROOF STEP]
unfolding std_normal_distribution_odd_moments_abs
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * \<bar>t\<bar> ^ (2 * n + 1) / fact (2 * n + 1) * (sqrt (2 / pi) * 2 ^ n * fact n) = 2 * \<bar>t\<bar> * sqrt (2 / pi) * ((2 * t\<^sup>2) ^ n * fact n / fact (2 * n + 1))
[PROOF STEP]
by (simp add: field_simps power_mult[symmetric] power_even_abs)
[PROOF STATE]
proof (state)
this:
2 * \<bar>t\<bar> ^ (2 * ?n + 1) / fact (2 * ?n + 1) * (LINT x|std_normal_distribution. \<bar>x\<bar> ^ (2 * ?n + 1)) = 2 * \<bar>t\<bar> * sqrt (2 / pi) * ((2 * t\<^sup>2) ^ ?n * fact ?n / fact (2 * ?n + 1))

goal (2 subgoals):
 1. (\<lambda>n. 2 * \<bar>t\<bar> ^ (2 * n + 1) / fact (2 * n + 1) * (LINT x|std_normal_distribution. \<bar>x\<bar> ^ (2 * n + 1))) \<longlonglongrightarrow> 0
 2. \<forall>\<^sub>F x in sequentially. dist (\<Sum>k\<le>x. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) (char std_normal_distribution t) \<le> dist (2 * \<bar>t\<bar> ^ x / fact x * (LINT xa|std_normal_distribution. \<bar>xa\<bar> ^ x)) 0
[PROOF STEP]
have "norm ((2 * t\<^sup>2) ^ n * fact n / fact (2 * n + 1)) \<le> (2 * t\<^sup>2) ^ n / fact n" for n
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm ((2 * t\<^sup>2) ^ n * fact n / fact (2 * n + 1)) \<le> (2 * t\<^sup>2) ^ n / fact n
[PROOF STEP]
using mult_mono[OF _ square_fact_le_2_fact, of 1 "1 + 2 * real n" n]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>1 \<le> 1 + 2 * real n; 0 \<le> 1 + 2 * real n; 0 \<le> fact n * fact n\<rbrakk> \<Longrightarrow> 1 * (fact n * fact n) \<le> (1 + 2 * real n) * fact (2 * n)

goal (1 subgoal):
 1. norm ((2 * t\<^sup>2) ^ n * fact n / fact (2 * n + 1)) \<le> (2 * t\<^sup>2) ^ n / fact n
[PROOF STEP]
by (auto simp add: divide_simps intro!: mult_left_mono)
[PROOF STATE]
proof (state)
this:
norm ((2 * t\<^sup>2) ^ ?n * fact ?n / fact (2 * ?n + 1)) \<le> (2 * t\<^sup>2) ^ ?n / fact ?n

goal (2 subgoals):
 1. (\<lambda>n. 2 * \<bar>t\<bar> ^ (2 * n + 1) / fact (2 * n + 1) * (LINT x|std_normal_distribution. \<bar>x\<bar> ^ (2 * n + 1))) \<longlonglongrightarrow> 0
 2. \<forall>\<^sub>F x in sequentially. dist (\<Sum>k\<le>x. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) (char std_normal_distribution t) \<le> dist (2 * \<bar>t\<bar> ^ x / fact x * (LINT xa|std_normal_distribution. \<bar>xa\<bar> ^ x)) 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
norm ((2 * t\<^sup>2) ^ ?n * fact ?n / fact (2 * ?n + 1)) \<le> (2 * t\<^sup>2) ^ ?n / fact ?n
[PROOF STEP]
show "(\<lambda>n. ?F (2 * n + 1)) \<longlonglongrightarrow> 0"
[PROOF STATE]
proof (prove)
using this:
norm ((2 * t\<^sup>2) ^ ?n * fact ?n / fact (2 * ?n + 1)) \<le> (2 * t\<^sup>2) ^ ?n / fact ?n

goal (1 subgoal):
 1. (\<lambda>n. 2 * \<bar>t\<bar> ^ (2 * n + 1) / fact (2 * n + 1) * (LINT x|std_normal_distribution. \<bar>x\<bar> ^ (2 * n + 1))) \<longlonglongrightarrow> 0
[PROOF STEP]
unfolding *
[PROOF STATE]
proof (prove)
using this:
norm ((2 * t\<^sup>2) ^ ?n * fact ?n / fact (2 * ?n + 1)) \<le> (2 * t\<^sup>2) ^ ?n / fact ?n

goal (1 subgoal):
 1. (\<lambda>n. 2 * \<bar>t\<bar> * sqrt (2 / pi) * ((2 * t\<^sup>2) ^ n * fact n / fact (2 * n + 1))) \<longlonglongrightarrow> 0
[PROOF STEP]
by (intro tendsto_mult_right_zero Lim_null_comparison [OF _ ** [of "2 * t\<^sup>2"]]) auto
[PROOF STATE]
proof (state)
this:
(\<lambda>n. 2 * \<bar>t\<bar> ^ (2 * n + 1) / fact (2 * n + 1) * (LINT x|std_normal_distribution. \<bar>x\<bar> ^ (2 * n + 1))) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. \<forall>\<^sub>F x in sequentially. dist (\<Sum>k\<le>x. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) (char std_normal_distribution t) \<le> dist (2 * \<bar>t\<bar> ^ x / fact x * (LINT xa|std_normal_distribution. \<bar>xa\<bar> ^ x)) 0
[PROOF STEP]
show "\<forall>\<^sub>F n in sequentially. dist (?f n) (char std_normal_distribution t) \<le> dist (?F n) 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. dist (\<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) (char std_normal_distribution t) \<le> dist (2 * \<bar>t\<bar> ^ n / fact n * (LINT x|std_normal_distribution. \<bar>x\<bar> ^ n)) 0
[PROOF STEP]
using real_distribution.char_approx1[OF real_dist_normal_dist integrable_std_normal_distribution_moment]
[PROOF STATE]
proof (prove)
using this:
cmod (char std_normal_distribution ?t - (\<Sum>k\<le>?n. (\<i> * complex_of_real ?t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k))) \<le> 2 * \<bar>?t\<bar> ^ ?n / fact ?n * (LINT x|std_normal_distribution. \<bar>x\<bar> ^ ?n)

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. dist (\<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) (char std_normal_distribution t) \<le> dist (2 * \<bar>t\<bar> ^ n / fact n * (LINT x|std_normal_distribution. \<bar>x\<bar> ^ n)) 0
[PROOF STEP]
by (auto simp: dist_norm integral_nonneg_AE norm_minus_commute)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F n in sequentially. dist (\<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) (char std_normal_distribution t) \<le> dist (2 * \<bar>t\<bar> ^ n / fact n * (LINT x|std_normal_distribution. \<bar>x\<bar> ^ n)) 0

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<Sum>k\<le>n. (\<i> * complex_of_real t) ^ k / fact k * complex_of_real (LINT x|std_normal_distribution. x ^ k)) \<longlonglongrightarrow> char std_normal_distribution t

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma nonneg_bdd_above_infsum:
  fixes f :: \<open>'a \<Rightarrow> 'b :: {conditionally_complete_linorder, ordered_comm_monoid_add, linorder_topology}\<close>
  assumes \<open>\<And>x. x\<in>A \<Longrightarrow> f x \<ge> 0\<close>
  assumes \<open>bdd_above (sum f ` {F. F\<subseteq>A \<and> finite F})\<close>
  shows \<open>infsum f A = (SUP F\<in>{F. finite F \<and> F\<subseteq>A}. sum f F)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infsum f A = Sup (sum f ` {F. finite F \<and> F \<subseteq> A})
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
?x \<in> A \<Longrightarrow> (0::'b) \<le> f ?x
bdd_above (sum f ` {F. F \<subseteq> A \<and> finite F})

goal (1 subgoal):
 1. infsum f A = Sup (sum f ` {F. finite F \<and> F \<subseteq> A})
[PROOF STEP]
by (auto intro!: infsumI nonneg_bdd_above_has_sum)


[STATEMENT]
lemma d_IN_diff:
  assumes "\<And>x. g (x, y) \<le> f (x, y)" "d_IN g y \<noteq> \<top>"
  shows "d_IN (\<lambda>e. f e - g e) y = d_IN f y - d_IN g y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. d_IN (\<lambda>e. f e - g e) y = d_IN f y - d_IN g y
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
g (?x, y) \<le> f (?x, y)
d_IN g y \<noteq> \<top>

goal (1 subgoal):
 1. d_IN (\<lambda>e. f e - g e) y = d_IN f y - d_IN g y
[PROOF STEP]
by(simp add: nn_integral_diff d_IN_def)


[STATEMENT]
lemma le_ncols: "(n <= ncols A) = (\<forall> m. (\<forall> j i. m <= i \<longrightarrow> (Rep_matrix A j i) = 0) \<longrightarrow> n <= m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (n \<le> ncols A) = (\<forall>m. (\<forall>j i. m \<le> i \<longrightarrow> Rep_matrix A j i = (0::'a)) \<longrightarrow> n \<le> m)
[PROOF STEP]
apply (auto)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>m. \<lbrakk>n \<le> ncols A; \<forall>j i. m \<le> i \<longrightarrow> Rep_matrix A j i = (0::'a)\<rbrakk> \<Longrightarrow> n \<le> m
 2. \<forall>m. (\<forall>j i. m \<le> i \<longrightarrow> Rep_matrix A j i = (0::'a)) \<longrightarrow> n \<le> m \<Longrightarrow> n \<le> ncols A
[PROOF STEP]
apply (subgoal_tac "ncols A <= m")
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>m. \<lbrakk>n \<le> ncols A; \<forall>j i. m \<le> i \<longrightarrow> Rep_matrix A j i = (0::'a); ncols A \<le> m\<rbrakk> \<Longrightarrow> n \<le> m
 2. \<And>m. \<lbrakk>n \<le> ncols A; \<forall>j i. m \<le> i \<longrightarrow> Rep_matrix A j i = (0::'a)\<rbrakk> \<Longrightarrow> ncols A \<le> m
 3. \<forall>m. (\<forall>j i. m \<le> i \<longrightarrow> Rep_matrix A j i = (0::'a)) \<longrightarrow> n \<le> m \<Longrightarrow> n \<le> ncols A
[PROOF STEP]
apply (simp)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>m. \<lbrakk>n \<le> ncols A; \<forall>j i. m \<le> i \<longrightarrow> Rep_matrix A j i = (0::'a)\<rbrakk> \<Longrightarrow> ncols A \<le> m
 2. \<forall>m. (\<forall>j i. m \<le> i \<longrightarrow> Rep_matrix A j i = (0::'a)) \<longrightarrow> n \<le> m \<Longrightarrow> n \<le> ncols A
[PROOF STEP]
apply (simp add: ncols_le)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>m. (\<forall>j i. m \<le> i \<longrightarrow> Rep_matrix A j i = (0::'a)) \<longrightarrow> n \<le> m \<Longrightarrow> n \<le> ncols A
[PROOF STEP]
apply (drule_tac x="ncols A" in spec)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>j i. ncols A \<le> i \<longrightarrow> Rep_matrix A j i = (0::'a)) \<longrightarrow> n \<le> ncols A \<Longrightarrow> n \<le> ncols A
[PROOF STEP]
by (simp add: ncols)


[STATEMENT]
lemma unstream_take_trans [stream_fusion]: "unstream (take_trans g) (n, s) = take n (unstream g s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unstream (take_trans g) (n, s) = take n (unstream g s)
[PROOF STEP]
proof (induction s arbitrary: n taking: g rule: unstream.induct)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>s n. \<lbrakk>\<And>x2 n. generator g s = Skip x2 \<Longrightarrow> unstream (take_trans g) (n, x2) = take n (unstream g x2); \<And>x31 x32 n. generator g s = Yield x31 x32 \<Longrightarrow> unstream (take_trans g) (n, x32) = take n (unstream g x32)\<rbrakk> \<Longrightarrow> unstream (take_trans g) (n, s) = take n (unstream g s)
[PROOF STEP]
case (1 s)
[PROOF STATE]
proof (state)
this:
generator g s = Skip ?x2.0 \<Longrightarrow> unstream (take_trans g) (?n, ?x2.0) = take ?n (unstream g ?x2.0)
generator g s = Yield ?x31.0 ?x32.0 \<Longrightarrow> unstream (take_trans g) (?n, ?x32.0) = take ?n (unstream g ?x32.0)

goal (1 subgoal):
 1. \<And>s n. \<lbrakk>\<And>x2 n. generator g s = Skip x2 \<Longrightarrow> unstream (take_trans g) (n, x2) = take n (unstream g x2); \<And>x31 x32 n. generator g s = Yield x31 x32 \<Longrightarrow> unstream (take_trans g) (n, x32) = take n (unstream g x32)\<rbrakk> \<Longrightarrow> unstream (take_trans g) (n, s) = take n (unstream g s)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unstream (take_trans g) (n, s) = take n (unstream g s)
[PROOF STEP]
using "1.IH"(1)[of _ n] "1.IH"(2)
[PROOF STATE]
proof (prove)
using this:
generator g s = Skip ?x2.0 \<Longrightarrow> unstream (take_trans g) (n, ?x2.0) = take n (unstream g ?x2.0)
generator g s = Yield ?x31.0 ?x32.0 \<Longrightarrow> unstream (take_trans g) (?n, ?x32.0) = take ?n (unstream g ?x32.0)

goal (1 subgoal):
 1. unstream (take_trans g) (n, s) = take n (unstream g s)
[PROOF STEP]
by(cases "generator g s" n rule: step.exhaust[case_product nat.exhaust])
      (simp_all add: take_trans.rep_eq)
[PROOF STATE]
proof (state)
this:
unstream (take_trans g) (n, s) = take n (unstream g s)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma dim_UNIV[simp]: "dim UNIV = card Basis"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim UNIV = card Basis
[PROOF STEP]
using dim_eq_card[of Basis UNIV]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>span Basis = span UNIV; independent Basis\<rbrakk> \<Longrightarrow> dim UNIV = card Basis

goal (1 subgoal):
 1. dim UNIV = card Basis
[PROOF STEP]
by (simp add: independent_Basis span_Basis)


[STATEMENT]
lemma map_Suc_lem[rule_format] : "n > 0 \<longrightarrow> map (\<lambda> i:: nat. f i)[1..<n] =
                                  map (\<lambda> i:: nat. f(Suc i))[0..<(n - 1)]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < n \<longrightarrow> map f [1..<n] = map (\<lambda>i. f (Suc i)) [0..<n - 1]
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 0 < n \<longrightarrow> map f [1..<n] = map (\<lambda>i. f (Suc i)) [0..<n - 1]
[PROOF STEP]
have "(f 0 # map (\<lambda>n. f (Suc n)) [0..<n - 1] = f 0 # map f [1..<n]) = (map (\<lambda>n. f (Suc n)) [0..<n - 1] = map f [1..<n])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f 0 # map (\<lambda>n. f (Suc n)) [0..<n - 1] = f 0 # map f [1..<n]) = (map (\<lambda>n. f (Suc n)) [0..<n - 1] = map f [1..<n])
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(f 0 # map (\<lambda>n. f (Suc n)) [0..<n - 1] = f 0 # map f [1..<n]) = (map (\<lambda>n. f (Suc n)) [0..<n - 1] = map f [1..<n])

goal (1 subgoal):
 1. 0 < n \<longrightarrow> map f [1..<n] = map (\<lambda>i. f (Suc i)) [0..<n - 1]
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(f 0 # map (\<lambda>n. f (Suc n)) [0..<n - 1] = f 0 # map f [1..<n]) = (map (\<lambda>n. f (Suc n)) [0..<n - 1] = map f [1..<n])
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(f 0 # map (\<lambda>n. f (Suc n)) [0..<n - 1] = f 0 # map f [1..<n]) = (map (\<lambda>n. f (Suc n)) [0..<n - 1] = map f [1..<n])

goal (1 subgoal):
 1. 0 < n \<longrightarrow> map f [1..<n] = map (\<lambda>i. f (Suc i)) [0..<n - 1]
[PROOF STEP]
by (metis Suc_pred' map_hd_lem map_upt_Suc)
[PROOF STATE]
proof (state)
this:
0 < n \<longrightarrow> map f [1..<n] = map (\<lambda>i. f (Suc i)) [0..<n - 1]

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mset_le_add_iff2:
  "i \<le> (j::nat) \<Longrightarrow> (repeat_mset i u + m \<le> repeat_mset j u + n) = (m \<le> repeat_mset (j-i) u + n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i \<le> j \<Longrightarrow> (repeat_mset i u + m \<le> repeat_mset j u + n) = (m \<le> repeat_mset (j - i) u + n)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i \<le> j \<Longrightarrow> (repeat_mset i u + m \<le> repeat_mset j u + n) = (m \<le> repeat_mset (j - i) u + n)
[PROOF STEP]
assume "i \<le> j"
[PROOF STATE]
proof (state)
this:
i \<le> j

goal (1 subgoal):
 1. i \<le> j \<Longrightarrow> (repeat_mset i u + m \<le> repeat_mset j u + n) = (m \<le> repeat_mset (j - i) u + n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i \<le> j
[PROOF STEP]
have "i + (j - i) = j"
[PROOF STATE]
proof (prove)
using this:
i \<le> j

goal (1 subgoal):
 1. i + (j - i) = j
[PROOF STEP]
using le_add_diff_inverse
[PROOF STATE]
proof (prove)
using this:
i \<le> j
?b \<le> ?a \<Longrightarrow> ?b + (?a - ?b) = ?a

goal (1 subgoal):
 1. i + (j - i) = j
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
i + (j - i) = j

goal (1 subgoal):
 1. i \<le> j \<Longrightarrow> (repeat_mset i u + m \<le> repeat_mset j u + n) = (m \<le> repeat_mset (j - i) u + n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
i + (j - i) = j
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
i + (j - i) = j

goal (1 subgoal):
 1. (repeat_mset i u + m \<le> repeat_mset j u + n) = (m \<le> repeat_mset (j - i) u + n)
[PROOF STEP]
by (metis (no_types) add_le_cancel_left left_add_mult_distrib_mset)
[PROOF STATE]
proof (state)
this:
(repeat_mset i u + m \<le> repeat_mset j u + n) = (m \<le> repeat_mset (j - i) u + n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma has_fps_expansion_diff [fps_expansion_intros]:
  assumes "f has_fps_expansion F" "g has_fps_expansion G"
  shows   "(\<lambda>x. f x - g x) has_fps_expansion F - G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. f x - g x) has_fps_expansion F - G
[PROOF STEP]
using has_fps_expansion_add[of f F "\<lambda>x. - g x" "-G"] assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>f has_fps_expansion F; (\<lambda>x. - g x) has_fps_expansion - G\<rbrakk> \<Longrightarrow> (\<lambda>x. f x + - g x) has_fps_expansion F + - G
f has_fps_expansion F
g has_fps_expansion G

goal (1 subgoal):
 1. (\<lambda>x. f x - g x) has_fps_expansion F - G
[PROOF STEP]
by (simp add: has_fps_expansion_minus)


[STATEMENT]
lemma arcsin_eq_iff: "\<bar>x\<bar> \<le> 1 \<Longrightarrow> \<bar>y\<bar> \<le> 1 \<Longrightarrow> arcsin x = arcsin y \<longleftrightarrow> x = y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<bar>x\<bar> \<le> 1; \<bar>y\<bar> \<le> 1\<rbrakk> \<Longrightarrow> (arcsin x = arcsin y) = (x = y)
[PROOF STEP]
by (metis abs_le_iff arcsin minus_le_iff)


[STATEMENT]
lemma sum_every_odd_summand_is_zero:
  fixes n:: nat
  assumes "n \<ge> 1"
  shows "\<forall>f::(nat \<Rightarrow> complex).(\<forall>i. i<2^(n+1) \<and> odd i \<longrightarrow> f i = 0) \<longrightarrow>
            (\<Sum>k\<in>{0..<2^(n+1)}. f k) = (\<Sum>k\<in>{0..<2^n}. f (2*k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>f. (\<forall>i. i < 2 ^ (n + 1) \<and> odd i \<longrightarrow> f i = 0) \<longrightarrow> sum f {0..<2 ^ (n + 1)} = (\<Sum>k = 0..<2 ^ n. f (2 * k))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
1 \<le> n

goal (1 subgoal):
 1. \<forall>f. (\<forall>i. i < 2 ^ (n + 1) \<and> odd i \<longrightarrow> f i = 0) \<longrightarrow> sum f {0..<2 ^ (n + 1)} = (\<Sum>k = 0..<2 ^ n. f (2 * k))
[PROOF STEP]
proof(rule nat_induct_at_least)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<forall>f. (\<forall>i. i < 2 ^ (1 + 1) \<and> odd i \<longrightarrow> f i = 0) \<longrightarrow> sum f {0..<2 ^ (1 + 1)} = (\<Sum>k = 0..<2 ^ 1. f (2 * k))
 2. \<And>n. \<lbrakk>1 \<le> n; \<forall>f. (\<forall>i. i < 2 ^ (n + 1) \<and> odd i \<longrightarrow> f i = 0) \<longrightarrow> sum f {0..<2 ^ (n + 1)} = (\<Sum>k = 0..<2 ^ n. f (2 * k))\<rbrakk> \<Longrightarrow> \<forall>f. (\<forall>i. i < 2 ^ (Suc n + 1) \<and> odd i \<longrightarrow> f i = 0) \<longrightarrow> sum f {0..<2 ^ (Suc n + 1)} = (\<Sum>k = 0..<2 ^ Suc n. f (2 * k))
[PROOF STEP]
show "\<forall>f::(nat \<Rightarrow> complex).(\<forall>i. i<2^(1+1) \<and> odd i \<longrightarrow> f i = 0) \<longrightarrow>
            (\<Sum>k\<in>{0..<2^(1+1)}. f k) = (\<Sum>k \<in> {0..<2^1}. f (2*k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>f. (\<forall>i. i < 2 ^ (1 + 1) \<and> odd i \<longrightarrow> f i = 0) \<longrightarrow> sum f {0..<2 ^ (1 + 1)} = (\<Sum>k = 0..<2 ^ 1. f (2 * k))
[PROOF STEP]
proof(rule allI,rule impI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (1 + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (1 + 1)} = (\<Sum>k = 0..<2 ^ 1. f (2 * k))
[PROOF STEP]
fix f:: "(nat \<Rightarrow> complex)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (1 + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (1 + 1)} = (\<Sum>k = 0..<2 ^ 1. f (2 * k))
[PROOF STEP]
assume asm: "(\<forall>i. i<2^(1+1) \<and> odd i \<longrightarrow> f i = 0)"
[PROOF STATE]
proof (state)
this:
\<forall>i. i < 2 ^ (1 + 1) \<and> odd i \<longrightarrow> f i = 0

goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (1 + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (1 + 1)} = (\<Sum>k = 0..<2 ^ 1. f (2 * k))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<forall>i. i < 2 ^ (1 + 1) \<and> odd i \<longrightarrow> f i = 0

goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (1 + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (1 + 1)} = (\<Sum>k = 0..<2 ^ 1. f (2 * k))
[PROOF STEP]
have "(\<Sum>k\<in>{0..<4}. f k) = f 0 + f 1 + f 2 + f 3"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f {0..<4} = f 0 + f 1 + f 2 + f 3
[PROOF STEP]
by (simp add: add.commute add.left_commute)
[PROOF STATE]
proof (state)
this:
sum f {0..<4} = f 0 + f 1 + f 2 + f 3

goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (1 + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (1 + 1)} = (\<Sum>k = 0..<2 ^ 1. f (2 * k))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
sum f {0..<4} = f 0 + f 1 + f 2 + f 3

goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (1 + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (1 + 1)} = (\<Sum>k = 0..<2 ^ 1. f (2 * k))
[PROOF STEP]
have "f 1 = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f 1 = 0
[PROOF STEP]
using asm
[PROOF STATE]
proof (prove)
using this:
\<forall>i. i < 2 ^ (1 + 1) \<and> odd i \<longrightarrow> f i = 0

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

goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (1 + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (1 + 1)} = (\<Sum>k = 0..<2 ^ 1. f (2 * k))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
f 1 = 0

goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (1 + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (1 + 1)} = (\<Sum>k = 0..<2 ^ 1. f (2 * k))
[PROOF STEP]
have "f 3 = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f 3 = 0
[PROOF STEP]
using asm
[PROOF STATE]
proof (prove)
using this:
\<forall>i. i < 2 ^ (1 + 1) \<and> odd i \<longrightarrow> f i = 0

goal (1 subgoal):
 1. f 3 = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
f 3 = 0

goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (1 + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (1 + 1)} = (\<Sum>k = 0..<2 ^ 1. f (2 * k))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
f 3 = 0

goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (1 + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (1 + 1)} = (\<Sum>k = 0..<2 ^ 1. f (2 * k))
[PROOF STEP]
have "(\<Sum>k\<in>{0..<2^1}. f (2*k)) = f 0 + f 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k = 0..<2 ^ 1. f (2 * k)) = f 0 + f 2
[PROOF STEP]
using add.commute add.left_commute
[PROOF STATE]
proof (prove)
using this:
?a + ?b = ?b + ?a
?b + (?a + ?c) = ?a + (?b + ?c)

goal (1 subgoal):
 1. (\<Sum>k = 0..<2 ^ 1. f (2 * k)) = f 0 + f 2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 0..<2 ^ 1. f (2 * k)) = f 0 + f 2

goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (1 + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (1 + 1)} = (\<Sum>k = 0..<2 ^ 1. f (2 * k))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<forall>i. i < 2 ^ (1 + 1) \<and> odd i \<longrightarrow> f i = 0
sum f {0..<4} = f 0 + f 1 + f 2 + f 3
f 1 = 0
f 3 = 0
(\<Sum>k = 0..<2 ^ 1. f (2 * k)) = f 0 + f 2
[PROOF STEP]
show "(\<Sum>k\<in>{0..<2^(1+1)}. f k) = (\<Sum>k\<in>{0..<2^1}. f (2*k))"
[PROOF STATE]
proof (prove)
using this:
\<forall>i. i < 2 ^ (1 + 1) \<and> odd i \<longrightarrow> f i = 0
sum f {0..<4} = f 0 + f 1 + f 2 + f 3
f 1 = 0
f 3 = 0
(\<Sum>k = 0..<2 ^ 1. f (2 * k)) = f 0 + f 2

goal (1 subgoal):
 1. sum f {0..<2 ^ (1 + 1)} = (\<Sum>k = 0..<2 ^ 1. f (2 * k))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sum f {0..<2 ^ (1 + 1)} = (\<Sum>k = 0..<2 ^ 1. f (2 * k))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>f. (\<forall>i. i < 2 ^ (1 + 1) \<and> odd i \<longrightarrow> f i = 0) \<longrightarrow> sum f {0..<2 ^ (1 + 1)} = (\<Sum>k = 0..<2 ^ 1. f (2 * k))

goal (1 subgoal):
 1. \<And>n. \<lbrakk>1 \<le> n; \<forall>f. (\<forall>i. i < 2 ^ (n + 1) \<and> odd i \<longrightarrow> f i = 0) \<longrightarrow> sum f {0..<2 ^ (n + 1)} = (\<Sum>k = 0..<2 ^ n. f (2 * k))\<rbrakk> \<Longrightarrow> \<forall>f. (\<forall>i. i < 2 ^ (Suc n + 1) \<and> odd i \<longrightarrow> f i = 0) \<longrightarrow> sum f {0..<2 ^ (Suc n + 1)} = (\<Sum>k = 0..<2 ^ Suc n. f (2 * k))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>1 \<le> n; \<forall>f. (\<forall>i. i < 2 ^ (n + 1) \<and> odd i \<longrightarrow> f i = 0) \<longrightarrow> sum f {0..<2 ^ (n + 1)} = (\<Sum>k = 0..<2 ^ n. f (2 * k))\<rbrakk> \<Longrightarrow> \<forall>f. (\<forall>i. i < 2 ^ (Suc n + 1) \<and> odd i \<longrightarrow> f i = 0) \<longrightarrow> sum f {0..<2 ^ (Suc n + 1)} = (\<Sum>k = 0..<2 ^ Suc n. f (2 * k))
[PROOF STEP]
fix n:: nat
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>1 \<le> n; \<forall>f. (\<forall>i. i < 2 ^ (n + 1) \<and> odd i \<longrightarrow> f i = 0) \<longrightarrow> sum f {0..<2 ^ (n + 1)} = (\<Sum>k = 0..<2 ^ n. f (2 * k))\<rbrakk> \<Longrightarrow> \<forall>f. (\<forall>i. i < 2 ^ (Suc n + 1) \<and> odd i \<longrightarrow> f i = 0) \<longrightarrow> sum f {0..<2 ^ (Suc n + 1)} = (\<Sum>k = 0..<2 ^ Suc n. f (2 * k))
[PROOF STEP]
assume "n \<ge> 1"
  and IH: "\<forall>f::(nat \<Rightarrow>complex).(\<forall>i. i<2^(n+1) \<and> odd i \<longrightarrow> f i = 0) \<longrightarrow>
(\<Sum>k\<in>{0..<2^(n+1)}. f k) = (\<Sum>k\<in>{0..<2^n}. f (2*k))"
[PROOF STATE]
proof (state)
this:
1 \<le> n
\<forall>f. (\<forall>i. i < 2 ^ (n + 1) \<and> odd i \<longrightarrow> f i = 0) \<longrightarrow> sum f {0..<2 ^ (n + 1)} = (\<Sum>k = 0..<2 ^ n. f (2 * k))

goal (1 subgoal):
 1. \<And>n. \<lbrakk>1 \<le> n; \<forall>f. (\<forall>i. i < 2 ^ (n + 1) \<and> odd i \<longrightarrow> f i = 0) \<longrightarrow> sum f {0..<2 ^ (n + 1)} = (\<Sum>k = 0..<2 ^ n. f (2 * k))\<rbrakk> \<Longrightarrow> \<forall>f. (\<forall>i. i < 2 ^ (Suc n + 1) \<and> odd i \<longrightarrow> f i = 0) \<longrightarrow> sum f {0..<2 ^ (Suc n + 1)} = (\<Sum>k = 0..<2 ^ Suc n. f (2 * k))
[PROOF STEP]
show "\<forall>f::(nat \<Rightarrow>complex).(\<forall>i. i<2^(Suc n +1) \<and> odd i \<longrightarrow> f i = 0) \<longrightarrow>
(\<Sum>k\<in>{0..<2^(Suc n +1)}. f k) = (\<Sum>k\<in>{0..< 2^(Suc n)}. f (2*k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>f. (\<forall>i. i < 2 ^ (Suc n + 1) \<and> odd i \<longrightarrow> f i = 0) \<longrightarrow> sum f {0..<2 ^ (Suc n + 1)} = (\<Sum>k = 0..<2 ^ Suc n. f (2 * k))
[PROOF STEP]
proof (rule allI,rule impI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (Suc n + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (Suc n + 1)} = (\<Sum>k = 0..<2 ^ Suc n. f (2 * k))
[PROOF STEP]
fix f::"nat \<Rightarrow> complex"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (Suc n + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (Suc n + 1)} = (\<Sum>k = 0..<2 ^ Suc n. f (2 * k))
[PROOF STEP]
assume asm: "(\<forall>i. i<2^(Suc n +1) \<and> odd i \<longrightarrow> f i = 0)"
[PROOF STATE]
proof (state)
this:
\<forall>i. i < 2 ^ (Suc n + 1) \<and> odd i \<longrightarrow> f i = 0

goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (Suc n + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (Suc n + 1)} = (\<Sum>k = 0..<2 ^ Suc n. f (2 * k))
[PROOF STEP]
have f0: "(\<Sum>k\<in>{0..<2^(n+1)}. f k) = (\<Sum>k\<in>{0..<2^n}. f (2*k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f {0..<2 ^ (n + 1)} = (\<Sum>k = 0..<2 ^ n. f (2 * k))
[PROOF STEP]
using asm IH
[PROOF STATE]
proof (prove)
using this:
\<forall>i. i < 2 ^ (Suc n + 1) \<and> odd i \<longrightarrow> f i = 0
\<forall>f. (\<forall>i. i < 2 ^ (n + 1) \<and> odd i \<longrightarrow> f i = 0) \<longrightarrow> sum f {0..<2 ^ (n + 1)} = (\<Sum>k = 0..<2 ^ n. f (2 * k))

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

goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (Suc n + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (Suc n + 1)} = (\<Sum>k = 0..<2 ^ Suc n. f (2 * k))
[PROOF STEP]
have f1: "(\<Sum>k\<in>{0..<2^(n+1)}. (\<lambda>x. f (x+2^(n+1))) k) = (\<Sum>k\<in>{0..< 2^n}. (\<lambda>x. f (x+2^(n+1))) (2*k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k = 0..<2 ^ (n + 1). f (k + 2 ^ (n + 1))) = (\<Sum>k = 0..<2 ^ n. f (2 * k + 2 ^ (n + 1)))
[PROOF STEP]
using asm IH
[PROOF STATE]
proof (prove)
using this:
\<forall>i. i < 2 ^ (Suc n + 1) \<and> odd i \<longrightarrow> f i = 0
\<forall>f. (\<forall>i. i < 2 ^ (n + 1) \<and> odd i \<longrightarrow> f i = 0) \<longrightarrow> sum f {0..<2 ^ (n + 1)} = (\<Sum>k = 0..<2 ^ n. f (2 * k))

goal (1 subgoal):
 1. (\<Sum>k = 0..<2 ^ (n + 1). f (k + 2 ^ (n + 1))) = (\<Sum>k = 0..<2 ^ n. f (2 * k + 2 ^ (n + 1)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 0..<2 ^ (n + 1). f (k + 2 ^ (n + 1))) = (\<Sum>k = 0..<2 ^ n. f (2 * k + 2 ^ (n + 1)))

goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (Suc n + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (Suc n + 1)} = (\<Sum>k = 0..<2 ^ Suc n. f (2 * k))
[PROOF STEP]
have "(\<Sum>k\<in>{0..<2^(n+2)}. f k) = (\<Sum>k\<in>{0..<2^(n+1)}. f k) + (\<Sum>k\<in>{2^(n+1)..<2^(n+2)}. f k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f {0..<2 ^ (n + 2)} = sum f {0..<2 ^ (n + 1)} + sum f {2 ^ (n + 1)..<2 ^ (n + 2)}
[PROOF STEP]
by (simp add: sum.atLeastLessThan_concat)
[PROOF STATE]
proof (state)
this:
sum f {0..<2 ^ (n + 2)} = sum f {0..<2 ^ (n + 1)} + sum f {2 ^ (n + 1)..<2 ^ (n + 2)}

goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (Suc n + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (Suc n + 1)} = (\<Sum>k = 0..<2 ^ Suc n. f (2 * k))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum f {0..<2 ^ (n + 2)} = sum f {0..<2 ^ (n + 1)} + sum f {2 ^ (n + 1)..<2 ^ (n + 2)}

goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (Suc n + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (Suc n + 1)} = (\<Sum>k = 0..<2 ^ Suc n. f (2 * k))
[PROOF STEP]
have "... = (\<Sum>k\<in>{0..<2^n}. f (2*k)) + (\<Sum>k\<in>{2^(n+1)..<2^(n+2)}. f k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f {0..<2 ^ (n + 1)} + sum f {2 ^ (n + 1)..<2 ^ (n + 2)} = (\<Sum>k = 0..<2 ^ n. f (2 * k)) + sum f {2 ^ (n + 1)..<2 ^ (n + 2)}
[PROOF STEP]
using f0
[PROOF STATE]
proof (prove)
using this:
sum f {0..<2 ^ (n + 1)} = (\<Sum>k = 0..<2 ^ n. f (2 * k))

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

goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (Suc n + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (Suc n + 1)} = (\<Sum>k = 0..<2 ^ Suc n. f (2 * k))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum f {0..<2 ^ (n + 1)} + sum f {2 ^ (n + 1)..<2 ^ (n + 2)} = (\<Sum>k = 0..<2 ^ n. f (2 * k)) + sum f {2 ^ (n + 1)..<2 ^ (n + 2)}

goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (Suc n + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (Suc n + 1)} = (\<Sum>k = 0..<2 ^ Suc n. f (2 * k))
[PROOF STEP]
have "... = (\<Sum>k\<in>{0..<2^n}. f (2*k)) + (\<Sum>k\<in>{0..<2^(n+1)}. f (k+2^(n+1)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k = 0..<2 ^ n. f (2 * k)) + sum f {2 ^ (n + 1)..<2 ^ (n + 2)} = (\<Sum>k = 0..<2 ^ n. f (2 * k)) + (\<Sum>k = 0..<2 ^ (n + 1). f (k + 2 ^ (n + 1)))
[PROOF STEP]
using sum.shift_bounds_nat_ivl[of "f" "0" "2^(n+1)" "2^(n+1)"]
[PROOF STATE]
proof (prove)
using this:
sum f {0 + 2 ^ (n + 1)..<2 ^ (n + 1) + 2 ^ (n + 1)} = (\<Sum>i = 0..<2 ^ (n + 1). f (i + 2 ^ (n + 1)))

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

goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (Suc n + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (Suc n + 1)} = (\<Sum>k = 0..<2 ^ Suc n. f (2 * k))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 0..<2 ^ n. f (2 * k)) + sum f {2 ^ (n + 1)..<2 ^ (n + 2)} = (\<Sum>k = 0..<2 ^ n. f (2 * k)) + (\<Sum>k = 0..<2 ^ (n + 1). f (k + 2 ^ (n + 1)))

goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (Suc n + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (Suc n + 1)} = (\<Sum>k = 0..<2 ^ Suc n. f (2 * k))
[PROOF STEP]
have "... = (\<Sum>k\<in>{0..<2^n}. f (2*k)) + (\<Sum>k\<in>{0..< 2^n}. (\<lambda>x. f (x+2^(n+1))) (2*k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k = 0..<2 ^ n. f (2 * k)) + (\<Sum>k = 0..<2 ^ (n + 1). f (k + 2 ^ (n + 1))) = (\<Sum>k = 0..<2 ^ n. f (2 * k)) + (\<Sum>k = 0..<2 ^ n. f (2 * k + 2 ^ (n + 1)))
[PROOF STEP]
using f1
[PROOF STATE]
proof (prove)
using this:
(\<Sum>k = 0..<2 ^ (n + 1). f (k + 2 ^ (n + 1))) = (\<Sum>k = 0..<2 ^ n. f (2 * k + 2 ^ (n + 1)))

goal (1 subgoal):
 1. (\<Sum>k = 0..<2 ^ n. f (2 * k)) + (\<Sum>k = 0..<2 ^ (n + 1). f (k + 2 ^ (n + 1))) = (\<Sum>k = 0..<2 ^ n. f (2 * k)) + (\<Sum>k = 0..<2 ^ n. f (2 * k + 2 ^ (n + 1)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 0..<2 ^ n. f (2 * k)) + (\<Sum>k = 0..<2 ^ (n + 1). f (k + 2 ^ (n + 1))) = (\<Sum>k = 0..<2 ^ n. f (2 * k)) + (\<Sum>k = 0..<2 ^ n. f (2 * k + 2 ^ (n + 1)))

goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (Suc n + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (Suc n + 1)} = (\<Sum>k = 0..<2 ^ Suc n. f (2 * k))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 0..<2 ^ n. f (2 * k)) + (\<Sum>k = 0..<2 ^ (n + 1). f (k + 2 ^ (n + 1))) = (\<Sum>k = 0..<2 ^ n. f (2 * k)) + (\<Sum>k = 0..<2 ^ n. f (2 * k + 2 ^ (n + 1)))

goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (Suc n + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (Suc n + 1)} = (\<Sum>k = 0..<2 ^ Suc n. f (2 * k))
[PROOF STEP]
have "... = (\<Sum>k\<in>{0..<2^n}. f (2*k)) + (\<Sum>k\<in>{2^n..< 2^(n+1)}. f (2 *k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k = 0..<2 ^ n. f (2 * k)) + (\<Sum>k = 0..<2 ^ n. f (2 * k + 2 ^ (n + 1))) = (\<Sum>k = 0..<2 ^ n. f (2 * k)) + (\<Sum>k = 2 ^ n..<2 ^ (n + 1). f (2 * k))
[PROOF STEP]
using sum.shift_bounds_nat_ivl[of "\<lambda>x. (f::nat\<Rightarrow>complex) (2*(x-2^n)+2^(n+1))" "0" "2^n" "2^n"]
[PROOF STATE]
proof (prove)
using this:
(\<Sum>x = 0 + 2 ^ n..<2 ^ n + 2 ^ n. f (2 * (x - 2 ^ n) + 2 ^ (n + 1))) = (\<Sum>i = 0..<2 ^ n. f (2 * (i + 2 ^ n - 2 ^ n) + 2 ^ (n + 1)))

goal (1 subgoal):
 1. (\<Sum>k = 0..<2 ^ n. f (2 * k)) + (\<Sum>k = 0..<2 ^ n. f (2 * k + 2 ^ (n + 1))) = (\<Sum>k = 0..<2 ^ n. f (2 * k)) + (\<Sum>k = 2 ^ n..<2 ^ (n + 1). f (2 * k))
[PROOF STEP]
by (simp add: mult_2)
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 0..<2 ^ n. f (2 * k)) + (\<Sum>k = 0..<2 ^ n. f (2 * k + 2 ^ (n + 1))) = (\<Sum>k = 0..<2 ^ n. f (2 * k)) + (\<Sum>k = 2 ^ n..<2 ^ (n + 1). f (2 * k))

goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (Suc n + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (Suc n + 1)} = (\<Sum>k = 0..<2 ^ Suc n. f (2 * k))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 0..<2 ^ n. f (2 * k)) + (\<Sum>k = 0..<2 ^ n. f (2 * k + 2 ^ (n + 1))) = (\<Sum>k = 0..<2 ^ n. f (2 * k)) + (\<Sum>k = 2 ^ n..<2 ^ (n + 1). f (2 * k))

goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (Suc n + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (Suc n + 1)} = (\<Sum>k = 0..<2 ^ Suc n. f (2 * k))
[PROOF STEP]
have "... = (\<Sum>k \<in> {0..<2^(n+1)}. f (2*k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k = 0..<2 ^ n. f (2 * k)) + (\<Sum>k = 2 ^ n..<2 ^ (n + 1). f (2 * k)) = (\<Sum>k = 0..<2 ^ (n + 1). f (2 * k))
[PROOF STEP]
by (metis Suc_eq_plus1 lessI less_imp_le_nat one_le_numeral power_increasing sum.atLeastLessThan_concat zero_le)
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 0..<2 ^ n. f (2 * k)) + (\<Sum>k = 2 ^ n..<2 ^ (n + 1). f (2 * k)) = (\<Sum>k = 0..<2 ^ (n + 1). f (2 * k))

goal (1 subgoal):
 1. \<And>f. \<forall>i. i < 2 ^ (Suc n + 1) \<and> odd i \<longrightarrow> f i = 0 \<Longrightarrow> sum f {0..<2 ^ (Suc n + 1)} = (\<Sum>k = 0..<2 ^ Suc n. f (2 * k))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sum f {0..<2 ^ (n + 2)} = (\<Sum>k = 0..<2 ^ (n + 1). f (2 * k))
[PROOF STEP]
show "(\<Sum>k\<in>{0..<2^((Suc n)+1)}. f k) = (\<Sum>k\<in>{0..< 2^(Suc n)}. f (2*k))"
[PROOF STATE]
proof (prove)
using this:
sum f {0..<2 ^ (n + 2)} = (\<Sum>k = 0..<2 ^ (n + 1). f (2 * k))

goal (1 subgoal):
 1. sum f {0..<2 ^ (Suc n + 1)} = (\<Sum>k = 0..<2 ^ Suc n. f (2 * k))
[PROOF STEP]
by (metis Suc_eq_plus1 add_2_eq_Suc')
[PROOF STATE]
proof (state)
this:
sum f {0..<2 ^ (Suc n + 1)} = (\<Sum>k = 0..<2 ^ Suc n. f (2 * k))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>f. (\<forall>i. i < 2 ^ (Suc n + 1) \<and> odd i \<longrightarrow> f i = 0) \<longrightarrow> sum f {0..<2 ^ (Suc n + 1)} = (\<Sum>k = 0..<2 ^ Suc n. f (2 * k))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma smallo_1_iff:
  "eventually_nonneg F f \<Longrightarrow> (\<lambda>_. 1 :: real) \<in> o[F](f) \<longleftrightarrow> filterlim f at_top F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eventually_nonneg F f \<Longrightarrow> ((\<lambda>_. 1) \<in> o[F](f)) = filterlim f at_top F
[PROOF STEP]
by (simp add: filterlim_at_top_iff_smallomega smallomega_iff_smallo)


[STATEMENT]
lemma sign_changes_uminus:
  fixes xs :: "'a :: linordered_idom list"
  shows   "sign_changes (map uminus xs) = sign_changes xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sign_changes (map uminus xs) = sign_changes xs
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. sign_changes (map uminus xs) = sign_changes xs
[PROOF STEP]
have "sign_changes (map uminus xs) =
          length (remdups_adj [x\<leftarrow>map sgn (map uminus xs) . x \<noteq> 0]) - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sign_changes (map uminus xs) = length (remdups_adj (filter (\<lambda>x. x \<noteq> (0::'a)) (map sgn (map uminus xs)))) - 1
[PROOF STEP]
unfolding sign_changes_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (remdups_adj (filter (\<lambda>x. x \<noteq> (0::'a)) (map sgn (map uminus xs)))) - 1 = length (remdups_adj (filter (\<lambda>x. x \<noteq> (0::'a)) (map sgn (map uminus xs)))) - 1
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
sign_changes (map uminus xs) = length (remdups_adj (filter (\<lambda>x. x \<noteq> (0::'a)) (map sgn (map uminus xs)))) - 1

goal (1 subgoal):
 1. sign_changes (map uminus xs) = sign_changes xs
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sign_changes (map uminus xs) = length (remdups_adj (filter (\<lambda>x. x \<noteq> (0::'a)) (map sgn (map uminus xs)))) - 1

goal (1 subgoal):
 1. sign_changes (map uminus xs) = sign_changes xs
[PROOF STEP]
have "map sgn (map uminus xs) = map uminus (map sgn xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map sgn (map uminus xs) = map uminus (map sgn xs)
[PROOF STEP]
by (auto simp: sgn_minus)
[PROOF STATE]
proof (state)
this:
map sgn (map uminus xs) = map uminus (map sgn xs)

goal (1 subgoal):
 1. sign_changes (map uminus xs) = sign_changes xs
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map sgn (map uminus xs) = map uminus (map sgn xs)

goal (1 subgoal):
 1. sign_changes (map uminus xs) = sign_changes xs
[PROOF STEP]
have "remdups_adj (filter (\<lambda>x. x \<noteq> 0) \<dots>) =
                 map uminus (remdups_adj (filter (\<lambda>x. x \<noteq> 0) (map sgn xs)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. remdups_adj (filter (\<lambda>x. x \<noteq> (0::'a)) (map uminus (map sgn xs))) = map uminus (remdups_adj (filter (\<lambda>x. x \<noteq> (0::'a)) (map sgn xs)))
[PROOF STEP]
by (subst filter_map, subst remdups_adj_map_injective)
       (simp_all add: o_def)
[PROOF STATE]
proof (state)
this:
remdups_adj (filter (\<lambda>x. x \<noteq> (0::'a)) (map uminus (map sgn xs))) = map uminus (remdups_adj (filter (\<lambda>x. x \<noteq> (0::'a)) (map sgn xs)))

goal (1 subgoal):
 1. sign_changes (map uminus xs) = sign_changes xs
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
remdups_adj (filter (\<lambda>x. x \<noteq> (0::'a)) (map uminus (map sgn xs))) = map uminus (remdups_adj (filter (\<lambda>x. x \<noteq> (0::'a)) (map sgn xs)))

goal (1 subgoal):
 1. sign_changes (map uminus xs) = sign_changes xs
[PROOF STEP]
have "length \<dots> - 1 = sign_changes xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (map uminus (remdups_adj (filter (\<lambda>x. x \<noteq> (0::'a)) (map sgn xs)))) - 1 = sign_changes xs
[PROOF STEP]
by (simp add: sign_changes_def)
[PROOF STATE]
proof (state)
this:
length (map uminus (remdups_adj (filter (\<lambda>x. x \<noteq> (0::'a)) (map sgn xs)))) - 1 = sign_changes xs

goal (1 subgoal):
 1. sign_changes (map uminus xs) = sign_changes xs
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sign_changes (map uminus xs) = sign_changes xs
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
sign_changes (map uminus xs) = sign_changes xs

goal (1 subgoal):
 1. sign_changes (map uminus xs) = sign_changes xs
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
sign_changes (map uminus xs) = sign_changes xs

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fermat:
  assumes "prime p" "m mod p \<noteq> 0"
  shows "m^(p-(1::nat)) mod p = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m ^ (p - 1) mod p = 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. m ^ (p - 1) mod p = 1
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
prime p
m mod p \<noteq> 0
[PROOF STEP]
have "[m ^ (p - 1) = 1] (mod p)"
[PROOF STATE]
proof (prove)
using this:
prime p
m mod p \<noteq> 0

goal (1 subgoal):
 1. [m ^ (p - 1) = 1] (mod p)
[PROOF STEP]
using fermat_theorem [of p m]
[PROOF STATE]
proof (prove)
using this:
prime p
m mod p \<noteq> 0
\<lbrakk>prime p; \<not> p dvd m\<rbrakk> \<Longrightarrow> [m ^ (p - 1) = 1] (mod p)

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

goal (1 subgoal):
 1. m ^ (p - 1) mod p = 1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[m ^ (p - 1) = 1] (mod p)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
[m ^ (p - 1) = 1] (mod p)

goal (1 subgoal):
 1. m ^ (p - 1) mod p = 1
[PROOF STEP]
using \<open>prime p\<close> prime_gt_1_nat [of p]
[PROOF STATE]
proof (prove)
using this:
[m ^ (p - 1) = 1] (mod p)
prime p
prime p \<Longrightarrow> 1 < p

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem integer_composition_enum_distinct:
  "distinct (integer_composition_enum n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct (integer_composition_enum n)
[PROOF STEP]
proof(induct n rule: integer_composition_enum.induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. distinct (integer_composition_enum 0)
 2. \<And>n. (\<And>x. x \<in> set [0..<Suc n] \<Longrightarrow> distinct (integer_composition_enum (n - x))) \<Longrightarrow> distinct (integer_composition_enum (Suc n))
[PROOF STEP]
case 1
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. distinct (integer_composition_enum 0)
 2. \<And>n. (\<And>x. x \<in> set [0..<Suc n] \<Longrightarrow> distinct (integer_composition_enum (n - x))) \<Longrightarrow> distinct (integer_composition_enum (Suc n))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct (integer_composition_enum 0)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
distinct (integer_composition_enum 0)

goal (1 subgoal):
 1. \<And>n. (\<And>x. x \<in> set [0..<Suc n] \<Longrightarrow> distinct (integer_composition_enum (n - x))) \<Longrightarrow> distinct (integer_composition_enum (Suc n))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. (\<And>x. x \<in> set [0..<Suc n] \<Longrightarrow> distinct (integer_composition_enum (n - x))) \<Longrightarrow> distinct (integer_composition_enum (Suc n))
[PROOF STEP]
case (2 n)
[PROOF STATE]
proof (state)
this:
?x \<in> set [0..<Suc n] \<Longrightarrow> distinct (integer_composition_enum (n - ?x))

goal (1 subgoal):
 1. \<And>n. (\<And>x. x \<in> set [0..<Suc n] \<Longrightarrow> distinct (integer_composition_enum (n - x))) \<Longrightarrow> distinct (integer_composition_enum (Suc n))
[PROOF STEP]
have h1: "x \<in> set [0..<Suc n] \<Longrightarrow> distinct (integer_composition_enum (n - x))" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> set [0..<Suc n] \<Longrightarrow> distinct (integer_composition_enum (n - x))
[PROOF STEP]
using "2"
[PROOF STATE]
proof (prove)
using this:
?x \<in> set [0..<Suc n] \<Longrightarrow> distinct (integer_composition_enum (n - ?x))

goal (1 subgoal):
 1. x \<in> set [0..<Suc n] \<Longrightarrow> distinct (integer_composition_enum (n - x))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
?x \<in> set [0..<Suc n] \<Longrightarrow> distinct (integer_composition_enum (n - ?x))

goal (1 subgoal):
 1. \<And>n. (\<And>x. x \<in> set [0..<Suc n] \<Longrightarrow> distinct (integer_composition_enum (n - x))) \<Longrightarrow> distinct (integer_composition_enum (Suc n))
[PROOF STEP]
have h2: "distinct [0..<n]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct [0..<n]
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
distinct [0..<n]

goal (1 subgoal):
 1. \<And>n. (\<And>x. x \<in> set [0..<Suc n] \<Longrightarrow> distinct (integer_composition_enum (n - x))) \<Longrightarrow> distinct (integer_composition_enum (Suc n))
[PROOF STEP]
have "distinct [Suc m #xs. m \<leftarrow> [0..< n], xs \<leftarrow> integer_composition_enum (n-m)]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct (concat (map (\<lambda>m. map ((#) (Suc m)) (integer_composition_enum (n - m))) [0..<n]))
[PROOF STEP]
using h1 h2 Cons_Suc_distinct_concat_map_function
[PROOF STATE]
proof (prove)
using this:
?x \<in> set [0..<Suc n] \<Longrightarrow> distinct (integer_composition_enum (n - ?x))
distinct [0..<n]
\<lbrakk>\<forall>x\<in>set ?xs. distinct (?g x); distinct ?xs\<rbrakk> \<Longrightarrow> distinct (concat (map (\<lambda>x. map ((#) (Suc x)) (?g x)) ?xs))

goal (1 subgoal):
 1. distinct (concat (map (\<lambda>m. map ((#) (Suc m)) (integer_composition_enum (n - m))) [0..<n]))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
distinct (concat (map (\<lambda>m. map ((#) (Suc m)) (integer_composition_enum (n - m))) [0..<n]))

goal (1 subgoal):
 1. \<And>n. (\<And>x. x \<in> set [0..<Suc n] \<Longrightarrow> distinct (integer_composition_enum (n - x))) \<Longrightarrow> distinct (integer_composition_enum (Suc n))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
distinct (concat (map (\<lambda>m. map ((#) (Suc m)) (integer_composition_enum (n - m))) [0..<n]))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
distinct (concat (map (\<lambda>m. map ((#) (Suc m)) (integer_composition_enum (n - m))) [0..<n]))

goal (1 subgoal):
 1. distinct (integer_composition_enum (Suc n))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
distinct (integer_composition_enum (Suc n))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fps_deriv_eq_iff:
  fixes f g :: "'a::{ring_1_no_zero_divisors,semiring_char_0} fps"
  shows "fps_deriv f = fps_deriv g \<longleftrightarrow> (f = fps_const(f$0 - g$0) + g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (fps_deriv f = fps_deriv g) = (f = fps_const (f $ 0 - g $ 0) + g)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (fps_deriv f = fps_deriv g) = (f = fps_const (f $ 0 - g $ 0) + g)
[PROOF STEP]
have "fps_deriv f = fps_deriv g \<longleftrightarrow> fps_deriv (f - g) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (fps_deriv f = fps_deriv g) = (fps_deriv (f - g) = 0)
[PROOF STEP]
using fps_deriv_sub[of f g]
[PROOF STATE]
proof (prove)
using this:
fps_deriv (f - g) = fps_deriv f - fps_deriv g

goal (1 subgoal):
 1. (fps_deriv f = fps_deriv g) = (fps_deriv (f - g) = 0)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(fps_deriv f = fps_deriv g) = (fps_deriv (f - g) = 0)

goal (1 subgoal):
 1. (fps_deriv f = fps_deriv g) = (f = fps_const (f $ 0 - g $ 0) + g)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(fps_deriv f = fps_deriv g) = (fps_deriv (f - g) = 0)

goal (1 subgoal):
 1. (fps_deriv f = fps_deriv g) = (f = fps_const (f $ 0 - g $ 0) + g)
[PROOF STEP]
have "\<dots> \<longleftrightarrow> f - g = fps_const ((f - g) $ 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (fps_deriv (f - g) = 0) = (f - g = fps_const ((f - g) $ 0))
[PROOF STEP]
unfolding fps_deriv_eq_0_iff
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f - g = fps_const ((f - g) $ 0)) = (f - g = fps_const ((f - g) $ 0))
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
(fps_deriv (f - g) = 0) = (f - g = fps_const ((f - g) $ 0))

goal (1 subgoal):
 1. (fps_deriv f = fps_deriv g) = (f = fps_const (f $ 0 - g $ 0) + g)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(fps_deriv f = fps_deriv g) = (f - g = fps_const ((f - g) $ 0))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(fps_deriv f = fps_deriv g) = (f - g = fps_const ((f - g) $ 0))

goal (1 subgoal):
 1. (fps_deriv f = fps_deriv g) = (f = fps_const (f $ 0 - g $ 0) + g)
[PROOF STEP]
by (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
(fps_deriv f = fps_deriv g) = (f = fps_const (f $ 0 - g $ 0) + g)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma separated_in_real_card_bound:
  assumes "T \<subseteq> {a..(b::real)}" "d > 0" "\<And>x y. x \<in> T \<Longrightarrow> y \<in> T \<Longrightarrow> y > x \<Longrightarrow> y \<ge> x + d"
  shows "finite T" "card T \<le> nat (floor ((b-a)/d) + 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite T &&& card T \<le> nat (\<lfloor>(b - a) / d\<rfloor> + 1)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. finite T
 2. card T \<le> nat (\<lfloor>(b - a) / d\<rfloor> + 1)
[PROOF STEP]
define f where "f = (\<lambda>x. floor ((x-a) / d))"
[PROOF STATE]
proof (state)
this:
f = (\<lambda>x. \<lfloor>(x - a) / d\<rfloor>)

goal (2 subgoals):
 1. finite T
 2. card T \<le> nat (\<lfloor>(b - a) / d\<rfloor> + 1)
[PROOF STEP]
have "f`{a..b} \<subseteq> {0..floor ((b-a)/d)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f ` {a..b} \<subseteq> {0..\<lfloor>(b - a) / d\<rfloor>}
[PROOF STEP]
unfolding f_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. \<lfloor>(x - a) / d\<rfloor>) ` {a..b} \<subseteq> {0..\<lfloor>(b - a) / d\<rfloor>}
[PROOF STEP]
using \<open>d > 0\<close>
[PROOF STATE]
proof (prove)
using this:
0 < d

goal (1 subgoal):
 1. (\<lambda>x. \<lfloor>(x - a) / d\<rfloor>) ` {a..b} \<subseteq> {0..\<lfloor>(b - a) / d\<rfloor>}
[PROOF STEP]
by (auto simp add: floor_mono frac_le)
[PROOF STATE]
proof (state)
this:
f ` {a..b} \<subseteq> {0..\<lfloor>(b - a) / d\<rfloor>}

goal (2 subgoals):
 1. finite T
 2. card T \<le> nat (\<lfloor>(b - a) / d\<rfloor> + 1)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f ` {a..b} \<subseteq> {0..\<lfloor>(b - a) / d\<rfloor>}
[PROOF STEP]
have *: "f`T \<subseteq> {0..floor ((b-a)/d)}"
[PROOF STATE]
proof (prove)
using this:
f ` {a..b} \<subseteq> {0..\<lfloor>(b - a) / d\<rfloor>}

goal (1 subgoal):
 1. f ` T \<subseteq> {0..\<lfloor>(b - a) / d\<rfloor>}
[PROOF STEP]
using \<open>T \<subseteq> {a..b}\<close>
[PROOF STATE]
proof (prove)
using this:
f ` {a..b} \<subseteq> {0..\<lfloor>(b - a) / d\<rfloor>}
T \<subseteq> {a..b}

goal (1 subgoal):
 1. f ` T \<subseteq> {0..\<lfloor>(b - a) / d\<rfloor>}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f ` T \<subseteq> {0..\<lfloor>(b - a) / d\<rfloor>}

goal (2 subgoals):
 1. finite T
 2. card T \<le> nat (\<lfloor>(b - a) / d\<rfloor> + 1)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f ` T \<subseteq> {0..\<lfloor>(b - a) / d\<rfloor>}
[PROOF STEP]
have "finite (f`T)"
[PROOF STATE]
proof (prove)
using this:
f ` T \<subseteq> {0..\<lfloor>(b - a) / d\<rfloor>}

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

goal (2 subgoals):
 1. finite T
 2. card T \<le> nat (\<lfloor>(b - a) / d\<rfloor> + 1)
[PROOF STEP]
have "card (f`T) \<le> card {0..floor ((b-a)/d)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (f ` T) \<le> card {0..\<lfloor>(b - a) / d\<rfloor>}
[PROOF STEP]
apply (rule card_mono)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. finite {0..\<lfloor>(b - a) / d\<rfloor>}
 2. f ` T \<subseteq> {0..\<lfloor>(b - a) / d\<rfloor>}
[PROOF STEP]
using *
[PROOF STATE]
proof (prove)
using this:
f ` T \<subseteq> {0..\<lfloor>(b - a) / d\<rfloor>}

goal (2 subgoals):
 1. finite {0..\<lfloor>(b - a) / d\<rfloor>}
 2. f ` T \<subseteq> {0..\<lfloor>(b - a) / d\<rfloor>}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card (f ` T) \<le> card {0..\<lfloor>(b - a) / d\<rfloor>}

goal (2 subgoals):
 1. finite T
 2. card T \<le> nat (\<lfloor>(b - a) / d\<rfloor> + 1)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
card (f ` T) \<le> card {0..\<lfloor>(b - a) / d\<rfloor>}
[PROOF STEP]
have card_le: "card (f`T) \<le> nat (floor ((b-a)/d) + 1)"
[PROOF STATE]
proof (prove)
using this:
card (f ` T) \<le> card {0..\<lfloor>(b - a) / d\<rfloor>}

goal (1 subgoal):
 1. card (f ` T) \<le> nat (\<lfloor>(b - a) / d\<rfloor> + 1)
[PROOF STEP]
using card_atLeastAtMost_int
[PROOF STATE]
proof (prove)
using this:
card (f ` T) \<le> card {0..\<lfloor>(b - a) / d\<rfloor>}
card {?l..?u} = nat (?u - ?l + 1)

goal (1 subgoal):
 1. card (f ` T) \<le> nat (\<lfloor>(b - a) / d\<rfloor> + 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card (f ` T) \<le> nat (\<lfloor>(b - a) / d\<rfloor> + 1)

goal (2 subgoals):
 1. finite T
 2. card T \<le> nat (\<lfloor>(b - a) / d\<rfloor> + 1)
[PROOF STEP]
have *: "f x \<noteq> f y" if "y \<ge> x + d" for x y
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f x \<noteq> f y
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. f x \<noteq> f y
[PROOF STEP]
have "(y-a)/d \<ge> (x-a)/d + 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x - a) / d + 1 \<le> (y - a) / d
[PROOF STEP]
using \<open>d > 0\<close> that
[PROOF STATE]
proof (prove)
using this:
0 < d
x + d \<le> y

goal (1 subgoal):
 1. (x - a) / d + 1 \<le> (y - a) / d
[PROOF STEP]
by (auto simp add: divide_simps)
[PROOF STATE]
proof (state)
this:
(x - a) / d + 1 \<le> (y - a) / d

goal (1 subgoal):
 1. f x \<noteq> f y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(x - a) / d + 1 \<le> (y - a) / d
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(x - a) / d + 1 \<le> (y - a) / d

goal (1 subgoal):
 1. f x \<noteq> f y
[PROOF STEP]
unfolding f_def
[PROOF STATE]
proof (prove)
using this:
(x - a) / d + 1 \<le> (y - a) / d

goal (1 subgoal):
 1. \<lfloor>(x - a) / d\<rfloor> \<noteq> \<lfloor>(y - a) / d\<rfloor>
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
f x \<noteq> f y

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?x + d \<le> ?y \<Longrightarrow> f ?x \<noteq> f ?y

goal (2 subgoals):
 1. finite T
 2. card T \<le> nat (\<lfloor>(b - a) / d\<rfloor> + 1)
[PROOF STEP]
have "inj_on f T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on f T
[PROOF STEP]
unfolding inj_on_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>T. \<forall>y\<in>T. f x = f y \<longrightarrow> x = y
[PROOF STEP]
using * assms(3)
[PROOF STATE]
proof (prove)
using this:
?x + d \<le> ?y \<Longrightarrow> f ?x \<noteq> f ?y
\<lbrakk>?x \<in> T; ?y \<in> T; ?x < ?y\<rbrakk> \<Longrightarrow> ?x + d \<le> ?y

goal (1 subgoal):
 1. \<forall>x\<in>T. \<forall>y\<in>T. f x = f y \<longrightarrow> x = y
[PROOF STEP]
by (auto, metis not_less_iff_gr_or_eq)
[PROOF STATE]
proof (state)
this:
inj_on f T

goal (2 subgoals):
 1. finite T
 2. card T \<le> nat (\<lfloor>(b - a) / d\<rfloor> + 1)
[PROOF STEP]
show "finite T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite T
[PROOF STEP]
using \<open>finite (f`T)\<close> \<open>inj_on f T\<close> finite_image_iff
[PROOF STATE]
proof (prove)
using this:
finite (f ` T)
inj_on f T
inj_on ?f ?A \<Longrightarrow> finite (?f ` ?A) = finite ?A

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

goal (1 subgoal):
 1. card T \<le> nat (\<lfloor>(b - a) / d\<rfloor> + 1)
[PROOF STEP]
have "card T = card (f`T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card T = card (f ` T)
[PROOF STEP]
using \<open>inj_on f T\<close>
[PROOF STATE]
proof (prove)
using this:
inj_on f T

goal (1 subgoal):
 1. card T = card (f ` T)
[PROOF STEP]
by (simp add: card_image)
[PROOF STATE]
proof (state)
this:
card T = card (f ` T)

goal (1 subgoal):
 1. card T \<le> nat (\<lfloor>(b - a) / d\<rfloor> + 1)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
card T = card (f ` T)
[PROOF STEP]
show "card T \<le> nat (floor ((b-a)/d) + 1)"
[PROOF STATE]
proof (prove)
using this:
card T = card (f ` T)

goal (1 subgoal):
 1. card T \<le> nat (\<lfloor>(b - a) / d\<rfloor> + 1)
[PROOF STEP]
using card_le
[PROOF STATE]
proof (prove)
using this:
card T = card (f ` T)
card (f ` T) \<le> nat (\<lfloor>(b - a) / d\<rfloor> + 1)

goal (1 subgoal):
 1. card T \<le> nat (\<lfloor>(b - a) / d\<rfloor> + 1)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card T \<le> nat (\<lfloor>(b - a) / d\<rfloor> + 1)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma UNIV_tau_i_is_empty:
  assumes "finite (UNIV :: 'a set)" and "mono (\<tau> :: ('a set \<Rightarrow> 'a set))"
    and   "(\<forall>i :: nat. ((\<tau> :: 'a set \<Rightarrow> 'a set) ^^ (i + (1 :: nat)))(UNIV :: 'a set) \<subset> (\<tau> ^^ i) UNIV)"
  shows "(\<tau> ^^ (card (UNIV ::'a set))) (UNIV ::'a set) = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<tau> ^^ card UNIV) UNIV = {}
[PROOF STEP]
by (meson assms card_UNIV_tau_i_below_zero finite_card_zero_empty finite_subset subset_UNIV)


[STATEMENT]
lemma eheight_exp_reduce_bound:
  assumes "n > 1"
  shows   "eheight_exp n \<le> 4 / n * (\<Sum>k<n. eheight_exp k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}
[PROOF STEP]
have [simp]: "real (max a b) = max (real a) (real b)" for a b
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (max a b) = max (real a) (real b)
[PROOF STEP]
by (simp add: max_def)
[PROOF STATE]
proof (state)
this:
real (max ?a ?b) = max (real ?a) (real ?b)

goal (1 subgoal):
 1. eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}
[PROOF STEP]
let ?f = "\<lambda>(h1,h2). max h1 h2"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}
[PROOF STEP]
let ?p = "\<lambda>k. pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k))"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}
[PROOF STEP]
have "eheight_exp n = measure_pmf.expectation (eheight_rbst n) real"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eheight_exp n = measure_pmf.expectation (eheight_rbst n) real
[PROOF STEP]
by (simp add: eheight_exp_def)
[PROOF STATE]
proof (state)
this:
eheight_exp n = measure_pmf.expectation (eheight_rbst n) real

goal (1 subgoal):
 1. eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
eheight_exp n = measure_pmf.expectation (eheight_rbst n) real

goal (1 subgoal):
 1. eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}
[PROOF STEP]
have "\<dots> = 1 / real n * (\<Sum>k<n. measure_pmf.expectation
                                         (map_pmf (\<lambda>(h1,h2). 2 * max h1 h2) (?p k)) real)"
    (is "_ = _ * ?S")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation (eheight_rbst n) real = 1 / real n * (\<Sum>k<n. measure_pmf.expectation (map_pmf (\<lambda>(h1, h2). 2 * max h1 h2) (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k)))) real)
[PROOF STEP]
unfolding pair_pmf_def map_bind_pmf
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation (eheight_rbst n) real = 1 / real n * (\<Sum>k<n. measure_pmf.expectation (eheight_rbst k \<bind> (\<lambda>x. eheight_rbst (n - Suc k) \<bind> (\<lambda>xa. map_pmf (\<lambda>(h1, h2). 2 * max h1 h2) (return_pmf (x, xa))))) real)
[PROOF STEP]
by (subst eheight_rbst_reduce [OF assms], subst pmf_expectation_bind_pmf_of_set)
       (insert assms, auto simp: sum_divide_distrib divide_simps)
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (eheight_rbst n) real = 1 / real n * (\<Sum>k<n. measure_pmf.expectation (map_pmf (\<lambda>(h1, h2). 2 * max h1 h2) (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k)))) real)

goal (1 subgoal):
 1. eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (eheight_rbst n) real = 1 / real n * (\<Sum>k<n. measure_pmf.expectation (map_pmf (\<lambda>(h1, h2). 2 * max h1 h2) (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k)))) real)

goal (1 subgoal):
 1. eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}
[PROOF STEP]
have "?S = (\<Sum>k<n. measure_pmf.expectation (map_pmf (\<lambda>x. 2 * x) (map_pmf ?f (?p k))) real)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k<n. measure_pmf.expectation (map_pmf (\<lambda>(h1, h2). 2 * max h1 h2) (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k)))) real) = (\<Sum>k<n. measure_pmf.expectation (map_pmf ((*) 2) (map_pmf (\<lambda>(h1, h2). max h1 h2) (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k))))) real)
[PROOF STEP]
by (simp only: pmf.map_comp o_def case_prod_unfold)
[PROOF STATE]
proof (state)
this:
(\<Sum>k<n. measure_pmf.expectation (map_pmf (\<lambda>(h1, h2). 2 * max h1 h2) (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k)))) real) = (\<Sum>k<n. measure_pmf.expectation (map_pmf ((*) 2) (map_pmf (\<lambda>(h1, h2). max h1 h2) (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k))))) real)

goal (1 subgoal):
 1. eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k<n. measure_pmf.expectation (map_pmf (\<lambda>(h1, h2). 2 * max h1 h2) (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k)))) real) = (\<Sum>k<n. measure_pmf.expectation (map_pmf ((*) 2) (map_pmf (\<lambda>(h1, h2). max h1 h2) (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k))))) real)

goal (1 subgoal):
 1. eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}
[PROOF STEP]
have "\<dots> = 2 * (\<Sum>k<n. measure_pmf.expectation (map_pmf ?f (?p k)) real)" (is "_ = _ * ?S'")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k<n. measure_pmf.expectation (map_pmf ((*) 2) (map_pmf (\<lambda>(h1, h2). max h1 h2) (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k))))) real) = 2 * (\<Sum>k<n. measure_pmf.expectation (map_pmf (\<lambda>(h1, h2). max h1 h2) (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k)))) real)
[PROOF STEP]
by (subst integral_map_pmf) (simp add: sum_distrib_left)
[PROOF STATE]
proof (state)
this:
(\<Sum>k<n. measure_pmf.expectation (map_pmf ((*) 2) (map_pmf (\<lambda>(h1, h2). max h1 h2) (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k))))) real) = 2 * (\<Sum>k<n. measure_pmf.expectation (map_pmf (\<lambda>(h1, h2). max h1 h2) (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k)))) real)

goal (1 subgoal):
 1. eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k<n. measure_pmf.expectation (map_pmf ((*) 2) (map_pmf (\<lambda>(h1, h2). max h1 h2) (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k))))) real) = 2 * (\<Sum>k<n. measure_pmf.expectation (map_pmf (\<lambda>(h1, h2). max h1 h2) (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k)))) real)

goal (1 subgoal):
 1. eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}
[PROOF STEP]
have "?S' = (\<Sum>k<n. measure_pmf.expectation (?p k) (\<lambda>(h1,h2). max (real h1) (real h2)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k<n. measure_pmf.expectation (map_pmf (\<lambda>(h1, h2). max h1 h2) (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k)))) real) = (\<Sum>k<n. measure_pmf.expectation (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k))) (\<lambda>(h1, h2). max (real h1) (real h2)))
[PROOF STEP]
by (simp add: case_prod_unfold)
[PROOF STATE]
proof (state)
this:
(\<Sum>k<n. measure_pmf.expectation (map_pmf (\<lambda>(h1, h2). max h1 h2) (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k)))) real) = (\<Sum>k<n. measure_pmf.expectation (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k))) (\<lambda>(h1, h2). max (real h1) (real h2)))

goal (1 subgoal):
 1. eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k<n. measure_pmf.expectation (map_pmf (\<lambda>(h1, h2). max h1 h2) (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k)))) real) = (\<Sum>k<n. measure_pmf.expectation (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k))) (\<lambda>(h1, h2). max (real h1) (real h2)))

goal (1 subgoal):
 1. eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}
[PROOF STEP]
have "\<dots> \<le> (\<Sum>k<n. measure_pmf.expectation (?p k) (\<lambda>(h1,h2). real h1 + real h2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k<n. measure_pmf.expectation (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k))) (\<lambda>(h1, h2). max (real h1) (real h2))) \<le> (\<Sum>k<n. measure_pmf.expectation (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k))) (\<lambda>(h1, h2). real h1 + real h2))
[PROOF STEP]
unfolding integral_map_pmf case_prod_unfold
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k<n. measure_pmf.expectation (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k))) (\<lambda>p. max (real (fst p)) (real (snd p)))) \<le> (\<Sum>k<n. measure_pmf.expectation (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k))) (\<lambda>p. real (fst p) + real (snd p)))
[PROOF STEP]
by (intro sum_mono Bochner_Integration.integral_mono integrable_measure_pmf_finite) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>k<n. measure_pmf.expectation (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k))) (\<lambda>(h1, h2). max (real h1) (real h2))) \<le> (\<Sum>k<n. measure_pmf.expectation (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k))) (\<lambda>(h1, h2). real h1 + real h2))

goal (1 subgoal):
 1. eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k<n. measure_pmf.expectation (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k))) (\<lambda>(h1, h2). max (real h1) (real h2))) \<le> (\<Sum>k<n. measure_pmf.expectation (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k))) (\<lambda>(h1, h2). real h1 + real h2))

goal (1 subgoal):
 1. eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}
[PROOF STEP]
have "\<dots> = (\<Sum>k<n. eheight_exp k) + (\<Sum>k<n. eheight_exp (n - Suc k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k<n. measure_pmf.expectation (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k))) (\<lambda>(h1, h2). real h1 + real h2)) = sum eheight_exp {..<n} + (\<Sum>k<n. eheight_exp (n - Suc k))
[PROOF STEP]
by (subst expectation_add_pair_pmf) (auto simp: sum.distrib eheight_exp_def)
[PROOF STATE]
proof (state)
this:
(\<Sum>k<n. measure_pmf.expectation (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k))) (\<lambda>(h1, h2). real h1 + real h2)) = sum eheight_exp {..<n} + (\<Sum>k<n. eheight_exp (n - Suc k))

goal (1 subgoal):
 1. eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k<n. measure_pmf.expectation (pair_pmf (eheight_rbst k) (eheight_rbst (n - Suc k))) (\<lambda>(h1, h2). real h1 + real h2)) = sum eheight_exp {..<n} + (\<Sum>k<n. eheight_exp (n - Suc k))

goal (1 subgoal):
 1. eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}
[PROOF STEP]
have "(\<Sum>k<n. eheight_exp (n - Suc k)) = (\<Sum>k<n. eheight_exp k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k<n. eheight_exp (n - Suc k)) = sum eheight_exp {..<n}
[PROOF STEP]
by (intro sum.reindex_bij_witness[of _ "\<lambda>k. n - Suc k" "\<lambda>k. n - Suc k"]) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>k<n. eheight_exp (n - Suc k)) = sum eheight_exp {..<n}

goal (1 subgoal):
 1. eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k<n. eheight_exp (n - Suc k)) = sum eheight_exp {..<n}

goal (1 subgoal):
 1. eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}
[PROOF STEP]
have "1 / real n * (2 * (\<dots> + \<dots>)) = 4 / real n * \<dots>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 / real n * (2 * (sum eheight_exp {..<n} + sum eheight_exp {..<n})) = 4 / real n * sum eheight_exp {..<n}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 / real n * (2 * (sum eheight_exp {..<n} + sum eheight_exp {..<n})) = 4 / real n * sum eheight_exp {..<n}

goal (1 subgoal):
 1. eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<And>x y. x \<le> y \<Longrightarrow> 1 / real n * (2 * x) \<le> 1 / real n * (2 * y)) \<Longrightarrow> eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<And>x y. x \<le> y \<Longrightarrow> 1 / real n * (2 * x) \<le> 1 / real n * (2 * y)) \<Longrightarrow> eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}

goal (1 subgoal):
 1. eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
(\<And>x y. x \<le> y \<Longrightarrow> 1 / real n * (2 * x) \<le> 1 / real n * (2 * y)) \<Longrightarrow> eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}
1 < n

goal (1 subgoal):
 1. eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}
[PROOF STEP]
by (simp_all add: mult_left_mono divide_right_mono)
[PROOF STATE]
proof (state)
this:
eheight_exp n \<le> 4 / real n * sum eheight_exp {..<n}

goal:
No subgoals!
[PROOF STEP]
qed