[STATEMENT]
lemma permutations_complete: (* could generalize with multi-sets *)
  assumes "distinct xs" "distinct ys" "set xs = set ys"
  shows "ys \<in> set (permutations xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ys \<in> set (permutations xs)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
distinct xs
distinct ys
set xs = set ys

goal (1 subgoal):
 1. ys \<in> set (permutations xs)
[PROOF STEP]
proof (induct "length xs" arbitrary: xs ys)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>xs ys. \<lbrakk>0 = length xs; distinct xs; distinct ys; set xs = set ys\<rbrakk> \<Longrightarrow> ys \<in> set (permutations xs)
 2. \<And>x xs ys. \<lbrakk>\<And>xs ys. \<lbrakk>x = length xs; distinct xs; distinct ys; set xs = set ys\<rbrakk> \<Longrightarrow> ys \<in> set (permutations xs); Suc x = length xs; distinct xs; distinct ys; set xs = set ys\<rbrakk> \<Longrightarrow> ys \<in> set (permutations xs)
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
0 = length xs
distinct xs
distinct ys
set xs = set ys

goal (2 subgoals):
 1. \<And>xs ys. \<lbrakk>0 = length xs; distinct xs; distinct ys; set xs = set ys\<rbrakk> \<Longrightarrow> ys \<in> set (permutations xs)
 2. \<And>x xs ys. \<lbrakk>\<And>xs ys. \<lbrakk>x = length xs; distinct xs; distinct ys; set xs = set ys\<rbrakk> \<Longrightarrow> ys \<in> set (permutations xs); Suc x = length xs; distinct xs; distinct ys; set xs = set ys\<rbrakk> \<Longrightarrow> ys \<in> set (permutations xs)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 = length xs
distinct xs
distinct ys
set xs = set ys
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
0 = length xs
distinct xs
distinct ys
set xs = set ys

goal (1 subgoal):
 1. ys \<in> set (permutations xs)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
ys \<in> set (permutations xs)

goal (1 subgoal):
 1. \<And>x xs ys. \<lbrakk>\<And>xs ys. \<lbrakk>x = length xs; distinct xs; distinct ys; set xs = set ys\<rbrakk> \<Longrightarrow> ys \<in> set (permutations xs); Suc x = length xs; distinct xs; distinct ys; set xs = set ys\<rbrakk> \<Longrightarrow> ys \<in> set (permutations xs)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x xs ys. \<lbrakk>\<And>xs ys. \<lbrakk>x = length xs; distinct xs; distinct ys; set xs = set ys\<rbrakk> \<Longrightarrow> ys \<in> set (permutations xs); Suc x = length xs; distinct xs; distinct ys; set xs = set ys\<rbrakk> \<Longrightarrow> ys \<in> set (permutations xs)
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
\<lbrakk>n = length ?xs; distinct ?xs; distinct ?ys; set ?xs = set ?ys\<rbrakk> \<Longrightarrow> ?ys \<in> set (permutations ?xs)
Suc n = length xs
distinct xs
distinct ys
set xs = set ys

goal (1 subgoal):
 1. \<And>x xs ys. \<lbrakk>\<And>xs ys. \<lbrakk>x = length xs; distinct xs; distinct ys; set xs = set ys\<rbrakk> \<Longrightarrow> ys \<in> set (permutations xs); Suc x = length xs; distinct xs; distinct ys; set xs = set ys\<rbrakk> \<Longrightarrow> ys \<in> set (permutations xs)
[PROOF STEP]
from Suc.hyps
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>n = length ?xs; distinct ?xs; distinct ?ys; set ?xs = set ?ys\<rbrakk> \<Longrightarrow> ?ys \<in> set (permutations ?xs)
Suc n = length xs
[PROOF STEP]
have "xs \<noteq> []"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>n = length ?xs; distinct ?xs; distinct ?ys; set ?xs = set ?ys\<rbrakk> \<Longrightarrow> ?ys \<in> set (permutations ?xs)
Suc n = length xs

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

goal (1 subgoal):
 1. \<And>x xs ys. \<lbrakk>\<And>xs ys. \<lbrakk>x = length xs; distinct xs; distinct ys; set xs = set ys\<rbrakk> \<Longrightarrow> ys \<in> set (permutations xs); Suc x = length xs; distinct xs; distinct ys; set xs = set ys\<rbrakk> \<Longrightarrow> ys \<in> set (permutations xs)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
xs \<noteq> []
[PROOF STEP]
obtain y ys' where [simp]: "ys = y # ys'" "y \<in> set xs"
[PROOF STATE]
proof (prove)
using this:
xs \<noteq> []

goal (1 subgoal):
 1. (\<And>y ys'. \<lbrakk>ys = y # ys'; y \<in> set xs\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using Suc.prems
[PROOF STATE]
proof (prove)
using this:
xs \<noteq> []
distinct xs
distinct ys
set xs = set ys

goal (1 subgoal):
 1. (\<And>y ys'. \<lbrakk>ys = y # ys'; y \<in> set xs\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (cases ys) auto
[PROOF STATE]
proof (state)
this:
ys = y # ys'
y \<in> set xs

goal (1 subgoal):
 1. \<And>x xs ys. \<lbrakk>\<And>xs ys. \<lbrakk>x = length xs; distinct xs; distinct ys; set xs = set ys\<rbrakk> \<Longrightarrow> ys \<in> set (permutations xs); Suc x = length xs; distinct xs; distinct ys; set xs = set ys\<rbrakk> \<Longrightarrow> ys \<in> set (permutations xs)
[PROOF STEP]
have "ys' \<in> set (permutations (remove1 y xs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ys' \<in> set (permutations (remove1 y xs))
[PROOF STEP]
using Suc.prems \<open>Suc n = _\<close>
[PROOF STATE]
proof (prove)
using this:
distinct xs
distinct ys
set xs = set ys
Suc n = length xs

goal (1 subgoal):
 1. ys' \<in> set (permutations (remove1 y xs))
[PROOF STEP]
by (intro Suc.hyps) (simp_all add: length_remove1 )
[PROOF STATE]
proof (state)
this:
ys' \<in> set (permutations (remove1 y xs))

goal (1 subgoal):
 1. \<And>x xs ys. \<lbrakk>\<And>xs ys. \<lbrakk>x = length xs; distinct xs; distinct ys; set xs = set ys\<rbrakk> \<Longrightarrow> ys \<in> set (permutations xs); Suc x = length xs; distinct xs; distinct ys; set xs = set ys\<rbrakk> \<Longrightarrow> ys \<in> set (permutations xs)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
ys' \<in> set (permutations (remove1 y xs))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
ys' \<in> set (permutations (remove1 y xs))

goal (1 subgoal):
 1. ys \<in> set (permutations xs)
[PROOF STEP]
using \<open>xs \<noteq> []\<close>
[PROOF STATE]
proof (prove)
using this:
ys' \<in> set (permutations (remove1 y xs))
xs \<noteq> []

goal (1 subgoal):
 1. ys \<in> set (permutations xs)
[PROOF STEP]
by (auto simp: set_permutations_step)
[PROOF STATE]
proof (state)
this:
ys \<in> set (permutations xs)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sin_cos_eq_iff: "sin y = sin x \<and> cos y = cos x \<longleftrightarrow> (\<exists>n::int. y = x + 2 * pi * n)" (is "?L=?R")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (sin y = sin x \<and> cos y = cos x) = (\<exists>xa. y = x + 2 * pi * real_of_int xa)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. sin y = sin x \<and> cos y = cos x \<Longrightarrow> \<exists>xa. y = x + 2 * pi * real_of_int xa
 2. \<exists>xa. y = x + 2 * pi * real_of_int xa \<Longrightarrow> sin y = sin x \<and> cos y = cos x
[PROOF STEP]
assume ?L
[PROOF STATE]
proof (state)
this:
sin y = sin x \<and> cos y = cos x

goal (2 subgoals):
 1. sin y = sin x \<and> cos y = cos x \<Longrightarrow> \<exists>xa. y = x + 2 * pi * real_of_int xa
 2. \<exists>xa. y = x + 2 * pi * real_of_int xa \<Longrightarrow> sin y = sin x \<and> cos y = cos x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
sin y = sin x \<and> cos y = cos x
[PROOF STEP]
have "cos (y-x) = 1"
[PROOF STATE]
proof (prove)
using this:
sin y = sin x \<and> cos y = cos x

goal (1 subgoal):
 1. cos (y - x) = 1
[PROOF STEP]
using cos_add [of y "-x"]
[PROOF STATE]
proof (prove)
using this:
sin y = sin x \<and> cos y = cos x
cos (y + - x) = cos y * cos (- x) - sin y * sin (- x)

goal (1 subgoal):
 1. cos (y - x) = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
cos (y - x) = 1

goal (2 subgoals):
 1. sin y = sin x \<and> cos y = cos x \<Longrightarrow> \<exists>xa. y = x + 2 * pi * real_of_int xa
 2. \<exists>xa. y = x + 2 * pi * real_of_int xa \<Longrightarrow> sin y = sin x \<and> cos y = cos x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
cos (y - x) = 1
[PROOF STEP]
show ?R
[PROOF STATE]
proof (prove)
using this:
cos (y - x) = 1

goal (1 subgoal):
 1. \<exists>xa. y = x + 2 * pi * real_of_int xa
[PROOF STEP]
by (metis cos_one_2pi_int add.commute diff_add_cancel mult.assoc mult.commute)
[PROOF STATE]
proof (state)
this:
\<exists>xa. y = x + 2 * pi * real_of_int xa

goal (1 subgoal):
 1. \<exists>xa. y = x + 2 * pi * real_of_int xa \<Longrightarrow> sin y = sin x \<and> cos y = cos x
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>xa. y = x + 2 * pi * real_of_int xa \<Longrightarrow> sin y = sin x \<and> cos y = cos x
[PROOF STEP]
assume ?R
[PROOF STATE]
proof (state)
this:
\<exists>xa. y = x + 2 * pi * real_of_int xa

goal (1 subgoal):
 1. \<exists>xa. y = x + 2 * pi * real_of_int xa \<Longrightarrow> sin y = sin x \<and> cos y = cos x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>xa. y = x + 2 * pi * real_of_int xa
[PROOF STEP]
show ?L
[PROOF STATE]
proof (prove)
using this:
\<exists>xa. y = x + 2 * pi * real_of_int xa

goal (1 subgoal):
 1. sin y = sin x \<and> cos y = cos x
[PROOF STEP]
by (auto simp: sin_add cos_add)
[PROOF STATE]
proof (state)
this:
sin y = sin x \<and> cos y = cos x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma norm_ell2_vec_of_basis_enum: "norm \<psi> =
  (let \<psi>' = vec_of_basis_enum \<psi> in
    sqrt (\<Sum> i \<in> {0 ..< dim_vec \<psi>'}. let z = vec_index \<psi>' i in (Re z)\<^sup>2 + (Im z)\<^sup>2))"
  (is "_ = ?rhs") for \<psi> :: "'a::onb_enum"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm \<psi> = (let \<psi>' = vec_of_basis_enum \<psi> in sqrt (\<Sum>i = 0..<dim_vec \<psi>'. let z = \<psi>' $ i in (Re z)\<^sup>2 + (Im z)\<^sup>2))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. norm \<psi> = (let \<psi>' = vec_of_basis_enum \<psi> in sqrt (\<Sum>i = 0..<dim_vec \<psi>'. let z = \<psi>' $ i in (Re z)\<^sup>2 + (Im z)\<^sup>2))
[PROOF STEP]
have "norm \<psi> = sqrt (cmod (\<Sum>i = 0..<dim_vec (vec_of_basis_enum \<psi>).
            vec_of_basis_enum \<psi> $ i * conjugate (vec_of_basis_enum \<psi>) $ i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm \<psi> = sqrt (cmod (\<Sum>i = 0..<dim_vec (vec_of_basis_enum \<psi>). vec_of_basis_enum \<psi> $ i * conjugate (vec_of_basis_enum \<psi>) $ i))
[PROOF STEP]
unfolding norm_eq_sqrt_cinner[where 'a='a] cscalar_prod_vec_of_basis_enum[symmetric] scalar_prod_def dim_vec_conjugate
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sqrt (cmod (\<Sum>i = 0..<dim_vec (vec_of_basis_enum \<psi>). vec_of_basis_enum \<psi> $ i * conjugate (vec_of_basis_enum \<psi>) $ i)) = sqrt (cmod (\<Sum>i = 0..<dim_vec (vec_of_basis_enum \<psi>). vec_of_basis_enum \<psi> $ i * conjugate (vec_of_basis_enum \<psi>) $ i))
[PROOF STEP]
by rule
[PROOF STATE]
proof (state)
this:
norm \<psi> = sqrt (cmod (\<Sum>i = 0..<dim_vec (vec_of_basis_enum \<psi>). vec_of_basis_enum \<psi> $ i * conjugate (vec_of_basis_enum \<psi>) $ i))

goal (1 subgoal):
 1. norm \<psi> = (let \<psi>' = vec_of_basis_enum \<psi> in sqrt (\<Sum>i = 0..<dim_vec \<psi>'. let z = \<psi>' $ i in (Re z)\<^sup>2 + (Im z)\<^sup>2))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
norm \<psi> = sqrt (cmod (\<Sum>i = 0..<dim_vec (vec_of_basis_enum \<psi>). vec_of_basis_enum \<psi> $ i * conjugate (vec_of_basis_enum \<psi>) $ i))

goal (1 subgoal):
 1. norm \<psi> = (let \<psi>' = vec_of_basis_enum \<psi> in sqrt (\<Sum>i = 0..<dim_vec \<psi>'. let z = \<psi>' $ i in (Re z)\<^sup>2 + (Im z)\<^sup>2))
[PROOF STEP]
have "\<dots> = sqrt (cmod (\<Sum>x = 0..<dim_vec (vec_of_basis_enum \<psi>).
                    let z = vec_of_basis_enum \<psi> $ x in (Re z)\<^sup>2 + (Im z)\<^sup>2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sqrt (cmod (\<Sum>i = 0..<dim_vec (vec_of_basis_enum \<psi>). vec_of_basis_enum \<psi> $ i * conjugate (vec_of_basis_enum \<psi>) $ i)) = sqrt (cmod (complex_of_real (\<Sum>x = 0..<dim_vec (vec_of_basis_enum \<psi>). let z = vec_of_basis_enum \<psi> $ x in (Re z)\<^sup>2 + (Im z)\<^sup>2)))
[PROOF STEP]
apply (subst sum.cong, rule refl)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x. x \<in> {0..<dim_vec (vec_of_basis_enum \<psi>)} \<Longrightarrow> vec_of_basis_enum \<psi> $ x * conjugate (vec_of_basis_enum \<psi>) $ x = ?h x
 2. sqrt (cmod (sum ?h {0..<dim_vec (vec_of_basis_enum \<psi>)})) = sqrt (cmod (complex_of_real (\<Sum>x = 0..<dim_vec (vec_of_basis_enum \<psi>). let z = vec_of_basis_enum \<psi> $ x in (Re z)\<^sup>2 + (Im z)\<^sup>2)))
[PROOF STEP]
apply (subst vec_index_conjugate)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>x. x \<in> {0..<dim_vec (vec_of_basis_enum \<psi>)} \<Longrightarrow> x < dim_vec (vec_of_basis_enum \<psi>)
 2. \<And>x. x \<in> {0..<dim_vec (vec_of_basis_enum \<psi>)} \<Longrightarrow> vec_of_basis_enum \<psi> $ x * conjugate (vec_of_basis_enum \<psi> $ x) = ?h3 x x
 3. sqrt (cmod (\<Sum>x = 0..<dim_vec (vec_of_basis_enum \<psi>). ?h3 x x)) = sqrt (cmod (complex_of_real (\<Sum>x = 0..<dim_vec (vec_of_basis_enum \<psi>). let z = vec_of_basis_enum \<psi> $ x in (Re z)\<^sup>2 + (Im z)\<^sup>2)))
[PROOF STEP]
by (auto simp: Let_def complex_mult_cnj)
[PROOF STATE]
proof (state)
this:
sqrt (cmod (\<Sum>i = 0..<dim_vec (vec_of_basis_enum \<psi>). vec_of_basis_enum \<psi> $ i * conjugate (vec_of_basis_enum \<psi>) $ i)) = sqrt (cmod (complex_of_real (\<Sum>x = 0..<dim_vec (vec_of_basis_enum \<psi>). let z = vec_of_basis_enum \<psi> $ x in (Re z)\<^sup>2 + (Im z)\<^sup>2)))

goal (1 subgoal):
 1. norm \<psi> = (let \<psi>' = vec_of_basis_enum \<psi> in sqrt (\<Sum>i = 0..<dim_vec \<psi>'. let z = \<psi>' $ i in (Re z)\<^sup>2 + (Im z)\<^sup>2))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sqrt (cmod (\<Sum>i = 0..<dim_vec (vec_of_basis_enum \<psi>). vec_of_basis_enum \<psi> $ i * conjugate (vec_of_basis_enum \<psi>) $ i)) = sqrt (cmod (complex_of_real (\<Sum>x = 0..<dim_vec (vec_of_basis_enum \<psi>). let z = vec_of_basis_enum \<psi> $ x in (Re z)\<^sup>2 + (Im z)\<^sup>2)))

goal (1 subgoal):
 1. norm \<psi> = (let \<psi>' = vec_of_basis_enum \<psi> in sqrt (\<Sum>i = 0..<dim_vec \<psi>'. let z = \<psi>' $ i in (Re z)\<^sup>2 + (Im z)\<^sup>2))
[PROOF STEP]
have "\<dots> = ?rhs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sqrt (cmod (complex_of_real (\<Sum>x = 0..<dim_vec (vec_of_basis_enum \<psi>). let z = vec_of_basis_enum \<psi> $ x in (Re z)\<^sup>2 + (Im z)\<^sup>2))) = (let \<psi>' = vec_of_basis_enum \<psi> in sqrt (\<Sum>i = 0..<dim_vec \<psi>'. let z = \<psi>' $ i in (Re z)\<^sup>2 + (Im z)\<^sup>2))
[PROOF STEP]
unfolding Let_def norm_of_real
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sqrt \<bar>\<Sum>x = 0..<dim_vec (vec_of_basis_enum \<psi>). (Re (vec_of_basis_enum \<psi> $ x))\<^sup>2 + (Im (vec_of_basis_enum \<psi> $ x))\<^sup>2\<bar> = sqrt (\<Sum>i = 0..<dim_vec (vec_of_basis_enum \<psi>). (Re (vec_of_basis_enum \<psi> $ i))\<^sup>2 + (Im (vec_of_basis_enum \<psi> $ i))\<^sup>2)
[PROOF STEP]
apply (subst abs_of_nonneg)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. 0 \<le> (\<Sum>x = 0..<dim_vec (vec_of_basis_enum \<psi>). (Re (vec_of_basis_enum \<psi> $ x))\<^sup>2 + (Im (vec_of_basis_enum \<psi> $ x))\<^sup>2)
 2. sqrt (\<Sum>x = 0..<dim_vec (vec_of_basis_enum \<psi>). (Re (vec_of_basis_enum \<psi> $ x))\<^sup>2 + (Im (vec_of_basis_enum \<psi> $ x))\<^sup>2) = sqrt (\<Sum>i = 0..<dim_vec (vec_of_basis_enum \<psi>). (Re (vec_of_basis_enum \<psi> $ i))\<^sup>2 + (Im (vec_of_basis_enum \<psi> $ i))\<^sup>2)
[PROOF STEP]
apply (rule sum_nonneg)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x. x \<in> {0..<dim_vec (vec_of_basis_enum \<psi>)} \<Longrightarrow> 0 \<le> (Re (vec_of_basis_enum \<psi> $ x))\<^sup>2 + (Im (vec_of_basis_enum \<psi> $ x))\<^sup>2
 2. sqrt (\<Sum>x = 0..<dim_vec (vec_of_basis_enum \<psi>). (Re (vec_of_basis_enum \<psi> $ x))\<^sup>2 + (Im (vec_of_basis_enum \<psi> $ x))\<^sup>2) = sqrt (\<Sum>i = 0..<dim_vec (vec_of_basis_enum \<psi>). (Re (vec_of_basis_enum \<psi> $ i))\<^sup>2 + (Im (vec_of_basis_enum \<psi> $ i))\<^sup>2)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
sqrt (cmod (complex_of_real (\<Sum>x = 0..<dim_vec (vec_of_basis_enum \<psi>). let z = vec_of_basis_enum \<psi> $ x in (Re z)\<^sup>2 + (Im z)\<^sup>2))) = (let \<psi>' = vec_of_basis_enum \<psi> in sqrt (\<Sum>i = 0..<dim_vec \<psi>'. let z = \<psi>' $ i in (Re z)\<^sup>2 + (Im z)\<^sup>2))

goal (1 subgoal):
 1. norm \<psi> = (let \<psi>' = vec_of_basis_enum \<psi> in sqrt (\<Sum>i = 0..<dim_vec \<psi>'. let z = \<psi>' $ i in (Re z)\<^sup>2 + (Im z)\<^sup>2))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
norm \<psi> = (let \<psi>' = vec_of_basis_enum \<psi> in sqrt (\<Sum>i = 0..<dim_vec \<psi>'. let z = \<psi>' $ i in (Re z)\<^sup>2 + (Im z)\<^sup>2))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
norm \<psi> = (let \<psi>' = vec_of_basis_enum \<psi> in sqrt (\<Sum>i = 0..<dim_vec \<psi>'. let z = \<psi>' $ i in (Re z)\<^sup>2 + (Im z)\<^sup>2))

goal (1 subgoal):
 1. norm \<psi> = (let \<psi>' = vec_of_basis_enum \<psi> in sqrt (\<Sum>i = 0..<dim_vec \<psi>'. let z = \<psi>' $ i in (Re z)\<^sup>2 + (Im z)\<^sup>2))
[PROOF STEP]
by -
[PROOF STATE]
proof (state)
this:
norm \<psi> = (let \<psi>' = vec_of_basis_enum \<psi> in sqrt (\<Sum>i = 0..<dim_vec \<psi>'. let z = \<psi>' $ i in (Re z)\<^sup>2 + (Im z)\<^sup>2))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem set_times_rearrange4: "C * (a *o D) = a *o (C * D)"
  for a :: "'a::comm_monoid_mult"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. C * a *o D = a *o (C * D)
[PROOF STEP]
by (metis mult.commute set_times_rearrange3)


[STATEMENT]
lemma sum_of_3_powers: "2 * (\<Sum>i=0..<n. 3^i) = 3^n - (1::nat)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * sum ((^) 3) {0..<n} = 3 ^ n - 1
[PROOF STEP]
by (induct n) auto


[STATEMENT]
lemma compact_differences:
  fixes s t :: "'a::real_normed_vector set"
  assumes "compact s"
    and "compact t"
  shows "compact {x - y | x y. x \<in> s \<and> y \<in> t}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. compact {x - y |x y. x \<in> s \<and> y \<in> t}
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. compact {x - y |x y. x \<in> s \<and> y \<in> t}
[PROOF STEP]
have "{x - y | x y. x\<in>s \<and> y \<in> t} = {x + y | x y. x \<in> s \<and> y \<in> (uminus ` t)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x - y |x y. x \<in> s \<and> y \<in> t} = {x + y |x y. x \<in> s \<and> y \<in> uminus ` t}
[PROOF STEP]
using diff_conv_add_uminus
[PROOF STATE]
proof (prove)
using this:
?a - ?b = ?a + - ?b

goal (1 subgoal):
 1. {x - y |x y. x \<in> s \<and> y \<in> t} = {x + y |x y. x \<in> s \<and> y \<in> uminus ` t}
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
{x - y |x y. x \<in> s \<and> y \<in> t} = {x + y |x y. x \<in> s \<and> y \<in> uminus ` t}

goal (1 subgoal):
 1. compact {x - y |x y. x \<in> s \<and> y \<in> t}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
{x - y |x y. x \<in> s \<and> y \<in> t} = {x + y |x y. x \<in> s \<and> y \<in> uminus ` t}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
{x - y |x y. x \<in> s \<and> y \<in> t} = {x + y |x y. x \<in> s \<and> y \<in> uminus ` t}

goal (1 subgoal):
 1. compact {x - y |x y. x \<in> s \<and> y \<in> t}
[PROOF STEP]
using compact_sums[OF assms(1) compact_negations[OF assms(2)]]
[PROOF STATE]
proof (prove)
using this:
{x - y |x y. x \<in> s \<and> y \<in> t} = {x + y |x y. x \<in> s \<and> y \<in> uminus ` t}
compact {x + y |x y. x \<in> s \<and> y \<in> uminus ` t}

goal (1 subgoal):
 1. compact {x - y |x y. x \<in> s \<and> y \<in> t}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
compact {x - y |x y. x \<in> s \<and> y \<in> t}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma exp_golomb_bit_count_est:
  assumes "n \<le> m "
  shows "bit_count (N\<^sub>e n) \<le> (2 * log 2 (real m+1) + 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bit_count (N\<^sub>e n) \<le> ereal (2 * log 2 (real m + 1) + 1)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. bit_count (N\<^sub>e n) \<le> ereal (2 * log 2 (real m + 1) + 1)
[PROOF STEP]
have "bit_count (N\<^sub>e n) \<le> (2 * log 2 (real n+1) + 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bit_count (N\<^sub>e n) \<le> ereal (2 * log 2 (real n + 1) + 1)
[PROOF STEP]
using exp_golomb_bit_count
[PROOF STATE]
proof (prove)
using this:
bit_count (N\<^sub>e ?n) \<le> ereal (2 * log 2 (real ?n + 1) + 1)

goal (1 subgoal):
 1. bit_count (N\<^sub>e n) \<le> ereal (2 * log 2 (real n + 1) + 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
bit_count (N\<^sub>e n) \<le> ereal (2 * log 2 (real n + 1) + 1)

goal (1 subgoal):
 1. bit_count (N\<^sub>e n) \<le> ereal (2 * log 2 (real m + 1) + 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
bit_count (N\<^sub>e n) \<le> ereal (2 * log 2 (real n + 1) + 1)

goal (1 subgoal):
 1. bit_count (N\<^sub>e n) \<le> ereal (2 * log 2 (real m + 1) + 1)
[PROOF STEP]
have "... \<le> (2 * log 2 (real m+1) + 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ereal (2 * log 2 (real n + 1) + 1) \<le> ereal (2 * log 2 (real m + 1) + 1)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
n \<le> m

goal (1 subgoal):
 1. ereal (2 * log 2 (real n + 1) + 1) \<le> ereal (2 * log 2 (real m + 1) + 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
ereal (2 * log 2 (real n + 1) + 1) \<le> ereal (2 * log 2 (real m + 1) + 1)

goal (1 subgoal):
 1. bit_count (N\<^sub>e n) \<le> ereal (2 * log 2 (real m + 1) + 1)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
bit_count (N\<^sub>e n) \<le> ereal (2 * log 2 (real m + 1) + 1)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
bit_count (N\<^sub>e n) \<le> ereal (2 * log 2 (real m + 1) + 1)

goal (1 subgoal):
 1. bit_count (N\<^sub>e n) \<le> ereal (2 * log 2 (real m + 1) + 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
bit_count (N\<^sub>e n) \<le> ereal (2 * log 2 (real m + 1) + 1)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma det_identical_columns:
  assumes A: "A \<in> carrier_mat n n"
    and ij: "i \<noteq> j"
    and i: "i < n" and j: "j < n"
    and r: "col A i = col A j"
  shows "det A = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det A = (0::'a)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. det A = (0::'a)
[PROOF STEP]
have "det A = det A\<^sup>T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det A = det A\<^sup>T
[PROOF STEP]
using det_transpose[OF A]
[PROOF STATE]
proof (prove)
using this:
det A\<^sup>T = det A

goal (1 subgoal):
 1. det A = det A\<^sup>T
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
det A = det A\<^sup>T

goal (1 subgoal):
 1. det A = (0::'a)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
det A = det A\<^sup>T

goal (1 subgoal):
 1. det A = (0::'a)
[PROOF STEP]
have "... = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det A\<^sup>T = (0::'a)
[PROOF STEP]
proof (rule det_identical_rows[of _ n i j])
[PROOF STATE]
proof (state)
goal (5 subgoals):
 1. A\<^sup>T \<in> carrier_mat n n
 2. i \<noteq> j
 3. i < n
 4. j < n
 5. row A\<^sup>T i = row A\<^sup>T j
[PROOF STEP]
show "row (transpose_mat A) i = row (transpose_mat A) j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. row A\<^sup>T i = row A\<^sup>T j
[PROOF STEP]
using A i j r
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n n
i < n
j < n
col A i = col A j

goal (1 subgoal):
 1. row A\<^sup>T i = row A\<^sup>T j
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
row A\<^sup>T i = row A\<^sup>T j

goal (4 subgoals):
 1. A\<^sup>T \<in> carrier_mat n n
 2. i \<noteq> j
 3. i < n
 4. j < n
[PROOF STEP]
qed (auto simp add: assms)
[PROOF STATE]
proof (state)
this:
det A\<^sup>T = (0::'a)

goal (1 subgoal):
 1. det A = (0::'a)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
det A = (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
det A = (0::'a)

goal (1 subgoal):
 1. det A = (0::'a)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
det A = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma floor_less_cancel: "\<lfloor>x\<rfloor> < \<lfloor>y\<rfloor> \<Longrightarrow> x < y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lfloor>x\<rfloor> < \<lfloor>y\<rfloor> \<Longrightarrow> x < y
[PROOF STEP]
by (auto simp add: not_le [symmetric] floor_mono)


[STATEMENT]
lemma max_all_edges_between:
  assumes "finite X" "finite Y"
  shows "card (all_edges_between X Y G) \<le> card X * card Y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (all_edges_between X Y G) \<le> card X * card Y
[PROOF STEP]
by (metis assms card_mono finite_SigmaI all_edges_between_subset card_cartesian_product)


[STATEMENT]
lemma Arg_minus_ii [simp]: "Arg (-\<i>) = -pi/2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Arg (- \<i>) = - pi / 2
[PROOF STEP]
proof (rule cis_Arg_unique)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. sgn (- \<i>) = cis (- pi / 2)
 2. - pi < - pi / 2
 3. - pi / 2 \<le> pi
[PROOF STEP]
show "sgn (- \<i>) = cis (- pi / 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sgn (- \<i>) = cis (- pi / 2)
[PROOF STEP]
by (simp add: sgn_eq)
[PROOF STATE]
proof (state)
this:
sgn (- \<i>) = cis (- pi / 2)

goal (2 subgoals):
 1. - pi < - pi / 2
 2. - pi / 2 \<le> pi
[PROOF STEP]
show "- pi / 2 \<le> pi"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. - pi / 2 \<le> pi
[PROOF STEP]
using pi_not_less_zero
[PROOF STATE]
proof (prove)
using this:
\<not> pi < 0

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

goal (1 subgoal):
 1. - pi < - pi / 2
[PROOF STEP]
qed auto


[STATEMENT]
lemma Least_imp_le: "
  \<lbrakk> \<exists>x. P x; \<And>x. P x \<Longrightarrow> Q x \<rbrakk> \<Longrightarrow>
  (LEAST (x::'a::wellorder). Q x) \<le> (LEAST x. P x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<exists>x. P x; \<And>x. P x \<Longrightarrow> Q x\<rbrakk> \<Longrightarrow> (LEAST x. Q x) \<le> (LEAST x. P x)
[PROOF STEP]
by (blast intro: Least_le LeastI2_ex)


[STATEMENT]
lemma length_chop:
  assumes "n > 0"
  shows   "length (chop n xs) = nat \<lceil>length xs / n\<rceil>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (chop n xs) = nat \<lceil>real (length xs) / real n\<rceil>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. length (chop n xs) = nat \<lceil>real (length xs) / real n\<rceil>
[PROOF STEP]
from \<open>n > 0\<close>
[PROOF STATE]
proof (chain)
picking this:
0 < n
[PROOF STEP]
have "real n * length (chop n xs) \<ge> length xs"
[PROOF STATE]
proof (prove)
using this:
0 < n

goal (1 subgoal):
 1. real (length xs) \<le> real n * real (length (chop n xs))
[PROOF STEP]
by (induction n xs rule: chop.induct; subst chop.simps) (auto simp: field_simps)
[PROOF STATE]
proof (state)
this:
real (length xs) \<le> real n * real (length (chop n xs))

goal (1 subgoal):
 1. length (chop n xs) = nat \<lceil>real (length xs) / real n\<rceil>
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
real (length xs) \<le> real n * real (length (chop n xs))

goal (1 subgoal):
 1. length (chop n xs) = nat \<lceil>real (length xs) / real n\<rceil>
[PROOF STEP]
from \<open>n > 0\<close>
[PROOF STATE]
proof (chain)
picking this:
0 < n
[PROOF STEP]
have "real n * length (chop n xs) < length xs + n"
[PROOF STATE]
proof (prove)
using this:
0 < n

goal (1 subgoal):
 1. real n * real (length (chop n xs)) < real (length xs + n)
[PROOF STEP]
by (induction n xs rule: chop.induct; subst chop.simps)
       (auto simp: field_simps split: nat_diff_split_asm)+
[PROOF STATE]
proof (state)
this:
real n * real (length (chop n xs)) < real (length xs + n)

goal (1 subgoal):
 1. length (chop n xs) = nat \<lceil>real (length xs) / real n\<rceil>
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
real (length xs) \<le> real n * real (length (chop n xs))
real n * real (length (chop n xs)) < real (length xs + n)
[PROOF STEP]
have "length (chop n xs) \<ge> length xs / n" and "length (chop n xs) < length xs / n + 1"
[PROOF STATE]
proof (prove)
using this:
real (length xs) \<le> real n * real (length (chop n xs))
real n * real (length (chop n xs)) < real (length xs + n)

goal (1 subgoal):
 1. real (length xs) / real n \<le> real (length (chop n xs)) &&& real (length (chop n xs)) < real (length xs) / real n + 1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
real (length xs) \<le> real n * real (length (chop n xs))
real n * real (length (chop n xs)) < real (length xs + n)
0 < n

goal (1 subgoal):
 1. real (length xs) / real n \<le> real (length (chop n xs)) &&& real (length (chop n xs)) < real (length xs) / real n + 1
[PROOF STEP]
by (auto simp: field_simps)
[PROOF STATE]
proof (state)
this:
real (length xs) / real n \<le> real (length (chop n xs))
real (length (chop n xs)) < real (length xs) / real n + 1

goal (1 subgoal):
 1. length (chop n xs) = nat \<lceil>real (length xs) / real n\<rceil>
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
real (length xs) / real n \<le> real (length (chop n xs))
real (length (chop n xs)) < real (length xs) / real n + 1

goal (1 subgoal):
 1. length (chop n xs) = nat \<lceil>real (length xs) / real n\<rceil>
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
length (chop n xs) = nat \<lceil>real (length xs) / real n\<rceil>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma convergent_prod_iff_nz_lim:
  fixes f :: "nat \<Rightarrow> 'a :: {topological_semigroup_mult,t2_space,idom}"
  assumes "\<And>i. f i \<noteq> 0"
  shows "convergent_prod f \<longleftrightarrow> (\<exists>L. (\<lambda>n. \<Prod>i\<le>n. f i) \<longlonglongrightarrow> L \<and> L \<noteq> 0)"
    (is "?lhs \<longleftrightarrow> ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. convergent_prod f = (\<exists>L. (\<lambda>n. prod f {..n}) \<longlonglongrightarrow> L \<and> L \<noteq> (0::'a))
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. convergent_prod f \<Longrightarrow> \<exists>L. (\<lambda>n. prod f {..n}) \<longlonglongrightarrow> L \<and> L \<noteq> (0::'a)
 2. \<exists>L. (\<lambda>n. prod f {..n}) \<longlonglongrightarrow> L \<and> L \<noteq> (0::'a) \<Longrightarrow> convergent_prod f
[PROOF STEP]
assume ?lhs
[PROOF STATE]
proof (state)
this:
convergent_prod f

goal (2 subgoals):
 1. convergent_prod f \<Longrightarrow> \<exists>L. (\<lambda>n. prod f {..n}) \<longlonglongrightarrow> L \<and> L \<noteq> (0::'a)
 2. \<exists>L. (\<lambda>n. prod f {..n}) \<longlonglongrightarrow> L \<and> L \<noteq> (0::'a) \<Longrightarrow> convergent_prod f
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
convergent_prod f
[PROOF STEP]
show ?rhs
[PROOF STATE]
proof (prove)
using this:
convergent_prod f

goal (1 subgoal):
 1. \<exists>L. (\<lambda>n. prod f {..n}) \<longlonglongrightarrow> L \<and> L \<noteq> (0::'a)
[PROOF STEP]
using assms convergentD convergent_prod_imp_convergent convergent_prod_to_zero_iff
[PROOF STATE]
proof (prove)
using this:
convergent_prod f
f ?i \<noteq> (0::'a)
convergent ?X \<Longrightarrow> \<exists>L. ?X \<longlonglongrightarrow> L
convergent_prod ?f \<Longrightarrow> convergent (\<lambda>n. prod ?f {..n})
convergent_prod ?f \<Longrightarrow> (\<lambda>n. prod ?f {..n}) \<longlonglongrightarrow> (0::?'a) = (\<exists>i. ?f i = (0::?'a))

goal (1 subgoal):
 1. \<exists>L. (\<lambda>n. prod f {..n}) \<longlonglongrightarrow> L \<and> L \<noteq> (0::'a)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>L. (\<lambda>n. prod f {..n}) \<longlonglongrightarrow> L \<and> L \<noteq> (0::'a)

goal (1 subgoal):
 1. \<exists>L. (\<lambda>n. prod f {..n}) \<longlonglongrightarrow> L \<and> L \<noteq> (0::'a) \<Longrightarrow> convergent_prod f
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>L. (\<lambda>n. prod f {..n}) \<longlonglongrightarrow> L \<and> L \<noteq> (0::'a) \<Longrightarrow> convergent_prod f
[PROOF STEP]
assume ?rhs
[PROOF STATE]
proof (state)
this:
\<exists>L. (\<lambda>n. prod f {..n}) \<longlonglongrightarrow> L \<and> L \<noteq> (0::'a)

goal (1 subgoal):
 1. \<exists>L. (\<lambda>n. prod f {..n}) \<longlonglongrightarrow> L \<and> L \<noteq> (0::'a) \<Longrightarrow> convergent_prod f
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>L. (\<lambda>n. prod f {..n}) \<longlonglongrightarrow> L \<and> L \<noteq> (0::'a)
[PROOF STEP]
show ?lhs
[PROOF STATE]
proof (prove)
using this:
\<exists>L. (\<lambda>n. prod f {..n}) \<longlonglongrightarrow> L \<and> L \<noteq> (0::'a)

goal (1 subgoal):
 1. convergent_prod f
[PROOF STEP]
unfolding prod_defs
[PROOF STATE]
proof (prove)
using this:
\<exists>L. (\<lambda>n. prod f {..n}) \<longlonglongrightarrow> L \<and> L \<noteq> (0::'a)

goal (1 subgoal):
 1. \<exists>M p. (\<lambda>n. \<Prod>i\<le>n. f (i + M)) \<longlonglongrightarrow> p \<and> p \<noteq> (0::'a)
[PROOF STEP]
by (rule_tac x=0 in exI) auto
[PROOF STATE]
proof (state)
this:
convergent_prod f

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma decompose_init_prod:
  fixes n::nat
  shows "(\<Prod> i\<in> {0..n}. f i) = f 0 * (\<Prod> i\<in> {1..n}. f i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prod f {0..n} = f 0 * prod f {1..n}
[PROOF STEP]
proof (cases "Suc 0 \<le> n")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Suc 0 \<le> n \<Longrightarrow> prod f {0..n} = f 0 * prod f {1..n}
 2. \<not> Suc 0 \<le> n \<Longrightarrow> prod f {0..n} = f 0 * prod f {1..n}
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
Suc 0 \<le> n

goal (2 subgoals):
 1. Suc 0 \<le> n \<Longrightarrow> prod f {0..n} = f 0 * prod f {1..n}
 2. \<not> Suc 0 \<le> n \<Longrightarrow> prod f {0..n} = f 0 * prod f {1..n}
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
Suc 0 \<le> n

goal (1 subgoal):
 1. prod f {0..n} = f 0 * prod f {1..n}
[PROOF STEP]
by (metis One_nat_def Suc_le_D True prod.atLeast0_atMost_Suc_shift prod.atLeast_Suc_atMost_Suc_shift)
[PROOF STATE]
proof (state)
this:
prod f {0..n} = f 0 * prod f {1..n}

goal (1 subgoal):
 1. \<not> Suc 0 \<le> n \<Longrightarrow> prod f {0..n} = f 0 * prod f {1..n}
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> Suc 0 \<le> n \<Longrightarrow> prod f {0..n} = f 0 * prod f {1..n}
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> Suc 0 \<le> n

goal (1 subgoal):
 1. \<not> Suc 0 \<le> n \<Longrightarrow> prod f {0..n} = f 0 * prod f {1..n}
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> Suc 0 \<le> n

goal (1 subgoal):
 1. prod f {0..n} = f 0 * prod f {1..n}
[PROOF STEP]
by (metis One_nat_def atLeastLessThanSuc_atLeastAtMost prod.atLeast0_lessThan_Suc_shift
        prod.atLeast_Suc_lessThan_Suc_shift)
[PROOF STATE]
proof (state)
this:
prod f {0..n} = f 0 * prod f {1..n}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fUnionM_funionM:
 "fUnionM ((\<lambda>y. funionM (f y) (g y)) |`| A) = funionM (fUnionM (f |`| A)) (fUnionM (g |`| A))" for f g A
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fUnionM ((\<lambda>y. funionM (f y) (g y)) |`| A) = funionM (fUnionM (f |`| A)) (fUnionM (g |`| A))
[PROOF STEP]
by(induction A)(simp_all add: funionM_assoc funionM_commute fun_left_comm)


[STATEMENT]
lemma var_sum_1:
  fixes f :: "'b \<Rightarrow> 'a \<Rightarrow> real"
  assumes "finite I"
  assumes "\<And>i. i \<in> I \<Longrightarrow> f i \<in> borel_measurable M"
  assumes "\<And>i. i \<in> I \<Longrightarrow> integrable M (\<lambda>\<omega>. f i \<omega>^2)"
  shows
    "variance (\<lambda>\<omega>. (\<Sum>i \<in> I. f i \<omega>)) = (\<Sum>i \<in> I. (\<Sum>j \<in> I. covariance (f i) (f j)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. \<Sum>j\<in>I. covariance (f i) (f j))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. \<Sum>j\<in>I. covariance (f i) (f j))
[PROOF STEP]
have a:"\<And>i j. i \<in> I \<Longrightarrow> j \<in> I \<Longrightarrow> integrable M (\<lambda>\<omega>. (f i \<omega> - expectation (f i)) * (f j \<omega> - expectation (f j)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i \<in> I; j \<in> I\<rbrakk> \<Longrightarrow> integrable M (\<lambda>\<omega>. (f i \<omega> - expectation (f i)) * (f j \<omega> - expectation (f j)))
[PROOF STEP]
using assms covar_integrable
[PROOF STATE]
proof (prove)
using this:
finite I
?i12 \<in> I \<Longrightarrow> random_variable borel (f ?i12)
?i12 \<in> I \<Longrightarrow> integrable M (\<lambda>\<omega>. (f ?i12 \<omega>)\<^sup>2)
\<lbrakk>random_variable borel ?f; random_variable borel ?g; integrable M (\<lambda>\<omega>. (?f \<omega>)\<^sup>2); integrable M (\<lambda>\<omega>. (?g \<omega>)\<^sup>2)\<rbrakk> \<Longrightarrow> integrable M (\<lambda>\<omega>. (?f \<omega> - expectation ?f) * (?g \<omega> - expectation ?g))

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i \<in> I; j \<in> I\<rbrakk> \<Longrightarrow> integrable M (\<lambda>\<omega>. (f i \<omega> - expectation (f i)) * (f j \<omega> - expectation (f j)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i12 \<in> I; ?j12 \<in> I\<rbrakk> \<Longrightarrow> integrable M (\<lambda>\<omega>. (f ?i12 \<omega> - expectation (f ?i12)) * (f ?j12 \<omega> - expectation (f ?j12)))

goal (1 subgoal):
 1. expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. \<Sum>j\<in>I. covariance (f i) (f j))
[PROOF STEP]
have "variance (\<lambda>\<omega>. (\<Sum>i \<in> I. f i \<omega>)) = expectation (\<lambda>\<omega>. (\<Sum>i\<in>I. f i \<omega> - expectation (f i))\<^sup>2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = expectation (\<lambda>\<omega>. (\<Sum>i\<in>I. f i \<omega> - expectation (f i))\<^sup>2)
[PROOF STEP]
using square_integrable_imp_integrable[OF assms(2,3)]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?i13 \<in> I; ?i13 \<in> I\<rbrakk> \<Longrightarrow> integrable M (f ?i13)

goal (1 subgoal):
 1. expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = expectation (\<lambda>\<omega>. (\<Sum>i\<in>I. f i \<omega> - expectation (f i))\<^sup>2)
[PROOF STEP]
by (simp add: Bochner_Integration.integral_sum  sum_subtractf)
[PROOF STATE]
proof (state)
this:
expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = expectation (\<lambda>\<omega>. (\<Sum>i\<in>I. f i \<omega> - expectation (f i))\<^sup>2)

goal (1 subgoal):
 1. expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. \<Sum>j\<in>I. covariance (f i) (f j))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = expectation (\<lambda>\<omega>. (\<Sum>i\<in>I. f i \<omega> - expectation (f i))\<^sup>2)

goal (1 subgoal):
 1. expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. \<Sum>j\<in>I. covariance (f i) (f j))
[PROOF STEP]
have "... = expectation (\<lambda>\<omega>. (\<Sum>i \<in> I. (\<Sum>j \<in> I. (f i \<omega> - expectation (f i)) *  (f j \<omega> - expectation (f j)))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. (\<Sum>i\<in>I. f i \<omega> - expectation (f i))\<^sup>2) = expectation (\<lambda>\<omega>. \<Sum>i\<in>I. \<Sum>j\<in>I. (f i \<omega> - expectation (f i)) * (f j \<omega> - expectation (f j)))
[PROOF STEP]
by (simp add: power2_eq_square sum_distrib_right sum_distrib_left mult.commute)
[PROOF STATE]
proof (state)
this:
expectation (\<lambda>\<omega>. (\<Sum>i\<in>I. f i \<omega> - expectation (f i))\<^sup>2) = expectation (\<lambda>\<omega>. \<Sum>i\<in>I. \<Sum>j\<in>I. (f i \<omega> - expectation (f i)) * (f j \<omega> - expectation (f j)))

goal (1 subgoal):
 1. expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. \<Sum>j\<in>I. covariance (f i) (f j))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
expectation (\<lambda>\<omega>. (\<Sum>i\<in>I. f i \<omega> - expectation (f i))\<^sup>2) = expectation (\<lambda>\<omega>. \<Sum>i\<in>I. \<Sum>j\<in>I. (f i \<omega> - expectation (f i)) * (f j \<omega> - expectation (f j)))

goal (1 subgoal):
 1. expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. \<Sum>j\<in>I. covariance (f i) (f j))
[PROOF STEP]
have "... = (\<Sum>i \<in> I. (\<Sum>j \<in> I. covariance (f i) (f j)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. \<Sum>i\<in>I. \<Sum>j\<in>I. (f i \<omega> - expectation (f i)) * (f j \<omega> - expectation (f j))) = (\<Sum>i\<in>I. \<Sum>j\<in>I. covariance (f i) (f j))
[PROOF STEP]
using a
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?i12 \<in> I; ?j12 \<in> I\<rbrakk> \<Longrightarrow> integrable M (\<lambda>\<omega>. (f ?i12 \<omega> - expectation (f ?i12)) * (f ?j12 \<omega> - expectation (f ?j12)))

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. \<Sum>i\<in>I. \<Sum>j\<in>I. (f i \<omega> - expectation (f i)) * (f j \<omega> - expectation (f j))) = (\<Sum>i\<in>I. \<Sum>j\<in>I. covariance (f i) (f j))
[PROOF STEP]
by (simp add: Bochner_Integration.integral_sum covariance_def)
[PROOF STATE]
proof (state)
this:
expectation (\<lambda>\<omega>. \<Sum>i\<in>I. \<Sum>j\<in>I. (f i \<omega> - expectation (f i)) * (f j \<omega> - expectation (f j))) = (\<Sum>i\<in>I. \<Sum>j\<in>I. covariance (f i) (f j))

goal (1 subgoal):
 1. expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. \<Sum>j\<in>I. covariance (f i) (f j))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. \<Sum>j\<in>I. covariance (f i) (f j))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. \<Sum>j\<in>I. covariance (f i) (f j))

goal (1 subgoal):
 1. expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. \<Sum>j\<in>I. covariance (f i) (f j))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
expectation (\<lambda>x. ((\<Sum>i\<in>I. f i x) - expectation (\<lambda>\<omega>. \<Sum>i\<in>I. f i \<omega>))\<^sup>2) = (\<Sum>i\<in>I. \<Sum>j\<in>I. covariance (f i) (f j))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma hnorm_add_less:
  "\<And>(x::'a::real_normed_vector star) y r s. hnorm x < r \<Longrightarrow> hnorm y < s \<Longrightarrow> hnorm (x + y) < r + s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x y r s. \<lbrakk>hnorm x < r; hnorm y < s\<rbrakk> \<Longrightarrow> hnorm (x + y) < r + s
[PROOF STEP]
by transfer (rule norm_add_less)


[STATEMENT]
lemma shortest_path_Min_alt:
  assumes "u \<in> V" "v \<in> V"
  shows "shortest_path u v = Min ((\<lambda> p. enat (walk_length p)) ` (connecting_paths u v))" (is "shortest_path u v = Min ?A")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. shortest_path u v = (MIN p\<in>connecting_paths u v. enat (walk_length p))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. shortest_path u v = (MIN p\<in>connecting_paths u v. enat (walk_length p))
[PROOF STEP]
have ne: "?A \<noteq> {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>p. enat (walk_length p)) ` connecting_paths u v \<noteq> {}
[PROOF STEP]
using connecting_paths_not_empty assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?u \<in> V; ?v \<in> V\<rbrakk> \<Longrightarrow> connecting_paths ?u ?v \<noteq> {}
u \<in> V
v \<in> V

goal (1 subgoal):
 1. (\<lambda>p. enat (walk_length p)) ` connecting_paths u v \<noteq> {}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>p. enat (walk_length p)) ` connecting_paths u v \<noteq> {}

goal (1 subgoal):
 1. shortest_path u v = (MIN p\<in>connecting_paths u v. enat (walk_length p))
[PROOF STEP]
have "finite (connecting_paths u v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (connecting_paths u v)
[PROOF STEP]
by (simp add: fin_connecting_paths)
[PROOF STATE]
proof (state)
this:
finite (connecting_paths u v)

goal (1 subgoal):
 1. shortest_path u v = (MIN p\<in>connecting_paths u v. enat (walk_length p))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
finite (connecting_paths u v)
[PROOF STEP]
have fin: "finite ?A"
[PROOF STATE]
proof (prove)
using this:
finite (connecting_paths u v)

goal (1 subgoal):
 1. finite ((\<lambda>p. enat (walk_length p)) ` connecting_paths u v)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
finite ((\<lambda>p. enat (walk_length p)) ` connecting_paths u v)

goal (1 subgoal):
 1. shortest_path u v = (MIN p\<in>connecting_paths u v. enat (walk_length p))
[PROOF STEP]
have "shortest_path u v = Inf ?A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. shortest_path u v = (INF p\<in>connecting_paths u v. enat (walk_length p))
[PROOF STEP]
unfolding shortest_path_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (INF p\<in>connecting_paths u v. enat (walk_length p)) = (INF p\<in>connecting_paths u v. enat (walk_length p))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
shortest_path u v = (INF p\<in>connecting_paths u v. enat (walk_length p))

goal (1 subgoal):
 1. shortest_path u v = (MIN p\<in>connecting_paths u v. enat (walk_length p))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
shortest_path u v = (INF p\<in>connecting_paths u v. enat (walk_length p))

goal (1 subgoal):
 1. shortest_path u v = (MIN p\<in>connecting_paths u v. enat (walk_length p))
[PROOF STEP]
using Min_Inf ne
[PROOF STATE]
proof (prove)
using this:
shortest_path u v = (INF p\<in>connecting_paths u v. enat (walk_length p))
\<lbrakk>finite ?A; ?A \<noteq> {}\<rbrakk> \<Longrightarrow> Min ?A = Inf ?A
(\<lambda>p. enat (walk_length p)) ` connecting_paths u v \<noteq> {}

goal (1 subgoal):
 1. shortest_path u v = (MIN p\<in>connecting_paths u v. enat (walk_length p))
[PROOF STEP]
by (metis fin)
[PROOF STATE]
proof (state)
this:
shortest_path u v = (MIN p\<in>connecting_paths u v. enat (walk_length p))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma connected_iff_connected_component:
  "connected S \<longleftrightarrow> (\<forall>x \<in> S. \<forall>y \<in> S. connected_component S x y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. connected S = (\<forall>x\<in>S. \<forall>y\<in>S. connected_component S x y)
[PROOF STEP]
using connected_component_in
[PROOF STATE]
proof (prove)
using this:
connected_component ?S ?x ?y \<Longrightarrow> ?x \<in> ?S \<and> ?y \<in> ?S

goal (1 subgoal):
 1. connected S = (\<forall>x\<in>S. \<forall>y\<in>S. connected_component S x y)
[PROOF STEP]
by (auto simp: connected_iff_eq_connected_component_set)


[STATEMENT]
lemma max_decr:
  fixes X :: "nat set"
  assumes "\<exists>x \<in> X. x \<ge> k" "finite X"
  shows "Max ((\<lambda>x. x - k) ` X) = Max X - k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (MAX x\<in>X. x - k) = Max X - k
[PROOF STEP]
proof (rule mono_Max_commute[symmetric])
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. mono (\<lambda>x. x - k)
 2. finite X
 3. X \<noteq> {}
[PROOF STEP]
show "mono (\<lambda>x. x - k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mono (\<lambda>x. x - k)
[PROOF STEP]
by (rule monoI) linarith
[PROOF STATE]
proof (state)
this:
mono (\<lambda>x. x - k)

goal (2 subgoals):
 1. finite X
 2. X \<noteq> {}
[PROOF STEP]
show "finite X"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite X
[PROOF STEP]
by fact
[PROOF STATE]
proof (state)
this:
finite X

goal (1 subgoal):
 1. X \<noteq> {}
[PROOF STEP]
show "X \<noteq> {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. X \<noteq> {}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<exists>x\<in>X. k \<le> x
finite X

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma has_real_derivative_inverse_sqrt:
  assumes "x > 0"
  shows "((\<lambda>x. inverse (sqrt x) / 2) has_real_derivative - (inverse (sqrt x ^ 3) / 4)) (at x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. inverse (sqrt x) / 2) has_real_derivative - (inverse (sqrt x ^ 3) / 4)) (at x)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ((\<lambda>x. inverse (sqrt x) / 2) has_real_derivative - (inverse (sqrt x ^ 3) / 4)) (at x)
[PROOF STEP]
have inv_sqrt_mult: "(inverse (sqrt x)/2) * (sqrt x * 2) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inverse (sqrt x) / 2 * (sqrt x * 2) = 1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < x

goal (1 subgoal):
 1. inverse (sqrt x) / 2 * (sqrt x * 2) = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
inverse (sqrt x) / 2 * (sqrt x * 2) = 1

goal (1 subgoal):
 1. ((\<lambda>x. inverse (sqrt x) / 2) has_real_derivative - (inverse (sqrt x ^ 3) / 4)) (at x)
[PROOF STEP]
have inv_sqrt_mult2: "(- inverse ((sqrt x)^3)/2)* x * (sqrt x * 2) = -1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. - inverse (sqrt x ^ 3) / 2 * x * (sqrt x * 2) = - 1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < x

goal (1 subgoal):
 1. - inverse (sqrt x ^ 3) / 2 * x * (sqrt x * 2) = - 1
[PROOF STEP]
by (simp add: field_simps power3_eq_cube)
[PROOF STATE]
proof (state)
this:
- inverse (sqrt x ^ 3) / 2 * x * (sqrt x * 2) = - 1

goal (1 subgoal):
 1. ((\<lambda>x. inverse (sqrt x) / 2) has_real_derivative - (inverse (sqrt x ^ 3) / 4)) (at x)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
- inverse (sqrt x ^ 3) / 2 * x * (sqrt x * 2) = - 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
- inverse (sqrt x ^ 3) / 2 * x * (sqrt x * 2) = - 1

goal (1 subgoal):
 1. ((\<lambda>x. inverse (sqrt x) / 2) has_real_derivative - (inverse (sqrt x ^ 3) / 4)) (at x)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
- inverse (sqrt x ^ 3) / 2 * x * (sqrt x * 2) = - 1
0 < x

goal (1 subgoal):
 1. ((\<lambda>x. inverse (sqrt x) / 2) has_real_derivative - (inverse (sqrt x ^ 3) / 4)) (at x)
[PROOF STEP]
by (safe intro!: DERIV_imp_deriv derivative_eq_intros)
        (auto intro: derivative_eq_intros inv_sqrt_mult [THEN ssubst] inv_sqrt_mult2 [THEN ssubst]
              simp add: divide_simps power3_eq_cube)
[PROOF STATE]
proof (state)
this:
((\<lambda>x. inverse (sqrt x) / 2) has_real_derivative - (inverse (sqrt x ^ 3) / 4)) (at x)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma homeomorphic_trans [trans]:
  assumes "S homeomorphic T"
      and "T homeomorphic U"
    shows "S homeomorphic U"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S homeomorphic U
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
S homeomorphic T
T homeomorphic U

goal (1 subgoal):
 1. S homeomorphic U
[PROOF STEP]
unfolding homeomorphic_def
[PROOF STATE]
proof (prove)
using this:
\<exists>f g. homeomorphism S T f g
\<exists>f g. homeomorphism T U f g

goal (1 subgoal):
 1. \<exists>f g. homeomorphism S U f g
[PROOF STEP]
by (metis homeomorphism_compose)


[STATEMENT]
lemma poly_roots_degree:
  fixes p :: "'a::idom poly"
  shows "p \<noteq> 0 \<Longrightarrow> card {x. poly p x = 0} \<le> degree p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p \<noteq> 0 \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
proof (induct n \<equiv> "degree p" arbitrary: p)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>p. \<lbrakk>0 = degree p; p \<noteq> 0\<rbrakk> \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
 2. \<And>n p. \<lbrakk>\<And>p. \<lbrakk>n = degree p; p \<noteq> 0\<rbrakk> \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p; Suc n = degree p; p \<noteq> 0\<rbrakk> \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
case (0 p)
[PROOF STATE]
proof (state)
this:
0 = degree p
p \<noteq> 0

goal (2 subgoals):
 1. \<And>p. \<lbrakk>0 = degree p; p \<noteq> 0\<rbrakk> \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
 2. \<And>n p. \<lbrakk>\<And>p. \<lbrakk>n = degree p; p \<noteq> 0\<rbrakk> \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p; Suc n = degree p; p \<noteq> 0\<rbrakk> \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 = degree p
p \<noteq> 0
[PROOF STEP]
obtain a where "a \<noteq> 0" and "p = [:a:]"
[PROOF STATE]
proof (prove)
using this:
0 = degree p
p \<noteq> 0

goal (1 subgoal):
 1. (\<And>a. \<lbrakk>a \<noteq> (0::'a); p = [:a:]\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (cases p, simp split: if_splits)
[PROOF STATE]
proof (state)
this:
a \<noteq> (0::'a)
p = [:a:]

goal (2 subgoals):
 1. \<And>p. \<lbrakk>0 = degree p; p \<noteq> 0\<rbrakk> \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
 2. \<And>n p. \<lbrakk>\<And>p. \<lbrakk>n = degree p; p \<noteq> 0\<rbrakk> \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p; Suc n = degree p; p \<noteq> 0\<rbrakk> \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
a \<noteq> (0::'a)
p = [:a:]
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
a \<noteq> (0::'a)
p = [:a:]

goal (1 subgoal):
 1. card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card {x. poly p x = (0::'a)} \<le> degree p

goal (1 subgoal):
 1. \<And>n p. \<lbrakk>\<And>p. \<lbrakk>n = degree p; p \<noteq> 0\<rbrakk> \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p; Suc n = degree p; p \<noteq> 0\<rbrakk> \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n p. \<lbrakk>\<And>p. \<lbrakk>n = degree p; p \<noteq> 0\<rbrakk> \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p; Suc n = degree p; p \<noteq> 0\<rbrakk> \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
case (Suc n p)
[PROOF STATE]
proof (state)
this:
\<lbrakk>n = degree ?p; ?p \<noteq> 0\<rbrakk> \<Longrightarrow> card {x. poly ?p x = (0::'a)} \<le> degree ?p
Suc n = degree p
p \<noteq> 0

goal (1 subgoal):
 1. \<And>n p. \<lbrakk>\<And>p. \<lbrakk>n = degree p; p \<noteq> 0\<rbrakk> \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p; Suc n = degree p; p \<noteq> 0\<rbrakk> \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
proof (cases "\<exists>x. poly p x = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<exists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
 2. \<nexists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
\<exists>x. poly p x = (0::'a)

goal (2 subgoals):
 1. \<exists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
 2. \<nexists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>x. poly p x = (0::'a)
[PROOF STEP]
obtain a where a: "poly p a = 0"
[PROOF STATE]
proof (prove)
using this:
\<exists>x. poly p x = (0::'a)

goal (1 subgoal):
 1. (\<And>a. poly p a = (0::'a) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
poly p a = (0::'a)

goal (2 subgoals):
 1. \<exists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
 2. \<nexists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
poly p a = (0::'a)
[PROOF STEP]
have "[:-a, 1:] dvd p"
[PROOF STATE]
proof (prove)
using this:
poly p a = (0::'a)

goal (1 subgoal):
 1. [:- a, 1::'a:] dvd p
[PROOF STEP]
by (simp only: poly_eq_0_iff_dvd)
[PROOF STATE]
proof (state)
this:
[:- a, 1::'a:] dvd p

goal (2 subgoals):
 1. \<exists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
 2. \<nexists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[:- a, 1::'a:] dvd p
[PROOF STEP]
obtain k where k: "p = [:-a, 1:] * k"
[PROOF STATE]
proof (prove)
using this:
[:- a, 1::'a:] dvd p

goal (1 subgoal):
 1. (\<And>k. p = [:- a, 1::'a:] * k \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
p = [:- a, 1::'a:] * k

goal (2 subgoals):
 1. \<exists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
 2. \<nexists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
with \<open>p \<noteq> 0\<close>
[PROOF STATE]
proof (chain)
picking this:
p \<noteq> 0
p = [:- a, 1::'a:] * k
[PROOF STEP]
have "k \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
p \<noteq> 0
p = [:- a, 1::'a:] * k

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

goal (2 subgoals):
 1. \<exists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
 2. \<nexists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
with k
[PROOF STATE]
proof (chain)
picking this:
p = [:- a, 1::'a:] * k
k \<noteq> 0
[PROOF STEP]
have "degree p = Suc (degree k)"
[PROOF STATE]
proof (prove)
using this:
p = [:- a, 1::'a:] * k
k \<noteq> 0

goal (1 subgoal):
 1. degree p = Suc (degree k)
[PROOF STEP]
by (simp add: degree_mult_eq del: mult_pCons_left)
[PROOF STATE]
proof (state)
this:
degree p = Suc (degree k)

goal (2 subgoals):
 1. \<exists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
 2. \<nexists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
with \<open>Suc n = degree p\<close>
[PROOF STATE]
proof (chain)
picking this:
Suc n = degree p
degree p = Suc (degree k)
[PROOF STEP]
have "n = degree k"
[PROOF STATE]
proof (prove)
using this:
Suc n = degree p
degree p = Suc (degree k)

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

goal (2 subgoals):
 1. \<exists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
 2. \<nexists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
from Suc.hyps(1)[OF this \<open>k \<noteq> 0\<close>]
[PROOF STATE]
proof (chain)
picking this:
card {x. poly k x = (0::'a)} \<le> degree k
[PROOF STEP]
have le: "card {x. poly k x = 0} \<le> degree k"
[PROOF STATE]
proof (prove)
using this:
card {x. poly k x = (0::'a)} \<le> degree k

goal (1 subgoal):
 1. card {x. poly k x = (0::'a)} \<le> degree k
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
card {x. poly k x = (0::'a)} \<le> degree k

goal (2 subgoals):
 1. \<exists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
 2. \<nexists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
have "card {x. poly p x = 0} = card {x. poly ([:-a, 1:] * k) x = 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {x. poly p x = (0::'a)} = card {x. poly ([:- a, 1::'a:] * k) x = (0::'a)}
[PROOF STEP]
unfolding k
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {x. poly ([:- a, 1::'a:] * k) x = (0::'a)} = card {x. poly ([:- a, 1::'a:] * k) x = (0::'a)}
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
card {x. poly p x = (0::'a)} = card {x. poly ([:- a, 1::'a:] * k) x = (0::'a)}

goal (2 subgoals):
 1. \<exists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
 2. \<nexists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card {x. poly p x = (0::'a)} = card {x. poly ([:- a, 1::'a:] * k) x = (0::'a)}

goal (2 subgoals):
 1. \<exists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
 2. \<nexists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
have "{x. poly ([:-a, 1:] * k) x = 0} = insert a {x. poly k x = 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x. poly ([:- a, 1::'a:] * k) x = (0::'a)} = insert a {x. poly k x = (0::'a)}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{x. poly ([:- a, 1::'a:] * k) x = (0::'a)} = insert a {x. poly k x = (0::'a)}

goal (2 subgoals):
 1. \<exists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
 2. \<nexists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
{x. poly ([:- a, 1::'a:] * k) x = (0::'a)} = insert a {x. poly k x = (0::'a)}

goal (2 subgoals):
 1. \<exists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
 2. \<nexists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
have "card \<dots> \<le> Suc (card {x. poly k x = 0})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (insert a {x. poly k x = (0::'a)}) \<le> Suc (card {x. poly k x = (0::'a)})
[PROOF STEP]
unfolding card_insert_if[OF poly_roots_finite[OF \<open>k \<noteq> 0\<close>]]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if a \<in> {x. poly k x = (0::'a)} then card {x. poly k x = (0::'a)} else Suc (card {x. poly k x = (0::'a)})) \<le> Suc (card {x. poly k x = (0::'a)})
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card (insert a {x. poly k x = (0::'a)}) \<le> Suc (card {x. poly k x = (0::'a)})

goal (2 subgoals):
 1. \<exists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
 2. \<nexists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card (insert a {x. poly k x = (0::'a)}) \<le> Suc (card {x. poly k x = (0::'a)})

goal (2 subgoals):
 1. \<exists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
 2. \<nexists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
have "\<dots> \<le> Suc (degree k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc (card {x. poly k x = (0::'a)}) \<le> Suc (degree k)
[PROOF STEP]
using le
[PROOF STATE]
proof (prove)
using this:
card {x. poly k x = (0::'a)} \<le> degree k

goal (1 subgoal):
 1. Suc (card {x. poly k x = (0::'a)}) \<le> Suc (degree k)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Suc (card {x. poly k x = (0::'a)}) \<le> Suc (degree k)

goal (2 subgoals):
 1. \<exists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
 2. \<nexists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
card {x. poly p x = (0::'a)} \<le> Suc (degree k)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
card {x. poly p x = (0::'a)} \<le> Suc (degree k)

goal (1 subgoal):
 1. card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
using \<open>degree p = Suc (degree k)\<close>
[PROOF STATE]
proof (prove)
using this:
card {x. poly p x = (0::'a)} \<le> Suc (degree k)
degree p = Suc (degree k)

goal (1 subgoal):
 1. card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card {x. poly p x = (0::'a)} \<le> degree p

goal (1 subgoal):
 1. \<nexists>x. poly p x = (0::'a) \<Longrightarrow> card {x. poly p x = (0::'a)} \<le> degree p
[PROOF STEP]
qed simp
[PROOF STATE]
proof (state)
this:
card {x. poly p x = (0::'a)} \<le> degree p

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma closed_segment_translation_eq [simp]:
    "d + x \<in> closed_segment (d + a) (d + b) \<longleftrightarrow> x \<in> closed_segment a b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (d + x \<in> closed_segment (d + a) (d + b)) = (x \<in> closed_segment a b)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (d + x \<in> closed_segment (d + a) (d + b)) = (x \<in> closed_segment a b)
[PROOF STEP]
have *: "\<And>d x a b. x \<in> closed_segment a b \<Longrightarrow> d + x \<in> closed_segment (d + a) (d + b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>d x a b. x \<in> closed_segment a b \<Longrightarrow> d + x \<in> closed_segment (d + a) (d + b)
[PROOF STEP]
apply (simp add: closed_segment_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>d x a b. \<exists>u. x = (1 - u) *\<^sub>R a + u *\<^sub>R b \<and> 0 \<le> u \<and> u \<le> 1 \<Longrightarrow> \<exists>u. d + x = (1 - u) *\<^sub>R (d + a) + u *\<^sub>R (d + b) \<and> 0 \<le> u \<and> u \<le> 1
[PROOF STEP]
apply (erule ex_forward)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>d x a b u. x = (1 - u) *\<^sub>R a + u *\<^sub>R b \<and> 0 \<le> u \<and> u \<le> 1 \<Longrightarrow> d + x = (1 - u) *\<^sub>R (d + a) + u *\<^sub>R (d + b) \<and> 0 \<le> u \<and> u \<le> 1
[PROOF STEP]
apply (simp add: algebra_simps)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
?x \<in> closed_segment ?a ?b \<Longrightarrow> ?d + ?x \<in> closed_segment (?d + ?a) (?d + ?b)

goal (1 subgoal):
 1. (d + x \<in> closed_segment (d + a) (d + b)) = (x \<in> closed_segment a b)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (d + x \<in> closed_segment (d + a) (d + b)) = (x \<in> closed_segment a b)
[PROOF STEP]
using * [where d = "-d"] *
[PROOF STATE]
proof (prove)
using this:
?x \<in> closed_segment ?a ?b \<Longrightarrow> - d + ?x \<in> closed_segment (- d + ?a) (- d + ?b)
?x \<in> closed_segment ?a ?b \<Longrightarrow> ?d + ?x \<in> closed_segment (?d + ?a) (?d + ?b)

goal (1 subgoal):
 1. (d + x \<in> closed_segment (d + a) (d + b)) = (x \<in> closed_segment a b)
[PROOF STEP]
by (fastforce simp add:)
[PROOF STATE]
proof (state)
this:
(d + x \<in> closed_segment (d + a) (d + b)) = (x \<in> closed_segment a b)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma d_OUT_h_plus_not_infty [simp]: "d_OUT (h_plus i) x \<noteq> top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. d_OUT (h_plus i) x \<noteq> \<top>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. d_OUT (h_plus i) x \<noteq> \<top>
[PROOF STEP]
have "d_OUT (h_plus i) x \<le> (\<Sum>\<^sup>+ y\<in>UNIV. \<Sum>\<^sup>+ x. h_plus i (x, y))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. d_OUT (h_plus i) x \<le> (\<Sum>\<^sup>+ y. \<Sum>\<^sup>+ x. h_plus i (x, y))
[PROOF STEP]
unfolding d_OUT_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>\<^sup>+ y. h_plus i (x, y)) \<le> (\<Sum>\<^sup>+ y. \<Sum>\<^sup>+ x. h_plus i (x, y))
[PROOF STEP]
by(rule nn_integral_mono nn_integral_ge_point)+ simp
[PROOF STATE]
proof (state)
this:
d_OUT (h_plus i) x \<le> (\<Sum>\<^sup>+ y. \<Sum>\<^sup>+ x. h_plus i (x, y))

goal (1 subgoal):
 1. d_OUT (h_plus i) x \<noteq> \<top>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
d_OUT (h_plus i) x \<le> (\<Sum>\<^sup>+ y. \<Sum>\<^sup>+ x. h_plus i (x, y))

goal (1 subgoal):
 1. d_OUT (h_plus i) x \<noteq> \<top>
[PROOF STEP]
have "\<dots> < \<top>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>\<^sup>+ y. \<Sum>\<^sup>+ x. h_plus i (x, y)) < \<top>
[PROOF STEP]
using h_plus_sum_finite
[PROOF STATE]
proof (prove)
using this:
integral\<^sup>N (count_space UNIV) (h_plus ?i) \<noteq> \<top>

goal (1 subgoal):
 1. (\<Sum>\<^sup>+ y. \<Sum>\<^sup>+ x. h_plus i (x, y)) < \<top>
[PROOF STEP]
by(simp add: nn_integral_snd_count_space less_top)
[PROOF STATE]
proof (state)
this:
(\<Sum>\<^sup>+ y. \<Sum>\<^sup>+ x. h_plus i (x, y)) < \<top>

goal (1 subgoal):
 1. d_OUT (h_plus i) x \<noteq> \<top>
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
d_OUT (h_plus i) x < \<top>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
d_OUT (h_plus i) x < \<top>

goal (1 subgoal):
 1. d_OUT (h_plus i) x \<noteq> \<top>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
d_OUT (h_plus i) x \<noteq> \<top>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fmrel_converse_tranclp_induct:
  "fmrel r\<^sup>+\<^sup>+ a b \<Longrightarrow>
   reflp r \<Longrightarrow>
   (\<And>y. fmrel r y b \<Longrightarrow> P y) \<Longrightarrow>
   (\<And>y z. fmrel r y z \<Longrightarrow> fmrel r\<^sup>+\<^sup>+ z b \<Longrightarrow> P z \<Longrightarrow> P y) \<Longrightarrow> P a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>fmrel r\<^sup>+\<^sup>+ a b; reflp r; \<And>y. fmrel r y b \<Longrightarrow> P y; \<And>y z. \<lbrakk>fmrel r y z; fmrel r\<^sup>+\<^sup>+ z b; P z\<rbrakk> \<Longrightarrow> P y\<rbrakk> \<Longrightarrow> P a
[PROOF STEP]
apply (drule fmrel_to_trancl, simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>fmrel r\<^sup>+\<^sup>+ a b; \<And>y. fmrel r y b \<Longrightarrow> P y; \<And>y z. \<lbrakk>fmrel r y z; fmrel r\<^sup>+\<^sup>+ z b; P z\<rbrakk> \<Longrightarrow> P y; (fmrel r)\<^sup>+\<^sup>+ a b\<rbrakk> \<Longrightarrow> P a
[PROOF STEP]
by (erule converse_tranclp_induct; simp add: trancl_to_fmrel)


[STATEMENT]
theorem (in state_space)
  shows "\<Gamma>\<turnstile> \<lbrace>True\<rbrace>
           \<acute>S :== 0;; \<acute>I :== 1;;
           WHILE \<acute>I \<noteq> n
           INV \<lbrace>\<acute>S = (SUMM j<\<acute>I. j)\<rbrace>
           DO
             \<acute>S :== \<acute>S + \<acute>I;;
             \<acute>I :== \<acute>I + 1
           OD
           \<lbrace>\<acute>S = (SUMM j<n. j)\<rbrace>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Gamma>\<turnstile> \<lbrace>True\<rbrace> \<acute>S :== 0;; \<acute>I :== 1;; WHILE \<acute>I \<noteq> n INV \<lbrace>\<acute>S = (SUMM j<\<acute>I. j)\<rbrace> DO \<acute>S :== \<acute>S + \<acute>I;; \<acute>I :== \<acute>I + 1 OD \<lbrace>\<acute>S = (SUMM j<n. j)\<rbrace>
[PROOF STEP]
apply vcg
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. True \<Longrightarrow> 0 = (SUMM j<1. j)
 2. \<And>I S. \<lbrakk>S = (SUMM j<I. j); I \<noteq> n\<rbrakk> \<Longrightarrow> S + I = (SUMM j<I + 1. j)
 3. \<And>I S. \<lbrakk>S = (SUMM j<I. j); \<not> I \<noteq> n\<rbrakk> \<Longrightarrow> S = (SUMM j<n. j)
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma hyperbola_method_semiring_sqrt:
  fixes f g :: "nat \<Rightarrow> 'a :: comm_semiring_0"
  assumes "x \<ge> 0"
  shows   "sum_upto (dirichlet_prod f g) x + sum_upto f (sqrt x) * sum_upto g (sqrt x) =
             sum_upto (\<lambda>n. f n * sum_upto g (x / real n)) (sqrt x) +
             sum_upto (\<lambda>n. sum_upto f (x / real n) * g n) (sqrt x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_upto (dirichlet_prod f g) x + sum_upto f (sqrt x) * sum_upto g (sqrt x) = sum_upto (\<lambda>n. f n * sum_upto g (x / real n)) (sqrt x) + sum_upto (\<lambda>n. sum_upto f (x / real n) * g n) (sqrt x)
[PROOF STEP]
using assms hyperbola_method_semiring[of "sqrt x" "sqrt x" x]
[PROOF STATE]
proof (prove)
using this:
0 \<le> x
\<lbrakk>0 \<le> sqrt x; 0 \<le> sqrt x; sqrt x * sqrt x = x\<rbrakk> \<Longrightarrow> sum_upto (dirichlet_prod ?f ?g) x + sum_upto ?f (sqrt x) * sum_upto ?g (sqrt x) = sum_upto (\<lambda>n. ?f n * sum_upto ?g (x / real n)) (sqrt x) + sum_upto (\<lambda>n. sum_upto ?f (x / real n) * ?g n) (sqrt x)

goal (1 subgoal):
 1. sum_upto (dirichlet_prod f g) x + sum_upto f (sqrt x) * sum_upto g (sqrt x) = sum_upto (\<lambda>n. f n * sum_upto g (x / real n)) (sqrt x) + sum_upto (\<lambda>n. sum_upto f (x / real n) * g n) (sqrt x)
[PROOF STEP]
by simp


[STATEMENT]
lemma fps_mult_assoc_lemma:
  fixes k :: nat
    and f :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> 'a::comm_monoid_add"
  shows "(\<Sum>j=0..k. \<Sum>i=0..j. f i (j - i) (n - j)) =
         (\<Sum>j=0..k. \<Sum>i=0..k - j. f j i (n - j - i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j = 0..k. \<Sum>i = 0..j. f i (j - i) (n - j)) = (\<Sum>j = 0..k. \<Sum>i = 0..k - j. f j i (n - j - i))
[PROOF STEP]
by (induct k) (simp_all add: Suc_diff_le sum.distrib add.assoc)


[STATEMENT]
lemma has_integral_cmul_iff:
  assumes "c \<noteq> 0"
  shows   "((\<lambda>x. c *\<^sub>R f x) has_integral (c *\<^sub>R I)) A \<longleftrightarrow> (f has_integral I) A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. c *\<^sub>R f x) has_integral c *\<^sub>R I) A = (f has_integral I) A
[PROOF STEP]
using assms has_integral_cmul[of f I A c]
        has_integral_cmul[of "\<lambda>x. c *\<^sub>R f x" "c *\<^sub>R I" A "inverse c"]
[PROOF STATE]
proof (prove)
using this:
c \<noteq> 0
(f has_integral I) A \<Longrightarrow> ((\<lambda>x. c *\<^sub>R f x) has_integral c *\<^sub>R I) A
((\<lambda>x. c *\<^sub>R f x) has_integral c *\<^sub>R I) A \<Longrightarrow> ((\<lambda>x. c *\<^sub>R f x /\<^sub>R c) has_integral c *\<^sub>R I /\<^sub>R c) A

goal (1 subgoal):
 1. ((\<lambda>x. c *\<^sub>R f x) has_integral c *\<^sub>R I) A = (f has_integral I) A
[PROOF STEP]
by (auto simp: field_simps)


[STATEMENT]
lemma UN_Ioc_eq_UNIV: "(\<Union>n. { -real n <.. real n}) = UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Union>n. {- real n<..real n}) = UNIV
[PROOF STEP]
by auto
     (metis le_less_trans minus_minus neg_less_iff_less not_le real_arch_simple
            of_nat_0_le_iff reals_Archimedean2)


[STATEMENT]
lemma ex2_3: "\<bar>integral {0 .. 1} (\<lambda>x::real. arctan (sqrt (x\<^sup>2 + 2)) / (sqrt (x\<^sup>2 + 2) * (x\<^sup>2 + 1))) - 5*pi\<^sup>2/96\<bar> \<le> 1 / 10^3"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>integral {0..1} (\<lambda>x. arctan (sqrt (x\<^sup>2 + 2)) / (sqrt (x\<^sup>2 + 2) * (x\<^sup>2 + 1))) - 5 * pi\<^sup>2 / 96\<bar> \<le> 1 / 10 ^ 3
[PROOF STEP]
by (rule abs_minus_leI) (tactic \<open>integral_bnds_tac 1 30 10 6 12 "" @{thms pow_gt_zero} @{context} 1\<close>)


[STATEMENT]
lemma inter_eq_blocks_eq_card: "card b1 = card b2 \<Longrightarrow> finite b1 \<Longrightarrow> finite b2 \<Longrightarrow> b1 |\<inter>| b2 = card b1
    \<Longrightarrow> b1 = b2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>card b1 = card b2; finite b1; finite b2; b1 |\<inter>| b2 = card b1\<rbrakk> \<Longrightarrow> b1 = b2
[PROOF STEP]
using equal_card_inter_fin_eq_sets intersection_number_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>finite ?A; finite ?B; card ?A = card ?B; card (?A \<inter> ?B) = card ?A\<rbrakk> \<Longrightarrow> ?A = ?B
?b1.0 |\<inter>| ?b2.0 \<equiv> card (?b1.0 \<inter> ?b2.0)

goal (1 subgoal):
 1. \<lbrakk>card b1 = card b2; finite b1; finite b2; b1 |\<inter>| b2 = card b1\<rbrakk> \<Longrightarrow> b1 = b2
[PROOF STEP]
by (metis)


[STATEMENT]
lemma ordLeq_Sigma_mono1:
assumes "\<forall>i \<in> I. p i \<le>o r i"
shows "|SIGMA i : I. Field(p i)| \<le>o |SIGMA i : I. Field(r i)|"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. |SIGMA i:I. Field (p i)| \<le>o |SIGMA i:I. Field (r i)|
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<forall>i\<in>I. p i \<le>o r i

goal (1 subgoal):
 1. |SIGMA i:I. Field (p i)| \<le>o |SIGMA i:I. Field (r i)|
[PROOF STEP]
by (auto simp add: card_of_Sigma_mono1)


[STATEMENT]
lemma left_null_space_orthogonal_complement_col_space:
  fixes A::"real^'cols::{finite,wellorder}^'rows"
  shows "left_null_space A = orthogonal_complement (col_space A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. left_null_space A = orthogonal_complement (col_space A)
[PROOF STEP]
using null_space_orthogonal_complement_row_space[of "transpose A"]
[PROOF STATE]
proof (prove)
using this:
null_space (Finite_Cartesian_Product.transpose A) = orthogonal_complement (row_space (Finite_Cartesian_Product.transpose A))

goal (1 subgoal):
 1. left_null_space A = orthogonal_complement (col_space A)
[PROOF STEP]
unfolding left_null_space_eq_null_space_transpose
[PROOF STATE]
proof (prove)
using this:
null_space (Finite_Cartesian_Product.transpose A) = orthogonal_complement (row_space (Finite_Cartesian_Product.transpose A))

goal (1 subgoal):
 1. null_space (Finite_Cartesian_Product.transpose A) = orthogonal_complement (col_space A)
[PROOF STEP]
unfolding col_space_eq_row_space_transpose
[PROOF STATE]
proof (prove)
using this:
null_space (Finite_Cartesian_Product.transpose A) = orthogonal_complement (row_space (Finite_Cartesian_Product.transpose A))

goal (1 subgoal):
 1. null_space (Finite_Cartesian_Product.transpose A) = orthogonal_complement (row_space (Finite_Cartesian_Product.transpose A))
[PROOF STEP]
.


[STATEMENT]
theorem height_expectation_bound:
  assumes "finite A" "A \<noteq> {}"
  shows   "measure_pmf.expectation (random_bst A) height
             \<le> height_exp_approx (card A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>x. real (height x)) \<le> height_exp_approx (card A)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>x. real (height x)) \<le> height_exp_approx (card A)
[PROOF STEP]
have "convex_on UNIV ((powr) 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. convex_on UNIV ((powr) 2)
[PROOF STEP]
by (intro convex_on_realI[where f' = "\<lambda>x. ln 2 * 2 powr x"])
       (auto intro!: derivative_eq_intros DERIV_powr simp: powr_def [abs_def])
[PROOF STATE]
proof (state)
this:
convex_on UNIV ((powr) 2)

goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>x. real (height x)) \<le> height_exp_approx (card A)
[PROOF STEP]
hence "2 powr measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t - 1)) \<le>
          measure_pmf.expectation (random_bst A) (\<lambda>t. 2 powr real (height t - 1))"
[PROOF STATE]
proof (prove)
using this:
convex_on UNIV ((powr) 2)

goal (1 subgoal):
 1. 2 powr measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t - 1)) \<le> measure_pmf.expectation (random_bst A) (\<lambda>t. 2 powr real (height t - 1))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
convex_on UNIV ((powr) 2)
finite A
A \<noteq> {}

goal (1 subgoal):
 1. 2 powr measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t - 1)) \<le> measure_pmf.expectation (random_bst A) (\<lambda>t. 2 powr real (height t - 1))
[PROOF STEP]
by (intro measure_pmf.jensens_inequality[where I = UNIV])
       (auto intro!: integrable_measure_pmf_finite)
[PROOF STATE]
proof (state)
this:
2 powr measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t - 1)) \<le> measure_pmf.expectation (random_bst A) (\<lambda>t. 2 powr real (height t - 1))

goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>x. real (height x)) \<le> height_exp_approx (card A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 powr measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t - 1)) \<le> measure_pmf.expectation (random_bst A) (\<lambda>t. 2 powr real (height t - 1))

goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>x. real (height x)) \<le> height_exp_approx (card A)
[PROOF STEP]
have "(\<lambda>t. 2 powr real (height t - 1)) = (\<lambda>t. 2 ^ (height t - 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>t. 2 powr real (height t - 1)) = (\<lambda>t. 2 ^ (height t - 1))
[PROOF STEP]
by (simp add: powr_realpow)
[PROOF STATE]
proof (state)
this:
(\<lambda>t. 2 powr real (height t - 1)) = (\<lambda>t. 2 ^ (height t - 1))

goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>x. real (height x)) \<le> height_exp_approx (card A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<lambda>t. 2 powr real (height t - 1)) = (\<lambda>t. 2 ^ (height t - 1))

goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>x. real (height x)) \<le> height_exp_approx (card A)
[PROOF STEP]
have "measure_pmf.expectation (random_bst A) (\<lambda>t. 2 ^ (height t - 1)) =
               measure_pmf.expectation (random_bst A) (\<lambda>t. real (eheight t))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>t. 2 ^ (height t - 1)) = measure_pmf.expectation (random_bst A) (\<lambda>t. real (eheight t))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite A
A \<noteq> {}

goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>t. 2 ^ (height t - 1)) = measure_pmf.expectation (random_bst A) (\<lambda>t. real (eheight t))
[PROOF STEP]
by (intro integral_cong_AE)
       (auto simp: AE_measure_pmf_iff random_bst_altdef eheight_def)
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (random_bst A) (\<lambda>t. 2 ^ (height t - 1)) = measure_pmf.expectation (random_bst A) (\<lambda>t. real (eheight t))

goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>x. real (height x)) \<le> height_exp_approx (card A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (random_bst A) (\<lambda>t. 2 ^ (height t - 1)) = measure_pmf.expectation (random_bst A) (\<lambda>t. real (eheight t))

goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>x. real (height x)) \<le> height_exp_approx (card A)
[PROOF STEP]
have "\<dots> = measure_pmf.expectation (map_pmf eheight (random_bst A)) real"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>t. real (eheight t)) = measure_pmf.expectation (map_pmf eheight (random_bst A)) real
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (random_bst A) (\<lambda>t. real (eheight t)) = measure_pmf.expectation (map_pmf eheight (random_bst A)) real

goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>x. real (height x)) \<le> height_exp_approx (card A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (random_bst A) (\<lambda>t. real (eheight t)) = measure_pmf.expectation (map_pmf eheight (random_bst A)) real

goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>x. real (height x)) \<le> height_exp_approx (card A)
[PROOF STEP]
have "map_pmf eheight (random_bst A) = eheight_rbst (card A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_pmf eheight (random_bst A) = eheight_rbst (card A)
[PROOF STEP]
by (rule eheight_rbst [symmetric]) fact+
[PROOF STATE]
proof (state)
this:
map_pmf eheight (random_bst A) = eheight_rbst (card A)

goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>x. real (height x)) \<le> height_exp_approx (card A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map_pmf eheight (random_bst A) = eheight_rbst (card A)

goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>x. real (height x)) \<le> height_exp_approx (card A)
[PROOF STEP]
have "measure_pmf.expectation \<dots> real = eheight_exp (card A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation (eheight_rbst (card A)) real = eheight_exp (card A)
[PROOF STEP]
by (simp add: eheight_exp_def)
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (eheight_rbst (card A)) real = eheight_exp (card A)

goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>x. real (height x)) \<le> height_exp_approx (card A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (eheight_rbst (card A)) real = eheight_exp (card A)

goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>x. real (height x)) \<le> height_exp_approx (card A)
[PROOF STEP]
have "\<dots> \<le> real ((card A + 3) choose 3) / 4"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eheight_exp (card A) \<le> real (card A + 3 choose 3) / 4
[PROOF STEP]
by (rule eheight_exp_bound)
[PROOF STATE]
proof (state)
this:
eheight_exp (card A) \<le> real (card A + 3 choose 3) / 4

goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>x. real (height x)) \<le> height_exp_approx (card A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
eheight_exp (card A) \<le> real (card A + 3 choose 3) / 4

goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>x. real (height x)) \<le> height_exp_approx (card A)
[PROOF STEP]
have "measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t - 1)) =
               measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t) - 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t - 1)) = measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t) - 1)
[PROOF STEP]
proof (intro integral_cong_AE AE_pmfI, goal_cases)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. measure_pmf.random_variable (random_bst A) borel (\<lambda>t. real (height t - 1))
 2. measure_pmf.random_variable (random_bst A) borel (\<lambda>t. real (height t) - 1)
 3. \<And>y. y \<in> set_pmf (random_bst A) \<Longrightarrow> real (height y - 1) = real (height y) - 1
[PROOF STEP]
case (3 t)
[PROOF STATE]
proof (state)
this:
t \<in> set_pmf (random_bst A)

goal (3 subgoals):
 1. measure_pmf.random_variable (random_bst A) borel (\<lambda>t. real (height t - 1))
 2. measure_pmf.random_variable (random_bst A) borel (\<lambda>t. real (height t) - 1)
 3. \<And>y. y \<in> set_pmf (random_bst A) \<Longrightarrow> real (height y - 1) = real (height y) - 1
[PROOF STEP]
with \<open>A \<noteq> {}\<close> and assms
[PROOF STATE]
proof (chain)
picking this:
A \<noteq> {}
finite A
A \<noteq> {}
t \<in> set_pmf (random_bst A)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
A \<noteq> {}
finite A
A \<noteq> {}
t \<in> set_pmf (random_bst A)

goal (1 subgoal):
 1. real (height t - 1) = real (height t) - 1
[PROOF STEP]
by (subst of_nat_diff) (auto simp: Suc_le_eq random_bst_altdef)
[PROOF STATE]
proof (state)
this:
real (height t - 1) = real (height t) - 1

goal (2 subgoals):
 1. measure_pmf.random_variable (random_bst A) borel (\<lambda>t. real (height t - 1))
 2. measure_pmf.random_variable (random_bst A) borel (\<lambda>t. real (height t) - 1)
[PROOF STEP]
qed auto
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t - 1)) = measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t) - 1)

goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>x. real (height x)) \<le> height_exp_approx (card A)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
2 powr measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t) - 1) \<le> real (card A + 3 choose 3) / 4
[PROOF STEP]
have "2 powr measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t) - 1)
                  \<le> real ((card A + 3) choose 3) / 4"
[PROOF STATE]
proof (prove)
using this:
2 powr measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t) - 1) \<le> real (card A + 3 choose 3) / 4

goal (1 subgoal):
 1. 2 powr measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t) - 1) \<le> real (card A + 3 choose 3) / 4
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
2 powr measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t) - 1) \<le> real (card A + 3 choose 3) / 4

goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>x. real (height x)) \<le> height_exp_approx (card A)
[PROOF STEP]
hence "log 2 (2 powr measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t) - 1)) \<le>
           log 2 (real ((card A + 3) choose 3) / 4)" (is "?lhs \<le> ?rhs")
[PROOF STATE]
proof (prove)
using this:
2 powr measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t) - 1) \<le> real (card A + 3 choose 3) / 4

goal (1 subgoal):
 1. log 2 (2 powr measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t) - 1)) \<le> log 2 (real (card A + 3 choose 3) / 4)
[PROOF STEP]
by (subst log_le_cancel_iff) auto
[PROOF STATE]
proof (state)
this:
log 2 (2 powr measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t) - 1)) \<le> log 2 (real (card A + 3 choose 3) / 4)

goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>x. real (height x)) \<le> height_exp_approx (card A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
log 2 (2 powr measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t) - 1)) \<le> log 2 (real (card A + 3 choose 3) / 4)

goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>x. real (height x)) \<le> height_exp_approx (card A)
[PROOF STEP]
have "?lhs = measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t) - 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. log 2 (2 powr measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t) - 1)) = measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t) - 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
log 2 (2 powr measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t) - 1)) = measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t) - 1)

goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>x. real (height x)) \<le> height_exp_approx (card A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
log 2 (2 powr measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t) - 1)) = measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t) - 1)

goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>x. real (height x)) \<le> height_exp_approx (card A)
[PROOF STEP]
have "\<dots> = measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t)) - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t) - 1) = measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t)) - 1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite A
A \<noteq> {}

goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t) - 1) = measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t)) - 1
[PROOF STEP]
by (subst Bochner_Integration.integral_diff) (auto intro!: integrable_measure_pmf_finite)
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t) - 1) = measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t)) - 1

goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>x. real (height x)) \<le> height_exp_approx (card A)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t)) - 1 \<le> log 2 (real (card A + 3 choose 3) / 4)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
measure_pmf.expectation (random_bst A) (\<lambda>t. real (height t)) - 1 \<le> log 2 (real (card A + 3 choose 3) / 4)

goal (1 subgoal):
 1. measure_pmf.expectation (random_bst A) (\<lambda>x. real (height x)) \<le> height_exp_approx (card A)
[PROOF STEP]
by (simp add: height_exp_approx_def)
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (random_bst A) (\<lambda>x. real (height x)) \<le> height_exp_approx (card A)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma cos_exp_eq:  "cos z = (exp(\<i> * z) + exp(-(\<i> * z))) / 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos z = (exp (\<i> * z) + exp (- (\<i> * z))) / 2
[PROOF STEP]
by (simp add: exp_Euler exp_minus_Euler)


[STATEMENT]
lemma complex_root_unity_eq_1:
  fixes j::nat and k::nat
  assumes "1 \<le> n"
    shows "exp(2 * of_real pi * \<i> * of_nat j / of_nat n) = 1 \<longleftrightarrow> n dvd j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (exp (2 * complex_of_real pi * \<i> * of_nat j / of_nat n) = 1) = (n dvd j)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (exp (2 * complex_of_real pi * \<i> * of_nat j / of_nat n) = 1) = (n dvd j)
[PROOF STEP]
have "1 = exp(2 * of_real pi * \<i> * (of_nat n / of_nat n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 = exp (2 * complex_of_real pi * \<i> * (of_nat n / of_nat n))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
1 \<le> n

goal (1 subgoal):
 1. 1 = exp (2 * complex_of_real pi * \<i> * (of_nat n / of_nat n))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 = exp (2 * complex_of_real pi * \<i> * (of_nat n / of_nat n))

goal (1 subgoal):
 1. (exp (2 * complex_of_real pi * \<i> * of_nat j / of_nat n) = 1) = (n dvd j)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
1 = exp (2 * complex_of_real pi * \<i> * (of_nat n / of_nat n))
[PROOF STEP]
have "exp(2 * of_real pi * \<i> * (of_nat j / of_nat n)) = 1 \<longleftrightarrow> j mod n = n mod n"
[PROOF STATE]
proof (prove)
using this:
1 = exp (2 * complex_of_real pi * \<i> * (of_nat n / of_nat n))

goal (1 subgoal):
 1. (exp (2 * complex_of_real pi * \<i> * (of_nat j / of_nat n)) = 1) = (j mod n = n mod n)
[PROOF STEP]
using complex_root_unity_eq [of n j n] assms
[PROOF STATE]
proof (prove)
using this:
1 = exp (2 * complex_of_real pi * \<i> * (of_nat n / of_nat n))
1 \<le> n \<Longrightarrow> (exp (2 * complex_of_real pi * \<i> * of_nat j / of_nat n) = exp (2 * complex_of_real pi * \<i> * of_nat n / of_nat n)) = (j mod n = n mod n)
1 \<le> n

goal (1 subgoal):
 1. (exp (2 * complex_of_real pi * \<i> * (of_nat j / of_nat n)) = 1) = (j mod n = n mod n)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(exp (2 * complex_of_real pi * \<i> * (of_nat j / of_nat n)) = 1) = (j mod n = n mod n)

goal (1 subgoal):
 1. (exp (2 * complex_of_real pi * \<i> * of_nat j / of_nat n) = 1) = (n dvd j)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(exp (2 * complex_of_real pi * \<i> * (of_nat j / of_nat n)) = 1) = (j mod n = n mod n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(exp (2 * complex_of_real pi * \<i> * (of_nat j / of_nat n)) = 1) = (j mod n = n mod n)

goal (1 subgoal):
 1. (exp (2 * complex_of_real pi * \<i> * of_nat j / of_nat n) = 1) = (n dvd j)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(exp (2 * complex_of_real pi * \<i> * of_nat j / of_nat n) = 1) = (n dvd j)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma bit_twiddle_min:
  "(y::'a::len word) XOR (((x::'a::len word) XOR y) AND (if x < y then -1 else 0)) = min x y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y XOR (x XOR y) AND (if x < y then - 1 else 0) = min x y
[PROOF STEP]
by (rule bit_eqI) (auto simp add: bit_simps)


[STATEMENT]
lemma  matrix_mul_sum_alt:
  fixes A B :: "'a::comm_ring_1^'n^'n"
  shows "A ** B = (\<chi> i. sum (\<lambda>k. A$i$k *s B $ k) (UNIV :: 'n set))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A ** B = (\<chi>i. \<Sum>k\<in>UNIV. A $ i $ k *s B $ k)
[PROOF STEP]
by (vector matrix_matrix_mult_def sum_component)


[STATEMENT]
lemma (in upper_semilattice) join_assoc_lemma:
  assumes L: "x \<in> carrier L"  "y \<in> carrier L"  "z \<in> carrier L"
  shows "x \<squnion> (y \<squnion> z) = \<Squnion>{x, y, z}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<squnion> (y \<squnion> z) = \<Squnion>{x, y, z}
[PROOF STEP]
using weak_join_assoc_lemma L
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?x \<in> carrier L; ?y \<in> carrier L; ?z \<in> carrier L\<rbrakk> \<Longrightarrow> ?x \<squnion> (?y \<squnion> ?z) .= \<Squnion>{?x, ?y, ?z}
x \<in> carrier L
y \<in> carrier L
z \<in> carrier L

goal (1 subgoal):
 1. x \<squnion> (y \<squnion> z) = \<Squnion>{x, y, z}
[PROOF STEP]
unfolding eq_is_equal
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?x \<in> carrier L; ?y \<in> carrier L; ?z \<in> carrier L\<rbrakk> \<Longrightarrow> ?x \<squnion> (?y \<squnion> ?z) = \<Squnion>{?x, ?y, ?z}
x \<in> carrier L
y \<in> carrier L
z \<in> carrier L

goal (1 subgoal):
 1. x \<squnion> (y \<squnion> z) = \<Squnion>{x, y, z}
[PROOF STEP]
.


[STATEMENT]
lemma  sorted_list_of_set_from_up_to:
  assumes  "(i::nat)  < j"
  assumes "k < j - i"
  shows "sorted_list_of_set {i..<j} ! k = i + k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted_list_of_set {i..<j} ! k = i + k
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
i < j
k < j - i

goal (1 subgoal):
 1. sorted_list_of_set {i..<j} ! k = i + k
[PROOF STEP]
apply(induction k)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>i < j; 0 < j - i\<rbrakk> \<Longrightarrow> sorted_list_of_set {i..<j} ! 0 = i + 0
 2. \<And>k. \<lbrakk>\<lbrakk>i < j; k < j - i\<rbrakk> \<Longrightarrow> sorted_list_of_set {i..<j} ! k = i + k; i < j; Suc k < j - i\<rbrakk> \<Longrightarrow> sorted_list_of_set {i..<j} ! Suc k = i + Suc k
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>k. \<lbrakk>\<lbrakk>i < j; k < j - i\<rbrakk> \<Longrightarrow> sorted_list_of_set {i..<j} ! k = i + k; i < j; Suc k < j - i\<rbrakk> \<Longrightarrow> sorted_list_of_set {i..<j} ! Suc k = i + Suc k
[PROOF STEP]
by simp


[STATEMENT]
lemma sum_collapse:
  fixes f :: "'a \<Rightarrow> 'b::{comm_monoid_add}"
  assumes "finite A"
  assumes "z \<in> A"
  assumes "\<And>y. y \<in> A \<Longrightarrow> y \<noteq> z \<Longrightarrow> f y = 0"
  shows "sum f A = f z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f A = f z
[PROOF STEP]
using sum.union_disjoint[where A="A-{z}" and B="{z}" and g="f"]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>finite (A - {z}); finite {z}; (A - {z}) \<inter> {z} = {}\<rbrakk> \<Longrightarrow> sum f (A - {z} \<union> {z}) = sum f (A - {z}) + sum f {z}

goal (1 subgoal):
 1. sum f A = f z
[PROOF STEP]
by (simp add: assms sum.insert_if)