[STATEMENT]
lemma linorder_sorted_wrt_list_of_set:
  assumes "linorder_on A R" "finite B" "B \<subseteq> A"
  shows   "set (sorted_wrt_list_of_set R B) = B" "distinct (sorted_wrt_list_of_set R B)"
          "sorted_wrt R (sorted_wrt_list_of_set R B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (sorted_wrt_list_of_set R B) = B &&& distinct (sorted_wrt_list_of_set R B) &&& Linorder_Relations.sorted_wrt R (sorted_wrt_list_of_set R B)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. set (sorted_wrt_list_of_set R B) = B
 2. distinct (sorted_wrt_list_of_set R B)
 3. Linorder_Relations.sorted_wrt R (sorted_wrt_list_of_set R B)
[PROOF STEP]
have "\<exists>!xs. set xs = B \<and> distinct xs \<and> sorted_wrt R xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>!xs. set xs = B \<and> distinct xs \<and> Linorder_Relations.sorted_wrt R xs
[PROOF STEP]
proof (rule ex_ex1I)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<exists>xs. set xs = B \<and> distinct xs \<and> Linorder_Relations.sorted_wrt R xs
 2. \<And>xs y. \<lbrakk>set xs = B \<and> distinct xs \<and> Linorder_Relations.sorted_wrt R xs; set y = B \<and> distinct y \<and> Linorder_Relations.sorted_wrt R y\<rbrakk> \<Longrightarrow> xs = y
[PROOF STEP]
show "\<exists>xs. set xs = B \<and> distinct xs \<and> sorted_wrt R xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>xs. set xs = B \<and> distinct xs \<and> Linorder_Relations.sorted_wrt R xs
[PROOF STEP]
by (rule linorder_sorted_wrt_exists assms)+
[PROOF STATE]
proof (state)
this:
\<exists>xs. set xs = B \<and> distinct xs \<and> Linorder_Relations.sorted_wrt R xs

goal (1 subgoal):
 1. \<And>xs y. \<lbrakk>set xs = B \<and> distinct xs \<and> Linorder_Relations.sorted_wrt R xs; set y = B \<and> distinct y \<and> Linorder_Relations.sorted_wrt R y\<rbrakk> \<Longrightarrow> xs = y
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>xs y. \<lbrakk>set xs = B \<and> distinct xs \<and> Linorder_Relations.sorted_wrt R xs; set y = B \<and> distinct y \<and> Linorder_Relations.sorted_wrt R y\<rbrakk> \<Longrightarrow> xs = y
[PROOF STEP]
fix xs ys
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>xs y. \<lbrakk>set xs = B \<and> distinct xs \<and> Linorder_Relations.sorted_wrt R xs; set y = B \<and> distinct y \<and> Linorder_Relations.sorted_wrt R y\<rbrakk> \<Longrightarrow> xs = y
[PROOF STEP]
assume "set xs = B \<and> distinct xs \<and> sorted_wrt R xs"
                     "set ys = B \<and> distinct ys \<and> sorted_wrt R ys"
[PROOF STATE]
proof (state)
this:
set xs = B \<and> distinct xs \<and> Linorder_Relations.sorted_wrt R xs
set ys = B \<and> distinct ys \<and> Linorder_Relations.sorted_wrt R ys

goal (1 subgoal):
 1. \<And>xs y. \<lbrakk>set xs = B \<and> distinct xs \<and> Linorder_Relations.sorted_wrt R xs; set y = B \<and> distinct y \<and> Linorder_Relations.sorted_wrt R y\<rbrakk> \<Longrightarrow> xs = y
[PROOF STEP]
thus "xs = ys"
[PROOF STATE]
proof (prove)
using this:
set xs = B \<and> distinct xs \<and> Linorder_Relations.sorted_wrt R xs
set ys = B \<and> distinct ys \<and> Linorder_Relations.sorted_wrt R ys

goal (1 subgoal):
 1. xs = ys
[PROOF STEP]
by (intro sorted_wrt_linorder_unique[OF assms(1)]) (auto simp: set_eq_iff_mset_eq_distinct)
[PROOF STATE]
proof (state)
this:
xs = ys

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>!xs. set xs = B \<and> distinct xs \<and> Linorder_Relations.sorted_wrt R xs

goal (3 subgoals):
 1. set (sorted_wrt_list_of_set R B) = B
 2. distinct (sorted_wrt_list_of_set R B)
 3. Linorder_Relations.sorted_wrt R (sorted_wrt_list_of_set R B)
[PROOF STEP]
from theI'[OF this]
[PROOF STATE]
proof (chain)
picking this:
set (THE x. set x = B \<and> distinct x \<and> Linorder_Relations.sorted_wrt R x) = B \<and> distinct (THE x. set x = B \<and> distinct x \<and> Linorder_Relations.sorted_wrt R x) \<and> Linorder_Relations.sorted_wrt R (THE x. set x = B \<and> distinct x \<and> Linorder_Relations.sorted_wrt R x)
[PROOF STEP]
show  "set (sorted_wrt_list_of_set R B) = B"
    "distinct (sorted_wrt_list_of_set R B)" "sorted_wrt R (sorted_wrt_list_of_set R B)"
[PROOF STATE]
proof (prove)
using this:
set (THE x. set x = B \<and> distinct x \<and> Linorder_Relations.sorted_wrt R x) = B \<and> distinct (THE x. set x = B \<and> distinct x \<and> Linorder_Relations.sorted_wrt R x) \<and> Linorder_Relations.sorted_wrt R (THE x. set x = B \<and> distinct x \<and> Linorder_Relations.sorted_wrt R x)

goal (1 subgoal):
 1. set (sorted_wrt_list_of_set R B) = B &&& distinct (sorted_wrt_list_of_set R B) &&& Linorder_Relations.sorted_wrt R (sorted_wrt_list_of_set R B)
[PROOF STEP]
by (simp_all add: sorted_wrt_list_of_set_def \<open>finite B\<close>)
[PROOF STATE]
proof (state)
this:
set (sorted_wrt_list_of_set R B) = B
distinct (sorted_wrt_list_of_set R B)
Linorder_Relations.sorted_wrt R (sorted_wrt_list_of_set R B)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma open_segment_bound1:
  assumes "x \<in> open_segment a b"
  shows "norm (x - a) < norm (b - a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (x - a) < norm (b - a)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. norm (x - a) < norm (b - a)
[PROOF STEP]
obtain u where "x = (1 - u) *\<^sub>R a + u *\<^sub>R b" "0 < u" "u < 1" "a \<noteq> b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>u. \<lbrakk>x = (1 - u) *\<^sub>R a + u *\<^sub>R b; 0 < u; u < 1; a \<noteq> b\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
x \<in> open_segment a b

goal (1 subgoal):
 1. (\<And>u. \<lbrakk>x = (1 - u) *\<^sub>R a + u *\<^sub>R b; 0 < u; u < 1; a \<noteq> b\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp add: open_segment_image_interval split: if_split_asm)
[PROOF STATE]
proof (state)
this:
x = (1 - u) *\<^sub>R a + u *\<^sub>R b
0 < u
u < 1
a \<noteq> b

goal (1 subgoal):
 1. norm (x - a) < norm (b - a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x = (1 - u) *\<^sub>R a + u *\<^sub>R b
0 < u
u < 1
a \<noteq> b
[PROOF STEP]
show "norm (x - a) < norm (b - a)"
[PROOF STATE]
proof (prove)
using this:
x = (1 - u) *\<^sub>R a + u *\<^sub>R b
0 < u
u < 1
a \<noteq> b

goal (1 subgoal):
 1. norm (x - a) < norm (b - a)
[PROOF STEP]
apply clarify
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < u; u < 1; a \<noteq> b; x = (1 - u) *\<^sub>R a + u *\<^sub>R b\<rbrakk> \<Longrightarrow> norm ((1 - u) *\<^sub>R a + u *\<^sub>R b - a) < norm (b - a)
[PROOF STEP]
apply (auto simp: algebra_simps)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < u; u < 1; a \<noteq> b; x + u *\<^sub>R a = a + u *\<^sub>R b\<rbrakk> \<Longrightarrow> norm (u *\<^sub>R b - u *\<^sub>R a) < norm (b - a)
[PROOF STEP]
apply (simp add: scaleR_diff_right [symmetric])
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
norm (x - a) < norm (b - a)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma eval_fds_diff:
  assumes "fds_converges f s" "fds_converges g s"
  shows   "eval_fds (f - g) s = eval_fds f s - eval_fds g s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eval_fds (f - g) s = eval_fds f s - eval_fds g s
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. eval_fds (f - g) s = eval_fds f s - eval_fds g s
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
fds_converges f s
fds_converges g s
[PROOF STEP]
have "(\<lambda>n. fds_nth f n / nat_power n s) sums eval_fds f s"
                  "(\<lambda>n. fds_nth g n / nat_power n s) sums eval_fds g s"
[PROOF STATE]
proof (prove)
using this:
fds_converges f s
fds_converges g s

goal (1 subgoal):
 1. (\<lambda>n. fds_nth f n / nat_power n s) sums eval_fds f s &&& (\<lambda>n. fds_nth g n / nat_power n s) sums eval_fds g s
[PROOF STEP]
by (simp_all add: fds_converges_def sums_iff eval_fds_def)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. fds_nth f n / nat_power n s) sums eval_fds f s
(\<lambda>n. fds_nth g n / nat_power n s) sums eval_fds g s

goal (1 subgoal):
 1. eval_fds (f - g) s = eval_fds f s - eval_fds g s
[PROOF STEP]
from sums_diff[OF this]
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>n. fds_nth f n / nat_power n s - fds_nth g n / nat_power n s) sums (eval_fds f s - eval_fds g s)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. fds_nth f n / nat_power n s - fds_nth g n / nat_power n s) sums (eval_fds f s - eval_fds g s)

goal (1 subgoal):
 1. eval_fds (f - g) s = eval_fds f s - eval_fds g s
[PROOF STEP]
by (simp add: eval_fds_def sums_iff diff_divide_distrib)
[PROOF STATE]
proof (state)
this:
eval_fds (f - g) s = eval_fds f s - eval_fds g s

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma nn_integral_erlang_ith_moment:
  fixes k i :: nat and l :: real
  assumes [arith]: "0 < l"
  shows "(\<integral>\<^sup>+ x. ennreal (erlang_density k l x * x ^ i) \<partial>lborel) = fact (k + i) / (fact k * l ^ i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (erlang_density k l x * x ^ i) \<partial>lborel = ennreal (fact (k + i) / (fact k * l ^ i))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (erlang_density k l x * x ^ i) \<partial>lborel = ennreal (fact (k + i) / (fact k * l ^ i))
[PROOF STEP]
have eq: "\<And>x. indicator {0..} (x / l) = indicator {0..} x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. indicator {0..} (x / l) = indicator {0..} x
[PROOF STEP]
by (simp add: field_simps split: split_indicator)
[PROOF STATE]
proof (state)
this:
indicator {0..} (?x / l) = indicator {0..} ?x

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (erlang_density k l x * x ^ i) \<partial>lborel = ennreal (fact (k + i) / (fact k * l ^ i))
[PROOF STEP]
have "(\<integral>\<^sup>+ x. ennreal (erlang_density k l x * x^i) \<partial>lborel) =
    (\<integral>\<^sup>+x. (l/(fact k * l^i)) * (ennreal ((l*x)^(k+i) * exp (- (l*x))) * indicator {0 ..} x) \<partial>lborel)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (erlang_density k l x * x ^ i) \<partial>lborel = \<integral>\<^sup>+ x. ennreal (l / (fact k * l ^ i)) * (ennreal ((l * x) ^ (k + i) * exp (- (l * x))) * indicator {0..} x) \<partial>lborel
[PROOF STEP]
by (intro nn_integral_cong)
       (auto simp: erlang_density_def power_mult_distrib power_add ennreal_mult'[symmetric] split: split_indicator)
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. ennreal (erlang_density k l x * x ^ i) \<partial>lborel = \<integral>\<^sup>+ x. ennreal (l / (fact k * l ^ i)) * (ennreal ((l * x) ^ (k + i) * exp (- (l * x))) * indicator {0..} x) \<partial>lborel

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (erlang_density k l x * x ^ i) \<partial>lborel = ennreal (fact (k + i) / (fact k * l ^ i))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. ennreal (erlang_density k l x * x ^ i) \<partial>lborel = \<integral>\<^sup>+ x. ennreal (l / (fact k * l ^ i)) * (ennreal ((l * x) ^ (k + i) * exp (- (l * x))) * indicator {0..} x) \<partial>lborel

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (erlang_density k l x * x ^ i) \<partial>lborel = ennreal (fact (k + i) / (fact k * l ^ i))
[PROOF STEP]
have "\<dots> = (l/(fact k * l^i)) * (\<integral>\<^sup>+x. ennreal ((l*x)^(k+i) * exp (- (l*x))) * indicator {0 ..} x \<partial>lborel)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (l / (fact k * l ^ i)) * (ennreal ((l * x) ^ (k + i) * exp (- (l * x))) * indicator {0..} x) \<partial>lborel = ennreal (l / (fact k * l ^ i)) * (\<integral>\<^sup>+x\<in>{0..}. ennreal ((l * x) ^ (k + i) * exp (- (l * x)))\<partial>lborel)
[PROOF STEP]
by (intro nn_integral_cmult) auto
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. ennreal (l / (fact k * l ^ i)) * (ennreal ((l * x) ^ (k + i) * exp (- (l * x))) * indicator {0..} x) \<partial>lborel = ennreal (l / (fact k * l ^ i)) * (\<integral>\<^sup>+x\<in>{0..}. ennreal ((l * x) ^ (k + i) * exp (- (l * x)))\<partial>lborel)

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (erlang_density k l x * x ^ i) \<partial>lborel = ennreal (fact (k + i) / (fact k * l ^ i))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. ennreal (l / (fact k * l ^ i)) * (ennreal ((l * x) ^ (k + i) * exp (- (l * x))) * indicator {0..} x) \<partial>lborel = ennreal (l / (fact k * l ^ i)) * (\<integral>\<^sup>+x\<in>{0..}. ennreal ((l * x) ^ (k + i) * exp (- (l * x)))\<partial>lborel)

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (erlang_density k l x * x ^ i) \<partial>lborel = ennreal (fact (k + i) / (fact k * l ^ i))
[PROOF STEP]
have "\<dots> = ennreal (l/(fact k * l^i)) * ((1/l) * (\<integral>\<^sup>+x. ennreal (x^(k+i) * exp (- x)) * indicator {0 ..} x \<partial>lborel))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ennreal (l / (fact k * l ^ i)) * (\<integral>\<^sup>+x\<in>{0..}. ennreal ((l * x) ^ (k + i) * exp (- (l * x)))\<partial>lborel) = ennreal (l / (fact k * l ^ i)) * (ennreal (1 / l) * (\<integral>\<^sup>+x\<in>{0..}. ennreal (x ^ (k + i) * exp (- x))\<partial>lborel))
[PROOF STEP]
by (subst nn_integral_real_affine[where c="1 / l" and t=0]) (auto simp: field_simps eq)
[PROOF STATE]
proof (state)
this:
ennreal (l / (fact k * l ^ i)) * (\<integral>\<^sup>+x\<in>{0..}. ennreal ((l * x) ^ (k + i) * exp (- (l * x)))\<partial>lborel) = ennreal (l / (fact k * l ^ i)) * (ennreal (1 / l) * (\<integral>\<^sup>+x\<in>{0..}. ennreal (x ^ (k + i) * exp (- x))\<partial>lborel))

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (erlang_density k l x * x ^ i) \<partial>lborel = ennreal (fact (k + i) / (fact k * l ^ i))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ennreal (l / (fact k * l ^ i)) * (\<integral>\<^sup>+x\<in>{0..}. ennreal ((l * x) ^ (k + i) * exp (- (l * x)))\<partial>lborel) = ennreal (l / (fact k * l ^ i)) * (ennreal (1 / l) * (\<integral>\<^sup>+x\<in>{0..}. ennreal (x ^ (k + i) * exp (- x))\<partial>lborel))

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (erlang_density k l x * x ^ i) \<partial>lborel = ennreal (fact (k + i) / (fact k * l ^ i))
[PROOF STEP]
have "\<dots> = fact (k + i) / (fact k * l ^ i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ennreal (l / (fact k * l ^ i)) * (ennreal (1 / l) * (\<integral>\<^sup>+x\<in>{0..}. ennreal (x ^ (k + i) * exp (- x))\<partial>lborel)) = ennreal (fact (k + i) / (fact k * l ^ i))
[PROOF STEP]
by (subst nn_intergal_power_times_exp_Ici) (auto simp: ennreal_mult'[symmetric])
[PROOF STATE]
proof (state)
this:
ennreal (l / (fact k * l ^ i)) * (ennreal (1 / l) * (\<integral>\<^sup>+x\<in>{0..}. ennreal (x ^ (k + i) * exp (- x))\<partial>lborel)) = ennreal (fact (k + i) / (fact k * l ^ i))

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (erlang_density k l x * x ^ i) \<partial>lborel = ennreal (fact (k + i) / (fact k * l ^ i))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<integral>\<^sup>+ x. ennreal (erlang_density k l x * x ^ i) \<partial>lborel = ennreal (fact (k + i) / (fact k * l ^ i))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<integral>\<^sup>+ x. ennreal (erlang_density k l x * x ^ i) \<partial>lborel = ennreal (fact (k + i) / (fact k * l ^ i))

goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (erlang_density k l x * x ^ i) \<partial>lborel = ennreal (fact (k + i) / (fact k * l ^ i))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
\<integral>\<^sup>+ x. ennreal (erlang_density k l x * x ^ i) \<partial>lborel = ennreal (fact (k + i) / (fact k * l ^ i))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma continuous_on_imp_absolutely_integrable_on:
  fixes f::"real \<Rightarrow> 'a::banach"
  shows "continuous_on {a..b} f \<Longrightarrow>
    norm (integral {a..b} f) \<le> integral {a..b} (\<lambda>x. norm (f x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous_on {a..b} f \<Longrightarrow> norm (integral {a..b} f) \<le> integral {a..b} (\<lambda>x. norm (f x))
[PROOF STEP]
by (intro integral_norm_bound_integral integrable_continuous_real continuous_on_norm) auto


[STATEMENT]
lemma integral_normal_moment_even:
  "integral\<^sup>L lborel (\<lambda>x. normal_density \<mu> \<sigma> x * (x - \<mu>)^(2 * k)) = fact (2 * k) / ((2 / \<sigma>\<^sup>2)^k * fact k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LBINT x. normal_density \<mu> \<sigma> x * (x - \<mu>) ^ (2 * k) = fact (2 * k) / ((2 / \<sigma>\<^sup>2) ^ k * fact k)
[PROOF STEP]
using normal_moment_even
[PROOF STATE]
proof (prove)
using this:
has_bochner_integral lborel (\<lambda>x. normal_density \<mu> \<sigma> x * (x - \<mu>) ^ (2 * k)) (fact (2 * k) / ((2 / \<sigma>\<^sup>2) ^ k * fact k))

goal (1 subgoal):
 1. LBINT x. normal_density \<mu> \<sigma> x * (x - \<mu>) ^ (2 * k) = fact (2 * k) / ((2 / \<sigma>\<^sup>2) ^ k * fact k)
[PROOF STEP]
by (rule has_bochner_integral_integral_eq)


[STATEMENT]
lemma exp_sq_mtx_diag: "exp (sq_mtx_diag f) = (\<d>\<i>\<a>\<g> i. exp (f i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. exp (sq_mtx_diag f) = (\<d>\<i>\<a>\<g> i. exp (f i))
[PROOF STEP]
apply(unfold exp_def, simp add: power_sq_mtx_diag scaleR_sq_mtx_diag)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>n. \<d>\<i>\<a>\<g> i. inverse (fact n) * f i ^ n) = (\<d>\<i>\<a>\<g> i. \<Sum>n. inverse (fact n) * f i ^ n)
[PROOF STEP]
apply(rule suminf_sq_mtx_diag)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i. (\<lambda>n. inverse (fact n) * f i ^ n) sums (\<Sum>n. inverse (fact n) * f i ^ n)
[PROOF STEP]
using exp_converges[of "f _"]
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. f ?uu3 ^ n /\<^sub>R fact n) sums exp (f ?uu3)

goal (1 subgoal):
 1. \<forall>i. (\<lambda>n. inverse (fact n) * f i ^ n) sums (\<Sum>n. inverse (fact n) * f i ^ n)
[PROOF STEP]
unfolding sums_def LIMSEQ_iff exp_def
[PROOF STATE]
proof (prove)
using this:
\<forall>r>0. \<exists>no. \<forall>n\<ge>no. \<parallel>(\<Sum>n<n. f ?uu3 ^ n /\<^sub>R fact n) - (\<Sum>n. f ?uu3 ^ n /\<^sub>R fact n)\<parallel> < r

goal (1 subgoal):
 1. \<forall>i r. 0 < r \<longrightarrow> (\<exists>no. \<forall>n\<ge>no. \<parallel>(\<Sum>n<n. inverse (fact n) * f i ^ n) - (\<Sum>n. inverse (fact n) * f i ^ n)\<parallel> < r)
[PROOF STEP]
by force


[STATEMENT]
lemma list_slice_aux_nth: "
 \<And>m xs. m < n \<Longrightarrow> (list_slice_aux xs k n) ! m = (xs \<up> (m * k) \<down> k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>m xs. m < n \<Longrightarrow> list_slice_aux xs k n ! m = xs \<up> (m * k) \<down> k
[PROOF STEP]
apply (induct n)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>m xs. m < 0 \<Longrightarrow> list_slice_aux xs k 0 ! m = xs \<up> (m * k) \<down> k
 2. \<And>n m xs. \<lbrakk>\<And>m xs. m < n \<Longrightarrow> list_slice_aux xs k n ! m = xs \<up> (m * k) \<down> k; m < Suc n\<rbrakk> \<Longrightarrow> list_slice_aux xs k (Suc n) ! m = xs \<up> (m * k) \<down> k
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n m xs. \<lbrakk>\<And>m xs. m < n \<Longrightarrow> list_slice_aux xs k n ! m = xs \<up> (m * k) \<down> k; m < Suc n\<rbrakk> \<Longrightarrow> list_slice_aux xs k (Suc n) ! m = xs \<up> (m * k) \<down> k
[PROOF STEP]
apply (simp add: nth_Cons' diff_mult_distrib)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma recurrent_subset_rel_incl:
  assumes "A \<subseteq> B"
  shows "recurrent_subset A \<subseteq> recurrent_subset B"
        "recurrent_subset_infty A \<subseteq> recurrent_subset_infty B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. recurrent_subset A \<subseteq> recurrent_subset B &&& recurrent_subset_infty A \<subseteq> recurrent_subset_infty B
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. recurrent_subset A \<subseteq> recurrent_subset B
 2. recurrent_subset_infty A \<subseteq> recurrent_subset_infty B
[PROOF STEP]
show "recurrent_subset A \<subseteq> recurrent_subset B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. recurrent_subset A \<subseteq> recurrent_subset B
[PROOF STEP]
unfolding recurrent_subset_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Union>n\<in>{1..}. A \<inter> (T ^^ n) -` A) \<subseteq> (\<Union>n\<in>{1..}. B \<inter> (T ^^ n) -` B)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
A \<subseteq> B

goal (1 subgoal):
 1. (\<Union>n\<in>{1..}. A \<inter> (T ^^ n) -` A) \<subseteq> (\<Union>n\<in>{1..}. B \<inter> (T ^^ n) -` B)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
recurrent_subset A \<subseteq> recurrent_subset B

goal (1 subgoal):
 1. recurrent_subset_infty A \<subseteq> recurrent_subset_infty B
[PROOF STEP]
show "recurrent_subset_infty A \<subseteq> recurrent_subset_infty B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. recurrent_subset_infty A \<subseteq> recurrent_subset_infty B
[PROOF STEP]
apply (auto, subst recurrent_subset_infty_inf_returns)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> recurrent_subset_infty A \<Longrightarrow> x \<in> B \<and> infinite {n. (T ^^ n) x \<in> B}
[PROOF STEP]
using assms recurrent_subset_incl(2) infinite_nat_iff_unbounded_le recurrent_subset_infty_inf_returns
[PROOF STATE]
proof (prove)
using this:
A \<subseteq> B
recurrent_subset_infty ?A \<subseteq> ?A
infinite ?S = (\<forall>m. \<exists>n\<ge>m. n \<in> ?S)
(?x \<in> recurrent_subset_infty ?A) = (?x \<in> ?A \<and> infinite {n. (T ^^ n) ?x \<in> ?A})

goal (1 subgoal):
 1. \<And>x. x \<in> recurrent_subset_infty A \<Longrightarrow> x \<in> B \<and> infinite {n. (T ^^ n) x \<in> B}
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
recurrent_subset_infty A \<subseteq> recurrent_subset_infty B

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma range_sbintrunc: "range ((signed_take_bit :: nat \<Rightarrow> int \<Rightarrow> int) n) = {i. - (2 ^ n) \<le> i \<and> i < 2 ^ n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. range (signed_take_bit n) = {i. - (2 ^ n) \<le> i \<and> i < 2 ^ n}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. range (signed_take_bit n) = {i. - (2 ^ n) \<le> i \<and> i < 2 ^ n}
[PROOF STEP]
have \<open>surj (\<lambda>k::int. k + 2 ^ n)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. surj (\<lambda>k. k + 2 ^ n)
[PROOF STEP]
by (rule surjI [of _ \<open>(\<lambda>k. k - 2 ^ n)\<close>]) simp
[PROOF STATE]
proof (state)
this:
surj (\<lambda>k. k + 2 ^ n)

goal (1 subgoal):
 1. range (signed_take_bit n) = {i. - (2 ^ n) \<le> i \<and> i < 2 ^ n}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
surj (\<lambda>k. k + 2 ^ n)

goal (1 subgoal):
 1. range (signed_take_bit n) = {i. - (2 ^ n) \<le> i \<and> i < 2 ^ n}
[PROOF STEP]
have \<open>(signed_take_bit :: nat \<Rightarrow> int \<Rightarrow> int) n = ((\<lambda>k. k - 2 ^ n) \<circ> take_bit (Suc n) \<circ> (\<lambda>k. k + 2 ^ n))\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. signed_take_bit n = (\<lambda>k. k - 2 ^ n) \<circ> take_bit (Suc n) \<circ> (\<lambda>k. k + 2 ^ n)
[PROOF STEP]
by (simp add: sbintrunc_eq_take_bit fun_eq_iff)
[PROOF STATE]
proof (state)
this:
signed_take_bit n = (\<lambda>k. k - 2 ^ n) \<circ> take_bit (Suc n) \<circ> (\<lambda>k. k + 2 ^ n)

goal (1 subgoal):
 1. range (signed_take_bit n) = {i. - (2 ^ n) \<le> i \<and> i < 2 ^ n}
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
surj (\<lambda>k. k + 2 ^ n)
signed_take_bit n = (\<lambda>k. k - 2 ^ n) \<circ> take_bit (Suc n) \<circ> (\<lambda>k. k + 2 ^ n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
surj (\<lambda>k. k + 2 ^ n)
signed_take_bit n = (\<lambda>k. k - 2 ^ n) \<circ> take_bit (Suc n) \<circ> (\<lambda>k. k + 2 ^ n)

goal (1 subgoal):
 1. range (signed_take_bit n) = {i. - (2 ^ n) \<le> i \<and> i < 2 ^ n}
[PROOF STEP]
apply (simp only: fun.set_map range_bintrunc)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>surj (\<lambda>k. k + 2 ^ n); signed_take_bit n = (\<lambda>k. k - 2 ^ n) \<circ> take_bit (Suc n) \<circ> (\<lambda>k. k + 2 ^ n)\<rbrakk> \<Longrightarrow> (\<lambda>k. k - 2 ^ n) ` {i. 0 \<le> i \<and> i < 2 ^ Suc n} = {i. - (2 ^ n) \<le> i \<and> i < 2 ^ n}
[PROOF STEP]
apply (auto simp add: image_iff)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>surj (\<lambda>k. k + 2 ^ n); signed_take_bit n = (\<lambda>k. k - 2 ^ n) \<circ> take_bit (Suc n) \<circ> (\<lambda>k. k + 2 ^ n); - (2 ^ n) \<le> x; x < 2 ^ n\<rbrakk> \<Longrightarrow> \<exists>xa\<ge>0. xa < 2 * 2 ^ n \<and> x = xa - 2 ^ n
[PROOF STEP]
apply presburger
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
range (signed_take_bit n) = {i. - (2 ^ n) \<le> i \<and> i < 2 ^ n}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ket_0_norm:
  shows "\<parallel>ket_0\<parallel> = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>ket_0\<parallel> = 1
[PROOF STEP]
using unit_cpx_vec_length
[PROOF STATE]
proof (prove)
using this:
?i < ?n \<Longrightarrow> \<parallel>unit_vec ?n ?i\<parallel> = 1

goal (1 subgoal):
 1. \<parallel>ket_0\<parallel> = 1
[PROOF STEP]
unfolding ket_0_def
[PROOF STATE]
proof (prove)
using this:
?i < ?n \<Longrightarrow> \<parallel>unit_vec ?n ?i\<parallel> = 1

goal (1 subgoal):
 1. \<parallel>unit_vec 2 0\<parallel> = 1
[PROOF STEP]
by simp


[STATEMENT]
theorem "!! (y::int) (z::int) (n::int). 3 dvd z ==> 2 dvd (y::int) ==>
  (\<exists>(x::int).  2*x =  y) & (\<exists>(k::int). 3*k = z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>y z n. \<lbrakk>3 dvd z; even y\<rbrakk> \<Longrightarrow> (\<exists>x. 2 * x = y) \<and> (\<exists>k. 3 * k = z)
[PROOF STEP]
by presburger


[STATEMENT]
lemma ennreal_pmf_bind: "pmf (bind_pmf N f) i = (\<integral>\<^sup>+x. pmf (f x) i \<partial>measure_pmf N)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ennreal (pmf (N \<bind> f) i) = \<integral>\<^sup>+ x. ennreal (pmf (f x) i) \<partial>measure_pmf N
[PROOF STEP]
unfolding pmf.rep_eq bind_pmf.rep_eq
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ennreal (Sigma_Algebra.measure (measure_pmf N \<bind> measure_pmf \<circ> f \<circ> id) {i}) = \<integral>\<^sup>+ x. ennreal (measure_pmf.prob (f x) {i}) \<partial>measure_pmf N
[PROOF STEP]
by (auto simp: measure_pmf.measure_bind[where N="count_space UNIV"] measure_subprob measure_nonneg
           intro!: nn_integral_eq_integral[symmetric] measure_pmf.integrable_const_bound[where B=1])


[STATEMENT]
lemma rk_AA'C :
  assumes "rk {A, C, P} = 3" and "rk {A, A'} = 2" and "rk {A, A', P} = 2"
  shows "rk {A, A', C} \<ge> 3"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 3 \<le> rk {A, A', C}
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 3 \<le> rk {A, A', C}
[PROOF STEP]
have f1:"rk {A, C, A', P} \<ge> 3"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 3 \<le> rk {A, C, A', P}
[PROOF STEP]
using assms(1) matroid_ax_2
[PROOF STATE]
proof (prove)
using this:
rk {A, C, P} = 3
?X \<subseteq> ?Y \<longrightarrow> rk ?X \<le> rk ?Y

goal (1 subgoal):
 1. 3 \<le> rk {A, C, A', P}
[PROOF STEP]
by (metis insert_commute subset_insertI)
[PROOF STATE]
proof (state)
this:
3 \<le> rk {A, C, A', P}

goal (1 subgoal):
 1. 3 \<le> rk {A, A', C}
[PROOF STEP]
have "rk {A, C, A', P} + rk {A, A'} \<le> rk {A, A', C} + rk {A, A', P}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rk {A, C, A', P} + rk {A, A'} \<le> rk {A, A', C} + rk {A, A', P}
[PROOF STEP]
using matroid_ax_3_alt[of "{A, A'}" "{A, A', C}" "{A, A', P}"]
[PROOF STATE]
proof (prove)
using this:
{A, A'} \<subseteq> {A, A', C} \<inter> {A, A', P} \<Longrightarrow> rk ({A, A', C} \<union> {A, A', P}) + rk {A, A'} \<le> rk {A, A', C} + rk {A, A', P}

goal (1 subgoal):
 1. rk {A, C, A', P} + rk {A, A'} \<le> rk {A, A', C} + rk {A, A', P}
[PROOF STEP]
by (simp add: insert_commute)
[PROOF STATE]
proof (state)
this:
rk {A, C, A', P} + rk {A, A'} \<le> rk {A, A', C} + rk {A, A', P}

goal (1 subgoal):
 1. 3 \<le> rk {A, A', C}
[PROOF STEP]
thus "rk {A, A', C} \<ge> 3"
[PROOF STATE]
proof (prove)
using this:
rk {A, C, A', P} + rk {A, A'} \<le> rk {A, A', C} + rk {A, A', P}

goal (1 subgoal):
 1. 3 \<le> rk {A, A', C}
[PROOF STEP]
using f1 assms(2) assms(3)
[PROOF STATE]
proof (prove)
using this:
rk {A, C, A', P} + rk {A, A'} \<le> rk {A, A', C} + rk {A, A', P}
3 \<le> rk {A, C, A', P}
rk {A, A'} = 2
rk {A, A', P} = 2

goal (1 subgoal):
 1. 3 \<le> rk {A, A', C}
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
3 \<le> rk {A, A', C}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma norm_sq_mtx_def2: "\<parallel>A\<parallel> = Sup {\<parallel>A *\<^sub>V x\<parallel> |x. \<parallel>x\<parallel> = 1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>A\<parallel> = Sup {\<parallel>A *\<^sub>V x\<parallel> |x. \<parallel>x\<parallel> = 1}
[PROOF STEP]
unfolding norm_sq_mtx_def op_norm_def sq_mtx_vec_mult_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Sup {\<parallel>to_vec A *v x\<parallel> |x. \<parallel>x\<parallel> = 1} = Sup {\<parallel>map_fun to_vec id (*v) A x\<parallel> |x. \<parallel>x\<parallel> = 1}
[PROOF STEP]
by simp


[STATEMENT]
lemma map_subseqs: "map (map f) (subseqs xs) = subseqs (map f xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map (map f) (subseqs xs) = subseqs (map f xs)
[PROOF STEP]
proof (induct xs)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. map (map f) (subseqs []) = subseqs (map f [])
 2. \<And>a xs. map (map f) (subseqs xs) = subseqs (map f xs) \<Longrightarrow> map (map f) (subseqs (a # xs)) = subseqs (map f (a # xs))
[PROOF STEP]
case (Cons x xs)
[PROOF STATE]
proof (state)
this:
map (map f) (subseqs xs) = subseqs (map f xs)

goal (2 subgoals):
 1. map (map f) (subseqs []) = subseqs (map f [])
 2. \<And>a xs. map (map f) (subseqs xs) = subseqs (map f xs) \<Longrightarrow> map (map f) (subseqs (a # xs)) = subseqs (map f (a # xs))
[PROOF STEP]
have "map (Cons (f x)) (map (map f) (subseqs xs)) = map (map f) (map (Cons x) (subseqs xs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map ((#) (f x)) (map (map f) (subseqs xs)) = map (map f) (map ((#) x) (subseqs xs))
[PROOF STEP]
by (induct "subseqs xs") auto
[PROOF STATE]
proof (state)
this:
map ((#) (f x)) (map (map f) (subseqs xs)) = map (map f) (map ((#) x) (subseqs xs))

goal (2 subgoals):
 1. map (map f) (subseqs []) = subseqs (map f [])
 2. \<And>a xs. map (map f) (subseqs xs) = subseqs (map f xs) \<Longrightarrow> map (map f) (subseqs (a # xs)) = subseqs (map f (a # xs))
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
map ((#) (f x)) (map (map f) (subseqs xs)) = map (map f) (map ((#) x) (subseqs xs))

goal (1 subgoal):
 1. map (map f) (subseqs (x # xs)) = subseqs (map f (x # xs))
[PROOF STEP]
by (simp add: Let_def Cons)
[PROOF STATE]
proof (state)
this:
map (map f) (subseqs (x # xs)) = subseqs (map f (x # xs))

goal (1 subgoal):
 1. map (map f) (subseqs []) = subseqs (map f [])
[PROOF STEP]
qed simp


[STATEMENT]
lemma r01_r01_to_r01'_well_formed:
  assumes "0 < r1" "r1 < 1"
      and "0 < r2" "r2 < 1"
    shows "biexp01_well_formed (r01_r01_to_r01' (r1,r2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. biexp01_well_formed (r01_r01_to_r01' (r1, r2))
[PROOF STEP]
using biexp01_well_formed_comb[of "r01_binary_expansion' (fst (r1,r2))" "r01_binary_expansion' (snd (r1,r2))"] r01_binary_expansion_well_formed[of r1] r01_binary_expansion_well_formed[of r2] assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>biexp01_well_formed (r01_binary_expansion' (fst (r1, r2))); biexp01_well_formed (r01_binary_expansion' (snd (r1, r2)))\<rbrakk> \<Longrightarrow> biexp01_well_formed (\<lambda>n. if even n then r01_binary_expansion' (fst (r1, r2)) (n div 2) else r01_binary_expansion' (snd (r1, r2)) ((n - 1) div 2))
\<lbrakk>0 < r1; r1 < 1\<rbrakk> \<Longrightarrow> biexp01_well_formed (r01_binary_expansion' r1)
\<lbrakk>0 < r2; r2 < 1\<rbrakk> \<Longrightarrow> biexp01_well_formed (r01_binary_expansion' r2)
0 < r1
r1 < 1
0 < r2
r2 < 1

goal (1 subgoal):
 1. biexp01_well_formed (r01_r01_to_r01' (r1, r2))
[PROOF STEP]
by (auto simp add: r01_r01_to_r01'_def)


[STATEMENT]
theorem prefix_append:
  "prefix xs (ys @ zs) = (prefix xs ys \<or> (\<exists>us. xs = ys @ us \<and> prefix us zs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prefix xs (ys @ zs) = (prefix xs ys \<or> (\<exists>us. xs = ys @ us \<and> prefix us zs))
[PROOF STEP]
apply (induct zs rule: rev_induct)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. prefix xs (ys @ []) = (prefix xs ys \<or> (\<exists>us. xs = ys @ us \<and> prefix us []))
 2. \<And>x xsa. prefix xs (ys @ xsa) = (prefix xs ys \<or> (\<exists>us. xs = ys @ us \<and> prefix us xsa)) \<Longrightarrow> prefix xs (ys @ xsa @ [x]) = (prefix xs ys \<or> (\<exists>us. xs = ys @ us \<and> prefix us (xsa @ [x])))
[PROOF STEP]
apply force
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x xsa. prefix xs (ys @ xsa) = (prefix xs ys \<or> (\<exists>us. xs = ys @ us \<and> prefix us xsa)) \<Longrightarrow> prefix xs (ys @ xsa @ [x]) = (prefix xs ys \<or> (\<exists>us. xs = ys @ us \<and> prefix us (xsa @ [x])))
[PROOF STEP]
apply (simp flip: append_assoc)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x xsa. prefix xs (ys @ xsa) = (prefix xs ys \<or> (\<exists>us. xs = ys @ us \<and> prefix us xsa)) \<Longrightarrow> (xs = (ys @ xsa) @ [x] \<or> prefix xs ys \<or> (\<exists>us. xs = ys @ us \<and> prefix us xsa)) = (prefix xs ys \<or> (\<exists>us. xs = ys @ us \<and> (us = xsa @ [x] \<or> prefix us xsa)))
[PROOF STEP]
apply (metis append_eq_appendI)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma has_contour_integral_subpath:
  assumes f: "f contour_integrable_on g" and g: "valid_path g"
      and uv: "u \<in> {0..1}" "v \<in> {0..1}" "u \<le> v"
    shows "(f has_contour_integral  integral {u..v} (\<lambda>x. f(g x) * vector_derivative g (at x)))
           (subpath u v g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f has_contour_integral integral {u..v} (\<lambda>x. f (g x) * vector_derivative g (at x))) (subpath u v g)
[PROOF STEP]
proof (cases "v=u")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. v = u \<Longrightarrow> (f has_contour_integral integral {u..v} (\<lambda>x. f (g x) * vector_derivative g (at x))) (subpath u v g)
 2. v \<noteq> u \<Longrightarrow> (f has_contour_integral integral {u..v} (\<lambda>x. f (g x) * vector_derivative g (at x))) (subpath u v g)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
v = u

goal (2 subgoals):
 1. v = u \<Longrightarrow> (f has_contour_integral integral {u..v} (\<lambda>x. f (g x) * vector_derivative g (at x))) (subpath u v g)
 2. v \<noteq> u \<Longrightarrow> (f has_contour_integral integral {u..v} (\<lambda>x. f (g x) * vector_derivative g (at x))) (subpath u v g)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
v = u
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
v = u

goal (1 subgoal):
 1. (f has_contour_integral integral {u..v} (\<lambda>x. f (g x) * vector_derivative g (at x))) (subpath u v g)
[PROOF STEP]
using f
[PROOF STATE]
proof (prove)
using this:
v = u
f contour_integrable_on g

goal (1 subgoal):
 1. (f has_contour_integral integral {u..v} (\<lambda>x. f (g x) * vector_derivative g (at x))) (subpath u v g)
[PROOF STEP]
by (simp add: contour_integrable_on_def subpath_def has_contour_integral)
[PROOF STATE]
proof (state)
this:
(f has_contour_integral integral {u..v} (\<lambda>x. f (g x) * vector_derivative g (at x))) (subpath u v g)

goal (1 subgoal):
 1. v \<noteq> u \<Longrightarrow> (f has_contour_integral integral {u..v} (\<lambda>x. f (g x) * vector_derivative g (at x))) (subpath u v g)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. v \<noteq> u \<Longrightarrow> (f has_contour_integral integral {u..v} (\<lambda>x. f (g x) * vector_derivative g (at x))) (subpath u v g)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
v \<noteq> u

goal (1 subgoal):
 1. v \<noteq> u \<Longrightarrow> (f has_contour_integral integral {u..v} (\<lambda>x. f (g x) * vector_derivative g (at x))) (subpath u v g)
[PROOF STEP]
obtain S where S: "\<And>x. x \<in> {0..1} - S \<Longrightarrow> g differentiable at x" and fs: "finite S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>S. \<lbrakk>\<And>x. x \<in> {0..1} - S \<Longrightarrow> g differentiable at x; finite S\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using g
[PROOF STATE]
proof (prove)
using this:
valid_path g

goal (1 subgoal):
 1. (\<And>S. \<lbrakk>\<And>x. x \<in> {0..1} - S \<Longrightarrow> g differentiable at x; finite S\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding piecewise_C1_differentiable_on_def C1_differentiable_on_eq valid_path_def
[PROOF STATE]
proof (prove)
using this:
continuous_on {0..1} g \<and> (\<exists>S. finite S \<and> (\<forall>x\<in>{0..1} - S. g differentiable at x) \<and> continuous_on ({0..1} - S) (\<lambda>x. vector_derivative g (at x)))

goal (1 subgoal):
 1. (\<And>S. \<lbrakk>\<And>x. x \<in> {0..1} - S \<Longrightarrow> g differentiable at x; finite S\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
?x \<in> {0..1} - S \<Longrightarrow> g differentiable at ?x
finite S

goal (1 subgoal):
 1. v \<noteq> u \<Longrightarrow> (f has_contour_integral integral {u..v} (\<lambda>x. f (g x) * vector_derivative g (at x))) (subpath u v g)
[PROOF STEP]
have \<section>: "(\<lambda>t. f (g t) * vector_derivative g (at t)) integrable_on {u..v}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>t. f (g t) * vector_derivative g (at t)) integrable_on {u..v}
[PROOF STEP]
using contour_integrable_on f integrable_on_subinterval uv
[PROOF STATE]
proof (prove)
using this:
(?f contour_integrable_on ?g) = ((\<lambda>t. ?f (?g t) * vector_derivative ?g (at t)) integrable_on {0..1})
f contour_integrable_on g
\<lbrakk>?f integrable_on ?S; {?a..?b} \<subseteq> ?S\<rbrakk> \<Longrightarrow> ?f integrable_on {?a..?b}
u \<in> {0..1}
v \<in> {0..1}
u \<le> v

goal (1 subgoal):
 1. (\<lambda>t. f (g t) * vector_derivative g (at t)) integrable_on {u..v}
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
(\<lambda>t. f (g t) * vector_derivative g (at t)) integrable_on {u..v}

goal (1 subgoal):
 1. v \<noteq> u \<Longrightarrow> (f has_contour_integral integral {u..v} (\<lambda>x. f (g x) * vector_derivative g (at x))) (subpath u v g)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>t. f (g t) * vector_derivative g (at t)) integrable_on {u..v}
[PROOF STEP]
have *: "((\<lambda>x. f (g ((v - u) * x + u)) * vector_derivative g (at ((v - u) * x + u)))
            has_integral (1 / (v - u)) * integral {u..v} (\<lambda>t. f (g t) * vector_derivative g (at t)))
           {0..1}"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>t. f (g t) * vector_derivative g (at t)) integrable_on {u..v}

goal (1 subgoal):
 1. ((\<lambda>x. f (g ((v - u) * x + u)) * vector_derivative g (at ((v - u) * x + u))) has_integral complex_of_real (1 / (v - u)) * integral {u..v} (\<lambda>t. f (g t) * vector_derivative g (at t))) {0..1}
[PROOF STEP]
using uv False
[PROOF STATE]
proof (prove)
using this:
(\<lambda>t. f (g t) * vector_derivative g (at t)) integrable_on {u..v}
u \<in> {0..1}
v \<in> {0..1}
u \<le> v
v \<noteq> u

goal (1 subgoal):
 1. ((\<lambda>x. f (g ((v - u) * x + u)) * vector_derivative g (at ((v - u) * x + u))) has_integral complex_of_real (1 / (v - u)) * integral {u..v} (\<lambda>t. f (g t) * vector_derivative g (at t))) {0..1}
[PROOF STEP]
unfolding has_integral_integral
[PROOF STATE]
proof (prove)
using this:
((\<lambda>t. f (g t) * vector_derivative g (at t)) has_integral integral {u..v} (\<lambda>t. f (g t) * vector_derivative g (at t))) {u..v}
u \<in> {0..1}
v \<in> {0..1}
u \<le> v
v \<noteq> u

goal (1 subgoal):
 1. ((\<lambda>x. f (g ((v - u) * x + u)) * vector_derivative g (at ((v - u) * x + u))) has_integral complex_of_real (1 / (v - u)) * integral {u..v} (\<lambda>t. f (g t) * vector_derivative g (at t))) {0..1}
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>((\<lambda>t. f (g t) * vector_derivative g (at t)) has_integral integral {u..v} (\<lambda>t. f (g t) * vector_derivative g (at t))) {u..v}; 0 \<le> u; v \<le> 1; u \<le> v; v \<noteq> u\<rbrakk> \<Longrightarrow> ((\<lambda>x. f (g ((v - u) * x + u)) * vector_derivative g (at ((v - u) * x + u))) has_integral integral {u..v} (\<lambda>t. f (g t) * vector_derivative g (at t)) / (complex_of_real v - complex_of_real u)) {0..1}
[PROOF STEP]
apply (drule has_integral_affinity [where m="v-u" and c=u, simplified])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>0 \<le> u; v \<le> 1; u \<le> v; v \<noteq> u\<rbrakk> \<Longrightarrow> v \<noteq> u
 2. \<lbrakk>0 \<le> u; v \<le> 1; u \<le> v; v \<noteq> u; ((\<lambda>x. f (g ((v - u) * x + u)) * vector_derivative g (at ((v - u) * x + u))) has_integral (1 / \<bar>v - u\<bar>) *\<^sub>R integral {u..v} (\<lambda>t. f (g t) * vector_derivative g (at t))) ((\<lambda>x. x / (v - u) - u / (v - u)) ` {u..v})\<rbrakk> \<Longrightarrow> ((\<lambda>x. f (g ((v - u) * x + u)) * vector_derivative g (at ((v - u) * x + u))) has_integral integral {u..v} (\<lambda>t. f (g t) * vector_derivative g (at t)) / (complex_of_real v - complex_of_real u)) {0..1}
[PROOF STEP]
apply (simp_all add: image_affinity_atLeastAtMost_div_diff scaleR_conv_of_real)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 \<le> u; v \<le> 1; u \<le> v; v \<noteq> u; ((\<lambda>x. f (g ((v - u) * x + u)) * vector_derivative g (at ((v - u) * x + u))) has_integral integral {u..v} (\<lambda>t. f (g t) * vector_derivative g (at t)) / (complex_of_real v - complex_of_real u)) {0..v / (v - u) - u / (v - u)}\<rbrakk> \<Longrightarrow> ((\<lambda>x. f (g ((v - u) * x + u)) * vector_derivative g (at ((v - u) * x + u))) has_integral integral {u..v} (\<lambda>t. f (g t) * vector_derivative g (at t)) / (complex_of_real v - complex_of_real u)) {0..1}
[PROOF STEP]
apply (simp add: divide_simps)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
((\<lambda>x. f (g ((v - u) * x + u)) * vector_derivative g (at ((v - u) * x + u))) has_integral complex_of_real (1 / (v - u)) * integral {u..v} (\<lambda>t. f (g t) * vector_derivative g (at t))) {0..1}

goal (1 subgoal):
 1. v \<noteq> u \<Longrightarrow> (f has_contour_integral integral {u..v} (\<lambda>x. f (g x) * vector_derivative g (at x))) (subpath u v g)
[PROOF STEP]
have vd: "vector_derivative (\<lambda>x. g ((v-u) * x + u)) (at x) = (v-u) *\<^sub>R vector_derivative g (at ((v-u) * x + u))"
    if "x \<in> {0..1}"  "x \<notin> (\<lambda>t. (v-u) *\<^sub>R t + u) -` S" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vector_derivative (\<lambda>x. g ((v - u) * x + u)) (at x) = (v - u) *\<^sub>R vector_derivative g (at ((v - u) * x + u))
[PROOF STEP]
proof (rule vector_derivative_at [OF vector_diff_chain_at [simplified o_def]])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ((\<lambda>x. (v - u) * x + u) has_vector_derivative v - u) (at x)
 2. (g has_vector_derivative vector_derivative g (at ((v - u) * x + u))) (at ((v - u) * x + u))
[PROOF STEP]
show "((\<lambda>x. (v - u) * x + u) has_vector_derivative v - u) (at x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. (v - u) * x + u) has_vector_derivative v - u) (at x)
[PROOF STEP]
by (intro derivative_eq_intros | simp)+
[PROOF STATE]
proof (state)
this:
((\<lambda>x. (v - u) * x + u) has_vector_derivative v - u) (at x)

goal (1 subgoal):
 1. (g has_vector_derivative vector_derivative g (at ((v - u) * x + u))) (at ((v - u) * x + u))
[PROOF STEP]
qed (use S uv mult_left_le [of x "v-u"] that in \<open>auto simp: vector_derivative_works\<close>)
[PROOF STATE]
proof (state)
this:
\<lbrakk>?x \<in> {0..1}; ?x \<notin> (\<lambda>t. (v - u) *\<^sub>R t + u) -` S\<rbrakk> \<Longrightarrow> vector_derivative (\<lambda>x. g ((v - u) * x + u)) (at ?x) = (v - u) *\<^sub>R vector_derivative g (at ((v - u) * ?x + u))

goal (1 subgoal):
 1. v \<noteq> u \<Longrightarrow> (f has_contour_integral integral {u..v} (\<lambda>x. f (g x) * vector_derivative g (at x))) (subpath u v g)
[PROOF STEP]
have fin: "finite ((\<lambda>t. (v - u) *\<^sub>R t + u) -` S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite ((\<lambda>t. (v - u) *\<^sub>R t + u) -` S)
[PROOF STEP]
using fs
[PROOF STATE]
proof (prove)
using this:
finite S

goal (1 subgoal):
 1. finite ((\<lambda>t. (v - u) *\<^sub>R t + u) -` S)
[PROOF STEP]
by (auto simp: inj_on_def False finite_vimageI)
[PROOF STATE]
proof (state)
this:
finite ((\<lambda>t. (v - u) *\<^sub>R t + u) -` S)

goal (1 subgoal):
 1. v \<noteq> u \<Longrightarrow> (f has_contour_integral integral {u..v} (\<lambda>x. f (g x) * vector_derivative g (at x))) (subpath u v g)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f has_contour_integral integral {u..v} (\<lambda>x. f (g x) * vector_derivative g (at x))) (subpath u v g)
[PROOF STEP]
unfolding subpath_def has_contour_integral
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. f (g ((v - u) * x + u)) * vector_derivative (\<lambda>x. g ((v - u) * x + u)) (at x)) has_integral integral {u..v} (\<lambda>x. f (g x) * vector_derivative g (at x))) {0..1}
[PROOF STEP]
apply (rule has_integral_spike_finite [OF fin])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x. x \<in> {0..1} - (\<lambda>t. (v - u) *\<^sub>R t + u) -` S \<Longrightarrow> f (g ((v - u) * x + u)) * vector_derivative (\<lambda>x. g ((v - u) * x + u)) (at x) = ?f x
 2. (?f has_integral integral {u..v} (\<lambda>x. f (g x) * vector_derivative g (at x))) {0..1}
[PROOF STEP]
using has_integral_cmul [OF *, where c = "v-u"] fs assms
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. (v - u) *\<^sub>R (f (g ((v - u) * x + u)) * vector_derivative g (at ((v - u) * x + u)))) has_integral (v - u) *\<^sub>R (complex_of_real (1 / (v - u)) * integral {u..v} (\<lambda>t. f (g t) * vector_derivative g (at t)))) {0..1}
finite S
f contour_integrable_on g
valid_path g
u \<in> {0..1}
v \<in> {0..1}
u \<le> v

goal (2 subgoals):
 1. \<And>x. x \<in> {0..1} - (\<lambda>t. (v - u) *\<^sub>R t + u) -` S \<Longrightarrow> f (g ((v - u) * x + u)) * vector_derivative (\<lambda>x. g ((v - u) * x + u)) (at x) = ?f x
 2. (?f has_integral integral {u..v} (\<lambda>x. f (g x) * vector_derivative g (at x))) {0..1}
[PROOF STEP]
by (auto simp: False vd scaleR_conv_of_real)
[PROOF STATE]
proof (state)
this:
(f has_contour_integral integral {u..v} (\<lambda>x. f (g x) * vector_derivative g (at x))) (subpath u v g)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem expectation_rqs_cost: "measure_pmf.expectation (rqs_cost n) real = rqs_cost_exp n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation (rqs_cost n) real = rqs_cost_exp n
[PROOF STEP]
proof (induction n rule: rqs_cost.induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. measure_pmf.expectation (rqs_cost 0) real = rqs_cost_exp 0
 2. \<And>n. \<lbrakk>\<And>x. x \<in> set_pmf (pmf_of_set {..n}) \<Longrightarrow> measure_pmf.expectation (rqs_cost x) real = rqs_cost_exp x; \<And>x xa. \<lbrakk>x \<in> set_pmf (pmf_of_set {..n}); xa \<in> set_pmf (rqs_cost x)\<rbrakk> \<Longrightarrow> measure_pmf.expectation (rqs_cost (n - x)) real = rqs_cost_exp (n - x)\<rbrakk> \<Longrightarrow> measure_pmf.expectation (rqs_cost (Suc n)) real = rqs_cost_exp (Suc n)
[PROOF STEP]
case (2 n)
[PROOF STATE]
proof (state)
this:
?x \<in> set_pmf (pmf_of_set {..n}) \<Longrightarrow> measure_pmf.expectation (rqs_cost ?x) real = rqs_cost_exp ?x
\<lbrakk>?x \<in> set_pmf (pmf_of_set {..n}); ?xa \<in> set_pmf (rqs_cost ?x)\<rbrakk> \<Longrightarrow> measure_pmf.expectation (rqs_cost (n - ?x)) real = rqs_cost_exp (n - ?x)

goal (2 subgoals):
 1. measure_pmf.expectation (rqs_cost 0) real = rqs_cost_exp 0
 2. \<And>n. \<lbrakk>\<And>x. x \<in> set_pmf (pmf_of_set {..n}) \<Longrightarrow> measure_pmf.expectation (rqs_cost x) real = rqs_cost_exp x; \<And>x xa. \<lbrakk>x \<in> set_pmf (pmf_of_set {..n}); xa \<in> set_pmf (rqs_cost x)\<rbrakk> \<Longrightarrow> measure_pmf.expectation (rqs_cost (n - x)) real = rqs_cost_exp (n - x)\<rbrakk> \<Longrightarrow> measure_pmf.expectation (rqs_cost (Suc n)) real = rqs_cost_exp (Suc n)
[PROOF STEP]
note IH = "2.IH"
[PROOF STATE]
proof (state)
this:
?x \<in> set_pmf (pmf_of_set {..n}) \<Longrightarrow> measure_pmf.expectation (rqs_cost ?x) real = rqs_cost_exp ?x
\<lbrakk>?x \<in> set_pmf (pmf_of_set {..n}); ?xa \<in> set_pmf (rqs_cost ?x)\<rbrakk> \<Longrightarrow> measure_pmf.expectation (rqs_cost (n - ?x)) real = rqs_cost_exp (n - ?x)

goal (2 subgoals):
 1. measure_pmf.expectation (rqs_cost 0) real = rqs_cost_exp 0
 2. \<And>n. \<lbrakk>\<And>x. x \<in> set_pmf (pmf_of_set {..n}) \<Longrightarrow> measure_pmf.expectation (rqs_cost x) real = rqs_cost_exp x; \<And>x xa. \<lbrakk>x \<in> set_pmf (pmf_of_set {..n}); xa \<in> set_pmf (rqs_cost x)\<rbrakk> \<Longrightarrow> measure_pmf.expectation (rqs_cost (n - x)) real = rqs_cost_exp (n - x)\<rbrakk> \<Longrightarrow> measure_pmf.expectation (rqs_cost (Suc n)) real = rqs_cost_exp (Suc n)
[PROOF STEP]
have "measure_pmf.expectation (rqs_cost (Suc n)) real =
          (\<Sum>a\<le>n. inverse (real (Suc n)) *
              measure_pmf.expectation (rqs_cost a \<bind> (\<lambda>aa. rqs_cost (n - a) \<bind>
                 (\<lambda>b. return_pmf (n + aa + b)))) real)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation (rqs_cost (Suc n)) real = (\<Sum>a\<le>n. inverse (real (Suc n)) * measure_pmf.expectation (rqs_cost a \<bind> (\<lambda>aa. rqs_cost (n - a) \<bind> (\<lambda>b. return_pmf (n + aa + b)))) real)
[PROOF STEP]
unfolding rqs_cost.simps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation (pmf_of_set {..n} \<bind> (\<lambda>i. rqs_cost i \<bind> (\<lambda>a. rqs_cost (n - i) \<bind> (\<lambda>b. return_pmf (n + a + b))))) real = (\<Sum>a\<le>n. inverse (real (Suc n)) * measure_pmf.expectation (rqs_cost a \<bind> (\<lambda>aa. rqs_cost (n - a) \<bind> (\<lambda>b. return_pmf (n + aa + b)))) real)
[PROOF STEP]
by (subst pmf_expectation_bind_pmf_of_set) auto
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (rqs_cost (Suc n)) real = (\<Sum>a\<le>n. inverse (real (Suc n)) * measure_pmf.expectation (rqs_cost a \<bind> (\<lambda>aa. rqs_cost (n - a) \<bind> (\<lambda>b. return_pmf (n + aa + b)))) real)

goal (2 subgoals):
 1. measure_pmf.expectation (rqs_cost 0) real = rqs_cost_exp 0
 2. \<And>n. \<lbrakk>\<And>x. x \<in> set_pmf (pmf_of_set {..n}) \<Longrightarrow> measure_pmf.expectation (rqs_cost x) real = rqs_cost_exp x; \<And>x xa. \<lbrakk>x \<in> set_pmf (pmf_of_set {..n}); xa \<in> set_pmf (rqs_cost x)\<rbrakk> \<Longrightarrow> measure_pmf.expectation (rqs_cost (n - x)) real = rqs_cost_exp (n - x)\<rbrakk> \<Longrightarrow> measure_pmf.expectation (rqs_cost (Suc n)) real = rqs_cost_exp (Suc n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (rqs_cost (Suc n)) real = (\<Sum>a\<le>n. inverse (real (Suc n)) * measure_pmf.expectation (rqs_cost a \<bind> (\<lambda>aa. rqs_cost (n - a) \<bind> (\<lambda>b. return_pmf (n + aa + b)))) real)

goal (2 subgoals):
 1. measure_pmf.expectation (rqs_cost 0) real = rqs_cost_exp 0
 2. \<And>n. \<lbrakk>\<And>x. x \<in> set_pmf (pmf_of_set {..n}) \<Longrightarrow> measure_pmf.expectation (rqs_cost x) real = rqs_cost_exp x; \<And>x xa. \<lbrakk>x \<in> set_pmf (pmf_of_set {..n}); xa \<in> set_pmf (rqs_cost x)\<rbrakk> \<Longrightarrow> measure_pmf.expectation (rqs_cost (n - x)) real = rqs_cost_exp (n - x)\<rbrakk> \<Longrightarrow> measure_pmf.expectation (rqs_cost (Suc n)) real = rqs_cost_exp (Suc n)
[PROOF STEP]
have "\<dots> = (\<Sum>i\<le>n. inverse (real (Suc n)) * (real n + rqs_cost_exp i + rqs_cost_exp (n - i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>a\<le>n. inverse (real (Suc n)) * measure_pmf.expectation (rqs_cost a \<bind> (\<lambda>aa. rqs_cost (n - a) \<bind> (\<lambda>b. return_pmf (n + aa + b)))) real) = (\<Sum>i\<le>n. inverse (real (Suc n)) * (real n + rqs_cost_exp i + rqs_cost_exp (n - i)))
[PROOF STEP]
proof (intro sum.cong refl, goal_cases)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {..n} \<Longrightarrow> inverse (real (Suc n)) * measure_pmf.expectation (rqs_cost x \<bind> (\<lambda>aa. rqs_cost (n - x) \<bind> (\<lambda>b. return_pmf (n + aa + b)))) real = inverse (real (Suc n)) * (real n + rqs_cost_exp x + rqs_cost_exp (n - x))
[PROOF STEP]
case (1 i)
[PROOF STATE]
proof (state)
this:
i \<in> {..n}

goal (1 subgoal):
 1. \<And>x. x \<in> {..n} \<Longrightarrow> inverse (real (Suc n)) * measure_pmf.expectation (rqs_cost x \<bind> (\<lambda>aa. rqs_cost (n - x) \<bind> (\<lambda>b. return_pmf (n + aa + b)))) real = inverse (real (Suc n)) * (real n + rqs_cost_exp x + rqs_cost_exp (n - x))
[PROOF STEP]
have "rqs_cost i \<bind> (\<lambda>a. rqs_cost (n - i) \<bind> (\<lambda>b. return_pmf (n + a + b))) =
            map_pmf (\<lambda>(a,b). n + a + b) (pair_pmf (rqs_cost i) (rqs_cost (n - i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rqs_cost i \<bind> (\<lambda>a. rqs_cost (n - i) \<bind> (\<lambda>b. return_pmf (n + a + b))) = map_pmf (\<lambda>(a, b). n + a + b) (pair_pmf (rqs_cost i) (rqs_cost (n - i)))
[PROOF STEP]
by (simp add: pair_pmf_def map_bind_pmf)
[PROOF STATE]
proof (state)
this:
rqs_cost i \<bind> (\<lambda>a. rqs_cost (n - i) \<bind> (\<lambda>b. return_pmf (n + a + b))) = map_pmf (\<lambda>(a, b). n + a + b) (pair_pmf (rqs_cost i) (rqs_cost (n - i)))

goal (1 subgoal):
 1. \<And>x. x \<in> {..n} \<Longrightarrow> inverse (real (Suc n)) * measure_pmf.expectation (rqs_cost x \<bind> (\<lambda>aa. rqs_cost (n - x) \<bind> (\<lambda>b. return_pmf (n + aa + b)))) real = inverse (real (Suc n)) * (real n + rqs_cost_exp x + rqs_cost_exp (n - x))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
rqs_cost i \<bind> (\<lambda>a. rqs_cost (n - i) \<bind> (\<lambda>b. return_pmf (n + a + b))) = map_pmf (\<lambda>(a, b). n + a + b) (pair_pmf (rqs_cost i) (rqs_cost (n - i)))

goal (1 subgoal):
 1. \<And>x. x \<in> {..n} \<Longrightarrow> inverse (real (Suc n)) * measure_pmf.expectation (rqs_cost x \<bind> (\<lambda>aa. rqs_cost (n - x) \<bind> (\<lambda>b. return_pmf (n + aa + b)))) real = inverse (real (Suc n)) * (real n + rqs_cost_exp x + rqs_cost_exp (n - x))
[PROOF STEP]
have "measure_pmf.expectation \<dots> real =
                 measure_pmf.expectation (pair_pmf (rqs_cost i) (rqs_cost (n - i)))
                   (\<lambda>z. real n + (real (fst z) + real (snd z)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation (map_pmf (\<lambda>(a, b). n + a + b) (pair_pmf (rqs_cost i) (rqs_cost (n - i)))) real = measure_pmf.expectation (pair_pmf (rqs_cost i) (rqs_cost (n - i))) (\<lambda>z. real n + (real (fst z) + real (snd z)))
[PROOF STEP]
by (subst integral_map_pmf) (simp add: case_prod_unfold add_ac)
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (map_pmf (\<lambda>(a, b). n + a + b) (pair_pmf (rqs_cost i) (rqs_cost (n - i)))) real = measure_pmf.expectation (pair_pmf (rqs_cost i) (rqs_cost (n - i))) (\<lambda>z. real n + (real (fst z) + real (snd z)))

goal (1 subgoal):
 1. \<And>x. x \<in> {..n} \<Longrightarrow> inverse (real (Suc n)) * measure_pmf.expectation (rqs_cost x \<bind> (\<lambda>aa. rqs_cost (n - x) \<bind> (\<lambda>b. return_pmf (n + aa + b)))) real = inverse (real (Suc n)) * (real n + rqs_cost_exp x + rqs_cost_exp (n - x))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (map_pmf (\<lambda>(a, b). n + a + b) (pair_pmf (rqs_cost i) (rqs_cost (n - i)))) real = measure_pmf.expectation (pair_pmf (rqs_cost i) (rqs_cost (n - i))) (\<lambda>z. real n + (real (fst z) + real (snd z)))

goal (1 subgoal):
 1. \<And>x. x \<in> {..n} \<Longrightarrow> inverse (real (Suc n)) * measure_pmf.expectation (rqs_cost x \<bind> (\<lambda>aa. rqs_cost (n - x) \<bind> (\<lambda>b. return_pmf (n + aa + b)))) real = inverse (real (Suc n)) * (real n + rqs_cost_exp x + rqs_cost_exp (n - x))
[PROOF STEP]
have "\<dots> = real n + measure_pmf.expectation (pair_pmf (rqs_cost i) (rqs_cost (n - i)))
                      (\<lambda>z. real (fst z) + real (snd z))" (is "_ = _ + ?A")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation (pair_pmf (rqs_cost i) (rqs_cost (n - i))) (\<lambda>z. real n + (real (fst z) + real (snd z))) = real n + measure_pmf.expectation (pair_pmf (rqs_cost i) (rqs_cost (n - i))) (\<lambda>z. real (fst z) + real (snd z))
[PROOF STEP]
by (subst Bochner_Integration.integral_add) (auto intro!: integrable_measure_pmf_finite)
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (pair_pmf (rqs_cost i) (rqs_cost (n - i))) (\<lambda>z. real n + (real (fst z) + real (snd z))) = real n + measure_pmf.expectation (pair_pmf (rqs_cost i) (rqs_cost (n - i))) (\<lambda>z. real (fst z) + real (snd z))

goal (1 subgoal):
 1. \<And>x. x \<in> {..n} \<Longrightarrow> inverse (real (Suc n)) * measure_pmf.expectation (rqs_cost x \<bind> (\<lambda>aa. rqs_cost (n - x) \<bind> (\<lambda>b. return_pmf (n + aa + b)))) real = inverse (real (Suc n)) * (real n + rqs_cost_exp x + rqs_cost_exp (n - x))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (pair_pmf (rqs_cost i) (rqs_cost (n - i))) (\<lambda>z. real n + (real (fst z) + real (snd z))) = real n + measure_pmf.expectation (pair_pmf (rqs_cost i) (rqs_cost (n - i))) (\<lambda>z. real (fst z) + real (snd z))

goal (1 subgoal):
 1. \<And>x. x \<in> {..n} \<Longrightarrow> inverse (real (Suc n)) * measure_pmf.expectation (rqs_cost x \<bind> (\<lambda>aa. rqs_cost (n - x) \<bind> (\<lambda>b. return_pmf (n + aa + b)))) real = inverse (real (Suc n)) * (real n + rqs_cost_exp x + rqs_cost_exp (n - x))
[PROOF STEP]
have "?A = measure_pmf.expectation (map_pmf fst (pair_pmf (rqs_cost i) (rqs_cost (n - i)))) real +
                    measure_pmf.expectation (map_pmf snd (pair_pmf (rqs_cost i) (rqs_cost (n - i)))) real"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation (pair_pmf (rqs_cost i) (rqs_cost (n - i))) (\<lambda>z. real (fst z) + real (snd z)) = measure_pmf.expectation (map_pmf fst (pair_pmf (rqs_cost i) (rqs_cost (n - i)))) real + measure_pmf.expectation (map_pmf snd (pair_pmf (rqs_cost i) (rqs_cost (n - i)))) real
[PROOF STEP]
unfolding integral_map_pmf
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation (pair_pmf (rqs_cost i) (rqs_cost (n - i))) (\<lambda>z. real (fst z) + real (snd z)) = measure_pmf.expectation (pair_pmf (rqs_cost i) (rqs_cost (n - i))) (\<lambda>x. real (fst x)) + measure_pmf.expectation (pair_pmf (rqs_cost i) (rqs_cost (n - i))) (\<lambda>x. real (snd x))
[PROOF STEP]
by (subst Bochner_Integration.integral_add) (auto intro!: integrable_measure_pmf_finite)
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (pair_pmf (rqs_cost i) (rqs_cost (n - i))) (\<lambda>z. real (fst z) + real (snd z)) = measure_pmf.expectation (map_pmf fst (pair_pmf (rqs_cost i) (rqs_cost (n - i)))) real + measure_pmf.expectation (map_pmf snd (pair_pmf (rqs_cost i) (rqs_cost (n - i)))) real

goal (1 subgoal):
 1. \<And>x. x \<in> {..n} \<Longrightarrow> inverse (real (Suc n)) * measure_pmf.expectation (rqs_cost x \<bind> (\<lambda>aa. rqs_cost (n - x) \<bind> (\<lambda>b. return_pmf (n + aa + b)))) real = inverse (real (Suc n)) * (real n + rqs_cost_exp x + rqs_cost_exp (n - x))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (pair_pmf (rqs_cost i) (rqs_cost (n - i))) (\<lambda>z. real (fst z) + real (snd z)) = measure_pmf.expectation (map_pmf fst (pair_pmf (rqs_cost i) (rqs_cost (n - i)))) real + measure_pmf.expectation (map_pmf snd (pair_pmf (rqs_cost i) (rqs_cost (n - i)))) real

goal (1 subgoal):
 1. \<And>x. x \<in> {..n} \<Longrightarrow> inverse (real (Suc n)) * measure_pmf.expectation (rqs_cost x \<bind> (\<lambda>aa. rqs_cost (n - x) \<bind> (\<lambda>b. return_pmf (n + aa + b)))) real = inverse (real (Suc n)) * (real n + rqs_cost_exp x + rqs_cost_exp (n - x))
[PROOF STEP]
have "\<dots> = measure_pmf.expectation (rqs_cost i) real +
                    measure_pmf.expectation (rqs_cost (n - i)) real"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation (map_pmf fst (pair_pmf (rqs_cost i) (rqs_cost (n - i)))) real + measure_pmf.expectation (map_pmf snd (pair_pmf (rqs_cost i) (rqs_cost (n - i)))) real = measure_pmf.expectation (rqs_cost i) real + measure_pmf.expectation (rqs_cost (n - i)) real
[PROOF STEP]
unfolding map_fst_pair_pmf map_snd_pair_pmf
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation (rqs_cost i) real + measure_pmf.expectation (rqs_cost (n - i)) real = measure_pmf.expectation (rqs_cost i) real + measure_pmf.expectation (rqs_cost (n - i)) real
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (map_pmf fst (pair_pmf (rqs_cost i) (rqs_cost (n - i)))) real + measure_pmf.expectation (map_pmf snd (pair_pmf (rqs_cost i) (rqs_cost (n - i)))) real = measure_pmf.expectation (rqs_cost i) real + measure_pmf.expectation (rqs_cost (n - i)) real

goal (1 subgoal):
 1. \<And>x. x \<in> {..n} \<Longrightarrow> inverse (real (Suc n)) * measure_pmf.expectation (rqs_cost x \<bind> (\<lambda>aa. rqs_cost (n - x) \<bind> (\<lambda>b. return_pmf (n + aa + b)))) real = inverse (real (Suc n)) * (real n + rqs_cost_exp x + rqs_cost_exp (n - x))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (map_pmf fst (pair_pmf (rqs_cost i) (rqs_cost (n - i)))) real + measure_pmf.expectation (map_pmf snd (pair_pmf (rqs_cost i) (rqs_cost (n - i)))) real = measure_pmf.expectation (rqs_cost i) real + measure_pmf.expectation (rqs_cost (n - i)) real

goal (1 subgoal):
 1. \<And>x. x \<in> {..n} \<Longrightarrow> inverse (real (Suc n)) * measure_pmf.expectation (rqs_cost x \<bind> (\<lambda>aa. rqs_cost (n - x) \<bind> (\<lambda>b. return_pmf (n + aa + b)))) real = inverse (real (Suc n)) * (real n + rqs_cost_exp x + rqs_cost_exp (n - x))
[PROOF STEP]
from 1
[PROOF STATE]
proof (chain)
picking this:
i \<in> {..n}
[PROOF STEP]
have "\<dots> = rqs_cost_exp i + rqs_cost_exp (n - i)"
[PROOF STATE]
proof (prove)
using this:
i \<in> {..n}

goal (1 subgoal):
 1. measure_pmf.expectation (rqs_cost i) real + measure_pmf.expectation (rqs_cost (n - i)) real = rqs_cost_exp i + rqs_cost_exp (n - i)
[PROOF STEP]
by (simp_all add: IH)
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (rqs_cost i) real + measure_pmf.expectation (rqs_cost (n - i)) real = rqs_cost_exp i + rqs_cost_exp (n - i)

goal (1 subgoal):
 1. \<And>x. x \<in> {..n} \<Longrightarrow> inverse (real (Suc n)) * measure_pmf.expectation (rqs_cost x \<bind> (\<lambda>aa. rqs_cost (n - x) \<bind> (\<lambda>b. return_pmf (n + aa + b)))) real = inverse (real (Suc n)) * (real n + rqs_cost_exp x + rqs_cost_exp (n - x))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
measure_pmf.expectation (rqs_cost i \<bind> (\<lambda>a. rqs_cost (n - i) \<bind> (\<lambda>b. return_pmf (n + a + b)))) real = real n + (rqs_cost_exp i + rqs_cost_exp (n - i))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
measure_pmf.expectation (rqs_cost i \<bind> (\<lambda>a. rqs_cost (n - i) \<bind> (\<lambda>b. return_pmf (n + a + b)))) real = real n + (rqs_cost_exp i + rqs_cost_exp (n - i))

goal (1 subgoal):
 1. inverse (real (Suc n)) * measure_pmf.expectation (rqs_cost i \<bind> (\<lambda>aa. rqs_cost (n - i) \<bind> (\<lambda>b. return_pmf (n + aa + b)))) real = inverse (real (Suc n)) * (real n + rqs_cost_exp i + rqs_cost_exp (n - i))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
inverse (real (Suc n)) * measure_pmf.expectation (rqs_cost i \<bind> (\<lambda>aa. rqs_cost (n - i) \<bind> (\<lambda>b. return_pmf (n + aa + b)))) real = inverse (real (Suc n)) * (real n + rqs_cost_exp i + rqs_cost_exp (n - i))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>a\<le>n. inverse (real (Suc n)) * measure_pmf.expectation (rqs_cost a \<bind> (\<lambda>aa. rqs_cost (n - a) \<bind> (\<lambda>b. return_pmf (n + aa + b)))) real) = (\<Sum>i\<le>n. inverse (real (Suc n)) * (real n + rqs_cost_exp i + rqs_cost_exp (n - i)))

goal (2 subgoals):
 1. measure_pmf.expectation (rqs_cost 0) real = rqs_cost_exp 0
 2. \<And>n. \<lbrakk>\<And>x. x \<in> set_pmf (pmf_of_set {..n}) \<Longrightarrow> measure_pmf.expectation (rqs_cost x) real = rqs_cost_exp x; \<And>x xa. \<lbrakk>x \<in> set_pmf (pmf_of_set {..n}); xa \<in> set_pmf (rqs_cost x)\<rbrakk> \<Longrightarrow> measure_pmf.expectation (rqs_cost (n - x)) real = rqs_cost_exp (n - x)\<rbrakk> \<Longrightarrow> measure_pmf.expectation (rqs_cost (Suc n)) real = rqs_cost_exp (Suc n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>a\<le>n. inverse (real (Suc n)) * measure_pmf.expectation (rqs_cost a \<bind> (\<lambda>aa. rqs_cost (n - a) \<bind> (\<lambda>b. return_pmf (n + aa + b)))) real) = (\<Sum>i\<le>n. inverse (real (Suc n)) * (real n + rqs_cost_exp i + rqs_cost_exp (n - i)))

goal (2 subgoals):
 1. measure_pmf.expectation (rqs_cost 0) real = rqs_cost_exp 0
 2. \<And>n. \<lbrakk>\<And>x. x \<in> set_pmf (pmf_of_set {..n}) \<Longrightarrow> measure_pmf.expectation (rqs_cost x) real = rqs_cost_exp x; \<And>x xa. \<lbrakk>x \<in> set_pmf (pmf_of_set {..n}); xa \<in> set_pmf (rqs_cost x)\<rbrakk> \<Longrightarrow> measure_pmf.expectation (rqs_cost (n - x)) real = rqs_cost_exp (n - x)\<rbrakk> \<Longrightarrow> measure_pmf.expectation (rqs_cost (Suc n)) real = rqs_cost_exp (Suc n)
[PROOF STEP]
have "\<dots> = (\<Sum>i\<le>n. inverse (real (Suc n)) * real n) +
                    (\<Sum>i\<le>n. rqs_cost_exp i + rqs_cost_exp (n - i)) / real (Suc n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<le>n. inverse (real (Suc n)) * (real n + rqs_cost_exp i + rqs_cost_exp (n - i))) = (\<Sum>i\<le>n. inverse (real (Suc n)) * real n) + (\<Sum>i\<le>n. rqs_cost_exp i + rqs_cost_exp (n - i)) / real (Suc n)
[PROOF STEP]
by (simp add: sum.distrib field_simps sum_distrib_left sum_distrib_right
          sum_divide_distrib [symmetric] del: of_nat_Suc)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>n. inverse (real (Suc n)) * (real n + rqs_cost_exp i + rqs_cost_exp (n - i))) = (\<Sum>i\<le>n. inverse (real (Suc n)) * real n) + (\<Sum>i\<le>n. rqs_cost_exp i + rqs_cost_exp (n - i)) / real (Suc n)

goal (2 subgoals):
 1. measure_pmf.expectation (rqs_cost 0) real = rqs_cost_exp 0
 2. \<And>n. \<lbrakk>\<And>x. x \<in> set_pmf (pmf_of_set {..n}) \<Longrightarrow> measure_pmf.expectation (rqs_cost x) real = rqs_cost_exp x; \<And>x xa. \<lbrakk>x \<in> set_pmf (pmf_of_set {..n}); xa \<in> set_pmf (rqs_cost x)\<rbrakk> \<Longrightarrow> measure_pmf.expectation (rqs_cost (n - x)) real = rqs_cost_exp (n - x)\<rbrakk> \<Longrightarrow> measure_pmf.expectation (rqs_cost (Suc n)) real = rqs_cost_exp (Suc n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>n. inverse (real (Suc n)) * (real n + rqs_cost_exp i + rqs_cost_exp (n - i))) = (\<Sum>i\<le>n. inverse (real (Suc n)) * real n) + (\<Sum>i\<le>n. rqs_cost_exp i + rqs_cost_exp (n - i)) / real (Suc n)

goal (2 subgoals):
 1. measure_pmf.expectation (rqs_cost 0) real = rqs_cost_exp 0
 2. \<And>n. \<lbrakk>\<And>x. x \<in> set_pmf (pmf_of_set {..n}) \<Longrightarrow> measure_pmf.expectation (rqs_cost x) real = rqs_cost_exp x; \<And>x xa. \<lbrakk>x \<in> set_pmf (pmf_of_set {..n}); xa \<in> set_pmf (rqs_cost x)\<rbrakk> \<Longrightarrow> measure_pmf.expectation (rqs_cost (n - x)) real = rqs_cost_exp (n - x)\<rbrakk> \<Longrightarrow> measure_pmf.expectation (rqs_cost (Suc n)) real = rqs_cost_exp (Suc n)
[PROOF STEP]
have "(\<Sum>i\<le>n. inverse (real (Suc n)) * real n) = real n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<le>n. inverse (real (Suc n)) * real n) = real n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>n. inverse (real (Suc n)) * real n) = real n

goal (2 subgoals):
 1. measure_pmf.expectation (rqs_cost 0) real = rqs_cost_exp 0
 2. \<And>n. \<lbrakk>\<And>x. x \<in> set_pmf (pmf_of_set {..n}) \<Longrightarrow> measure_pmf.expectation (rqs_cost x) real = rqs_cost_exp x; \<And>x xa. \<lbrakk>x \<in> set_pmf (pmf_of_set {..n}); xa \<in> set_pmf (rqs_cost x)\<rbrakk> \<Longrightarrow> measure_pmf.expectation (rqs_cost (n - x)) real = rqs_cost_exp (n - x)\<rbrakk> \<Longrightarrow> measure_pmf.expectation (rqs_cost (Suc n)) real = rqs_cost_exp (Suc n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>n. inverse (real (Suc n)) * real n) = real n

goal (2 subgoals):
 1. measure_pmf.expectation (rqs_cost 0) real = rqs_cost_exp 0
 2. \<And>n. \<lbrakk>\<And>x. x \<in> set_pmf (pmf_of_set {..n}) \<Longrightarrow> measure_pmf.expectation (rqs_cost x) real = rqs_cost_exp x; \<And>x xa. \<lbrakk>x \<in> set_pmf (pmf_of_set {..n}); xa \<in> set_pmf (rqs_cost x)\<rbrakk> \<Longrightarrow> measure_pmf.expectation (rqs_cost (n - x)) real = rqs_cost_exp (n - x)\<rbrakk> \<Longrightarrow> measure_pmf.expectation (rqs_cost (Suc n)) real = rqs_cost_exp (Suc n)
[PROOF STEP]
have "\<dots> + (\<Sum>i\<le>n. rqs_cost_exp i + rqs_cost_exp (n - i)) / real (Suc n) = rqs_cost_exp (Suc n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real n + (\<Sum>i\<le>n. rqs_cost_exp i + rqs_cost_exp (n - i)) / real (Suc n) = rqs_cost_exp (Suc n)
[PROOF STEP]
by (simp add: rqs_cost_exp_Suc)
[PROOF STATE]
proof (state)
this:
real n + (\<Sum>i\<le>n. rqs_cost_exp i + rqs_cost_exp (n - i)) / real (Suc n) = rqs_cost_exp (Suc n)

goal (2 subgoals):
 1. measure_pmf.expectation (rqs_cost 0) real = rqs_cost_exp 0
 2. \<And>n. \<lbrakk>\<And>x. x \<in> set_pmf (pmf_of_set {..n}) \<Longrightarrow> measure_pmf.expectation (rqs_cost x) real = rqs_cost_exp x; \<And>x xa. \<lbrakk>x \<in> set_pmf (pmf_of_set {..n}); xa \<in> set_pmf (rqs_cost x)\<rbrakk> \<Longrightarrow> measure_pmf.expectation (rqs_cost (n - x)) real = rqs_cost_exp (n - x)\<rbrakk> \<Longrightarrow> measure_pmf.expectation (rqs_cost (Suc n)) real = rqs_cost_exp (Suc n)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
measure_pmf.expectation (rqs_cost (Suc n)) real = rqs_cost_exp (Suc n)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
measure_pmf.expectation (rqs_cost (Suc n)) real = rqs_cost_exp (Suc n)

goal (1 subgoal):
 1. measure_pmf.expectation (rqs_cost (Suc n)) real = rqs_cost_exp (Suc n)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (rqs_cost (Suc n)) real = rqs_cost_exp (Suc n)

goal (1 subgoal):
 1. measure_pmf.expectation (rqs_cost 0) real = rqs_cost_exp 0
[PROOF STEP]
qed simp_all


[STATEMENT]
lemma lower_asymptotic_density_intersection:
  "lower_asymptotic_density A + lower_asymptotic_density B \<le> lower_asymptotic_density (A \<inter> B) + 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lower_asymptotic_density A + lower_asymptotic_density B \<le> lower_asymptotic_density (A \<inter> B) + 1
[PROOF STEP]
using upper_asymptotic_density_union[of "UNIV - A" "UNIV - B"]
[PROOF STATE]
proof (prove)
using this:
upper_asymptotic_density (UNIV - A \<union> (UNIV - B)) \<le> upper_asymptotic_density (UNIV - A) + upper_asymptotic_density (UNIV - B)

goal (1 subgoal):
 1. lower_asymptotic_density A + lower_asymptotic_density B \<le> lower_asymptotic_density (A \<inter> B) + 1
[PROOF STEP]
unfolding lower_upper_asymptotic_density_complement
[PROOF STATE]
proof (prove)
using this:
upper_asymptotic_density (UNIV - A \<union> (UNIV - B)) \<le> upper_asymptotic_density (UNIV - A) + upper_asymptotic_density (UNIV - B)

goal (1 subgoal):
 1. 1 - upper_asymptotic_density (UNIV - A) + (1 - upper_asymptotic_density (UNIV - B)) \<le> 1 - upper_asymptotic_density (UNIV - A \<inter> B) + 1
[PROOF STEP]
by (auto simp add: algebra_simps Diff_Int)


[STATEMENT]
lemma matrix_left_invertible_ker:
  "(\<exists>B. (B::'a::{field} ^'m^'n) ** (A::'a::{field}^'n^'m) = mat 1) \<longleftrightarrow> (\<forall>x. A *v x = 0 \<longrightarrow> x = 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<exists>B. B ** A = mat (1::'a)) = (\<forall>x. A *v x = 0 \<longrightarrow> x = 0)
[PROOF STEP]
unfolding matrix_left_invertible_injective
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj ((*v) A) = (\<forall>x. A *v x = 0 \<longrightarrow> x = 0)
[PROOF STEP]
using vec.inj_on_iff_eq_0[OF vec.subspace_UNIV, of A]
[PROOF STATE]
proof (prove)
using this:
inj ((*v) A) = (\<forall>x\<in>UNIV. A *v x = 0 \<longrightarrow> x = 0)

goal (1 subgoal):
 1. inj ((*v) A) = (\<forall>x. A *v x = 0 \<longrightarrow> x = 0)
[PROOF STEP]
by (simp add: inj_on_def)


[STATEMENT]
lemma sin_of_quarter_pi:
  fixes x:: real
  assumes "x = pi/2"
  shows "sin (x/2) = (sqrt 2)/2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin (x / 2) = sqrt 2 / 2
[PROOF STEP]
by (auto simp add: assms sin_45)


[STATEMENT]
lemma preimage_of_inter:
  fixes f::"'a \<Rightarrow> 'b" and X::"'a set" and V::"'b set" and V'::"'b set"
  shows "f\<^sup>\<inverse> X (V \<inter> V') = (f\<^sup>\<inverse> X V) \<inter> (f\<^sup>\<inverse> X V')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f \<^sup>\<inverse> X (V \<inter> V') = f \<^sup>\<inverse> X V \<inter> f \<^sup>\<inverse> X V'
[PROOF STEP]
by blast


[STATEMENT]
lemma pderiv_power: "pderiv (p ^ n) = smult (of_nat n) (p ^ (n-1)) * pderiv p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pderiv (p ^ n) = smult (of_nat n) (p ^ (n - 1)) * pderiv p
[PROOF STEP]
apply (cases n)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. n = 0 \<Longrightarrow> pderiv (p ^ n) = smult (of_nat n) (p ^ (n - 1)) * pderiv p
 2. \<And>nat. n = Suc nat \<Longrightarrow> pderiv (p ^ n) = smult (of_nat n) (p ^ (n - 1)) * pderiv p
[PROOF STEP]
using pderiv_power_Suc
[PROOF STATE]
proof (prove)
using this:
pderiv (?p ^ Suc ?n) = smult (of_nat (Suc ?n)) (?p ^ ?n) * pderiv ?p

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> pderiv (p ^ n) = smult (of_nat n) (p ^ (n - 1)) * pderiv p
 2. \<And>nat. n = Suc nat \<Longrightarrow> pderiv (p ^ n) = smult (of_nat n) (p ^ (n - 1)) * pderiv p
[PROOF STEP]
by auto


[STATEMENT]
lemma ennreal_suminf_minus:
  fixes f g :: "nat \<Rightarrow> ennreal"
  shows "(\<And>i. g i \<le> f i) \<Longrightarrow> suminf f \<noteq> top \<Longrightarrow> suminf g \<noteq> top \<Longrightarrow> (\<Sum>i. f i - g i) = suminf f - suminf g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<And>i. g i \<le> f i; suminf f \<noteq> top; suminf g \<noteq> top\<rbrakk> \<Longrightarrow> (\<Sum>i. f i - g i) = suminf f - suminf g
[PROOF STEP]
by transfer
     (auto simp add: max.absorb2 ereal_diff_positive suminf_le_pos top_ereal_def intro!: suminf_ereal_minus)


[STATEMENT]
lemma Least_le_imp_le_disj: "
  \<lbrakk> \<exists>x. P x; \<And>x y. \<lbrakk> P x; Q y \<rbrakk> \<Longrightarrow> x \<le> y \<rbrakk> \<Longrightarrow>
  (LEAST (x::'a::wellorder). P x \<or> Q x) = (LEAST (x::'a::wellorder). P x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<exists>x. P x; \<And>x y. \<lbrakk>P x; Q y\<rbrakk> \<Longrightarrow> x \<le> y\<rbrakk> \<Longrightarrow> (LEAST x. P x \<or> Q x) = (LEAST x. P x)
[PROOF STEP]
apply (case_tac "\<exists>x. Q x")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>\<exists>x. P x; \<And>x y. \<lbrakk>P x; Q y\<rbrakk> \<Longrightarrow> x \<le> y; \<exists>x. Q x\<rbrakk> \<Longrightarrow> (LEAST x. P x \<or> Q x) = (LEAST x. P x)
 2. \<lbrakk>\<exists>x. P x; \<And>x y. \<lbrakk>P x; Q y\<rbrakk> \<Longrightarrow> x \<le> y; \<nexists>x. Q x\<rbrakk> \<Longrightarrow> (LEAST x. P x \<or> Q x) = (LEAST x. P x)
[PROOF STEP]
apply (simp only: Least_disj min.absorb_iff1[THEN iffD1, OF Least_le_imp_le])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<exists>x. P x; \<And>x y. \<lbrakk>P x; Q y\<rbrakk> \<Longrightarrow> x \<le> y; \<nexists>x. Q x\<rbrakk> \<Longrightarrow> (LEAST x. P x \<or> Q x) = (LEAST x. P x)
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma prime_factors_characterization'_nat:
  "finite {p. 0 < f (p::nat)} \<Longrightarrow>
    (\<forall>p. 0 < f p \<longrightarrow> prime p) \<Longrightarrow>
      prime_factors (\<Prod>p | 0 < f p. p ^ f p) = {p. 0 < f p}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite {p. 0 < f p}; \<forall>p. 0 < f p \<longrightarrow> prime p\<rbrakk> \<Longrightarrow> prime_factors (\<Prod>p\<in>{p. 0 < f p}. p ^ f p) = {p. 0 < f p}
[PROOF STEP]
by (rule prime_factors_characterization_nat) auto


[STATEMENT]
lemma sin_zero_iff:
  "sin x = 0 \<longleftrightarrow> ((\<exists>n. even n \<and> x = real n * (pi/2)) \<or> (\<exists>n. even n \<and> x = - (real n * (pi/2))))"
  (is "?lhs = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (sin x = 0) = ((\<exists>n. even n \<and> x = real n * (pi / 2)) \<or> (\<exists>n. even n \<and> x = - (real n * (pi / 2))))
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. sin x = 0 \<Longrightarrow> (\<exists>n. even n \<and> x = real n * (pi / 2)) \<or> (\<exists>n. even n \<and> x = - (real n * (pi / 2)))
 2. (\<exists>n. even n \<and> x = real n * (pi / 2)) \<or> (\<exists>n. even n \<and> x = - (real n * (pi / 2))) \<Longrightarrow> sin x = 0
[PROOF STEP]
show ?rhs if ?lhs
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<exists>n. even n \<and> x = real n * (pi / 2)) \<or> (\<exists>n. even n \<and> x = - (real n * (pi / 2)))
[PROOF STEP]
using that sin_zero_lemma [of x] sin_zero_lemma [of "-x"]
[PROOF STATE]
proof (prove)
using this:
sin x = 0
\<lbrakk>0 \<le> x; sin x = 0\<rbrakk> \<Longrightarrow> \<exists>n. even n \<and> x = real n * (pi / 2)
\<lbrakk>0 \<le> - x; sin (- x) = 0\<rbrakk> \<Longrightarrow> \<exists>n. even n \<and> - x = real n * (pi / 2)

goal (1 subgoal):
 1. (\<exists>n. even n \<and> x = real n * (pi / 2)) \<or> (\<exists>n. even n \<and> x = - (real n * (pi / 2)))
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
sin x = 0 \<Longrightarrow> (\<exists>n. even n \<and> x = real n * (pi / 2)) \<or> (\<exists>n. even n \<and> x = - (real n * (pi / 2)))

goal (1 subgoal):
 1. (\<exists>n. even n \<and> x = real n * (pi / 2)) \<or> (\<exists>n. even n \<and> x = - (real n * (pi / 2))) \<Longrightarrow> sin x = 0
[PROOF STEP]
show ?lhs if ?rhs
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin x = 0
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
(\<exists>n. even n \<and> x = real n * (pi / 2)) \<or> (\<exists>n. even n \<and> x = - (real n * (pi / 2)))

goal (1 subgoal):
 1. sin x = 0
[PROOF STEP]
by (auto elim: evenE)
[PROOF STATE]
proof (state)
this:
(\<exists>n. even n \<and> x = real n * (pi / 2)) \<or> (\<exists>n. even n \<and> x = - (real n * (pi / 2))) \<Longrightarrow> sin x = 0

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mod_plus_minus_zero:
  assumes "x mod+- b = 0"
  shows "x mod b = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x mod b = 0
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
x mod+- b = 0

goal (1 subgoal):
 1. x mod b = 0
[PROOF STEP]
unfolding mod_plus_minus_def
[PROOF STATE]
proof (prove)
using this:
(x + \<lfloor>real_of_int b / 2\<rfloor>) mod b - \<lfloor>real_of_int b / 2\<rfloor> = 0

goal (1 subgoal):
 1. x mod b = 0
[PROOF STEP]
by (metis add.commute add.right_neutral bits_mod_0
  diff_add_cancel group_cancel.add1 mod_add_left_eq)


[STATEMENT]
lemma right_invertible_iff_invertible:
  fixes M :: "real^'n^'n"
  shows "(\<exists> N. M ** N = mat 1) \<longleftrightarrow> invertible M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<exists>N. M ** N = mat 1) = invertible M
[PROOF STEP]
by (simp add: invertible_def matrix_left_right_inverse)


[STATEMENT]
lemma even_odd_cases:
  fixes x :: nat
  obtains n where "x=n+n" | n where "x = n + Suc n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<And>n. x = n + n \<Longrightarrow> thesis; \<And>n. x = n + Suc n \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
apply (cases "even x"; simp)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>\<And>n. x = n + n \<Longrightarrow> thesis; \<And>n. x = Suc (n + n) \<Longrightarrow> thesis; even x\<rbrakk> \<Longrightarrow> thesis
 2. \<lbrakk>\<And>n. x = n + n \<Longrightarrow> thesis; \<And>n. x = Suc (n + n) \<Longrightarrow> thesis; odd x\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
apply (metis add_self_div_2 div_add)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<And>n. x = n + n \<Longrightarrow> thesis; \<And>n. x = Suc (n + n) \<Longrightarrow> thesis; odd x\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
by (metis add.commute mult_2 oddE plus_1_eq_Suc)


[STATEMENT]
lemma Limsup_mono:
  assumes ev: "eventually (\<lambda>x. f x \<le> g x) F"
  shows "Limsup F f \<le> Limsup F g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Limsup F f \<le> Limsup F g
[PROOF STEP]
unfolding Limsup_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (INF P\<in>{P. eventually P F}. Sup (f ` Collect P)) \<le> (INF P\<in>{P. eventually P F}. Sup (g ` Collect P))
[PROOF STEP]
proof (safe intro!: INF_mono)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>m. eventually m F \<Longrightarrow> \<exists>P\<in>{P. eventually P F}. Sup (f ` Collect P) \<le> Sup (g ` Collect m)
[PROOF STEP]
fix P
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>m. eventually m F \<Longrightarrow> \<exists>P\<in>{P. eventually P F}. Sup (f ` Collect P) \<le> Sup (g ` Collect m)
[PROOF STEP]
assume "eventually P F"
[PROOF STATE]
proof (state)
this:
eventually P F

goal (1 subgoal):
 1. \<And>m. eventually m F \<Longrightarrow> \<exists>P\<in>{P. eventually P F}. Sup (f ` Collect P) \<le> Sup (g ` Collect m)
[PROOF STEP]
with ev
[PROOF STATE]
proof (chain)
picking this:
\<forall>\<^sub>F x in F. f x \<le> g x
eventually P F
[PROOF STEP]
have "eventually (\<lambda>x. f x \<le> g x \<and> P x) F" (is "eventually ?Q F")
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in F. f x \<le> g x
eventually P F

goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. f x \<le> g x \<and> P x
[PROOF STEP]
by (rule eventually_conj)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in F. f x \<le> g x \<and> P x

goal (1 subgoal):
 1. \<And>m. eventually m F \<Longrightarrow> \<exists>P\<in>{P. eventually P F}. Sup (f ` Collect P) \<le> Sup (g ` Collect m)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>\<^sub>F x in F. f x \<le> g x \<and> P x
[PROOF STEP]
show "\<exists>Q\<in>{P. eventually P F}. Sup (f ` (Collect Q)) \<le> Sup (g ` (Collect P))"
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in F. f x \<le> g x \<and> P x

goal (1 subgoal):
 1. \<exists>Q\<in>{P. eventually P F}. Sup (f ` Collect Q) \<le> Sup (g ` Collect P)
[PROOF STEP]
by (intro bexI[of _ ?Q]) (auto intro!: SUP_mono)
[PROOF STATE]
proof (state)
this:
\<exists>Q\<in>{P. eventually P F}. Sup (f ` Collect Q) \<le> Sup (g ` Collect P)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma has_field_derivative_inverse_strong_x:
  fixes f :: "'a::{euclidean_space,real_normed_field} \<Rightarrow> 'a"
  shows  "\<lbrakk>DERIV f (g y) :> f'; f' \<noteq> 0; open S; continuous_on S f; g y \<in> S; f(g y) = y;
           \<And>z. z \<in> S \<Longrightarrow> g (f z) = z\<rbrakk>
          \<Longrightarrow> DERIV g y :> inverse (f')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(f has_field_derivative f') (at (g y)); f' \<noteq> (0::'a); open S; continuous_on S f; g y \<in> S; f (g y) = y; \<And>z. z \<in> S \<Longrightarrow> g (f z) = z\<rbrakk> \<Longrightarrow> (g has_field_derivative inverse f') (at y)
[PROOF STEP]
unfolding has_field_derivative_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(f has_derivative (*) f') (at (g y)); f' \<noteq> (0::'a); open S; continuous_on S f; g y \<in> S; f (g y) = y; \<And>z. z \<in> S \<Longrightarrow> g (f z) = z\<rbrakk> \<Longrightarrow> (g has_derivative (*) (inverse f')) (at y)
[PROOF STEP]
by (rule has_derivative_inverse_strong_x [of S g y f]) auto


[STATEMENT]
lemma norm_eq_1: "norm x = 1 \<longleftrightarrow> inner x x = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (norm x = 1) = (inner x x = 1)
[PROOF STEP]
by (simp add: norm_eq_sqrt_inner)


[STATEMENT]
lemma cos_2npi [simp]: "cos (2 * real n * pi) = 1"
  for n :: nat
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos (2 * real n * pi) = 1
[PROOF STEP]
by (cases "even n") (simp_all add: cos_double mult.assoc)


[STATEMENT]
lemma poly_mult_l_distr:
  assumes "subring K R" "polynomial K p1" "polynomial K p2" "polynomial K p3"
  shows "poly_mult (poly_add p1 p2) p3 = poly_add (poly_mult p1 p3) (poly_mult p2 p3)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_mult (poly_add p1 p2) p3 = poly_add (poly_mult p1 p3) (poly_mult p2 p3)
[PROOF STEP]
using poly_mult_l_distr' polynomial_in_carrier assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>set ?p1.0 \<subseteq> carrier R; set ?p2.0 \<subseteq> carrier R; set ?p3.0 \<subseteq> carrier R\<rbrakk> \<Longrightarrow> poly_mult (poly_add ?p1.0 ?p2.0) ?p3.0 = poly_add (poly_mult ?p1.0 ?p3.0) (poly_mult ?p2.0 ?p3.0)
\<lbrakk>subring ?K R; polynomial ?K ?p\<rbrakk> \<Longrightarrow> set ?p \<subseteq> carrier R
subring K R
polynomial K p1
polynomial K p2
polynomial K p3

goal (1 subgoal):
 1. poly_mult (poly_add p1 p2) p3 = poly_add (poly_mult p1 p3) (poly_mult p2 p3)
[PROOF STEP]
by auto


[STATEMENT]
lemma sums_le: "(\<And>n. f n \<le> g n) \<Longrightarrow> f sums s \<Longrightarrow> g sums t \<Longrightarrow> s \<le> t"
  for f g :: "nat \<Rightarrow> 'a::{ordered_comm_monoid_add,linorder_topology}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<And>n. f n \<le> g n; f sums s; g sums t\<rbrakk> \<Longrightarrow> s \<le> t
[PROOF STEP]
by (rule LIMSEQ_le) (auto intro: sum_mono simp: sums_def)


[STATEMENT]
lemma convergent_minus_iff:
  fixes X :: "nat \<Rightarrow> 'a::topological_group_add"
  shows "convergent X \<longleftrightarrow> convergent (\<lambda>n. - X n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. convergent X = convergent (\<lambda>n. - X n)
[PROOF STEP]
unfolding convergent_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<exists>L. X \<longlonglongrightarrow> L) = (\<exists>L. (\<lambda>n. - X n) \<longlonglongrightarrow> L)
[PROOF STEP]
by (force dest: tendsto_minus)


[STATEMENT]
lemma tendsto_norm_zero_iff: "((\<lambda>x. norm (f x)) \<longlongrightarrow> 0) F \<longleftrightarrow> (f \<longlongrightarrow> 0) F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. norm (f x)) \<longlongrightarrow> 0) F = (f \<longlongrightarrow> (0::'b)) F
[PROOF STEP]
unfolding tendsto_iff dist_norm
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>e>0. \<forall>\<^sub>F x in F. norm (norm (f x) - 0) < e) = (\<forall>e>0. \<forall>\<^sub>F x in F. norm (f x - (0::'b)) < e)
[PROOF STEP]
by simp


[STATEMENT]
lemma Cauchy_contour_integral_circlepath_2:
  assumes "continuous_on (cball z r) f" "f holomorphic_on ball z r" "w \<in> ball z r"
    shows "contour_integral(circlepath z r) (\<lambda>u. f u/(u - w)^2) = (2 * pi * \<i>) * deriv f w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. contour_integral (circlepath z r) (\<lambda>u. f u / (u - w)\<^sup>2) = complex_of_real (2 * pi) * \<i> * deriv f w
[PROOF STEP]
using Cauchy_contour_integral_circlepath [OF assms, of 1]
[PROOF STATE]
proof (prove)
using this:
contour_integral (circlepath z r) (\<lambda>u. f u / (u - w) ^ Suc 1) = complex_of_real (2 * pi) * \<i> * (deriv ^^ 1) f w / fact 1

goal (1 subgoal):
 1. contour_integral (circlepath z r) (\<lambda>u. f u / (u - w)\<^sup>2) = complex_of_real (2 * pi) * \<i> * deriv f w
[PROOF STEP]
by (simp add: power2_eq_square)


[STATEMENT]
lemma isometry_preserves_hausdorff_distance:
  "hausdorff_distance (f`A) (f`B) = hausdorff_distance A B"
  if "isometry_on X f" "A \<subseteq> X" "B \<subseteq> X"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. hausdorff_distance (f ` A) (f ` B) = hausdorff_distance A B
[PROOF STEP]
using that isometry_preserves_infdist [OF that(1) that(2)]
  isometry_preserves_infdist [OF that(1) that(3)]
  isometry_preserves_bounded [OF that(1) that(2)]
  isometry_preserves_bounded [OF that(1) that(3)]
[PROOF STATE]
proof (prove)
using this:
isometry_on X f
A \<subseteq> X
B \<subseteq> X
?x \<in> X \<Longrightarrow> infdist (f ?x) (f ` A) = infdist ?x A
?x \<in> X \<Longrightarrow> infdist (f ?x) (f ` B) = infdist ?x B
bounded (f ` A) = bounded A
bounded (f ` B) = bounded B

goal (1 subgoal):
 1. hausdorff_distance (f ` A) (f ` B) = hausdorff_distance A B
[PROOF STEP]
by (simp add: hausdorff_distance_def image_comp subset_eq)


[STATEMENT]
lemma hmset_pos_plus:
  "hmset_pos (A + B) = (hmset_pos A - hmset_neg B) + (hmset_pos B - hmset_neg A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. hmset_pos (A + B) = hmset_pos A - hmset_neg B + (hmset_pos B - hmset_neg A)
[PROOF STEP]
by (simp add: HMSet_diff HMSet_plus zhmsetmset_plus)


[STATEMENT]
lemma cong_solve_coprime_nat: "coprime (a::nat) (n::nat) \<Longrightarrow> \<exists>x. (a*x) mod n = 1 mod n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coprime a n \<Longrightarrow> \<exists>x. a * x mod n = 1 mod n
[PROOF STEP]
using cong_solve_nat[of a n] coprime_iff_gcd_eq_1[of a n]
[PROOF STATE]
proof (prove)
using this:
a \<noteq> 0 \<Longrightarrow> \<exists>x. a * x mod n = gcd a n mod n
coprime a n = (gcd a n = 1)

goal (1 subgoal):
 1. coprime a n \<Longrightarrow> \<exists>x. a * x mod n = 1 mod n
[PROOF STEP]
by fastforce


[STATEMENT]
lemma cindex_polyE_inverse_add_cross:
  fixes p q::"real poly"
  assumes "a < b" "coprime p q"
  shows "cindex_polyE a b q p  + cindex_polyE a b p q = cross_alt p q a b / 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cindex_polyE a b q p + cindex_polyE a b p q = real_of_int (cross_alt p q a b) / 2
[PROOF STEP]
apply (subst cindex_polyE_inverse_add[OF \<open>coprime p q\<close>])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cindex_polyE a b 1 (q * p) = real_of_int (cross_alt p q a b) / 2
[PROOF STEP]
apply (subst cindex_polyE_cross[OF \<open>a<b\<close>])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_of_int (cross_alt 1 (q * p) a b) / 2 = real_of_int (cross_alt p q a b) / 2
[PROOF STEP]
apply (subst mult.commute)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_of_int (cross_alt 1 (p * q) a b) / 2 = real_of_int (cross_alt p q a b) / 2
[PROOF STEP]
apply (subst (2) cross_alt_clear)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_of_int (cross_alt 1 (p * q) a b) / 2 = real_of_int (cross_alt 1 (p * q) a b) / 2
[PROOF STEP]
by simp


[STATEMENT]
lemma mod_partition_is_disjoint: "
  \<lbrakk> 0 < (m::nat); k \<noteq> k' \<rbrakk> \<Longrightarrow>
  (A \<inter> [k * m\<dots>,m - Suc 0]) \<inter>  (A \<inter> [k' * m\<dots>,m - Suc 0]) = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < m; k \<noteq> k'\<rbrakk> \<Longrightarrow> A \<inter> [k * m\<dots>,m - Suc 0] \<inter> (A \<inter> [k' * m\<dots>,m - Suc 0]) = {}
[PROOF STEP]
apply (clarsimp simp add: all_not_in_conv[symmetric] iT_iff)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>0 < m; k \<noteq> k'; k' * m \<le> x; x \<in> A; x \<le> k * m + m - Suc 0; k * m \<le> x; x \<le> k' * m + m - Suc 0\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
apply (subgoal_tac "\<And>k. \<lbrakk> k * m \<le> x; x \<le> k * m + m - Suc 0 \<rbrakk> \<Longrightarrow> x div m = k")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x. \<lbrakk>0 < m; k \<noteq> k'; k' * m \<le> x; x \<in> A; x \<le> k * m + m - Suc 0; k * m \<le> x; x \<le> k' * m + m - Suc 0; \<And>k. \<lbrakk>k * m \<le> x; x \<le> k * m + m - Suc 0\<rbrakk> \<Longrightarrow> x div m = k\<rbrakk> \<Longrightarrow> False
 2. \<And>x ka. \<lbrakk>0 < m; k \<noteq> k'; k' * m \<le> x; x \<in> A; x \<le> k * m + m - Suc 0; k * m \<le> x; x \<le> k' * m + m - Suc 0; ka * m \<le> x; x \<le> ka * m + m - Suc 0\<rbrakk> \<Longrightarrow> x div m = ka
[PROOF STEP]
apply blast
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x ka. \<lbrakk>0 < m; k \<noteq> k'; k' * m \<le> x; x \<in> A; x \<le> k * m + m - Suc 0; k * m \<le> x; x \<le> k' * m + m - Suc 0; ka * m \<le> x; x \<le> ka * m + m - Suc 0\<rbrakk> \<Longrightarrow> x div m = ka
[PROOF STEP]
apply (rule le_less_imp_div, assumption)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x ka. \<lbrakk>0 < m; k \<noteq> k'; k' * m \<le> x; x \<in> A; x \<le> k * m + m - Suc 0; k * m \<le> x; x \<le> k' * m + m - Suc 0; ka * m \<le> x; x \<le> ka * m + m - Suc 0\<rbrakk> \<Longrightarrow> x < Suc ka * m
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma geometric_deriv_sums:
  fixes z :: "'a :: {real_normed_field,banach}"
  assumes "norm z < 1"
  shows   "(\<lambda>n. of_nat (Suc n) * z ^ n) sums (1 / (1 - z)^2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. of_nat (Suc n) * z ^ n) sums ((1::'a) / ((1::'a) - z)\<^sup>2)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>n. of_nat (Suc n) * z ^ n) sums ((1::'a) / ((1::'a) - z)\<^sup>2)
[PROOF STEP]
have "(\<lambda>n. diffs (\<lambda>n. 1) n * z^n) sums (1 / (1 - z)^2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. diffs (\<lambda>n. 1::'a) n * z ^ n) sums ((1::'a) / ((1::'a) - z)\<^sup>2)
[PROOF STEP]
proof (rule termdiffs_sums_strong)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>z. norm z < ?K \<Longrightarrow> (\<lambda>n. (1::'a) * z ^ n) sums ?f z
 2. (?f has_field_derivative (1::'a) / ((1::'a) - z)\<^sup>2) (at z)
 3. norm z < ?K
[PROOF STEP]
fix z :: 'a
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>z. norm z < ?K \<Longrightarrow> (\<lambda>n. (1::'a) * z ^ n) sums ?f z
 2. (?f has_field_derivative (1::'a) / ((1::'a) - z)\<^sup>2) (at z)
 3. norm z < ?K
[PROOF STEP]
assume "norm z < 1"
[PROOF STATE]
proof (state)
this:
norm z < 1

goal (3 subgoals):
 1. \<And>z. norm z < ?K \<Longrightarrow> (\<lambda>n. (1::'a) * z ^ n) sums ?f z
 2. (?f has_field_derivative (1::'a) / ((1::'a) - z)\<^sup>2) (at z)
 3. norm z < ?K
[PROOF STEP]
thus "(\<lambda>n. 1 * z^n) sums (1 / (1 - z))"
[PROOF STATE]
proof (prove)
using this:
norm z < 1

goal (1 subgoal):
 1. (\<lambda>n. (1::'a) * z ^ n) sums ((1::'a) / ((1::'a) - z))
[PROOF STEP]
by (simp add: geometric_sums)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. (1::'a) * z ^ n) sums ((1::'a) / ((1::'a) - z))

goal (2 subgoals):
 1. ((\<lambda>z. (1::'a) / ((1::'a) - z)) has_field_derivative (1::'a) / ((1::'a) - z)\<^sup>2) (at z)
 2. norm z < 1
[PROOF STEP]
qed (insert assms, auto intro!: derivative_eq_intros simp: power2_eq_square)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. diffs (\<lambda>n. 1::'a) n * z ^ n) sums ((1::'a) / ((1::'a) - z)\<^sup>2)

goal (1 subgoal):
 1. (\<lambda>n. of_nat (Suc n) * z ^ n) sums ((1::'a) / ((1::'a) - z)\<^sup>2)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. diffs (\<lambda>n. 1::'a) n * z ^ n) sums ((1::'a) / ((1::'a) - z)\<^sup>2)

goal (1 subgoal):
 1. (\<lambda>n. of_nat (Suc n) * z ^ n) sums ((1::'a) / ((1::'a) - z)\<^sup>2)
[PROOF STEP]
unfolding diffs_def
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. of_nat (Suc n) * (1::'a) * z ^ n) sums ((1::'a) / ((1::'a) - z)\<^sup>2)

goal (1 subgoal):
 1. (\<lambda>n. of_nat (Suc n) * z ^ n) sums ((1::'a) / ((1::'a) - z)\<^sup>2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<lambda>n. of_nat (Suc n) * z ^ n) sums ((1::'a) / ((1::'a) - z)\<^sup>2)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem trans_inv:
"\<forall> p f x . cfni p (\<lambda> y. f y + x) = cfni p f + x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>p f x. cfni p (\<lambda>y. f y + x) = cfni p f + x
[PROOF STEP]
apply (auto simp add: cfni_def trans_inv' distrib_right
       divide_inverse  constants_ax)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma Rep_matrix_mult: "Rep_matrix ((a::('a::semiring_0) matrix) * b) j i =
  foldseq (+) (% k.  (Rep_matrix a j k) * (Rep_matrix b k i)) (max (ncols a) (nrows b))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Rep_matrix (a * b) j i = foldseq (+) (\<lambda>k. Rep_matrix a j k * Rep_matrix b k i) (max (ncols a) (nrows b))
[PROOF STEP]
apply (simp add: times_matrix_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Rep_matrix (mult_matrix (*) (+) a b) j i = foldseq (+) (\<lambda>k. Rep_matrix a j k * Rep_matrix b k i) (max (ncols a) (nrows b))
[PROOF STEP]
apply (simp add: Rep_mult_matrix)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
theorem ln_lower_3_eq: "0<x \<Longrightarrow> ln_lower_3 x = (1/2)*(1 + 5*x)*(x - 1) / (x*(2 + x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < x \<Longrightarrow> ln_lower_3 x = 1 / 2 * (1 + 5 * x) * (x - 1) / (x * (2 + x))
[PROOF STEP]
unfolding ln_lower_3_def ln_upper_3_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < x \<Longrightarrow> - ((inverse x + 5) * (inverse x - 1) / (2 * (2 * inverse x + 1))) = 1 / 2 * (1 + 5 * x) * (x - 1) / (x * (2 + x))
[PROOF STEP]
by (simp add: divide_simps) algebra


[STATEMENT]
lemma norm_cross7_dot_magnitude: "(norm (x \<times>\<^sub>7 y))\<^sup>2 = (norm x)\<^sup>2 * (norm y)\<^sup>2 - (x \<bullet> y)\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (norm (x \<times>\<^sub>7 y))\<^sup>2 = (norm x)\<^sup>2 * (norm y)\<^sup>2 - (x \<bullet> y)\<^sup>2
[PROOF STEP]
unfolding norm_square_vec_eq sum_7 cross7_components inner_vec_def real_norm_def inner_real_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x $ 2 * y $ 4 - x $ 4 * y $ 2 + x $ 3 * y $ 7 - x $ 7 * y $ 3 + x $ 5 * y $ 6 - x $ 6 * y $ 5)\<^sup>2 + (x $ 4 * y $ 1 - x $ 1 * y $ 4 + x $ 3 * y $ 5 - x $ 5 * y $ 3 + x $ 6 * y $ 7 - x $ 7 * y $ 6)\<^sup>2 + (x $ 5 * y $ 2 - x $ 2 * y $ 5 + x $ 4 * y $ 6 - x $ 6 * y $ 4 + x $ 7 * y $ 1 - x $ 1 * y $ 7)\<^sup>2 + (x $ 1 * y $ 2 - x $ 2 * y $ 1 + x $ 6 * y $ 3 - x $ 3 * y $ 6 + x $ 5 * y $ 7 - x $ 7 * y $ 5)\<^sup>2 + (x $ 6 * y $ 1 - x $ 1 * y $ 6 + x $ 2 * y $ 3 - x $ 3 * y $ 2 + x $ 7 * y $ 4 - x $ 4 * y $ 7)\<^sup>2 + (x $ 1 * y $ 5 - x $ 5 * y $ 1 + x $ 7 * y $ 2 - x $ 2 * y $ 7 + x $ 3 * y $ 4 - x $ 4 * y $ 3)\<^sup>2 + (x $ 1 * y $ 3 - x $ 3 * y $ 1 + x $ 4 * y $ 5 - x $ 5 * y $ 4 + x $ 2 * y $ 6 - x $ 6 * y $ 2)\<^sup>2 = ((x $ 1)\<^sup>2 + (x $ 2)\<^sup>2 + (x $ 3)\<^sup>2 + (x $ 4)\<^sup>2 + (x $ 5)\<^sup>2 + (x $ 6)\<^sup>2 + (x $ 7)\<^sup>2) * ((y $ 1)\<^sup>2 + (y $ 2)\<^sup>2 + (y $ 3)\<^sup>2 + (y $ 4)\<^sup>2 + (y $ 5)\<^sup>2 + (y $ 6)\<^sup>2 + (y $ 7)\<^sup>2) - (x $ 1 * y $ 1 + x $ 2 * y $ 2 + x $ 3 * y $ 3 + x $ 4 * y $ 4 + x $ 5 * y $ 5 + x $ 6 * y $ 6 + x $ 7 * y $ 7)\<^sup>2
[PROOF STEP]
by algebra