[STATEMENT]
lemma size_less_than_median_of_medians_strong:
  fixes xs :: "'a :: linorder list" and d :: nat
  assumes d: "d > 0"
  assumes median: "\<And>xs. xs \<noteq> [] \<Longrightarrow> length xs \<le> d \<Longrightarrow> is_median (med xs) xs"
  assumes median': "is_median x (map med (chop d xs))"
  defines "m \<equiv> length (chop d xs)"
  shows   "size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
define n where [simp]: "n = length xs"
  \<comment> \<open>The medians of the sublists\<close>
[PROOF STATE]
proof (state)
this:
n = length xs

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
define M where "M = mset (map med (chop d xs))"
[PROOF STATE]
proof (state)
this:
M = mset (map med (chop d xs))

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
define YS where "YS = mset (chop d xs)"
  \<comment> \<open>The sublists with a smaller median than the median-of-medians @{term x} and the rest.\<close>
[PROOF STATE]
proof (state)
this:
YS = mset (chop d xs)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
define YS1 where "YS1 = filter_mset (\<lambda>ys. med ys < x) (mset (chop d xs))"
[PROOF STATE]
proof (state)
this:
YS1 = {#ys \<in># mset (chop d xs). med ys < x#}

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
define YS2 where "YS2 = filter_mset (\<lambda>ys. \<not>(med ys < x)) (mset (chop d xs))"

  \<comment> \<open>At most roughly half of the lists have a median that is smaller than @{term M}\<close>
[PROOF STATE]
proof (state)
this:
YS2 = {#ys \<in># mset (chop d xs). \<not> med ys < x#}

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "size YS1 = size (image_mset med YS1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. size YS1 = size (image_mset med YS1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
size YS1 = size (image_mset med YS1)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
size YS1 = size (image_mset med YS1)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "image_mset med YS1 = {#y \<in># mset (map med (chop d xs)). y < x#}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. image_mset med YS1 = {#y \<in># mset (map med (chop d xs)). y < x#}
[PROOF STEP]
unfolding YS1_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. image_mset med {#ys \<in># mset (chop d xs). med ys < x#} = {#y \<in># mset (map med (chop d xs)). y < x#}
[PROOF STEP]
by (subst filter_mset_image_mset [symmetric]) simp_all
[PROOF STATE]
proof (state)
this:
image_mset med YS1 = {#y \<in># mset (map med (chop d xs)). y < x#}

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
image_mset med YS1 = {#y \<in># mset (map med (chop d xs)). y < x#}

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "size \<dots> \<le> (length (map med (chop d xs))) div 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. size {#y \<in># mset (map med (chop d xs)). y < x#} \<le> length (map med (chop d xs)) div 2
[PROOF STEP]
using median'
[PROOF STATE]
proof (prove)
using this:
is_median x (map med (chop d xs))

goal (1 subgoal):
 1. size {#y \<in># mset (map med (chop d xs)). y < x#} \<le> length (map med (chop d xs)) div 2
[PROOF STEP]
unfolding is_median_altdef
[PROOF STATE]
proof (prove)
using this:
size {#y \<in># mset (map med (chop d xs)). y < x#} \<le> length (map med (chop d xs)) div 2 \<and> size (filter_mset ((<) x) (mset (map med (chop d xs)))) \<le> length (map med (chop d xs)) div 2

goal (1 subgoal):
 1. size {#y \<in># mset (map med (chop d xs)). y < x#} \<le> length (map med (chop d xs)) div 2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
size {#y \<in># mset (map med (chop d xs)). y < x#} \<le> length (map med (chop d xs)) div 2

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
size {#y \<in># mset (map med (chop d xs)). y < x#} \<le> length (map med (chop d xs)) div 2

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "\<dots> = m div 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (map med (chop d xs)) div 2 = m div 2
[PROOF STEP]
by (simp add: m_def)
[PROOF STATE]
proof (state)
this:
length (map med (chop d xs)) div 2 = m div 2

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
size YS1 \<le> m div 2
[PROOF STEP]
have size_YS1: "size YS1 \<le> m div 2"
[PROOF STATE]
proof (prove)
using this:
size YS1 \<le> m div 2

goal (1 subgoal):
 1. size YS1 \<le> m div 2
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
size YS1 \<le> m div 2

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "m = size (mset (chop d xs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m = size (mset (chop d xs))
[PROOF STEP]
by (simp add: m_def)
[PROOF STATE]
proof (state)
this:
m = size (mset (chop d xs))

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
m = size (mset (chop d xs))

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "mset (chop d xs) = YS1 + YS2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mset (chop d xs) = YS1 + YS2
[PROOF STEP]
unfolding YS1_def YS2_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mset (chop d xs) = {#ys \<in># mset (chop d xs). med ys < x#} + {#ys \<in># mset (chop d xs). \<not> med ys < x#}
[PROOF STEP]
by (rule multiset_partition)
[PROOF STATE]
proof (state)
this:
mset (chop d xs) = YS1 + YS2

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
m = size (YS1 + YS2)
[PROOF STEP]
have m_eq: "m = size YS1 + size YS2"
[PROOF STATE]
proof (prove)
using this:
m = size (YS1 + YS2)

goal (1 subgoal):
 1. m = size YS1 + size YS2
[PROOF STEP]
by simp

  \<comment> \<open>We estimate the number of elements less than @{term x} by grouping them into elements
      coming from @{term YS1} and elements coming from @{term YS2}. In the first case, we
      just note that no more than @{term d} elements can come from each sublist, whereas in
      the second case, we make the analysis more precise and note that only elements that are
      less than the median of their sublist can be less than @{term x}.\<close>
[PROOF STATE]
proof (state)
this:
m = size YS1 + size YS2

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "{# y \<in># mset xs. y < x#} = {# y \<in># (\<Sum>ys\<leftarrow>chop d xs. mset ys). y < x#}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {#y \<in># mset xs. y < x#} = {#y \<in># sum_list (map mset (chop d xs)). y < x#}
[PROOF STEP]
using d
[PROOF STATE]
proof (prove)
using this:
0 < d

goal (1 subgoal):
 1. {#y \<in># mset xs. y < x#} = {#y \<in># sum_list (map mset (chop d xs)). y < x#}
[PROOF STEP]
by (subst sum_msets_chop) simp_all
[PROOF STATE]
proof (state)
this:
{#y \<in># mset xs. y < x#} = {#y \<in># sum_list (map mset (chop d xs)). y < x#}

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
{#y \<in># mset xs. y < x#} = {#y \<in># sum_list (map mset (chop d xs)). y < x#}

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "\<dots> = (\<Sum>ys\<leftarrow>chop d xs. {#y \<in># mset ys. y < x#})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {#y \<in># sum_list (map mset (chop d xs)). y < x#} = (\<Sum>ys\<leftarrow>chop d xs. {#y \<in># mset ys. y < x#})
[PROOF STEP]
by (subst filter_mset_sum_list) (simp add: o_def)
[PROOF STATE]
proof (state)
this:
{#y \<in># sum_list (map mset (chop d xs)). y < x#} = (\<Sum>ys\<leftarrow>chop d xs. {#y \<in># mset ys. y < x#})

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
{#y \<in># sum_list (map mset (chop d xs)). y < x#} = (\<Sum>ys\<leftarrow>chop d xs. {#y \<in># mset ys. y < x#})

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "\<dots> = (\<Sum>ys\<in>#YS. {#y \<in># mset ys. y < x#})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ys\<leftarrow>chop d xs. {#y \<in># mset ys. y < x#}) = (\<Sum>ys\<in>#YS. {#y \<in># mset ys. y < x#})
[PROOF STEP]
unfolding YS_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ys\<leftarrow>chop d xs. {#y \<in># mset ys. y < x#}) = (\<Sum>ys\<in>#mset (chop d xs). {#y \<in># mset ys. y < x#})
[PROOF STEP]
by (subst sum_mset_sum_list [symmetric]) simp_all
[PROOF STATE]
proof (state)
this:
(\<Sum>ys\<leftarrow>chop d xs. {#y \<in># mset ys. y < x#}) = (\<Sum>ys\<in>#YS. {#y \<in># mset ys. y < x#})

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ys\<leftarrow>chop d xs. {#y \<in># mset ys. y < x#}) = (\<Sum>ys\<in>#YS. {#y \<in># mset ys. y < x#})

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "YS = YS1 + YS2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. YS = YS1 + YS2
[PROOF STEP]
by (simp add: YS_def YS1_def YS2_def not_le)
[PROOF STATE]
proof (state)
this:
YS = YS1 + YS2

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
YS = YS1 + YS2

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "(\<Sum>ys\<in>#\<dots>. {#y \<in># mset ys. y < x#}) =
               (\<Sum>ys\<in>#YS1. {#y \<in># mset ys. y < x#}) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < x#})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ys\<in>#YS1 + YS2. {#y \<in># mset ys. y < x#}) = (\<Sum>ys\<in>#YS1. {#y \<in># mset ys. y < x#}) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < x#})
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>ys\<in>#YS1 + YS2. {#y \<in># mset ys. y < x#}) = (\<Sum>ys\<in>#YS1. {#y \<in># mset ys. y < x#}) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < x#})

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ys\<in>#YS1 + YS2. {#y \<in># mset ys. y < x#}) = (\<Sum>ys\<in>#YS1. {#y \<in># mset ys. y < x#}) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < x#})

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "\<dots> \<subseteq># (\<Sum>ys\<in>#YS1. mset ys) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ys\<in>#YS1. {#y \<in># mset ys. y < x#}) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < x#}) \<subseteq># \<Sum>\<^sub># (image_mset mset YS1) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#})
[PROOF STEP]
by (intro subset_mset.add_mono sum_mset_mset_mono mset_filter_mono) (auto simp: YS2_def)
[PROOF STATE]
proof (state)
this:
(\<Sum>ys\<in>#YS1. {#y \<in># mset ys. y < x#}) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < x#}) \<subseteq># \<Sum>\<^sub># (image_mset mset YS1) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#})

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
{#y \<in># mset xs. y < x#} \<subseteq># \<Sum>\<^sub># (image_mset mset YS1) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#})
[PROOF STEP]
have "{# y \<in># mset xs. y < x #} \<subseteq># \<dots>"
[PROOF STATE]
proof (prove)
using this:
{#y \<in># mset xs. y < x#} \<subseteq># \<Sum>\<^sub># (image_mset mset YS1) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#})

goal (1 subgoal):
 1. {#y \<in># mset xs. y < x#} \<subseteq># \<Sum>\<^sub># (image_mset mset YS1) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#})
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
{#y \<in># mset xs. y < x#} \<subseteq># \<Sum>\<^sub># (image_mset mset YS1) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#})

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
hence "size {# y \<in># mset xs. y < x #} \<le> size \<dots>"
[PROOF STATE]
proof (prove)
using this:
{#y \<in># mset xs. y < x#} \<subseteq># \<Sum>\<^sub># (image_mset mset YS1) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#})

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> size (\<Sum>\<^sub># (image_mset mset YS1) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#}))
[PROOF STEP]
by (rule size_mset_mono)

  \<comment> \<open>We do some further straightforward estimations and arrive at our goal.\<close>
[PROOF STATE]
proof (state)
this:
size {#y \<in># mset xs. y < x#} \<le> size (\<Sum>\<^sub># (image_mset mset YS1) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#}))

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
size {#y \<in># mset xs. y < x#} \<le> size (\<Sum>\<^sub># (image_mset mset YS1) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#}))

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "\<dots> = (\<Sum>ys\<in>#YS1. length ys) + (\<Sum>x\<in>#YS2. size {#y \<in># mset x. y < med x#})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. size (\<Sum>\<^sub># (image_mset mset YS1) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#})) = \<Sum>\<^sub># (image_mset length YS1) + (\<Sum>x\<in>#YS2. size {#y \<in># mset x. y < med x#})
[PROOF STEP]
by (simp add: size_mset_sum_mset_distrib multiset.map_comp o_def)
[PROOF STATE]
proof (state)
this:
size (\<Sum>\<^sub># (image_mset mset YS1) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#})) = \<Sum>\<^sub># (image_mset length YS1) + (\<Sum>x\<in>#YS2. size {#y \<in># mset x. y < med x#})

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
size (\<Sum>\<^sub># (image_mset mset YS1) + (\<Sum>ys\<in>#YS2. {#y \<in># mset ys. y < med ys#})) = \<Sum>\<^sub># (image_mset length YS1) + (\<Sum>x\<in>#YS2. size {#y \<in># mset x. y < med x#})

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "(\<Sum>ys\<in>#YS1. length ys) \<le> (\<Sum>ys\<in>#YS1. d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Sum>\<^sub># (image_mset length YS1) \<le> (\<Sum>ys\<in>#YS1. d)
[PROOF STEP]
by (intro sum_mset_mono) (auto simp: YS1_def length_chop_part_le)
[PROOF STATE]
proof (state)
this:
\<Sum>\<^sub># (image_mset length YS1) \<le> (\<Sum>ys\<in>#YS1. d)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<Sum>\<^sub># (image_mset length YS1) \<le> (\<Sum>ys\<in>#YS1. d)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "\<dots> = size YS1 * d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ys\<in>#YS1. d) = size YS1 * d
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>ys\<in>#YS1. d) = size YS1 * d

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ys\<in>#YS1. d) = size YS1 * d

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have d: "d = (d div 2) + ((d + 1) div 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. d = d div 2 + (d + 1) div 2
[PROOF STEP]
using d
[PROOF STATE]
proof (prove)
using this:
0 < d

goal (1 subgoal):
 1. d = d div 2 + (d + 1) div 2
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
d = d div 2 + (d + 1) div 2

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "size YS1 * d = size YS1 * (d div 2) + size YS1 * ((d + 1) div 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. size YS1 * d = size YS1 * (d div 2) + size YS1 * ((d + 1) div 2)
[PROOF STEP]
by (subst d) (simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
size YS1 * d = size YS1 * (d div 2) + size YS1 * ((d + 1) div 2)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
size YS1 * d = size YS1 * (d div 2) + size YS1 * ((d + 1) div 2)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "(\<Sum>ys\<in>#YS2. size {#y \<in># mset ys. y < med ys#}) \<le>
               (\<Sum>ys\<in>#YS2. length ys div 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ys\<in>#YS2. size {#y \<in># mset ys. y < med ys#}) \<le> (\<Sum>ys\<in>#YS2. length ys div 2)
[PROOF STEP]
proof (intro sum_mset_mono size_less_than_median, goal_cases)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>ys. ys \<in># YS2 \<Longrightarrow> size {#y \<in># mset ys. y < med ys#} \<le> length ys div 2
[PROOF STEP]
case (1 ys)
[PROOF STATE]
proof (state)
this:
ys \<in># YS2

goal (1 subgoal):
 1. \<And>ys. ys \<in># YS2 \<Longrightarrow> size {#y \<in># mset ys. y < med ys#} \<le> length ys div 2
[PROOF STEP]
hence "ys \<noteq> []" "length ys \<le> d"
[PROOF STATE]
proof (prove)
using this:
ys \<in># YS2

goal (1 subgoal):
 1. ys \<noteq> [] &&& length ys \<le> d
[PROOF STEP]
by (auto simp: YS2_def length_chop_part_le)
[PROOF STATE]
proof (state)
this:
ys \<noteq> []
length ys \<le> d

goal (1 subgoal):
 1. \<And>ys. ys \<in># YS2 \<Longrightarrow> size {#y \<in># mset ys. y < med ys#} \<le> length ys div 2
[PROOF STEP]
from median[OF this]
[PROOF STATE]
proof (chain)
picking this:
is_median (med ys) ys
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
is_median (med ys) ys

goal (1 subgoal):
 1. size {#y \<in># mset ys. y < med ys#} \<le> length ys div 2
[PROOF STEP]
by (auto simp: is_median_altdef)
[PROOF STATE]
proof (state)
this:
size {#y \<in># mset ys. y < med ys#} \<le> length ys div 2

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>ys\<in>#YS2. size {#y \<in># mset ys. y < med ys#}) \<le> (\<Sum>ys\<in>#YS2. length ys div 2)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ys\<in>#YS2. size {#y \<in># mset ys. y < med ys#}) \<le> (\<Sum>ys\<in>#YS2. length ys div 2)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "\<dots> \<le> (\<Sum>ys\<in>#YS2. d div 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ys\<in>#YS2. length ys div 2) \<le> (\<Sum>ys\<in>#YS2. d div 2)
[PROOF STEP]
by (intro sum_mset_mono div_le_mono diff_le_mono) (auto simp: YS2_def dest: length_chop_part_le)
[PROOF STATE]
proof (state)
this:
(\<Sum>ys\<in>#YS2. length ys div 2) \<le> (\<Sum>ys\<in>#YS2. d div 2)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ys\<in>#YS2. length ys div 2) \<le> (\<Sum>ys\<in>#YS2. d div 2)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "\<dots> = size YS2 * (d div 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ys\<in>#YS2. d div 2) = size YS2 * (d div 2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>ys\<in>#YS2. d div 2) = size YS2 * (d div 2)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ys\<in>#YS2. d div 2) = size YS2 * (d div 2)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + \<dots> =
               m * (d div 2) + size YS1 * ((d + 1) div 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + size YS2 * (d div 2) = m * (d div 2) + size YS1 * ((d + 1) div 2)
[PROOF STEP]
by (simp add: m_eq algebra_simps)
[PROOF STATE]
proof (state)
this:
size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + size YS2 * (d div 2) = m * (d div 2) + size YS1 * ((d + 1) div 2)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + size YS2 * (d div 2) = m * (d div 2) + size YS1 * ((d + 1) div 2)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
have "size YS1 * ((d + 1) div 2) \<le> (m div 2) * ((d + 1) div 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. size YS1 * ((d + 1) div 2) \<le> m div 2 * ((d + 1) div 2)
[PROOF STEP]
by (intro mult_right_mono size_YS1) auto
[PROOF STATE]
proof (state)
this:
size YS1 * ((d + 1) div 2) \<le> m div 2 * ((d + 1) div 2)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>\<And>ys y. ys \<le> y \<Longrightarrow> ys + (\<Sum>ys\<in>#YS2. size {#y \<in># mset ys. y < med ys#}) \<le> y + (\<Sum>ys\<in>#YS2. size {#y \<in># mset ys. y < med ys#}); \<And>x y. x \<le> y \<Longrightarrow> size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + x \<le> size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + y; \<And>x y. x \<le> y \<Longrightarrow> size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + x \<le> size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + y; \<And>x y. x \<le> y \<Longrightarrow> m * (d div 2) + x \<le> m * (d div 2) + y\<rbrakk> \<Longrightarrow> size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
show "size {#y \<in># mset xs. y < x#} \<le>
                  m * (d div 2) + m div 2 * ((d + 1) div 2)"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>ys y. ys \<le> y \<Longrightarrow> ys + (\<Sum>ys\<in>#YS2. size {#y \<in># mset ys. y < med ys#}) \<le> y + (\<Sum>ys\<in>#YS2. size {#y \<in># mset ys. y < med ys#}); \<And>x y. x \<le> y \<Longrightarrow> size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + x \<le> size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + y; \<And>x y. x \<le> y \<Longrightarrow> size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + x \<le> size YS1 * (d div 2) + size YS1 * ((d + 1) div 2) + y; \<And>x y. x \<le> y \<Longrightarrow> m * (d div 2) + x \<le> m * (d div 2) + y\<rbrakk> \<Longrightarrow> size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)

goal (1 subgoal):
 1. size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)
[PROOF STEP]
by simp_all
[PROOF STATE]
proof (state)
this:
size {#y \<in># mset xs. y < x#} \<le> m * (d div 2) + m div 2 * ((d + 1) div 2)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sorted_list_of_set_mono_on:
  "finite A \<Longrightarrow> mono_on {..<card A} (\<lambda>n. sorted_list_of_set A ! n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite A \<Longrightarrow> mono_on {..<card A} ((!) (sorted_list_of_set A))
[PROOF STEP]
by (rule nth_mono_on) (auto)


[STATEMENT]
lemma atom_map_inf_pres: "atom_map (x \<sqinter> y) = atom_map x \<inter> atom_map y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. atom_map (x \<sqinter> y) = atom_map x \<inter> atom_map y
[PROOF STEP]
by (smt Diff_Un atom_map_compl_pres atom_map_sup_pres compl_inf double_compl)


[STATEMENT]
lemma minus_core_weaker:
  "|a \<ominus> b| = |a| \<ominus> |b|"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1.  |a \<ominus> b|  =  |a|  \<ominus>  |b|
[PROOF STEP]
proof (cases "a \<succeq> b")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. a \<succeq> b \<Longrightarrow>  |a \<ominus> b|  =  |a|  \<ominus>  |b|
 2. \<not> a \<succeq> b \<Longrightarrow>  |a \<ominus> b|  =  |a|  \<ominus>  |b|
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
a \<succeq> b

goal (2 subgoals):
 1. a \<succeq> b \<Longrightarrow>  |a \<ominus> b|  =  |a|  \<ominus>  |b|
 2. \<not> a \<succeq> b \<Longrightarrow>  |a \<ominus> b|  =  |a|  \<ominus>  |b|
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
a \<succeq> b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
a \<succeq> b

goal (1 subgoal):
 1.  |a \<ominus> b|  =  |a|  \<ominus>  |b|
[PROOF STEP]
by (metis greater_equiv max_projection_prop_pure_core minus_core minus_default minus_equiv_def mpp_invo succ_antisym)
[PROOF STATE]
proof (state)
this:
 |a \<ominus> b|  =  |a|  \<ominus>  |b|

goal (1 subgoal):
 1. \<not> a \<succeq> b \<Longrightarrow>  |a \<ominus> b|  =  |a|  \<ominus>  |b|
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> a \<succeq> b \<Longrightarrow>  |a \<ominus> b|  =  |a|  \<ominus>  |b|
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> a \<succeq> b

goal (1 subgoal):
 1. \<not> a \<succeq> b \<Longrightarrow>  |a \<ominus> b|  =  |a|  \<ominus>  |b|
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> a \<succeq> b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> a \<succeq> b

goal (1 subgoal):
 1.  |a \<ominus> b|  =  |a|  \<ominus>  |b|
[PROOF STEP]
by (metis greater_equiv max_projection_prop_pure_core minus_default minus_equiv_def mpp_invo succ_antisym)
[PROOF STATE]
proof (state)
this:
 |a \<ominus> b|  =  |a|  \<ominus>  |b|

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma of_nat_word_less_eq_iff:
  \<open>of_nat m \<le> (of_nat n :: 'a::len word) \<longleftrightarrow> take_bit LENGTH('a) m \<le> take_bit LENGTH('a) n\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (word_of_nat m \<le> word_of_nat n) = (take_bit LENGTH('a) m \<le> take_bit LENGTH('a) n)
[PROOF STEP]
by transfer (simp add: take_bit_of_nat)


[STATEMENT]
lemma has_vector_derivative_circlepath [derivative_intros]:
 "((circlepath z r) has_vector_derivative (2 * pi * \<i> * r * exp (2 * of_real pi * \<i> * x)))
   (at x within X)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (circlepath z r has_vector_derivative complex_of_real (2 * pi) * \<i> * complex_of_real r * exp (2 * complex_of_real pi * \<i> * complex_of_real x)) (at x within X)
[PROOF STEP]
unfolding circlepath_def scaleR_conv_of_real
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (part_circlepath z r 0 (2 * pi) has_vector_derivative complex_of_real (2 * pi) * \<i> * complex_of_real r * exp (2 * complex_of_real pi * \<i> * complex_of_real x)) (at x within X)
[PROOF STEP]
by (rule derivative_eq_intros) (simp add: algebra_simps)


[STATEMENT]
lemma "(14::nat) - 15 = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 14 - 15 = 0
[PROOF STEP]
by simp


[STATEMENT]
lemma F2set3_bd: "|F2set3 x| <o bd_F1 +c bd_F2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. |F2set3 x| <o bd_F1 +c bd_F2
[PROOF STEP]
apply (rule ordLess_ordLeq_trans)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. |F2set3 x| <o ?r'
 2. ?r' \<le>o bd_F1 +c bd_F2
[PROOF STEP]
apply (rule F2.set_bd(3))
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bd_F2 \<le>o bd_F1 +c bd_F2
[PROOF STEP]
apply (rule ordLeq_csum2)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Card_order bd_F2
[PROOF STEP]
apply (rule F2.bd_Card_order)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma "filterlim (\<lambda>i::real. i powr (-i/(i-1)) - i powr (-1/(i-1))) (at_left 1) (at_right 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LIM i at_right 0. i powr (- i / (i - 1)) - i powr (- 1 / (i - 1)) :> at_left 1
[PROOF STEP]
by real_asymp


[STATEMENT]
lemma A_authenticates_B:
     "\<lbrakk> Outpts (Card A) A  \<lbrace>Agent B, Nonce Nb, Key K, Certificate\<rbrace> \<in> set evs;
        \<not>illegalUse(Card B);
        evs \<in> srb \<rbrakk>
 \<Longrightarrow> \<exists> Na. Outpts (Card B) B \<lbrace>Nonce Nb, Agent A, Key K,
                Crypt (pairK(A,B)) \<lbrace>Nonce Na, Nonce Nb\<rbrace>,
                Crypt (pairK(A,B)) (Nonce Nb)\<rbrace> \<in> set evs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Outpts (Card A) A \<lbrace>Agent B, Nonce Nb, Key K, Certificate\<rbrace> \<in> set evs; \<not> illegalUse (Card B); evs \<in> srb\<rbrakk> \<Longrightarrow> \<exists>Na. Outpts (Card B) B \<lbrace>Nonce Nb, Agent A, Key K, Crypt (pairK (A, B)) \<lbrace>Nonce Na, Nonce Nb\<rbrace>, Crypt (pairK (A, B)) (Nonce Nb)\<rbrace> \<in> set evs
[PROOF STEP]
apply (blast dest: Na_Nb_certificate_authentic Outpts_A_Card_form_10 Outpts_A_Card_imp_pairK_parts)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma "encode [1,2,3,4::nat]
  = [True, True, True, True, True, True, True, True, True, True, True, True, True, True, False]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. encode [1, 2, 3, 4] = [True, True, True, True, True, True, True, True, True, True, True, True, True, True, False]
[PROOF STEP]
by eval


[STATEMENT]
lemma RDirProd_list_is_ring:
  assumes "\<And>i. i < length Rs \<Longrightarrow> ring (Rs ! i)" shows "ring (RDirProd_list Rs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ring (RDirProd_list Rs)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
?i < length Rs \<Longrightarrow> ring (Rs ! ?i)

goal (1 subgoal):
 1. ring (RDirProd_list Rs)
[PROOF STEP]
proof (induct Rs)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (\<And>i. i < length [] \<Longrightarrow> ring ([] ! i)) \<Longrightarrow> ring (RDirProd_list [])
 2. \<And>a Rs. \<lbrakk>(\<And>i. i < length Rs \<Longrightarrow> ring (Rs ! i)) \<Longrightarrow> ring (RDirProd_list Rs); \<And>i. i < length (a # Rs) \<Longrightarrow> ring ((a # Rs) ! i)\<rbrakk> \<Longrightarrow> ring (RDirProd_list (a # Rs))
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
?i < length [] \<Longrightarrow> ring ([] ! ?i)

goal (2 subgoals):
 1. (\<And>i. i < length [] \<Longrightarrow> ring ([] ! i)) \<Longrightarrow> ring (RDirProd_list [])
 2. \<And>a Rs. \<lbrakk>(\<And>i. i < length Rs \<Longrightarrow> ring (Rs ! i)) \<Longrightarrow> ring (RDirProd_list Rs); \<And>i. i < length (a # Rs) \<Longrightarrow> ring ((a # Rs) ! i)\<rbrakk> \<Longrightarrow> ring (RDirProd_list (a # Rs))
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
?i < length [] \<Longrightarrow> ring ([] ! ?i)

goal (1 subgoal):
 1. ring (RDirProd_list [])
[PROOF STEP]
unfolding RDirProd_list_def
[PROOF STATE]
proof (prove)
using this:
?i < length [] \<Longrightarrow> ring ([] ! ?i)

goal (1 subgoal):
 1. ring (foldr (\<lambda>R S. image_ring (\<lambda>(x, y). x # y) (RDirProd R S)) [] nil_ring)
[PROOF STEP]
by (unfold_locales, auto simp add: monoid.defs Units_def)
[PROOF STATE]
proof (state)
this:
ring (RDirProd_list [])

goal (1 subgoal):
 1. \<And>a Rs. \<lbrakk>(\<And>i. i < length Rs \<Longrightarrow> ring (Rs ! i)) \<Longrightarrow> ring (RDirProd_list Rs); \<And>i. i < length (a # Rs) \<Longrightarrow> ring ((a # Rs) ! i)\<rbrakk> \<Longrightarrow> ring (RDirProd_list (a # Rs))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a Rs. \<lbrakk>(\<And>i. i < length Rs \<Longrightarrow> ring (Rs ! i)) \<Longrightarrow> ring (RDirProd_list Rs); \<And>i. i < length (a # Rs) \<Longrightarrow> ring ((a # Rs) ! i)\<rbrakk> \<Longrightarrow> ring (RDirProd_list (a # Rs))
[PROOF STEP]
case (Cons R Rs)
[PROOF STATE]
proof (state)
this:
(\<And>i. i < length Rs \<Longrightarrow> ring (Rs ! i)) \<Longrightarrow> ring (RDirProd_list Rs)
?i < length (R # Rs) \<Longrightarrow> ring ((R # Rs) ! ?i)

goal (1 subgoal):
 1. \<And>a Rs. \<lbrakk>(\<And>i. i < length Rs \<Longrightarrow> ring (Rs ! i)) \<Longrightarrow> ring (RDirProd_list Rs); \<And>i. i < length (a # Rs) \<Longrightarrow> ring ((a # Rs) ! i)\<rbrakk> \<Longrightarrow> ring (RDirProd_list (a # Rs))
[PROOF STEP]
hence is_ring: "ring (RDirProd R (RDirProd_list Rs))"
[PROOF STATE]
proof (prove)
using this:
(\<And>i. i < length Rs \<Longrightarrow> ring (Rs ! i)) \<Longrightarrow> ring (RDirProd_list Rs)
?i < length (R # Rs) \<Longrightarrow> ring ((R # Rs) ! ?i)

goal (1 subgoal):
 1. ring (RDirProd R (RDirProd_list Rs))
[PROOF STEP]
using RDirProd_ring[of R "RDirProd_list Rs"]
[PROOF STATE]
proof (prove)
using this:
(\<And>i. i < length Rs \<Longrightarrow> ring (Rs ! i)) \<Longrightarrow> ring (RDirProd_list Rs)
?i < length (R # Rs) \<Longrightarrow> ring ((R # Rs) ! ?i)
\<lbrakk>ring R; ring (RDirProd_list Rs)\<rbrakk> \<Longrightarrow> ring (RDirProd R (RDirProd_list Rs))

goal (1 subgoal):
 1. ring (RDirProd R (RDirProd_list Rs))
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
ring (RDirProd R (RDirProd_list Rs))

goal (1 subgoal):
 1. \<And>a Rs. \<lbrakk>(\<And>i. i < length Rs \<Longrightarrow> ring (Rs ! i)) \<Longrightarrow> ring (RDirProd_list Rs); \<And>i. i < length (a # Rs) \<Longrightarrow> ring ((a # Rs) ! i)\<rbrakk> \<Longrightarrow> ring (RDirProd_list (a # Rs))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ring (RDirProd_list (R # Rs))
[PROOF STEP]
using ring.inj_imp_image_ring_is_ring[OF is_ring inj_on_RDirProd_carrier]
[PROOF STATE]
proof (prove)
using this:
ring (image_ring (\<lambda>(a, as). a # as) (RDirProd R (RDirProd_list Rs)))

goal (1 subgoal):
 1. ring (RDirProd_list (R # Rs))
[PROOF STEP]
unfolding RDirProd_list_def
[PROOF STATE]
proof (prove)
using this:
ring (image_ring (\<lambda>(a, as). a # as) (RDirProd R (foldr (\<lambda>R S. image_ring (\<lambda>(x, y). x # y) (RDirProd R S)) Rs nil_ring)))

goal (1 subgoal):
 1. ring (foldr (\<lambda>R S. image_ring (\<lambda>(x, y). x # y) (RDirProd R S)) (R # Rs) nil_ring)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ring (RDirProd_list (R # Rs))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma rGamma_series_real:
  "eventually (\<lambda>n. rGamma_series x n = Re (rGamma_series (of_real x) n)) sequentially"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. rGamma_series x n = Re (rGamma_series (complex_of_real x) n)
[PROOF STEP]
using eventually_gt_at_top[of "0 :: nat"]
[PROOF STATE]
proof (prove)
using this:
eventually ((<) 0) sequentially

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. rGamma_series x n = Re (rGamma_series (complex_of_real x) n)
[PROOF STEP]
proof eventually_elim
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. 0 < n \<Longrightarrow> rGamma_series x n = Re (rGamma_series (complex_of_real x) n)
[PROOF STEP]
fix n :: nat
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. 0 < n \<Longrightarrow> rGamma_series x n = Re (rGamma_series (complex_of_real x) n)
[PROOF STEP]
assume n: "n > 0"
[PROOF STATE]
proof (state)
this:
0 < n

goal (1 subgoal):
 1. \<And>n. 0 < n \<Longrightarrow> rGamma_series x n = Re (rGamma_series (complex_of_real x) n)
[PROOF STEP]
have "Re (rGamma_series (of_real x) n) =
          Re (of_real (pochhammer x (Suc n)) / (fact n * exp (of_real (x * ln (real_of_nat n)))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Re (rGamma_series (complex_of_real x) n) = Re (complex_of_real (pochhammer x (Suc n)) / (fact n * exp (complex_of_real (x * ln (real n)))))
[PROOF STEP]
using n
[PROOF STATE]
proof (prove)
using this:
0 < n

goal (1 subgoal):
 1. Re (rGamma_series (complex_of_real x) n) = Re (complex_of_real (pochhammer x (Suc n)) / (fact n * exp (complex_of_real (x * ln (real n)))))
[PROOF STEP]
by (simp add: rGamma_series_def powr_def pochhammer_of_real)
[PROOF STATE]
proof (state)
this:
Re (rGamma_series (complex_of_real x) n) = Re (complex_of_real (pochhammer x (Suc n)) / (fact n * exp (complex_of_real (x * ln (real n)))))

goal (1 subgoal):
 1. \<And>n. 0 < n \<Longrightarrow> rGamma_series x n = Re (rGamma_series (complex_of_real x) n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Re (rGamma_series (complex_of_real x) n) = Re (complex_of_real (pochhammer x (Suc n)) / (fact n * exp (complex_of_real (x * ln (real n)))))

goal (1 subgoal):
 1. \<And>n. 0 < n \<Longrightarrow> rGamma_series x n = Re (rGamma_series (complex_of_real x) n)
[PROOF STEP]
from n
[PROOF STATE]
proof (chain)
picking this:
0 < n
[PROOF STEP]
have "\<dots> = Re (of_real ((pochhammer x (Suc n)) /
                              (fact n * (exp (x * ln (real_of_nat n))))))"
[PROOF STATE]
proof (prove)
using this:
0 < n

goal (1 subgoal):
 1. Re (complex_of_real (pochhammer x (Suc n)) / (fact n * exp (complex_of_real (x * ln (real n))))) = Re (complex_of_real (pochhammer x (Suc n) / (fact n * exp (x * ln (real n)))))
[PROOF STEP]
by (subst exp_of_real) simp
[PROOF STATE]
proof (state)
this:
Re (complex_of_real (pochhammer x (Suc n)) / (fact n * exp (complex_of_real (x * ln (real n))))) = Re (complex_of_real (pochhammer x (Suc n) / (fact n * exp (x * ln (real n)))))

goal (1 subgoal):
 1. \<And>n. 0 < n \<Longrightarrow> rGamma_series x n = Re (rGamma_series (complex_of_real x) n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Re (complex_of_real (pochhammer x (Suc n)) / (fact n * exp (complex_of_real (x * ln (real n))))) = Re (complex_of_real (pochhammer x (Suc n) / (fact n * exp (x * ln (real n)))))

goal (1 subgoal):
 1. \<And>n. 0 < n \<Longrightarrow> rGamma_series x n = Re (rGamma_series (complex_of_real x) n)
[PROOF STEP]
from n
[PROOF STATE]
proof (chain)
picking this:
0 < n
[PROOF STEP]
have "\<dots> = rGamma_series x n"
[PROOF STATE]
proof (prove)
using this:
0 < n

goal (1 subgoal):
 1. Re (complex_of_real (pochhammer x (Suc n) / (fact n * exp (x * ln (real n))))) = rGamma_series x n
[PROOF STEP]
by (subst Re_complex_of_real) (simp add: rGamma_series_def powr_def)
[PROOF STATE]
proof (state)
this:
Re (complex_of_real (pochhammer x (Suc n) / (fact n * exp (x * ln (real n))))) = rGamma_series x n

goal (1 subgoal):
 1. \<And>n. 0 < n \<Longrightarrow> rGamma_series x n = Re (rGamma_series (complex_of_real x) n)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
Re (rGamma_series (complex_of_real x) n) = rGamma_series x n
[PROOF STEP]
show "rGamma_series x n = Re (rGamma_series (of_real x) n)"
[PROOF STATE]
proof (prove)
using this:
Re (rGamma_series (complex_of_real x) n) = rGamma_series x n

goal (1 subgoal):
 1. rGamma_series x n = Re (rGamma_series (complex_of_real x) n)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
rGamma_series x n = Re (rGamma_series (complex_of_real x) n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma set_contI:
  assumes  "\<And> Y. chain Y \<Longrightarrow> f (\<Squnion> i. Y i) = \<Union> (f ` range Y)"
  shows "cont f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cont f
[PROOF STEP]
proof(rule contI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>Y. chain Y \<Longrightarrow> range (\<lambda>i. f (Y i)) <<| f (\<Squnion>i. Y i)
[PROOF STEP]
fix Y :: "nat \<Rightarrow> 'a"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>Y. chain Y \<Longrightarrow> range (\<lambda>i. f (Y i)) <<| f (\<Squnion>i. Y i)
[PROOF STEP]
assume "chain Y"
[PROOF STATE]
proof (state)
this:
chain Y

goal (1 subgoal):
 1. \<And>Y. chain Y \<Longrightarrow> range (\<lambda>i. f (Y i)) <<| f (\<Squnion>i. Y i)
[PROOF STEP]
hence "f (\<Squnion> i. Y i) = \<Union> (f ` range Y)"
[PROOF STATE]
proof (prove)
using this:
chain Y

goal (1 subgoal):
 1. f (\<Squnion>i. Y i) = \<Union> (f ` range Y)
[PROOF STEP]
by (rule assms)
[PROOF STATE]
proof (state)
this:
f (\<Squnion>i. Y i) = \<Union> (f ` range Y)

goal (1 subgoal):
 1. \<And>Y. chain Y \<Longrightarrow> range (\<lambda>i. f (Y i)) <<| f (\<Squnion>i. Y i)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
f (\<Squnion>i. Y i) = \<Union> (f ` range Y)

goal (1 subgoal):
 1. \<And>Y. chain Y \<Longrightarrow> range (\<lambda>i. f (Y i)) <<| f (\<Squnion>i. Y i)
[PROOF STEP]
have "\<dots> = \<Union> (range (\<lambda>i. f (Y i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Union> (f ` range Y) = (\<Union>i. f (Y i))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<Union> (f ` range Y) = (\<Union>i. f (Y i))

goal (1 subgoal):
 1. \<And>Y. chain Y \<Longrightarrow> range (\<lambda>i. f (Y i)) <<| f (\<Squnion>i. Y i)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
f (\<Squnion>i. Y i) = (\<Union>i. f (Y i))
[PROOF STEP]
show "range (\<lambda>i. f (Y i)) <<| f (\<Squnion> i. Y i)"
[PROOF STATE]
proof (prove)
using this:
f (\<Squnion>i. Y i) = (\<Union>i. f (Y i))

goal (1 subgoal):
 1. range (\<lambda>i. f (Y i)) <<| f (\<Squnion>i. Y i)
[PROOF STEP]
using is_lub_set
[PROOF STATE]
proof (prove)
using this:
f (\<Squnion>i. Y i) = (\<Union>i. f (Y i))
?S <<| \<Union> ?S

goal (1 subgoal):
 1. range (\<lambda>i. f (Y i)) <<| f (\<Squnion>i. Y i)
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
range (\<lambda>i. f (Y i)) <<| f (\<Squnion>i. Y i)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma additive_implies_homogenous:
  assumes "\<And>x y. f (x + y) = f x + ((f (y::'a::monoid_add))::'b::cancel_comm_monoid_add)"
  shows "f 0 = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f (0::'a) = (0::'b)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. f (0::'a) = (0::'b)
[PROOF STEP]
have "f (0 + 0) = f 0 + f 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f ((0::'a) + (0::'a)) = f (0::'a) + f (0::'a)
[PROOF STEP]
by (rule assms)
[PROOF STATE]
proof (state)
this:
f ((0::'a) + (0::'a)) = f (0::'a) + f (0::'a)

goal (1 subgoal):
 1. f (0::'a) = (0::'b)
[PROOF STEP]
hence "f 0 = f 0 + f 0"
[PROOF STATE]
proof (prove)
using this:
f ((0::'a) + (0::'a)) = f (0::'a) + f (0::'a)

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

goal (1 subgoal):
 1. f (0::'a) = (0::'b)
[PROOF STEP]
thus "f 0 = 0"
[PROOF STATE]
proof (prove)
using this:
f (0::'a) = f (0::'a) + f (0::'a)

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma is_aligned_weaken:
  "\<lbrakk> is_aligned w x; x \<ge> y \<rbrakk> \<Longrightarrow> is_aligned w y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>is_aligned w x; y \<le> x\<rbrakk> \<Longrightarrow> is_aligned w y
[PROOF STEP]
unfolding is_aligned_iff_dvd_nat
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>2 ^ x dvd unat w; y \<le> x\<rbrakk> \<Longrightarrow> 2 ^ y dvd unat w
[PROOF STEP]
by (erule dvd_trans [rotated]) (simp add: le_imp_power_dvd)


[STATEMENT]
lemma countable_Image:
  assumes "\<And>y. y \<in> Y \<Longrightarrow> countable (X `` {y})"
  assumes "countable Y"
  shows "countable (X `` Y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. countable (X `` Y)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. countable (X `` Y)
[PROOF STEP]
have "countable (X `` (\<Union>y\<in>Y. {y}))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. countable (X `` (\<Union>y\<in>Y. {y}))
[PROOF STEP]
unfolding Image_UN
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. countable (\<Union>x\<in>Y. X `` {x})
[PROOF STEP]
by (intro countable_UN assms)
[PROOF STATE]
proof (state)
this:
countable (X `` (\<Union>y\<in>Y. {y}))

goal (1 subgoal):
 1. countable (X `` Y)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
countable (X `` (\<Union>y\<in>Y. {y}))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
countable (X `` (\<Union>y\<in>Y. {y}))

goal (1 subgoal):
 1. countable (X `` Y)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
countable (X `` Y)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma symetric:
  fixes P :: pi
  and   Q :: pi

  assumes "P \<simeq> Q"

  shows "Q \<simeq> P"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Q \<simeq> P
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
P \<simeq> Q

goal (1 subgoal):
 1. Q \<simeq> P
[PROOF STEP]
by(force simp add: substClosed_def congruence_def)


[STATEMENT]
lemma cos_limit_1:
  assumes "(\<lambda>j. cos (\<theta> j)) \<longlonglongrightarrow> 1"
  shows "\<exists>k. (\<lambda>j. \<theta> j - of_int (k j) * (2 * pi)) \<longlonglongrightarrow> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>k. (\<lambda>j. \<theta> j - real_of_int (k j) * (2 * pi)) \<longlonglongrightarrow> 0
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>k. (\<lambda>j. \<theta> j - real_of_int (k j) * (2 * pi)) \<longlonglongrightarrow> 0
[PROOF STEP]
have "\<forall>\<^sub>F j in sequentially. cos (\<theta> j) \<in> {- 1..1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F j in sequentially. cos (\<theta> j) \<in> {- 1..1}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F j in sequentially. cos (\<theta> j) \<in> {- 1..1}

goal (1 subgoal):
 1. \<exists>k. (\<lambda>j. \<theta> j - real_of_int (k j) * (2 * pi)) \<longlonglongrightarrow> 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>\<^sub>F j in sequentially. cos (\<theta> j) \<in> {- 1..1}
[PROOF STEP]
have "(\<lambda>j. arccos (cos (\<theta> j))) \<longlonglongrightarrow> arccos 1"
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F j in sequentially. cos (\<theta> j) \<in> {- 1..1}

goal (1 subgoal):
 1. (\<lambda>j. arccos (cos (\<theta> j))) \<longlonglongrightarrow> arccos 1
[PROOF STEP]
using continuous_on_tendsto_compose [OF continuous_on_arccos' assms]
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F j in sequentially. cos (\<theta> j) \<in> {- 1..1}
\<lbrakk>1 \<in> {- 1..1}; \<forall>\<^sub>F x in sequentially. cos (\<theta> x) \<in> {- 1..1}\<rbrakk> \<Longrightarrow> (\<lambda>x. arccos (cos (\<theta> x))) \<longlonglongrightarrow> arccos 1

goal (1 subgoal):
 1. (\<lambda>j. arccos (cos (\<theta> j))) \<longlonglongrightarrow> arccos 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>j. arccos (cos (\<theta> j))) \<longlonglongrightarrow> arccos 1

goal (1 subgoal):
 1. \<exists>k. (\<lambda>j. \<theta> j - real_of_int (k j) * (2 * pi)) \<longlonglongrightarrow> 0
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<lambda>j. arccos (cos (\<theta> j))) \<longlonglongrightarrow> arccos 1

goal (1 subgoal):
 1. \<exists>k. (\<lambda>j. \<theta> j - real_of_int (k j) * (2 * pi)) \<longlonglongrightarrow> 0
[PROOF STEP]
have "\<And>j. \<exists>k. arccos (cos (\<theta> j)) = \<bar>\<theta> j - of_int k * (2 * pi)\<bar>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>j. \<exists>k. arccos (cos (\<theta> j)) = \<bar>\<theta> j - real_of_int k * (2 * pi)\<bar>
[PROOF STEP]
using arccos_cos_eq_abs_2pi
[PROOF STATE]
proof (prove)
using this:
(\<And>k. arccos (cos ?\<theta>) = \<bar>?\<theta> - real_of_int k * (2 * pi)\<bar> \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. \<And>j. \<exists>k. arccos (cos (\<theta> j)) = \<bar>\<theta> j - real_of_int k * (2 * pi)\<bar>
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
\<exists>k. arccos (cos (\<theta> ?j)) = \<bar>\<theta> ?j - real_of_int k * (2 * pi)\<bar>

goal (1 subgoal):
 1. \<exists>k. (\<lambda>j. \<theta> j - real_of_int (k j) * (2 * pi)) \<longlonglongrightarrow> 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>k. arccos (cos (\<theta> ?j)) = \<bar>\<theta> ?j - real_of_int k * (2 * pi)\<bar>
[PROOF STEP]
have "\<exists>k. \<forall>j. arccos (cos (\<theta> j)) = \<bar>\<theta> j - of_int (k j) * (2 * pi)\<bar>"
[PROOF STATE]
proof (prove)
using this:
\<exists>k. arccos (cos (\<theta> ?j)) = \<bar>\<theta> ?j - real_of_int k * (2 * pi)\<bar>

goal (1 subgoal):
 1. \<exists>k. \<forall>j. arccos (cos (\<theta> j)) = \<bar>\<theta> j - real_of_int (k j) * (2 * pi)\<bar>
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
\<exists>k. \<forall>j. arccos (cos (\<theta> j)) = \<bar>\<theta> j - real_of_int (k j) * (2 * pi)\<bar>

goal (1 subgoal):
 1. \<exists>k. (\<lambda>j. \<theta> j - real_of_int (k j) * (2 * pi)) \<longlonglongrightarrow> 0
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>j. arccos (cos (\<theta> j))) \<longlonglongrightarrow> arccos 1
\<exists>k. \<forall>j. arccos (cos (\<theta> j)) = \<bar>\<theta> j - real_of_int (k j) * (2 * pi)\<bar>
[PROOF STEP]
have "\<exists>k. (\<lambda>j. \<bar>\<theta> j - of_int (k j) * (2 * pi)\<bar>) \<longlonglongrightarrow> 0"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>j. arccos (cos (\<theta> j))) \<longlonglongrightarrow> arccos 1
\<exists>k. \<forall>j. arccos (cos (\<theta> j)) = \<bar>\<theta> j - real_of_int (k j) * (2 * pi)\<bar>

goal (1 subgoal):
 1. \<exists>k. (\<lambda>j. \<bar>\<theta> j - real_of_int (k j) * (2 * pi)\<bar>) \<longlonglongrightarrow> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>k. (\<lambda>j. \<bar>\<theta> j - real_of_int (k j) * (2 * pi)\<bar>) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. \<exists>k. (\<lambda>j. \<theta> j - real_of_int (k j) * (2 * pi)) \<longlonglongrightarrow> 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>k. (\<lambda>j. \<bar>\<theta> j - real_of_int (k j) * (2 * pi)\<bar>) \<longlonglongrightarrow> 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<exists>k. (\<lambda>j. \<bar>\<theta> j - real_of_int (k j) * (2 * pi)\<bar>) \<longlonglongrightarrow> 0

goal (1 subgoal):
 1. \<exists>k. (\<lambda>j. \<theta> j - real_of_int (k j) * (2 * pi)) \<longlonglongrightarrow> 0
[PROOF STEP]
by (simp add: tendsto_rabs_zero_iff)
[PROOF STATE]
proof (state)
this:
\<exists>k. (\<lambda>j. \<theta> j - real_of_int (k j) * (2 * pi)) \<longlonglongrightarrow> 0

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma poly_at_top_or_bot_at_bot:
  fixes p :: "real poly"
  assumes "degree p \<ge> 1" "coeff p (degree p) > 0"
  shows "LIM x at_bot. poly p x :> (if even (degree p) then at_top else at_bot)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. filterlim (poly p) (if even (degree p) then at_top else at_bot) at_bot
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. filterlim (poly p) (if even (degree p) then at_top else at_bot) at_bot
[PROOF STEP]
let ?n = "degree p"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. filterlim (poly p) (if even (degree p) then at_top else at_bot) at_bot
[PROOF STEP]
define f g where "f x = poly p x / x ^ ?n" and "g x = x ^ ?n" for x :: real
[PROOF STATE]
proof (state)
this:
f ?x = poly p ?x / ?x ^ degree p
g ?x = ?x ^ degree p

goal (1 subgoal):
 1. filterlim (poly p) (if even (degree p) then at_top else at_bot) at_bot
[PROOF STEP]
from poly_limit_aux
[PROOF STATE]
proof (chain)
picking this:
((\<lambda>x. poly ?p x / x ^ degree ?p) \<longlongrightarrow> lead_coeff ?p) at_infinity
[PROOF STEP]
have "(f \<longlongrightarrow> coeff p (degree p)) at_bot"
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. poly ?p x / x ^ degree ?p) \<longlongrightarrow> lead_coeff ?p) at_infinity

goal (1 subgoal):
 1. (f \<longlongrightarrow> lead_coeff p) at_bot
[PROOF STEP]
using tendsto_mono at_bot_le_at_infinity
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. poly ?p x / x ^ degree ?p) \<longlongrightarrow> lead_coeff ?p) at_infinity
\<lbrakk>?F \<le> ?F'; (?f \<longlongrightarrow> ?l) ?F'\<rbrakk> \<Longrightarrow> (?f \<longlongrightarrow> ?l) ?F
at_bot \<le> at_infinity

goal (1 subgoal):
 1. (f \<longlongrightarrow> lead_coeff p) at_bot
[PROOF STEP]
by (force simp: f_def [abs_def])
[PROOF STATE]
proof (state)
this:
(f \<longlongrightarrow> lead_coeff p) at_bot

goal (1 subgoal):
 1. filterlim (poly p) (if even (degree p) then at_top else at_bot) at_bot
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(f \<longlongrightarrow> lead_coeff p) at_bot

goal (1 subgoal):
 1. filterlim (poly p) (if even (degree p) then at_top else at_bot) at_bot
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
1 \<le> degree p
0 < lead_coeff p
[PROOF STEP]
have "LIM x at_bot. g x :> (if even (degree p) then at_top else at_bot)"
[PROOF STATE]
proof (prove)
using this:
1 \<le> degree p
0 < lead_coeff p

goal (1 subgoal):
 1. filterlim g (if even (degree p) then at_top else at_bot) at_bot
[PROOF STEP]
by (auto simp add: g_def split: if_split_asm intro: filterlim_pow_at_bot_even filterlim_pow_at_bot_odd filterlim_ident)
[PROOF STATE]
proof (state)
this:
filterlim g (if even (degree p) then at_top else at_bot) at_bot

goal (1 subgoal):
 1. filterlim (poly p) (if even (degree p) then at_top else at_bot) at_bot
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(f \<longlongrightarrow> lead_coeff p) at_bot
filterlim g (if even (degree p) then at_top else at_bot) at_bot
[PROOF STEP]
have "LIM x at_bot. f x * g x :>
                      (if even ?n then at_top else at_bot)"
[PROOF STATE]
proof (prove)
using this:
(f \<longlongrightarrow> lead_coeff p) at_bot
filterlim g (if even (degree p) then at_top else at_bot) at_bot

goal (1 subgoal):
 1. LIM x at_bot. f x * g x :> if even (degree p) then at_top else at_bot
[PROOF STEP]
by (auto simp: assms intro: filterlim_tendsto_pos_mult_at_top
                                  filterlim_tendsto_pos_mult_at_bot)
[PROOF STATE]
proof (state)
this:
LIM x at_bot. f x * g x :> if even (degree p) then at_top else at_bot

goal (1 subgoal):
 1. filterlim (poly p) (if even (degree p) then at_top else at_bot) at_bot
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
LIM x at_bot. f x * g x :> if even (degree p) then at_top else at_bot

goal (1 subgoal):
 1. filterlim (poly p) (if even (degree p) then at_top else at_bot) at_bot
[PROOF STEP]
have "eventually (\<lambda>x. f x * g x = poly p x) at_bot"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_bot. f x * g x = poly p x
[PROOF STEP]
unfolding f_def g_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_bot. poly p x / x ^ degree p * x ^ degree p = poly p x
[PROOF STEP]
by (subst eventually_at_bot_linorder, rule exI[of _ "-1"],
          simp add: poly_altdef field_simps sum_distrib_left power_diff)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in at_bot. f x * g x = poly p x

goal (1 subgoal):
 1. filterlim (poly p) (if even (degree p) then at_top else at_bot) at_bot
[PROOF STEP]
note filterlim_cong[OF refl refl this]
[PROOF STATE]
proof (state)
this:
(LIM x at_bot. f x * g x :> ?F1.0) = filterlim (poly p) ?F1.0 at_bot

goal (1 subgoal):
 1. filterlim (poly p) (if even (degree p) then at_top else at_bot) at_bot
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
filterlim (poly p) (if even (degree p) then at_top else at_bot) at_bot
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
filterlim (poly p) (if even (degree p) then at_top else at_bot) at_bot

goal (1 subgoal):
 1. filterlim (poly p) (if even (degree p) then at_top else at_bot) at_bot
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
filterlim (poly p) (if even (degree p) then at_top else at_bot) at_bot

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma rtrancl_len_E [elim]:
  assumes "(x, y) \<in> r\<^sup>*" obtains n where "(x, y) \<in> r^^n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>n. (x, y) \<in> r ^^ n \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using rtrancl_imp_UN_relpow [OF assms]
[PROOF STATE]
proof (prove)
using this:
(x, y) \<in> \<Union> (range ((^^) r))

goal (1 subgoal):
 1. (\<And>n. (x, y) \<in> r ^^ n \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by best


[STATEMENT]
lemma eventually_deriv_add:
  assumes "f twice_field_differentiable_at x"
      and "g twice_field_differentiable_at x"
    shows "\<forall>\<^sub>F x in nhds x. deriv (\<lambda>x. f x + g x) x = deriv f x + deriv g x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in nhds x. deriv (\<lambda>x. f x + g x) x = deriv f x + deriv g x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in nhds x. deriv (\<lambda>x. f x + g x) x = deriv f x + deriv g x
[PROOF STEP]
obtain S where Df_on_S: "f field_differentiable_on S" and x_int_S: "x \<in> interior S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>S. \<lbrakk>f field_differentiable_on S; x \<in> interior S\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms twice_field_differentiable_at_def
[PROOF STATE]
proof (prove)
using this:
f twice_field_differentiable_at x
g twice_field_differentiable_at x
?f twice_field_differentiable_at ?x \<equiv> \<exists>S. ?f field_differentiable_on S \<and> ?x \<in> interior S \<and> deriv ?f field_differentiable at ?x

goal (1 subgoal):
 1. (\<And>S. \<lbrakk>f field_differentiable_on S; x \<in> interior S\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
f field_differentiable_on S
x \<in> interior S

goal (1 subgoal):
 1. \<forall>\<^sub>F x in nhds x. deriv (\<lambda>x. f x + g x) x = deriv f x + deriv g x
[PROOF STEP]
obtain S' where Dg_on_S: "g field_differentiable_on S'" and x_int_S': "x \<in> interior S'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>S'. \<lbrakk>g field_differentiable_on S'; x \<in> interior S'\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms twice_field_differentiable_at_def
[PROOF STATE]
proof (prove)
using this:
f twice_field_differentiable_at x
g twice_field_differentiable_at x
?f twice_field_differentiable_at ?x \<equiv> \<exists>S. ?f field_differentiable_on S \<and> ?x \<in> interior S \<and> deriv ?f field_differentiable at ?x

goal (1 subgoal):
 1. (\<And>S'. \<lbrakk>g field_differentiable_on S'; x \<in> interior S'\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
g field_differentiable_on S'
x \<in> interior S'

goal (1 subgoal):
 1. \<forall>\<^sub>F x in nhds x. deriv (\<lambda>x. f x + g x) x = deriv f x + deriv g x
[PROOF STEP]
have "x \<in> interior (S \<inter> S')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> interior (S \<inter> S')
[PROOF STEP]
by (simp add: x_int_S x_int_S')
[PROOF STATE]
proof (state)
this:
x \<in> interior (S \<inter> S')

goal (1 subgoal):
 1. \<forall>\<^sub>F x in nhds x. deriv (\<lambda>x. f x + g x) x = deriv f x + deriv g x
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
x \<in> interior (S \<inter> S')

goal (1 subgoal):
 1. \<forall>\<^sub>F x in nhds x. deriv (\<lambda>x. f x + g x) x = deriv f x + deriv g x
[PROOF STEP]
have Df_on_SS': "f field_differentiable_on (S \<inter> S')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f field_differentiable_on S \<inter> S'
[PROOF STEP]
by (meson Df_on_S IntD1 field_differentiable_on_def field_differentiable_within_subset inf_sup_ord(1))
[PROOF STATE]
proof (state)
this:
f field_differentiable_on S \<inter> S'

goal (1 subgoal):
 1. \<forall>\<^sub>F x in nhds x. deriv (\<lambda>x. f x + g x) x = deriv f x + deriv g x
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
f field_differentiable_on S \<inter> S'

goal (1 subgoal):
 1. \<forall>\<^sub>F x in nhds x. deriv (\<lambda>x. f x + g x) x = deriv f x + deriv g x
[PROOF STEP]
have Dg_on_SS': "g field_differentiable_on (S \<inter> S')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g field_differentiable_on S \<inter> S'
[PROOF STEP]
by (meson Dg_on_S IntD2 field_differentiable_on_def field_differentiable_within_subset inf_le2)
[PROOF STATE]
proof (state)
this:
g field_differentiable_on S \<inter> S'

goal (1 subgoal):
 1. \<forall>\<^sub>F x in nhds x. deriv (\<lambda>x. f x + g x) x = deriv f x + deriv g x
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
g field_differentiable_on S \<inter> S'

goal (1 subgoal):
 1. \<forall>\<^sub>F x in nhds x. deriv (\<lambda>x. f x + g x) x = deriv f x + deriv g x
[PROOF STEP]
have "open (interior (S \<inter> S'))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. open (interior (S \<inter> S'))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
open (interior (S \<inter> S'))

goal (1 subgoal):
 1. \<forall>\<^sub>F x in nhds x. deriv (\<lambda>x. f x + g x) x = deriv f x + deriv g x
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
open (interior (S \<inter> S'))

goal (1 subgoal):
 1. \<forall>\<^sub>F x in nhds x. deriv (\<lambda>x. f x + g x) x = deriv f x + deriv g x
[PROOF STEP]
have "\<forall>x\<in> interior (S \<inter> S'). deriv (\<lambda>x. f x + g x) x = deriv f x + deriv g x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>interior (S \<inter> S'). deriv (\<lambda>x. f x + g x) x = deriv f x + deriv g x
[PROOF STEP]
by (metis (full_types) Df_on_SS' Dg_on_SS' at_within_interior deriv_add field_differentiable_on_def in_mono interior_subset)
[PROOF STATE]
proof (state)
this:
\<forall>x\<in>interior (S \<inter> S'). deriv (\<lambda>x. f x + g x) x = deriv f x + deriv g x

goal (1 subgoal):
 1. \<forall>\<^sub>F x in nhds x. deriv (\<lambda>x. f x + g x) x = deriv f x + deriv g x
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
x \<in> interior (S \<inter> S')
f field_differentiable_on S \<inter> S'
g field_differentiable_on S \<inter> S'
open (interior (S \<inter> S'))
\<forall>x\<in>interior (S \<inter> S'). deriv (\<lambda>x. f x + g x) x = deriv f x + deriv g x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
x \<in> interior (S \<inter> S')
f field_differentiable_on S \<inter> S'
g field_differentiable_on S \<inter> S'
open (interior (S \<inter> S'))
\<forall>x\<in>interior (S \<inter> S'). deriv (\<lambda>x. f x + g x) x = deriv f x + deriv g x

goal (1 subgoal):
 1. \<forall>\<^sub>F x in nhds x. deriv (\<lambda>x. f x + g x) x = deriv f x + deriv g x
[PROOF STEP]
using eventually_nhds
[PROOF STATE]
proof (prove)
using this:
x \<in> interior (S \<inter> S')
f field_differentiable_on S \<inter> S'
g field_differentiable_on S \<inter> S'
open (interior (S \<inter> S'))
\<forall>x\<in>interior (S \<inter> S'). deriv (\<lambda>x. f x + g x) x = deriv f x + deriv g x
eventually ?P (nhds ?a) = (\<exists>S. open S \<and> ?a \<in> S \<and> (\<forall>x\<in>S. ?P x))

goal (1 subgoal):
 1. \<forall>\<^sub>F x in nhds x. deriv (\<lambda>x. f x + g x) x = deriv f x + deriv g x
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in nhds x. deriv (\<lambda>x. f x + g x) x = deriv f x + deriv g x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma enum_0_eq_Inf:
  fixes N :: "nat set"
  assumes "infinite N"
  shows "enum N 0 = Inf N"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. enum N 0 = \<Sqinter> N
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. enum N 0 = \<Sqinter> N
[PROOF STEP]
have "enum N 0 \<in> N"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. enum N 0 \<in> N
[PROOF STEP]
using assms range_enum
[PROOF STATE]
proof (prove)
using this:
infinite N
infinite ?N \<Longrightarrow> range (enum ?N) = ?N

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

goal (1 subgoal):
 1. enum N 0 = \<Sqinter> N
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
enum N 0 \<in> N

goal (1 subgoal):
 1. enum N 0 = \<Sqinter> N
[PROOF STEP]
have "\<And>x. x \<in> N \<Longrightarrow> enum N 0 \<le> x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> N \<Longrightarrow> enum N 0 \<le> x
[PROOF STEP]
by (metis (mono_tags, opaque_lifting) assms imageE le0 less_mono_imp_le_mono range_enum strict_monoD strict_mono_enum)
[PROOF STATE]
proof (state)
this:
?x \<in> N \<Longrightarrow> enum N 0 \<le> ?x

goal (1 subgoal):
 1. enum N 0 = \<Sqinter> N
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
enum N 0 \<in> N
?x \<in> N \<Longrightarrow> enum N 0 \<le> ?x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
enum N 0 \<in> N
?x \<in> N \<Longrightarrow> enum N 0 \<le> ?x

goal (1 subgoal):
 1. enum N 0 = \<Sqinter> N
[PROOF STEP]
by (metis cInf_eq_minimum)
[PROOF STATE]
proof (state)
this:
enum N 0 = \<Sqinter> N

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma scene_override_union: "X ##\<^sub>S Y \<Longrightarrow> S\<^sub>1 \<oplus>\<^sub>S S\<^sub>2 on (X \<squnion>\<^sub>S Y) = (S\<^sub>1 \<oplus>\<^sub>S S\<^sub>2 on X) \<oplus>\<^sub>S S\<^sub>2 on Y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. X ##\<^sub>S Y \<Longrightarrow> S\<^sub>1 \<oplus>\<^sub>S S\<^sub>2 on (X \<squnion>\<^sub>S Y) = S\<^sub>1 \<oplus>\<^sub>S S\<^sub>2 on X \<oplus>\<^sub>S S\<^sub>2 on Y
[PROOF STEP]
by (transfer, auto)


[STATEMENT]
lemma (in Ring) bilinear_r_lin1:"\<lbrakk>R module M1; R module M2; R module N;
      m1 \<in> carrier M1; m2 \<in> carrier M2; r \<in> carrier R;
      bilinear_map f R M1 M2 N\<rbrakk> \<Longrightarrow>
      f (m1, r \<cdot>\<^sub>s\<^bsub>M2\<^esub> m2)  \<plusminus>\<^bsub>N\<^esub> -\<^sub>a\<^bsub>N\<^esub> (r \<cdot>\<^sub>s\<^bsub>N\<^esub> (f (m1, m2))) = \<zero>\<^bsub>N\<^esub> "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>R module M1; R module M2; R module N; m1 \<in> carrier M1; m2 \<in> carrier M2; r \<in> carrier R; bilinear_map f R M1 M2 N\<rbrakk> \<Longrightarrow> f (m1, r \<cdot>\<^sub>s\<^bsub>M2\<^esub> m2) \<plusminus>\<^bsub>N\<^esub> -\<^sub>a\<^bsub>N\<^esub> r \<cdot>\<^sub>s\<^bsub>N\<^esub> f (m1, m2) = \<zero>\<^bsub>N\<^esub>
[PROOF STEP]
apply (frule Module.module_is_ag[of N],
       subst aGroup.ag_eq_diffzero[of N, THEN sym], assumption+,
       frule_tac a = r and m = m2 in Module.sc_mem[of M2 R], assumption+,
       simp add:bilinear_mem)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>R module M1; R module M2; R module N; m1 \<in> carrier M1; m2 \<in> carrier M2; r \<in> carrier R; bilinear_map f R M1 M2 N; aGroup N\<rbrakk> \<Longrightarrow> r \<cdot>\<^sub>s\<^bsub>N\<^esub> f (m1, m2) \<in> carrier N
 2. \<lbrakk>R module M1; R module M2; R module N; m1 \<in> carrier M1; m2 \<in> carrier M2; r \<in> carrier R; bilinear_map f R M1 M2 N; aGroup N\<rbrakk> \<Longrightarrow> f (m1, r \<cdot>\<^sub>s\<^bsub>M2\<^esub> m2) = r \<cdot>\<^sub>s\<^bsub>N\<^esub> f (m1, m2)
[PROOF STEP]
apply (rule Module.sc_mem, assumption+, simp add:bilinear_mem,
        simp add:bilinear_r_lin)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma prod_dhs_ga[autoref_ga_rules]:
  "\<lbrakk> GEN_ALGO_tag (is_valid_def_hm_size TYPE('a) n1);
     GEN_ALGO_tag (is_valid_def_hm_size TYPE('b) n2) \<rbrakk>
   \<Longrightarrow> is_valid_def_hm_size TYPE('a*'b) (n1+n2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>GEN_ALGO_tag (is_valid_def_hm_size TYPE('a) n1); GEN_ALGO_tag (is_valid_def_hm_size TYPE('b) n2)\<rbrakk> \<Longrightarrow> is_valid_def_hm_size TYPE('a \<times> 'b) (n1 + n2)
[PROOF STEP]
unfolding is_valid_def_hm_size_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>GEN_ALGO_tag (1 < n1); GEN_ALGO_tag (1 < n2)\<rbrakk> \<Longrightarrow> 1 < n1 + n2
[PROOF STEP]
by auto


[STATEMENT]
theorem or_intro1: "\<not> (P \<or> Q) \<Longrightarrow> \<not> P"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> (P \<or> Q) \<Longrightarrow> \<not> P
[PROOF STEP]
by simp


[STATEMENT]
lemma (in auto_ll_on_open) f_tendsto[tendsto_intros]:
  assumes g1: "(g1 \<longlongrightarrow> b1) (at s within S)" and "b1 \<in> X"
  shows "((\<lambda>x. f (g1 x)) \<longlongrightarrow> f b1) (at s within S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. f (g1 x)) \<longlongrightarrow> f b1) (at s within S)
[PROOF STEP]
apply (rule continuous_on_tendsto_compose[OF continuous tendsto_Pair[OF tendsto_const],
      unfolded split_beta fst_conv snd_conv, OF g1])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. (?a1, b1) \<in> UNIV \<times> X
 2. \<forall>\<^sub>F x in at s within S. (?a1, g1 x) \<in> UNIV \<times> X
[PROOF STEP]
by (auto simp: \<open>b1 \<in> X\<close> intro!: topological_tendstoD[OF g1])


[STATEMENT]
theorem constr_fp_uniq:
  assumes "constr F E" "mono F" "\<Sqinter> (range E) = C"
  shows "(C \<and> \<mu> F) = (C \<and> \<nu> F)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (C \<and> \<mu> F) = (C \<and> \<nu> F)
[PROOF STEP]
using assms(1) assms(2) assms(3) chain_pred_terminates
[PROOF STATE]
proof (prove)
using this:
constr F E
Monotonic F
\<Or>range E = C
\<lbrakk>constr ?F ?E; Monotonic ?F\<rbrakk> \<Longrightarrow> (\<Or>range ?E \<and> \<mu> ?F) = (\<Or>range ?E \<and> \<nu> ?F)

goal (1 subgoal):
 1. (C \<and> \<mu> F) = (C \<and> \<nu> F)
[PROOF STEP]
by blast


[STATEMENT]
lemma open_PiE [intro?]:
  fixes X::"'i \<Rightarrow> ('b::topological_space) set"
  assumes "\<And>i. open (X i)" "finite {i. X i \<noteq> UNIV}"
  shows "open (Pi\<^sub>E UNIV X)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. open (Pi\<^sub>E UNIV X)
[PROOF STEP]
by (simp add: assms open_fun_def product_topology_basis)


[STATEMENT]
lemma (in Ring) nsMulDistrL:"\<lbrakk> x \<in> carrier R; y \<in> carrier R \<rbrakk>
        \<Longrightarrow> x \<cdot>\<^sub>r (nscal R y n) = nscal R (x \<cdot>\<^sub>r y) n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x \<in> carrier R; y \<in> carrier R\<rbrakk> \<Longrightarrow> x \<cdot>\<^sub>r  n \<times>\<^bsub>R\<^esub> y =  n \<times>\<^bsub>R\<^esub> (x \<cdot>\<^sub>r y)
[PROOF STEP]
apply (induct_tac n)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>x \<in> carrier R; y \<in> carrier R\<rbrakk> \<Longrightarrow> x \<cdot>\<^sub>r  0 \<times>\<^bsub>R\<^esub> y =  0 \<times>\<^bsub>R\<^esub> (x \<cdot>\<^sub>r y)
 2. \<And>n. \<lbrakk>x \<in> carrier R; y \<in> carrier R; x \<cdot>\<^sub>r  n \<times>\<^bsub>R\<^esub> y =  n \<times>\<^bsub>R\<^esub> (x \<cdot>\<^sub>r y)\<rbrakk> \<Longrightarrow> x \<cdot>\<^sub>r  Suc n \<times>\<^bsub>R\<^esub> y =  Suc n \<times>\<^bsub>R\<^esub> (x \<cdot>\<^sub>r y)
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>x \<in> carrier R; y \<in> carrier R\<rbrakk> \<Longrightarrow> x \<cdot>\<^sub>r \<zero> = \<zero>
 2. \<And>n. \<lbrakk>x \<in> carrier R; y \<in> carrier R; x \<cdot>\<^sub>r  n \<times>\<^bsub>R\<^esub> y =  n \<times>\<^bsub>R\<^esub> (x \<cdot>\<^sub>r y)\<rbrakk> \<Longrightarrow> x \<cdot>\<^sub>r  Suc n \<times>\<^bsub>R\<^esub> y =  Suc n \<times>\<^bsub>R\<^esub> (x \<cdot>\<^sub>r y)
[PROOF STEP]
apply (simp add:ring_times_x_0)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>x \<in> carrier R; y \<in> carrier R; x \<cdot>\<^sub>r  n \<times>\<^bsub>R\<^esub> y =  n \<times>\<^bsub>R\<^esub> (x \<cdot>\<^sub>r y)\<rbrakk> \<Longrightarrow> x \<cdot>\<^sub>r  Suc n \<times>\<^bsub>R\<^esub> y =  Suc n \<times>\<^bsub>R\<^esub> (x \<cdot>\<^sub>r y)
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>x \<in> carrier R; y \<in> carrier R; x \<cdot>\<^sub>r  n \<times>\<^bsub>R\<^esub> y =  n \<times>\<^bsub>R\<^esub> (x \<cdot>\<^sub>r y)\<rbrakk> \<Longrightarrow> x \<cdot>\<^sub>r ( n \<times>\<^bsub>R\<^esub> y \<plusminus> y) =  n \<times>\<^bsub>R\<^esub> (x \<cdot>\<^sub>r y) \<plusminus> x \<cdot>\<^sub>r y
[PROOF STEP]
apply (subst ring_distrib1, assumption+)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>n. \<lbrakk>x \<in> carrier R; y \<in> carrier R; x \<cdot>\<^sub>r  n \<times>\<^bsub>R\<^esub> y =  n \<times>\<^bsub>R\<^esub> (x \<cdot>\<^sub>r y)\<rbrakk> \<Longrightarrow>  n \<times>\<^bsub>R\<^esub> y \<in> carrier R
 2. \<And>n. \<lbrakk>x \<in> carrier R; y \<in> carrier R; x \<cdot>\<^sub>r  n \<times>\<^bsub>R\<^esub> y =  n \<times>\<^bsub>R\<^esub> (x \<cdot>\<^sub>r y)\<rbrakk> \<Longrightarrow> y \<in> carrier R
 3. \<And>n. \<lbrakk>x \<in> carrier R; y \<in> carrier R; x \<cdot>\<^sub>r  n \<times>\<^bsub>R\<^esub> y =  n \<times>\<^bsub>R\<^esub> (x \<cdot>\<^sub>r y)\<rbrakk> \<Longrightarrow> x \<cdot>\<^sub>r  n \<times>\<^bsub>R\<^esub> y \<plusminus> x \<cdot>\<^sub>r y =  n \<times>\<^bsub>R\<^esub> (x \<cdot>\<^sub>r y) \<plusminus> x \<cdot>\<^sub>r y
[PROOF STEP]
apply (rule nsClose, assumption+)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>x \<in> carrier R; y \<in> carrier R; x \<cdot>\<^sub>r  n \<times>\<^bsub>R\<^esub> y =  n \<times>\<^bsub>R\<^esub> (x \<cdot>\<^sub>r y)\<rbrakk> \<Longrightarrow> x \<cdot>\<^sub>r  n \<times>\<^bsub>R\<^esub> y \<plusminus> x \<cdot>\<^sub>r y =  n \<times>\<^bsub>R\<^esub> (x \<cdot>\<^sub>r y) \<plusminus> x \<cdot>\<^sub>r y
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma corthogonal_inv:
  assumes orth: "corthogonal (vs ::'a::conjugatable_field vec list)"
      and V: "set vs \<subseteq> carrier_vec n"
  shows "inverts_mat (mat_of_rows n (map vec_inv vs)) (mat_of_cols n vs)"
    (is "inverts_mat ?W ?V")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inverts_mat (mat_of_rows n (map vec_inv vs)) (mat_of_cols n vs)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. inverts_mat (mat_of_rows n (map vec_inv vs)) (mat_of_cols n vs)
[PROOF STEP]
define l where "l = length vs"
[PROOF STATE]
proof (state)
this:
l = length vs

goal (1 subgoal):
 1. inverts_mat (mat_of_rows n (map vec_inv vs)) (mat_of_cols n vs)
[PROOF STEP]
have rW[simp]: "dim_row ?W = l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row (mat_of_rows n (map vec_inv vs)) = l
[PROOF STEP]
using l_def
[PROOF STATE]
proof (prove)
using this:
l = length vs

goal (1 subgoal):
 1. dim_row (mat_of_rows n (map vec_inv vs)) = l
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
dim_row (mat_of_rows n (map vec_inv vs)) = l

goal (1 subgoal):
 1. inverts_mat (mat_of_rows n (map vec_inv vs)) (mat_of_cols n vs)
[PROOF STEP]
have cV[simp]:"dim_col ?V = l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_col (mat_of_cols n vs) = l
[PROOF STEP]
using l_def
[PROOF STATE]
proof (prove)
using this:
l = length vs

goal (1 subgoal):
 1. dim_col (mat_of_cols n vs) = l
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
dim_col (mat_of_cols n vs) = l

goal (1 subgoal):
 1. inverts_mat (mat_of_rows n (map vec_inv vs)) (mat_of_cols n vs)
[PROOF STEP]
have dim: "\<And>i. i < length vs \<Longrightarrow> vs!i \<in> carrier_vec n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i < length vs \<Longrightarrow> vs ! i \<in> carrier_vec n
[PROOF STEP]
using V
[PROOF STATE]
proof (prove)
using this:
set vs \<subseteq> carrier_vec n

goal (1 subgoal):
 1. \<And>i. i < length vs \<Longrightarrow> vs ! i \<in> carrier_vec n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?i < length vs \<Longrightarrow> vs ! ?i \<in> carrier_vec n

goal (1 subgoal):
 1. inverts_mat (mat_of_rows n (map vec_inv vs)) (mat_of_cols n vs)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inverts_mat (mat_of_rows n (map vec_inv vs)) (mat_of_cols n vs)
[PROOF STEP]
unfolding inverts_mat_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_of_rows n (map vec_inv vs) * mat_of_cols n vs = 1\<^sub>m (dim_row (mat_of_rows n (map vec_inv vs)))
[PROOF STEP]
apply rule
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row (1\<^sub>m (dim_row (mat_of_rows n (map vec_inv vs)))); j < dim_col (1\<^sub>m (dim_row (mat_of_rows n (map vec_inv vs))))\<rbrakk> \<Longrightarrow> (mat_of_rows n (map vec_inv vs) * mat_of_cols n vs) $$ (i, j) = 1\<^sub>m (dim_row (mat_of_rows n (map vec_inv vs))) $$ (i, j)
 2. dim_row (mat_of_rows n (map vec_inv vs) * mat_of_cols n vs) = dim_row (1\<^sub>m (dim_row (mat_of_rows n (map vec_inv vs))))
 3. dim_col (mat_of_rows n (map vec_inv vs) * mat_of_cols n vs) = dim_col (1\<^sub>m (dim_row (mat_of_rows n (map vec_inv vs))))
[PROOF STEP]
unfolding mat_of_rows_carrier length_map l_def[symmetric]
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row (1\<^sub>m l); j < dim_col (1\<^sub>m l)\<rbrakk> \<Longrightarrow> (mat_of_rows n (map vec_inv vs) * mat_of_cols n vs) $$ (i, j) = 1\<^sub>m l $$ (i, j)
 2. dim_row (mat_of_rows n (map vec_inv vs) * mat_of_cols n vs) = dim_row (1\<^sub>m l)
 3. dim_col (mat_of_rows n (map vec_inv vs) * mat_of_cols n vs) = dim_col (1\<^sub>m l)
[PROOF STEP]
unfolding index_one_mat
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < l; j < l\<rbrakk> \<Longrightarrow> (mat_of_rows n (map vec_inv vs) * mat_of_cols n vs) $$ (i, j) = (if i = j then 1::'a else (0::'a))
 2. dim_row (mat_of_rows n (map vec_inv vs) * mat_of_cols n vs) = l
 3. dim_col (mat_of_rows n (map vec_inv vs) * mat_of_cols n vs) = l
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < l; j < l\<rbrakk> \<Longrightarrow> (mat_of_rows n (map vec_inv vs) * mat_of_cols n vs) $$ (i, j) = (if i = j then 1::'a else (0::'a))
 2. dim_row (mat_of_rows n (map vec_inv vs) * mat_of_cols n vs) = l
 3. dim_col (mat_of_rows n (map vec_inv vs) * mat_of_cols n vs) = l
[PROOF STEP]
show "dim_row (?W * ?V) = l" "dim_col (?W * ?V) = l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row (mat_of_rows n (map vec_inv vs) * mat_of_cols n vs) = l &&& dim_col (mat_of_rows n (map vec_inv vs) * mat_of_cols n vs) = l
[PROOF STEP]
unfolding times_mat_def rW cV
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row (mat l l (\<lambda>(i, j). row (mat_of_rows n (map vec_inv vs)) i \<bullet> col (mat_of_cols n vs) j)) = l &&& dim_col (mat l l (\<lambda>(i, j). row (mat_of_rows n (map vec_inv vs)) i \<bullet> col (mat_of_cols n vs) j)) = l
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
dim_row (mat_of_rows n (map vec_inv vs) * mat_of_cols n vs) = l
dim_col (mat_of_rows n (map vec_inv vs) * mat_of_cols n vs) = l

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < l; j < l\<rbrakk> \<Longrightarrow> (mat_of_rows n (map vec_inv vs) * mat_of_cols n vs) $$ (i, j) = (if i = j then 1::'a else (0::'a))
[PROOF STEP]
fix i j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < l; j < l\<rbrakk> \<Longrightarrow> (mat_of_rows n (map vec_inv vs) * mat_of_cols n vs) $$ (i, j) = (if i = j then 1::'a else (0::'a))
[PROOF STEP]
assume i:"i<l" and j: "j<l"
[PROOF STATE]
proof (state)
this:
i < l
j < l

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < l; j < l\<rbrakk> \<Longrightarrow> (mat_of_rows n (map vec_inv vs) * mat_of_cols n vs) $$ (i, j) = (if i = j then 1::'a else (0::'a))
[PROOF STEP]
hence i2: "i<length vs"
      and i3: "i<length (map vec_inv vs)"
      and j2: "j<length vs"
[PROOF STATE]
proof (prove)
using this:
i < l
j < l

goal (1 subgoal):
 1. i < length vs &&& i < length (map vec_inv vs) &&& j < length vs
[PROOF STEP]
using l_def
[PROOF STATE]
proof (prove)
using this:
i < l
j < l
l = length vs

goal (1 subgoal):
 1. i < length vs &&& i < length (map vec_inv vs) &&& j < length vs
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i < length vs
i < length (map vec_inv vs)
j < length vs

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < l; j < l\<rbrakk> \<Longrightarrow> (mat_of_rows n (map vec_inv vs) * mat_of_cols n vs) $$ (i, j) = (if i = j then 1::'a else (0::'a))
[PROOF STEP]
hence id2: "vs ! i \<in> carrier_vec n"
      and id3: "map vec_inv vs ! i \<in> carrier_vec n"
      and id4: "conjugate (vs ! i) \<in> carrier_vec n"
      and jd2: "vs ! j \<in> carrier_vec n"
[PROOF STATE]
proof (prove)
using this:
i < length vs
i < length (map vec_inv vs)
j < length vs

goal (1 subgoal):
 1. (vs ! i \<in> carrier_vec n &&& map vec_inv vs ! i \<in> carrier_vec n) &&& conjugate (vs ! i) \<in> carrier_vec n &&& vs ! j \<in> carrier_vec n
[PROOF STEP]
using dim
[PROOF STATE]
proof (prove)
using this:
i < length vs
i < length (map vec_inv vs)
j < length vs
?i < length vs \<Longrightarrow> vs ! ?i \<in> carrier_vec n

goal (1 subgoal):
 1. (vs ! i \<in> carrier_vec n &&& map vec_inv vs ! i \<in> carrier_vec n) &&& conjugate (vs ! i) \<in> carrier_vec n &&& vs ! j \<in> carrier_vec n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
vs ! i \<in> carrier_vec n
map vec_inv vs ! i \<in> carrier_vec n
conjugate (vs ! i) \<in> carrier_vec n
vs ! j \<in> carrier_vec n

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i < l; j < l\<rbrakk> \<Longrightarrow> (mat_of_rows n (map vec_inv vs) * mat_of_cols n vs) $$ (i, j) = (if i = j then 1::'a else (0::'a))
[PROOF STEP]
show "(?W * ?V) $$ (i,j) = (if i = j then 1 else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (mat_of_rows n (map vec_inv vs) * mat_of_cols n vs) $$ (i, j) = (if i = j then 1::'a else (0::'a))
[PROOF STEP]
unfolding times_mat_def rW cV
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat l l (\<lambda>(i, j). row (mat_of_rows n (map vec_inv vs)) i \<bullet> col (mat_of_cols n vs) j) $$ (i, j) = (if i = j then 1::'a else (0::'a))
[PROOF STEP]
unfolding index_mat[OF i j] split
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. row (mat_of_rows n (map vec_inv vs)) i \<bullet> col (mat_of_cols n vs) j = (if i = j then 1::'a else (0::'a))
[PROOF STEP]
unfolding mat_of_rows_row[OF i3 id3]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map vec_inv vs ! i \<bullet> col (mat_of_cols n vs) j = (if i = j then 1::'a else (0::'a))
[PROOF STEP]
unfolding col_mat_of_cols[OF j2 jd2]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map vec_inv vs ! i \<bullet> vs ! j = (if i = j then 1::'a else (0::'a))
[PROOF STEP]
unfolding nth_map[OF i2]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_inv (vs ! i) \<bullet> vs ! j = (if i = j then 1::'a else (0::'a))
[PROOF STEP]
unfolding vec_inv_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((1::'a) / (vs ! i \<bullet>c vs ! i) \<cdot>\<^sub>v conjugate (vs ! i)) \<bullet> vs ! j = (if i = j then 1::'a else (0::'a))
[PROOF STEP]
unfolding smult_scalar_prod_distrib[OF id4 jd2]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (1::'a) / (vs ! i \<bullet>c vs ! i) * (conjugate (vs ! i) \<bullet> vs ! j) = (if i = j then 1::'a else (0::'a))
[PROOF STEP]
unfolding comm_scalar_prod[OF id4 jd2]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (1::'a) / (vs ! i \<bullet>c vs ! i) * (vs ! j \<bullet>c vs ! i) = (if i = j then 1::'a else (0::'a))
[PROOF STEP]
using corthogonalD[OF orth j2 i2]
[PROOF STATE]
proof (prove)
using this:
(vs ! j \<bullet>c vs ! i = (0::'a)) = (j \<noteq> i)

goal (1 subgoal):
 1. (1::'a) / (vs ! i \<bullet>c vs ! i) * (vs ! j \<bullet>c vs ! i) = (if i = j then 1::'a else (0::'a))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(mat_of_rows n (map vec_inv vs) * mat_of_cols n vs) $$ (i, j) = (if i = j then 1::'a else (0::'a))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
inverts_mat (mat_of_rows n (map vec_inv vs)) (mat_of_cols n vs)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma gcd_mult_div_cancel_right1 [simp]:
  "(a div gcd a b) * gcd a b  = (a::'a::semiring_gcd)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a div gcd a b * gcd a b = a
[PROOF STEP]
by simp


[STATEMENT]
lemma nat_implode_append:
 \<open>nat_implode (a@[b]) = (1*b + foldr (+) (map (\<lambda>(p, y). 10 ^ p * y) (enumerate (Suc 0) (rev a))) 0 )\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nat_implode (a @ [b]) = (1::'a) * b + foldr (+) (map (\<lambda>(p, y). (10::'a) ^ p * y) (enumerate (Suc 0) (rev a))) (0::'a)
[PROOF STEP]
by(simp add:nat_implode_def)


[STATEMENT]
lemma farkas_minkowsky_weyl_theorem:
  "(\<exists> X. X \<subseteq> carrier_vec n \<and> finite X \<and> P = cone X)
  \<longleftrightarrow> (\<exists> A nr. A \<in> carrier_mat nr n \<and> P = polyhedral_cone A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<exists>X\<subseteq>carrier_vec n. finite X \<and> P = cone X) = (\<exists>A nr. A \<in> carrier_mat nr n \<and> P = polyhedral_cone A)
[PROOF STEP]
using farkas_minkowsky_weyl_theorem_1 farkas_minkowsky_weyl_theorem_2
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?X \<subseteq> carrier_vec n; finite ?X\<rbrakk> \<Longrightarrow> \<exists>nr A. A \<in> carrier_mat nr n \<and> cone ?X = polyhedral_cone A \<and> (is_det_bound ?db \<longrightarrow> ?X \<subseteq> \<int>\<^sub>v \<inter> Bounded_vec (of_int ?Bnd) \<longrightarrow> A \<in> \<int>\<^sub>m \<inter> Bounded_mat (of_int (?db (n - 1) (max 1 ?Bnd))))
?A \<in> carrier_mat ?nr n \<Longrightarrow> \<exists>X\<subseteq>carrier_vec n. finite X \<and> polyhedral_cone ?A = cone X \<and> (is_det_bound ?db \<longrightarrow> ?A \<in> \<int>\<^sub>m \<inter> Bounded_mat (of_int ?Bnd) \<longrightarrow> X \<subseteq> \<int>\<^sub>v \<inter> Bounded_vec (of_int (?db (n - 1) (max 1 ?Bnd))))

goal (1 subgoal):
 1. (\<exists>X\<subseteq>carrier_vec n. finite X \<and> P = cone X) = (\<exists>A nr. A \<in> carrier_mat nr n \<and> P = polyhedral_cone A)
[PROOF STEP]
by metis


[STATEMENT]
lemma map_butlast: "map f (butlast xs) = butlast (map f xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map f (butlast xs) = butlast (map f xs)
[PROOF STEP]
by (induct xs) simp_all


[STATEMENT]
lemma Digamma_approx:
  assumes x: "(x :: real) > 0"
  shows   "Digamma x = ln x - 1 / (2 * x) - P x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Digamma x = ln x - 1 / (2 * x) - P x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Digamma x = ln x - 1 / (2 * x) - P x
[PROOF STEP]
have "eventually (\<lambda>n. ln (inverse (1 + x / real n)) + ln x - 1/(2*x) - p n x =
          ln (real n) - S' n x - 1/(2*x)) at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. ln (inverse (1 + x / real n)) + ln x - 1 / (2 * x) - p n x = ln (real n) - S' n x - 1 / (2 * x)
[PROOF STEP]
using eventually_gt_at_top[of "1::nat"]
[PROOF STATE]
proof (prove)
using this:
eventually ((<) 1) sequentially

goal (1 subgoal):
 1. \<forall>\<^sub>F n in sequentially. ln (inverse (1 + x / real n)) + ln x - 1 / (2 * x) - p n x = ln (real n) - S' n x - 1 / (2 * x)
[PROOF STEP]
proof eventually_elim
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. 1 < n \<Longrightarrow> ln (inverse (1 + x / real n)) + ln x - 1 / (2 * x) - p n x = ln (real n) - S' n x - 1 / (2 * x)
[PROOF STEP]
fix n :: nat
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. 1 < n \<Longrightarrow> ln (inverse (1 + x / real n)) + ln x - 1 / (2 * x) - p n x = ln (real n) - S' n x - 1 / (2 * x)
[PROOF STEP]
assume n: "n > 1"
[PROOF STATE]
proof (state)
this:
1 < n

goal (1 subgoal):
 1. \<And>n. 1 < n \<Longrightarrow> ln (inverse (1 + x / real n)) + ln x - 1 / (2 * x) - p n x = ln (real n) - S' n x - 1 / (2 * x)
[PROOF STEP]
have "ln (real n) - S' n x = ln ((real n) / (real n + x)) + ln x - p n x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ln (real n) - S' n x = ln (real n / (real n + x)) + ln x - p n x
[PROOF STEP]
using assms n
[PROOF STATE]
proof (prove)
using this:
0 < x
1 < n

goal (1 subgoal):
 1. ln (real n) - S' n x = ln (real n / (real n + x)) + ln x - p n x
[PROOF STEP]
unfolding S'_approx
[PROOF STATE]
proof (prove)
using this:
0 < x
1 < n

goal (1 subgoal):
 1. ln (real n) - (ln (real n + x) - ln x + p n x) = ln (real n / (real n + x)) + ln x - p n x
[PROOF STEP]
by (subst ln_div) (auto simp: algebra_simps)
[PROOF STATE]
proof (state)
this:
ln (real n) - S' n x = ln (real n / (real n + x)) + ln x - p n x

goal (1 subgoal):
 1. \<And>n. 1 < n \<Longrightarrow> ln (inverse (1 + x / real n)) + ln x - 1 / (2 * x) - p n x = ln (real n) - S' n x - 1 / (2 * x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ln (real n) - S' n x = ln (real n / (real n + x)) + ln x - p n x

goal (1 subgoal):
 1. \<And>n. 1 < n \<Longrightarrow> ln (inverse (1 + x / real n)) + ln x - 1 / (2 * x) - p n x = ln (real n) - S' n x - 1 / (2 * x)
[PROOF STEP]
from n
[PROOF STATE]
proof (chain)
picking this:
1 < n
[PROOF STEP]
have "real n / (real n + x) = inverse (1 + x / real n)"
[PROOF STATE]
proof (prove)
using this:
1 < n

goal (1 subgoal):
 1. real n / (real n + x) = inverse (1 + x / real n)
[PROOF STEP]
by (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
real n / (real n + x) = inverse (1 + x / real n)

goal (1 subgoal):
 1. \<And>n. 1 < n \<Longrightarrow> ln (inverse (1 + x / real n)) + ln x - 1 / (2 * x) - p n x = ln (real n) - S' n x - 1 / (2 * x)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
ln (real n) - S' n x = ln (inverse (1 + x / real n)) + ln x - p n x
[PROOF STEP]
show "ln (inverse (1 + x / real n)) + ln x - 1/(2*x) - p n x =
                    ln (real n) - S' n x - 1/(2*x)"
[PROOF STATE]
proof (prove)
using this:
ln (real n) - S' n x = ln (inverse (1 + x / real n)) + ln x - p n x

goal (1 subgoal):
 1. ln (inverse (1 + x / real n)) + ln x - 1 / (2 * x) - p n x = ln (real n) - S' n x - 1 / (2 * x)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
ln (inverse (1 + x / real n)) + ln x - 1 / (2 * x) - p n x = ln (real n) - S' n x - 1 / (2 * x)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F n in sequentially. ln (inverse (1 + x / real n)) + ln x - 1 / (2 * x) - p n x = ln (real n) - S' n x - 1 / (2 * x)

goal (1 subgoal):
 1. Digamma x = ln x - 1 / (2 * x) - P x
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F n in sequentially. ln (inverse (1 + x / real n)) + ln x - 1 / (2 * x) - p n x = ln (real n) - S' n x - 1 / (2 * x)

goal (1 subgoal):
 1. Digamma x = ln x - 1 / (2 * x) - P x
[PROOF STEP]
have "(\<lambda>n. ln (inverse (1 + x / real n)) + ln x - 1/(2*x) - p n x)
                   \<longlonglongrightarrow> ln (inverse (1 + 0)) + ln x - 1/(2*x) - P x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. ln (inverse (1 + x / real n)) + ln x - 1 / (2 * x) - p n x) \<longlonglongrightarrow> ln (inverse (1 + 0)) + ln x - 1 / (2 * x) - P x
[PROOF STEP]
by (rule tendsto_intros p_LIMSEQ x real_tendsto_divide_at_top
          filterlim_real_sequentially | simp)+
[PROOF STATE]
proof (state)
this:
(\<lambda>n. ln (inverse (1 + x / real n)) + ln x - 1 / (2 * x) - p n x) \<longlonglongrightarrow> ln (inverse (1 + 0)) + ln x - 1 / (2 * x) - P x

goal (1 subgoal):
 1. Digamma x = ln x - 1 / (2 * x) - P x
[PROOF STEP]
hence "(\<lambda>n. ln (inverse (1 + x / real n)) + ln x - 1/(2*x) - p n x)
             \<longlonglongrightarrow> ln x - 1/(2*x) - P x"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. ln (inverse (1 + x / real n)) + ln x - 1 / (2 * x) - p n x) \<longlonglongrightarrow> ln (inverse (1 + 0)) + ln x - 1 / (2 * x) - P x

goal (1 subgoal):
 1. (\<lambda>n. ln (inverse (1 + x / real n)) + ln x - 1 / (2 * x) - p n x) \<longlonglongrightarrow> ln x - 1 / (2 * x) - P x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<lambda>n. ln (inverse (1 + x / real n)) + ln x - 1 / (2 * x) - p n x) \<longlonglongrightarrow> ln x - 1 / (2 * x) - P x

goal (1 subgoal):
 1. Digamma x = ln x - 1 / (2 * x) - P x
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<forall>\<^sub>F n in sequentially. ln (inverse (1 + x / real n)) + ln x - 1 / (2 * x) - p n x = ln (real n) - S' n x - 1 / (2 * x)
(\<lambda>n. ln (inverse (1 + x / real n)) + ln x - 1 / (2 * x) - p n x) \<longlonglongrightarrow> ln x - 1 / (2 * x) - P x
[PROOF STEP]
have "(\<lambda>n. ln (real n) - S' n x - 1 / (2 * x)) \<longlonglongrightarrow> ln x - 1/(2*x) - P x"
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F n in sequentially. ln (inverse (1 + x / real n)) + ln x - 1 / (2 * x) - p n x = ln (real n) - S' n x - 1 / (2 * x)
(\<lambda>n. ln (inverse (1 + x / real n)) + ln x - 1 / (2 * x) - p n x) \<longlonglongrightarrow> ln x - 1 / (2 * x) - P x

goal (1 subgoal):
 1. (\<lambda>n. ln (real n) - S' n x - 1 / (2 * x)) \<longlonglongrightarrow> ln x - 1 / (2 * x) - P x
[PROOF STEP]
by (blast intro: Lim_transform_eventually)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. ln (real n) - S' n x - 1 / (2 * x)) \<longlonglongrightarrow> ln x - 1 / (2 * x) - P x

goal (1 subgoal):
 1. Digamma x = ln x - 1 / (2 * x) - P x
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<lambda>n. ln (real n) - S' n x - 1 / (2 * x)) \<longlonglongrightarrow> ln x - 1 / (2 * x) - P x

goal (1 subgoal):
 1. Digamma x = ln x - 1 / (2 * x) - P x
[PROOF STEP]
from x
[PROOF STATE]
proof (chain)
picking this:
0 < x
[PROOF STEP]
have "(\<lambda>n. ln (real n) - S' n x - 1 / (2 * x)) \<longlonglongrightarrow> Digamma x"
[PROOF STATE]
proof (prove)
using this:
0 < x

goal (1 subgoal):
 1. (\<lambda>n. ln (real n) - S' n x - 1 / (2 * x)) \<longlonglongrightarrow> Digamma x
[PROOF STEP]
by (intro S'_LIMSEQ_Digamma) simp_all
[PROOF STATE]
proof (state)
this:
(\<lambda>n. ln (real n) - S' n x - 1 / (2 * x)) \<longlonglongrightarrow> Digamma x

goal (1 subgoal):
 1. Digamma x = ln x - 1 / (2 * x) - P x
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>n. ln (real n) - S' n x - 1 / (2 * x)) \<longlonglongrightarrow> ln x - 1 / (2 * x) - P x
(\<lambda>n. ln (real n) - S' n x - 1 / (2 * x)) \<longlonglongrightarrow> Digamma x
[PROOF STEP]
show "Digamma x = ln x - 1 / (2 * x) - P x"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. ln (real n) - S' n x - 1 / (2 * x)) \<longlonglongrightarrow> ln x - 1 / (2 * x) - P x
(\<lambda>n. ln (real n) - S' n x - 1 / (2 * x)) \<longlonglongrightarrow> Digamma x

goal (1 subgoal):
 1. Digamma x = ln x - 1 / (2 * x) - P x
[PROOF STEP]
by (rule LIMSEQ_unique [rotated])
[PROOF STATE]
proof (state)
this:
Digamma x = ln x - 1 / (2 * x) - P x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma graph_max_final_ex:
 "\<exists>f\<in>set (finals (graph n)). |vertices f| = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>f\<in>set (finals (graph n)). |vertices f| = n
[PROOF STEP]
proof (induct "n")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<exists>f\<in>set (finals (graph 0)). |vertices f| = 0
 2. \<And>n. \<exists>f\<in>set (finals (graph n)). |vertices f| = n \<Longrightarrow> \<exists>f\<in>set (finals (graph (Suc n))). |vertices f| = Suc n
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. \<exists>f\<in>set (finals (graph 0)). |vertices f| = 0
 2. \<And>n. \<exists>f\<in>set (finals (graph n)). |vertices f| = n \<Longrightarrow> \<exists>f\<in>set (finals (graph (Suc n))). |vertices f| = Suc n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>f\<in>set (finals (graph 0)). |vertices f| = 0
[PROOF STEP]
by (simp add: graph_def finals_def)
[PROOF STATE]
proof (state)
this:
\<exists>f\<in>set (finals (graph 0)). |vertices f| = 0

goal (1 subgoal):
 1. \<And>n. \<exists>f\<in>set (finals (graph n)). |vertices f| = n \<Longrightarrow> \<exists>f\<in>set (finals (graph (Suc n))). |vertices f| = Suc n
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. \<exists>f\<in>set (finals (graph n)). |vertices f| = n \<Longrightarrow> \<exists>f\<in>set (finals (graph (Suc n))). |vertices f| = Suc n
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
\<exists>f\<in>set (finals (graph n)). |vertices f| = n

goal (1 subgoal):
 1. \<And>n. \<exists>f\<in>set (finals (graph n)). |vertices f| = n \<Longrightarrow> \<exists>f\<in>set (finals (graph (Suc n))). |vertices f| = Suc n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>f\<in>set (finals (graph n)). |vertices f| = n
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
\<exists>f\<in>set (finals (graph n)). |vertices f| = n

goal (1 subgoal):
 1. \<exists>f\<in>set (finals (graph (Suc n))). |vertices f| = Suc n
[PROOF STEP]
by (simp add: graph_def finals_def)
[PROOF STATE]
proof (state)
this:
\<exists>f\<in>set (finals (graph (Suc n))). |vertices f| = Suc n

goal:
No subgoals!
[PROOF STEP]
qed