[STATEMENT]
theorem budan_fourier_interval:
  assumes "a<b" "p\<noteq>0"
  shows "changes_itv_der a b p \<ge> proots_count p {x. a< x \<and> x\<le> b} \<and>
          even (changes_itv_der a b p - proots_count p {x. a< x \<and> x\<le> b})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
[PROOF STEP]
using \<open>a<b\<close>
[PROOF STATE]
proof (prove)
using this:
a < b

goal (1 subgoal):
 1. int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
[PROOF STEP]
proof (induct "card {x. \<exists>p\<in>set (pders p). poly p x=0 \<and> a<x \<and> x<b}" arbitrary:b)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>b. \<lbrakk>0 = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
 2. \<And>x b. \<lbrakk>\<And>b. \<lbrakk>x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b})); Suc x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
0 = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}
a < b

goal (2 subgoals):
 1. \<And>b. \<lbrakk>0 = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
 2. \<And>x b. \<lbrakk>\<And>b. \<lbrakk>x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b})); Suc x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
[PROOF STEP]
have nzero:"\<forall>x. a<x \<and> x<b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x\<noteq>0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x. a < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<forall>x. a < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0)
[PROOF STEP]
define S where "S={x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}"
[PROOF STATE]
proof (state)
this:
S = {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}

goal (1 subgoal):
 1. \<forall>x. a < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0)
[PROOF STEP]
have "finite S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite S
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. finite S
[PROOF STEP]
have "S \<subseteq> (\<Union>p\<in>set (pders p). proots p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S \<subseteq> \<Union> (proots ` set (pders p))
[PROOF STEP]
unfolding S_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b} \<subseteq> \<Union> (proots ` set (pders p))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
S \<subseteq> \<Union> (proots ` set (pders p))

goal (1 subgoal):
 1. finite S
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
S \<subseteq> \<Union> (proots ` set (pders p))

goal (1 subgoal):
 1. finite S
[PROOF STEP]
have "finite (\<Union>p\<in>set (pders p). proots p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (\<Union> (proots ` set (pders p)))
[PROOF STEP]
apply (subst finite_UN)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. finite (set (pders p))
 2. \<forall>x\<in>set (pders p). finite (proots x)
[PROOF STEP]
using set_pders_nzero[OF \<open>p\<noteq>0\<close>]
[PROOF STATE]
proof (prove)
using this:
?q \<in> set (pders p) \<Longrightarrow> ?q \<noteq> 0

goal (2 subgoals):
 1. finite (set (pders p))
 2. \<forall>x\<in>set (pders p). finite (proots x)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite (\<Union> (proots ` set (pders p)))

goal (1 subgoal):
 1. finite S
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
S \<subseteq> \<Union> (proots ` set (pders p))
finite (\<Union> (proots ` set (pders p)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
S \<subseteq> \<Union> (proots ` set (pders p))
finite (\<Union> (proots ` set (pders p)))

goal (1 subgoal):
 1. finite S
[PROOF STEP]
by (simp add: finite_subset)
[PROOF STATE]
proof (state)
this:
finite S

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
finite S

goal (1 subgoal):
 1. \<forall>x. a < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
finite S

goal (1 subgoal):
 1. \<forall>x. a < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0)
[PROOF STEP]
have "card S = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card S = 0
[PROOF STEP]
unfolding S_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b} = 0
[PROOF STEP]
using 0
[PROOF STATE]
proof (prove)
using this:
0 = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}
a < b

goal (1 subgoal):
 1. card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b} = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card S = 0

goal (1 subgoal):
 1. \<forall>x. a < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
finite S
card S = 0
[PROOF STEP]
have "S={}"
[PROOF STATE]
proof (prove)
using this:
finite S
card S = 0

goal (1 subgoal):
 1. S = {}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
S = {}

goal (1 subgoal):
 1. \<forall>x. a < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
S = {}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
S = {}

goal (1 subgoal):
 1. \<forall>x. a < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0)
[PROOF STEP]
unfolding S_def
[PROOF STATE]
proof (prove)
using this:
{x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b} = {}

goal (1 subgoal):
 1. \<forall>x. a < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0)
[PROOF STEP]
using \<open>a<b\<close> assms(2) pders.simps
[PROOF STATE]
proof (prove)
using this:
{x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b} = {}
a < b
p \<noteq> 0
pders ?p = (if ?p = 0 then [] else ?p # pders (pderiv ?p))

goal (1 subgoal):
 1. \<forall>x. a < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0)
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
\<forall>x. a < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>x. a < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0)

goal (2 subgoals):
 1. \<And>b. \<lbrakk>0 = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
 2. \<And>x b. \<lbrakk>\<And>b. \<lbrakk>x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b})); Suc x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
[PROOF STEP]
from budan_fourier_aux_left[OF \<open>a<b\<close> \<open>p\<noteq>0\<close> this]
[PROOF STATE]
proof (chain)
picking this:
int (order b p) \<le> changes_itv_der a b p
even (changes_itv_der a b p - int (order b p))
[PROOF STEP]
have "order b p \<le> changes_itv_der a b p" "even (changes_itv_der a b p - order b p)"
[PROOF STATE]
proof (prove)
using this:
int (order b p) \<le> changes_itv_der a b p
even (changes_itv_der a b p - int (order b p))

goal (1 subgoal):
 1. int (order b p) \<le> changes_itv_der a b p &&& even (changes_itv_der a b p - int (order b p))
[PROOF STEP]
by simp_all
[PROOF STATE]
proof (state)
this:
int (order b p) \<le> changes_itv_der a b p
even (changes_itv_der a b p - int (order b p))

goal (2 subgoals):
 1. \<And>b. \<lbrakk>0 = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
 2. \<And>x b. \<lbrakk>\<And>b. \<lbrakk>x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b})); Suc x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
int (order b p) \<le> changes_itv_der a b p
even (changes_itv_der a b p - int (order b p))

goal (2 subgoals):
 1. \<And>b. \<lbrakk>0 = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
 2. \<And>x b. \<lbrakk>\<And>b. \<lbrakk>x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b})); Suc x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
[PROOF STEP]
have "proots_count p {x. a< x \<and> x\<le> b} = order b p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proots_count p {x. a < x \<and> x \<le> b} = order b p
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. proots_count p {x. a < x \<and> x \<le> b} = order b p
[PROOF STEP]
have p_cons:"pders p=p#pders (pderiv p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pders p = p # pders (pderiv p)
[PROOF STEP]
by (simp add: assms(2) pders.simps)
[PROOF STATE]
proof (state)
this:
pders p = p # pders (pderiv p)

goal (1 subgoal):
 1. proots_count p {x. a < x \<and> x \<le> b} = order b p
[PROOF STEP]
have "proots_within p {x. a < x \<and> x \<le> b} = (if poly p b=0 then {b} else {})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proots_within p {x. a < x \<and> x \<le> b} = (if poly p b = 0 then {b} else {})
[PROOF STEP]
using nzero \<open>a< b\<close>
[PROOF STATE]
proof (prove)
using this:
\<forall>x. a < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0)
a < b

goal (1 subgoal):
 1. proots_within p {x. a < x \<and> x \<le> b} = (if poly p b = 0 then {b} else {})
[PROOF STEP]
unfolding p_cons
[PROOF STATE]
proof (prove)
using this:
\<forall>x. a < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (p # pders (pderiv p)). poly q x \<noteq> 0)
a < b

goal (1 subgoal):
 1. proots_within p {x. a < x \<and> x \<le> b} = (if poly p b = 0 then {b} else {})
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>\<forall>x. a < x \<and> x < b \<longrightarrow> poly p x \<noteq> 0 \<and> (\<forall>q\<in>set (pders (pderiv p)). poly q x \<noteq> 0); poly p b \<noteq> 0; poly p x = 0; a < x; x \<le> b\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
using not_le
[PROOF STATE]
proof (prove)
using this:
(\<not> ?x \<le> ?y) = (?y < ?x)

goal (1 subgoal):
 1. \<And>x. \<lbrakk>\<forall>x. a < x \<and> x < b \<longrightarrow> poly p x \<noteq> 0 \<and> (\<forall>q\<in>set (pders (pderiv p)). poly q x \<noteq> 0); poly p b \<noteq> 0; poly p x = 0; a < x; x \<le> b\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
proots_within p {x. a < x \<and> x \<le> b} = (if poly p b = 0 then {b} else {})

goal (1 subgoal):
 1. proots_count p {x. a < x \<and> x \<le> b} = order b p
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
proots_within p {x. a < x \<and> x \<le> b} = (if poly p b = 0 then {b} else {})
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
proots_within p {x. a < x \<and> x \<le> b} = (if poly p b = 0 then {b} else {})

goal (1 subgoal):
 1. proots_count p {x. a < x \<and> x \<le> b} = order b p
[PROOF STEP]
unfolding proots_count_def
[PROOF STATE]
proof (prove)
using this:
proots_within p {x. a < x \<and> x \<le> b} = (if poly p b = 0 then {b} else {})

goal (1 subgoal):
 1. (\<Sum>r\<in>proots_within p {x. a < x \<and> x \<le> b}. order r p) = order b p
[PROOF STEP]
using order_root
[PROOF STATE]
proof (prove)
using this:
proots_within p {x. a < x \<and> x \<le> b} = (if poly p b = 0 then {b} else {})
(poly ?p ?a = (0::?'a)) = (?p = 0 \<or> order ?a ?p \<noteq> 0)

goal (1 subgoal):
 1. (\<Sum>r\<in>proots_within p {x. a < x \<and> x \<le> b}. order r p) = order b p
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
proots_count p {x. a < x \<and> x \<le> b} = order b p

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
proots_count p {x. a < x \<and> x \<le> b} = order b p

goal (2 subgoals):
 1. \<And>b. \<lbrakk>0 = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
 2. \<And>x b. \<lbrakk>\<And>b. \<lbrakk>x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b})); Suc x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
int (order b p) \<le> changes_itv_der a b p
even (changes_itv_der a b p - int (order b p))
proots_count p {x. a < x \<and> x \<le> b} = order b p
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
int (order b p) \<le> changes_itv_der a b p
even (changes_itv_der a b p - int (order b p))
proots_count p {x. a < x \<and> x \<le> b} = order b p

goal (1 subgoal):
 1. int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))

goal (1 subgoal):
 1. \<And>x b. \<lbrakk>\<And>b. \<lbrakk>x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b})); Suc x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x b. \<lbrakk>\<And>b. \<lbrakk>x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b})); Suc x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
\<lbrakk>n = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < ?b}; a < ?b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> ?b}) \<le> changes_itv_der a ?b p \<and> even (changes_itv_der a ?b p - int (proots_count p {x. a < x \<and> x \<le> ?b}))
Suc n = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}
a < b

goal (1 subgoal):
 1. \<And>x b. \<lbrakk>\<And>b. \<lbrakk>x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b})); Suc x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
[PROOF STEP]
define P where "P=(\<lambda>x. \<exists>p\<in>set (pders p). poly p x = 0)"
[PROOF STATE]
proof (state)
this:
P = (\<lambda>x. \<exists>p\<in>set (pders p). poly p x = 0)

goal (1 subgoal):
 1. \<And>x b. \<lbrakk>\<And>b. \<lbrakk>x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b})); Suc x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
[PROOF STEP]
define S where "S=(\<lambda>b. {x. P x \<and> a < x \<and> x < b})"
[PROOF STATE]
proof (state)
this:
S = (\<lambda>b. {x. P x \<and> a < x \<and> x < b})

goal (1 subgoal):
 1. \<And>x b. \<lbrakk>\<And>b. \<lbrakk>x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b})); Suc x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
[PROOF STEP]
define b' where "b'=Max (S b)"
[PROOF STATE]
proof (state)
this:
b' = Max (S b)

goal (1 subgoal):
 1. \<And>x b. \<lbrakk>\<And>b. \<lbrakk>x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b})); Suc x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
[PROOF STEP]
have f_S:"finite (S x)" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (S x)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. finite (S x)
[PROOF STEP]
have "S x \<subseteq> (\<Union>p\<in>set (pders p). proots p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S x \<subseteq> \<Union> (proots ` set (pders p))
[PROOF STEP]
unfolding S_def P_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {xa. (\<exists>p\<in>set (pders p). poly p xa = 0) \<and> a < xa \<and> xa < x} \<subseteq> \<Union> (proots ` set (pders p))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
S x \<subseteq> \<Union> (proots ` set (pders p))

goal (1 subgoal):
 1. finite (S x)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
S x \<subseteq> \<Union> (proots ` set (pders p))

goal (1 subgoal):
 1. finite (S x)
[PROOF STEP]
have "finite (\<Union>p\<in>set (pders p). proots p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (\<Union> (proots ` set (pders p)))
[PROOF STEP]
apply (subst finite_UN)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. finite (set (pders p))
 2. \<forall>x\<in>set (pders p). finite (proots x)
[PROOF STEP]
using set_pders_nzero[OF \<open>p\<noteq>0\<close>]
[PROOF STATE]
proof (prove)
using this:
?q \<in> set (pders p) \<Longrightarrow> ?q \<noteq> 0

goal (2 subgoals):
 1. finite (set (pders p))
 2. \<forall>x\<in>set (pders p). finite (proots x)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite (\<Union> (proots ` set (pders p)))

goal (1 subgoal):
 1. finite (S x)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
S x \<subseteq> \<Union> (proots ` set (pders p))
finite (\<Union> (proots ` set (pders p)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
S x \<subseteq> \<Union> (proots ` set (pders p))
finite (\<Union> (proots ` set (pders p)))

goal (1 subgoal):
 1. finite (S x)
[PROOF STEP]
by (simp add: finite_subset)
[PROOF STATE]
proof (state)
this:
finite (S x)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
finite (S ?x)

goal (1 subgoal):
 1. \<And>x b. \<lbrakk>\<And>b. \<lbrakk>x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b})); Suc x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
[PROOF STEP]
have "b'\<in>S b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b' \<in> S b
[PROOF STEP]
unfolding b'_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Max (S b) \<in> S b
[PROOF STEP]
apply (rule Max_in[OF f_S])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S b \<noteq> {}
[PROOF STEP]
using Suc(2)
[PROOF STATE]
proof (prove)
using this:
Suc n = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}

goal (1 subgoal):
 1. S b \<noteq> {}
[PROOF STEP]
unfolding S_def P_def
[PROOF STATE]
proof (prove)
using this:
Suc n = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}

goal (1 subgoal):
 1. {x. (\<exists>p\<in>set (pders p). poly p x = 0) \<and> a < x \<and> x < b} \<noteq> {}
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
b' \<in> S b

goal (1 subgoal):
 1. \<And>x b. \<lbrakk>\<And>b. \<lbrakk>x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b})); Suc x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
b' \<in> S b
[PROOF STEP]
have "a<b'" "b'<b"
[PROOF STATE]
proof (prove)
using this:
b' \<in> S b

goal (1 subgoal):
 1. a < b' &&& b' < b
[PROOF STEP]
unfolding S_def
[PROOF STATE]
proof (prove)
using this:
b' \<in> {x. P x \<and> a < x \<and> x < b}

goal (1 subgoal):
 1. a < b' &&& b' < b
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a < b'
b' < b

goal (1 subgoal):
 1. \<And>x b. \<lbrakk>\<And>b. \<lbrakk>x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b})); Suc x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
[PROOF STEP]
have b'_nzero:"\<forall>x. b'<x \<and> x<b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x\<noteq>0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x. b' < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0)
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> (\<forall>x. b' < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0)) \<Longrightarrow> False
[PROOF STEP]
assume "\<not> (\<forall>x. b' < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0))"
[PROOF STATE]
proof (state)
this:
\<not> (\<forall>x. b' < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0))

goal (1 subgoal):
 1. \<not> (\<forall>x. b' < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0)) \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> (\<forall>x. b' < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0))
[PROOF STEP]
obtain bb where "P bb" "b'<bb" "bb<b"
[PROOF STATE]
proof (prove)
using this:
\<not> (\<forall>x. b' < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0))

goal (1 subgoal):
 1. (\<And>bb. \<lbrakk>P bb; b' < bb; bb < b\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding P_def
[PROOF STATE]
proof (prove)
using this:
\<not> (\<forall>x. b' < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0))

goal (1 subgoal):
 1. (\<And>bb. \<lbrakk>\<exists>p\<in>set (pders p). poly p bb = 0; b' < bb; bb < b\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
P bb
b' < bb
bb < b

goal (1 subgoal):
 1. \<not> (\<forall>x. b' < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0)) \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
P bb
b' < bb
bb < b
[PROOF STEP]
have "bb\<in>S b"
[PROOF STATE]
proof (prove)
using this:
P bb
b' < bb
bb < b

goal (1 subgoal):
 1. bb \<in> S b
[PROOF STEP]
unfolding S_def
[PROOF STATE]
proof (prove)
using this:
P bb
b' < bb
bb < b

goal (1 subgoal):
 1. bb \<in> {x. P x \<and> a < x \<and> x < b}
[PROOF STEP]
using \<open>a<b'\<close> \<open>b'<b\<close>
[PROOF STATE]
proof (prove)
using this:
P bb
b' < bb
bb < b
a < b'
b' < b

goal (1 subgoal):
 1. bb \<in> {x. P x \<and> a < x \<and> x < b}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
bb \<in> S b

goal (1 subgoal):
 1. \<not> (\<forall>x. b' < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0)) \<Longrightarrow> False
[PROOF STEP]
from Max_ge[OF f_S this, folded b'_def]
[PROOF STATE]
proof (chain)
picking this:
bb \<le> b'
[PROOF STEP]
have "bb \<le> b'"
[PROOF STATE]
proof (prove)
using this:
bb \<le> b'

goal (1 subgoal):
 1. bb \<le> b'
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
bb \<le> b'

goal (1 subgoal):
 1. \<not> (\<forall>x. b' < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0)) \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
bb \<le> b'
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
bb \<le> b'

goal (1 subgoal):
 1. False
[PROOF STEP]
using \<open>b'<bb\<close>
[PROOF STATE]
proof (prove)
using this:
bb \<le> b'
b' < bb

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>x. b' < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0)

goal (1 subgoal):
 1. \<And>x b. \<lbrakk>\<And>b. \<lbrakk>x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b})); Suc x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
[PROOF STEP]
have hyps:"proots_count p {x. a < x \<and> x \<le> b'} \<le> changes_itv_der a b' p \<and>
                even (changes_itv_der a b' p - proots_count p {x. a < x \<and> x \<le> b'})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int (proots_count p {x. a < x \<and> x \<le> b'}) \<le> changes_itv_der a b' p \<and> even (changes_itv_der a b' p - int (proots_count p {x. a < x \<and> x \<le> b'}))
[PROOF STEP]
proof (rule Suc(1)[OF _ \<open>a<b'\<close>])
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b'}
[PROOF STEP]
have "S b= {b'} \<union> S b'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S b = {b'} \<union> S b'
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. S b = {b'} \<union> S b'
[PROOF STEP]
have "{x. P x \<and> b' < x \<and> x < b} = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x. P x \<and> b' < x \<and> x < b} = {}
[PROOF STEP]
using b'_nzero
[PROOF STATE]
proof (prove)
using this:
\<forall>x. b' < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0)

goal (1 subgoal):
 1. {x. P x \<and> b' < x \<and> x < b} = {}
[PROOF STEP]
unfolding P_def
[PROOF STATE]
proof (prove)
using this:
\<forall>x. b' < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0)

goal (1 subgoal):
 1. {x. (\<exists>p\<in>set (pders p). poly p x = 0) \<and> b' < x \<and> x < b} = {}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{x. P x \<and> b' < x \<and> x < b} = {}

goal (1 subgoal):
 1. S b = {b'} \<union> S b'
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
{x. P x \<and> b' < x \<and> x < b} = {}
[PROOF STEP]
have "{x. P x\<and> b' \<le> x \<and> x < b} = {b'}"
[PROOF STATE]
proof (prove)
using this:
{x. P x \<and> b' < x \<and> x < b} = {}

goal (1 subgoal):
 1. {x. P x \<and> b' \<le> x \<and> x < b} = {b'}
[PROOF STEP]
using \<open>b'\<in>S b\<close>
[PROOF STATE]
proof (prove)
using this:
{x. P x \<and> b' < x \<and> x < b} = {}
b' \<in> S b

goal (1 subgoal):
 1. {x. P x \<and> b' \<le> x \<and> x < b} = {b'}
[PROOF STEP]
unfolding S_def
[PROOF STATE]
proof (prove)
using this:
{x. P x \<and> b' < x \<and> x < b} = {}
b' \<in> {x. P x \<and> a < x \<and> x < b}

goal (1 subgoal):
 1. {x. P x \<and> b' \<le> x \<and> x < b} = {b'}
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
{x. P x \<and> b' \<le> x \<and> x < b} = {b'}

goal (1 subgoal):
 1. S b = {b'} \<union> S b'
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
{x. P x \<and> b' \<le> x \<and> x < b} = {b'}

goal (1 subgoal):
 1. S b = {b'} \<union> S b'
[PROOF STEP]
have "S b= S b' \<union>  {x. P x \<and> b' \<le> x \<and> x < b}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S b = S b' \<union> {x. P x \<and> b' \<le> x \<and> x < b}
[PROOF STEP]
unfolding S_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x. P x \<and> a < x \<and> x < b} = {x. P x \<and> a < x \<and> x < b'} \<union> {x. P x \<and> b' \<le> x \<and> x < b}
[PROOF STEP]
using \<open>a<b'\<close> \<open>b'<b\<close>
[PROOF STATE]
proof (prove)
using this:
a < b'
b' < b

goal (1 subgoal):
 1. {x. P x \<and> a < x \<and> x < b} = {x. P x \<and> a < x \<and> x < b'} \<union> {x. P x \<and> b' \<le> x \<and> x < b}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
S b = S b' \<union> {x. P x \<and> b' \<le> x \<and> x < b}

goal (1 subgoal):
 1. S b = {b'} \<union> S b'
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
{x. P x \<and> b' \<le> x \<and> x < b} = {b'}
S b = S b' \<union> {x. P x \<and> b' \<le> x \<and> x < b}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
{x. P x \<and> b' \<le> x \<and> x < b} = {b'}
S b = S b' \<union> {x. P x \<and> b' \<le> x \<and> x < b}

goal (1 subgoal):
 1. S b = {b'} \<union> S b'
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
S b = {b'} \<union> S b'

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
S b = {b'} \<union> S b'

goal (1 subgoal):
 1. n = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b'}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
S b = {b'} \<union> S b'

goal (1 subgoal):
 1. n = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b'}
[PROOF STEP]
have "Suc n = card (S b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc n = card (S b)
[PROOF STEP]
using Suc(2)
[PROOF STATE]
proof (prove)
using this:
Suc n = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}

goal (1 subgoal):
 1. Suc n = card (S b)
[PROOF STEP]
unfolding S_def P_def
[PROOF STATE]
proof (prove)
using this:
Suc n = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}

goal (1 subgoal):
 1. Suc n = card {x. (\<exists>p\<in>set (pders p). poly p x = 0) \<and> a < x \<and> x < b}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Suc n = card (S b)

goal (1 subgoal):
 1. n = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b'}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
Suc n = card (S b)

goal (1 subgoal):
 1. n = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b'}
[PROOF STEP]
have "b'\<notin>S b'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b' \<notin> S b'
[PROOF STEP]
unfolding S_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b' \<notin> {x. P x \<and> a < x \<and> x < b'}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
b' \<notin> S b'

goal (1 subgoal):
 1. n = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b'}
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
S b = {b'} \<union> S b'
Suc n = card (S b)
b' \<notin> S b'
[PROOF STEP]
have "n=card (S b')"
[PROOF STATE]
proof (prove)
using this:
S b = {b'} \<union> S b'
Suc n = card (S b)
b' \<notin> S b'

goal (1 subgoal):
 1. n = card (S b')
[PROOF STEP]
using f_S
[PROOF STATE]
proof (prove)
using this:
S b = {b'} \<union> S b'
Suc n = card (S b)
b' \<notin> S b'
finite (S ?x)

goal (1 subgoal):
 1. n = card (S b')
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
n = card (S b')

goal (1 subgoal):
 1. n = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b'}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n = card (S b')
[PROOF STEP]
show "n = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b'}"
[PROOF STATE]
proof (prove)
using this:
n = card (S b')

goal (1 subgoal):
 1. n = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b'}
[PROOF STEP]
unfolding S_def P_def
[PROOF STATE]
proof (prove)
using this:
n = card {x. (\<exists>p\<in>set (pders p). poly p x = 0) \<and> a < x \<and> x < b'}

goal (1 subgoal):
 1. n = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b'}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
n = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b'}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
int (proots_count p {x. a < x \<and> x \<le> b'}) \<le> changes_itv_der a b' p \<and> even (changes_itv_der a b' p - int (proots_count p {x. a < x \<and> x \<le> b'}))

goal (1 subgoal):
 1. \<And>x b. \<lbrakk>\<And>b. \<lbrakk>x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b})); Suc x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
int (proots_count p {x. a < x \<and> x \<le> b'}) \<le> changes_itv_der a b' p \<and> even (changes_itv_der a b' p - int (proots_count p {x. a < x \<and> x \<le> b'}))

goal (1 subgoal):
 1. \<And>x b. \<lbrakk>\<And>b. \<lbrakk>x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b})); Suc x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
[PROOF STEP]
have "proots_count p {x. a < x \<and> x \<le> b}
                    = proots_count p {x. a < x \<and> x \<le> b'} + order b p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proots_count p {x. a < x \<and> x \<le> b} = proots_count p {x. a < x \<and> x \<le> b'} + order b p
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. proots_count p {x. a < x \<and> x \<le> b} = proots_count p {x. a < x \<and> x \<le> b'} + order b p
[PROOF STEP]
have p_cons:"pders p=p#pders (pderiv p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pders p = p # pders (pderiv p)
[PROOF STEP]
by (simp add: assms(2) pders.simps)
[PROOF STATE]
proof (state)
this:
pders p = p # pders (pderiv p)

goal (1 subgoal):
 1. proots_count p {x. a < x \<and> x \<le> b} = proots_count p {x. a < x \<and> x \<le> b'} + order b p
[PROOF STEP]
have "proots_within p {x. b' < x \<and> x \<le> b} = (if poly p b=0 then {b} else {})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proots_within p {x. b' < x \<and> x \<le> b} = (if poly p b = 0 then {b} else {})
[PROOF STEP]
using b'_nzero \<open>b' < b\<close>
[PROOF STATE]
proof (prove)
using this:
\<forall>x. b' < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (pders p). poly q x \<noteq> 0)
b' < b

goal (1 subgoal):
 1. proots_within p {x. b' < x \<and> x \<le> b} = (if poly p b = 0 then {b} else {})
[PROOF STEP]
unfolding p_cons
[PROOF STATE]
proof (prove)
using this:
\<forall>x. b' < x \<and> x < b \<longrightarrow> (\<forall>q\<in>set (p # pders (pderiv p)). poly q x \<noteq> 0)
b' < b

goal (1 subgoal):
 1. proots_within p {x. b' < x \<and> x \<le> b} = (if poly p b = 0 then {b} else {})
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>\<forall>x. b' < x \<and> x < b \<longrightarrow> poly p x \<noteq> 0 \<and> (\<forall>q\<in>set (pders (pderiv p)). poly q x \<noteq> 0); poly p b \<noteq> 0; poly p x = 0; b' < x; x \<le> b\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
using not_le
[PROOF STATE]
proof (prove)
using this:
(\<not> ?x \<le> ?y) = (?y < ?x)

goal (1 subgoal):
 1. \<And>x. \<lbrakk>\<forall>x. b' < x \<and> x < b \<longrightarrow> poly p x \<noteq> 0 \<and> (\<forall>q\<in>set (pders (pderiv p)). poly q x \<noteq> 0); poly p b \<noteq> 0; poly p x = 0; b' < x; x \<le> b\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
proots_within p {x. b' < x \<and> x \<le> b} = (if poly p b = 0 then {b} else {})

goal (1 subgoal):
 1. proots_count p {x. a < x \<and> x \<le> b} = proots_count p {x. a < x \<and> x \<le> b'} + order b p
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
proots_within p {x. b' < x \<and> x \<le> b} = (if poly p b = 0 then {b} else {})
[PROOF STEP]
have "proots_count p {x. b' < x \<and> x \<le> b} = order b p"
[PROOF STATE]
proof (prove)
using this:
proots_within p {x. b' < x \<and> x \<le> b} = (if poly p b = 0 then {b} else {})

goal (1 subgoal):
 1. proots_count p {x. b' < x \<and> x \<le> b} = order b p
[PROOF STEP]
unfolding proots_count_def
[PROOF STATE]
proof (prove)
using this:
proots_within p {x. b' < x \<and> x \<le> b} = (if poly p b = 0 then {b} else {})

goal (1 subgoal):
 1. (\<Sum>r\<in>proots_within p {x. b' < x \<and> x \<le> b}. order r p) = order b p
[PROOF STEP]
using order_root
[PROOF STATE]
proof (prove)
using this:
proots_within p {x. b' < x \<and> x \<le> b} = (if poly p b = 0 then {b} else {})
(poly ?p ?a = (0::?'a)) = (?p = 0 \<or> order ?a ?p \<noteq> 0)

goal (1 subgoal):
 1. (\<Sum>r\<in>proots_within p {x. b' < x \<and> x \<le> b}. order r p) = order b p
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
proots_count p {x. b' < x \<and> x \<le> b} = order b p

goal (1 subgoal):
 1. proots_count p {x. a < x \<and> x \<le> b} = proots_count p {x. a < x \<and> x \<le> b'} + order b p
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
proots_count p {x. b' < x \<and> x \<le> b} = order b p

goal (1 subgoal):
 1. proots_count p {x. a < x \<and> x \<le> b} = proots_count p {x. a < x \<and> x \<le> b'} + order b p
[PROOF STEP]
have "proots_count p {x. a < x \<and> x \<le> b} = proots_count p {x. a < x \<and> x \<le> b'} +
            proots_count p {x. b' < x \<and> x \<le> b}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. proots_count p {x. a < x \<and> x \<le> b} = proots_count p {x. a < x \<and> x \<le> b'} + proots_count p {x. b' < x \<and> x \<le> b}
[PROOF STEP]
apply (subst proots_count_union_disjoint[symmetric])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. {x. a < x \<and> x \<le> b'} \<inter> {x. b' < x \<and> x \<le> b} = {}
 2. p \<noteq> 0
 3. proots_count p {x. a < x \<and> x \<le> b} = proots_count p ({x. a < x \<and> x \<le> b'} \<union> {x. b' < x \<and> x \<le> b})
[PROOF STEP]
using \<open>a<b'\<close> \<open>b'<b\<close> \<open>p\<noteq>0\<close>
[PROOF STATE]
proof (prove)
using this:
a < b'
b' < b
p \<noteq> 0

goal (3 subgoals):
 1. {x. a < x \<and> x \<le> b'} \<inter> {x. b' < x \<and> x \<le> b} = {}
 2. p \<noteq> 0
 3. proots_count p {x. a < x \<and> x \<le> b} = proots_count p ({x. a < x \<and> x \<le> b'} \<union> {x. b' < x \<and> x \<le> b})
[PROOF STEP]
by (auto intro:arg_cong2[where f=proots_count])
[PROOF STATE]
proof (state)
this:
proots_count p {x. a < x \<and> x \<le> b} = proots_count p {x. a < x \<and> x \<le> b'} + proots_count p {x. b' < x \<and> x \<le> b}

goal (1 subgoal):
 1. proots_count p {x. a < x \<and> x \<le> b} = proots_count p {x. a < x \<and> x \<le> b'} + order b p
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
proots_count p {x. b' < x \<and> x \<le> b} = order b p
proots_count p {x. a < x \<and> x \<le> b} = proots_count p {x. a < x \<and> x \<le> b'} + proots_count p {x. b' < x \<and> x \<le> b}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
proots_count p {x. b' < x \<and> x \<le> b} = order b p
proots_count p {x. a < x \<and> x \<le> b} = proots_count p {x. a < x \<and> x \<le> b'} + proots_count p {x. b' < x \<and> x \<le> b}

goal (1 subgoal):
 1. proots_count p {x. a < x \<and> x \<le> b} = proots_count p {x. a < x \<and> x \<le> b'} + order b p
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
proots_count p {x. a < x \<and> x \<le> b} = proots_count p {x. a < x \<and> x \<le> b'} + order b p

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
proots_count p {x. a < x \<and> x \<le> b} = proots_count p {x. a < x \<and> x \<le> b'} + order b p

goal (1 subgoal):
 1. \<And>x b. \<lbrakk>\<And>b. \<lbrakk>x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b})); Suc x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
proots_count p {x. a < x \<and> x \<le> b} = proots_count p {x. a < x \<and> x \<le> b'} + order b p

goal (1 subgoal):
 1. \<And>x b. \<lbrakk>\<And>b. \<lbrakk>x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b})); Suc x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
[PROOF STEP]
note budan_fourier_aux_left[OF \<open>b'<b\<close> \<open>p\<noteq>0\<close> b'_nzero]
[PROOF STATE]
proof (state)
this:
int (order b p) \<le> changes_itv_der b' b p
even (changes_itv_der b' b p - int (order b p))

goal (1 subgoal):
 1. \<And>x b. \<lbrakk>\<And>b. \<lbrakk>x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b})); Suc x = card {x. \<exists>p\<in>set (pders p). poly p x = 0 \<and> a < x \<and> x < b}; a < b\<rbrakk> \<Longrightarrow> int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
int (proots_count p {x. a < x \<and> x \<le> b'}) \<le> changes_itv_der a b' p \<and> even (changes_itv_der a b' p - int (proots_count p {x. a < x \<and> x \<le> b'}))
proots_count p {x. a < x \<and> x \<le> b} = proots_count p {x. a < x \<and> x \<le> b'} + order b p
int (order b p) \<le> changes_itv_der b' b p
even (changes_itv_der b' b p - int (order b p))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
int (proots_count p {x. a < x \<and> x \<le> b'}) \<le> changes_itv_der a b' p \<and> even (changes_itv_der a b' p - int (proots_count p {x. a < x \<and> x \<le> b'}))
proots_count p {x. a < x \<and> x \<le> b} = proots_count p {x. a < x \<and> x \<le> b'} + order b p
int (order b p) \<le> changes_itv_der b' b p
even (changes_itv_der b' b p - int (order b p))

goal (1 subgoal):
 1. int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))
[PROOF STEP]
unfolding changes_itv_der_def Let_def
[PROOF STATE]
proof (prove)
using this:
int (proots_count p {x. a < x \<and> x \<le> b'}) \<le> changes_poly_at (pders p) a - changes_poly_at (pders p) b' \<and> even (changes_poly_at (pders p) a - changes_poly_at (pders p) b' - int (proots_count p {x. a < x \<and> x \<le> b'}))
proots_count p {x. a < x \<and> x \<le> b} = proots_count p {x. a < x \<and> x \<le> b'} + order b p
int (order b p) \<le> changes_poly_at (pders p) b' - changes_poly_at (pders p) b
even (changes_poly_at (pders p) b' - changes_poly_at (pders p) b - int (order b p))

goal (1 subgoal):
 1. int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_poly_at (pders p) a - changes_poly_at (pders p) b \<and> even (changes_poly_at (pders p) a - changes_poly_at (pders p) b - int (proots_count p {x. a < x \<and> x \<le> b}))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
int (proots_count p {x. a < x \<and> x \<le> b}) \<le> changes_itv_der a b p \<and> even (changes_itv_der a b p - int (proots_count p {x. a < x \<and> x \<le> b}))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma prec_st_simp: "prec_st p r u x = (\<forall> n . (\<forall> i < n . inpt_st r (u i) (u (Suc i)) (x i)) \<longrightarrow> p (u n) (u (Suc n)) (x n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prec_st p r u x = (\<forall>n. (\<forall>i<n. inpt_st r (u i) (u (Suc i)) (x i)) \<longrightarrow> p (u n) (u (Suc n)) (x n))
[PROOF STEP]
by (simp add: prec_st_def until_def lft_pred_st_def inpt_st_def at_fun_def, metis)


[STATEMENT]
lemma ev_HLD_sset: "ev (HLD A) w \<longleftrightarrow> sset w \<inter> A \<noteq> {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ev (HLD A) w = (sset w \<inter> A \<noteq> {})
[PROOF STEP]
unfolding HLD_def ev_holds_sset
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<exists>x\<in>sset w. x \<in> A) = (sset w \<inter> A \<noteq> {})
[PROOF STEP]
by auto


[STATEMENT]
lemma compact_compact_with: "compact s = compact_with open s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. compact s = compact_with open s
[PROOF STEP]
unfolding compact_with_def compact_eq_Heine_Borel[abs_def]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>C. Ball C open \<and> s \<subseteq> \<Union> C \<longrightarrow> (\<exists>D\<subseteq>C. finite D \<and> s \<subseteq> \<Union> D)) = (\<forall>C. Ball C open \<and> s \<subseteq> \<Union> C \<longrightarrow> (\<exists>D\<subseteq>C. finite D \<and> s \<subseteq> \<Union> D))
[PROOF STEP]
..


[STATEMENT]
lemma word_sub_plus_one_nonzero:
  fixes n :: "'a :: len word"
  shows "\<lbrakk>n' \<le> n; n' \<noteq> 0\<rbrakk> \<Longrightarrow> (n - n') + 1 \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>n' \<le> n; n' \<noteq> 0\<rbrakk> \<Longrightarrow> n - n' + 1 \<noteq> 0
[PROOF STEP]
apply (subst lt1_neq0 [symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>n' \<le> n; n' \<noteq> 0\<rbrakk> \<Longrightarrow> 1 \<le> n - n' + 1
[PROOF STEP]
apply (subst olen_add_eqv [symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>n' \<le> n; n' \<noteq> 0\<rbrakk> \<Longrightarrow> n - n' \<le> n - n' + 1
[PROOF STEP]
apply (rule word_random [where x' = n'])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>n' \<le> n; n' \<noteq> 0\<rbrakk> \<Longrightarrow> n - n' \<le> n - n' + n'
 2. \<lbrakk>n' \<le> n; n' \<noteq> 0\<rbrakk> \<Longrightarrow> 1 \<le> n'
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>n' \<le> n; n' \<noteq> 0\<rbrakk> \<Longrightarrow> n - n' \<le> n
 2. \<lbrakk>n' \<le> n; n' \<noteq> 0\<rbrakk> \<Longrightarrow> 1 \<le> n'
[PROOF STEP]
apply (erule word_sub_le)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>n' \<le> n; n' \<noteq> 0\<rbrakk> \<Longrightarrow> 1 \<le> n'
[PROOF STEP]
apply (simp add: lt1_neq0)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma decseq_SucI: "(\<And>n. X (Suc n) \<le> X n) \<Longrightarrow> decseq X"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>n. X (Suc n) \<le> X n) \<Longrightarrow> decseq X
[PROOF STEP]
using order.lift_Suc_mono_le[OF dual_order, of X]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>n. X (Suc n) \<le> X n; ?n \<le> ?n'\<rbrakk> \<Longrightarrow> X ?n' \<le> X ?n

goal (1 subgoal):
 1. (\<And>n. X (Suc n) \<le> X n) \<Longrightarrow> decseq X
[PROOF STEP]
by (auto simp: decseq_def)


[STATEMENT]
lemma map_indets_map_indets: "map_indets f (map_indets g p) = map_indets (f \<circ> g) p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_indets f (map_indets g p) = map_indets (f \<circ> g) p
[PROOF STEP]
by (simp add: map_indets_def poly_subst_poly_subst poly_subst_monomial subst_pp_single)


[STATEMENT]
lemma sign_changes_coeff_sign_changes:
  assumes "Poly xs = (p :: 'a :: linordered_idom poly)"
  shows   "sign_changes xs = coeff_sign_changes p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sign_changes xs = sign_changes (coeffs p)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. sign_changes xs = sign_changes (coeffs p)
[PROOF STEP]
have "coeffs p = coeffs (Poly xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeffs p = coeffs (Poly xs)
[PROOF STEP]
by (subst assms) (rule refl)
[PROOF STATE]
proof (state)
this:
coeffs p = coeffs (Poly xs)

goal (1 subgoal):
 1. sign_changes xs = sign_changes (coeffs p)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
coeffs p = coeffs (Poly xs)

goal (1 subgoal):
 1. sign_changes xs = sign_changes (coeffs p)
[PROOF STEP]
have "\<dots> = strip_while ((=) 0) xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coeffs (Poly xs) = strip_while ((=) (0::'a)) xs
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
coeffs (Poly xs) = strip_while ((=) (0::'a)) xs

goal (1 subgoal):
 1. sign_changes xs = sign_changes (coeffs p)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
coeffs (Poly xs) = strip_while ((=) (0::'a)) xs

goal (1 subgoal):
 1. sign_changes xs = sign_changes (coeffs p)
[PROOF STEP]
have "filter ((\<noteq>) 0) \<dots> = filter ((\<noteq>) 0) xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. filter ((\<noteq>) (0::'a)) (strip_while ((=) (0::'a)) xs) = filter ((\<noteq>) (0::'a)) xs
[PROOF STEP]
unfolding strip_while_def o_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. filter ((\<noteq>) (0::'a)) (rev (dropWhile ((=) (0::'a)) (rev xs))) = filter ((\<noteq>) (0::'a)) xs
[PROOF STEP]
by (subst rev_filter [symmetric], subst filter_dropWhile) (simp_all add: rev_filter)
[PROOF STATE]
proof (state)
this:
filter ((\<noteq>) (0::'a)) (strip_while ((=) (0::'a)) xs) = filter ((\<noteq>) (0::'a)) xs

goal (1 subgoal):
 1. sign_changes xs = sign_changes (coeffs p)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
filter ((\<noteq>) (0::'a)) (strip_while ((=) (0::'a)) xs) = filter ((\<noteq>) (0::'a)) xs

goal (1 subgoal):
 1. sign_changes xs = sign_changes (coeffs p)
[PROOF STEP]
have "sign_changes \<dots> = sign_changes xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sign_changes (filter ((\<noteq>) (0::'a)) xs) = sign_changes xs
[PROOF STEP]
by (simp add: sign_changes_filter)
[PROOF STATE]
proof (state)
this:
sign_changes (filter ((\<noteq>) (0::'a)) xs) = sign_changes xs

goal (1 subgoal):
 1. sign_changes xs = sign_changes (coeffs p)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sign_changes (filter ((\<noteq>) (0::'a)) (coeffs p)) = sign_changes xs
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
sign_changes (filter ((\<noteq>) (0::'a)) (coeffs p)) = sign_changes xs

goal (1 subgoal):
 1. sign_changes xs = sign_changes (coeffs p)
[PROOF STEP]
by (simp add: sign_changes_filter)
[PROOF STATE]
proof (state)
this:
sign_changes xs = sign_changes (coeffs p)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma SUP_ereal_le_addI:
  fixes f :: "'i \<Rightarrow> ereal"
  assumes "\<And>i. f i + y \<le> z" and "y \<noteq> -\<infinity>"
  shows "Sup (f ` UNIV) + y \<le> z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Sup (range f) + y \<le> z
[PROOF STEP]
unfolding SUP_ereal_add_left[OF UNIV_not_empty \<open>y \<noteq> -\<infinity>\<close>, symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (SUP i. f i + y) \<le> z
[PROOF STEP]
by (rule SUP_least assms)+


[STATEMENT]
lemma open_map_imp_subset_topspace:
     "open_map X1 X2 f \<Longrightarrow> f ` (topspace X1) \<subseteq> topspace X2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. open_map X1 X2 f \<Longrightarrow> f ` topspace X1 \<subseteq> topspace X2
[PROOF STEP]
unfolding open_map_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>U. openin X1 U \<longrightarrow> openin X2 (f ` U) \<Longrightarrow> f ` topspace X1 \<subseteq> topspace X2
[PROOF STEP]
by (simp add: openin_subset)


[STATEMENT]
lemma append_natpermute_less_eq:
  assumes "xs @ ys \<in> natpermute n k"
  shows "sum_list xs \<le> n"
    and "sum_list ys \<le> n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_list xs \<le> n &&& sum_list ys \<le> n
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. sum_list xs \<le> n
 2. sum_list ys \<le> n
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
xs @ ys \<in> natpermute n k
[PROOF STEP]
have "sum_list (xs @ ys) = n"
[PROOF STATE]
proof (prove)
using this:
xs @ ys \<in> natpermute n k

goal (1 subgoal):
 1. sum_list (xs @ ys) = n
[PROOF STEP]
by (simp add: natpermute_def)
[PROOF STATE]
proof (state)
this:
sum_list (xs @ ys) = n

goal (2 subgoals):
 1. sum_list xs \<le> n
 2. sum_list ys \<le> n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
sum_list (xs @ ys) = n
[PROOF STEP]
have "sum_list xs + sum_list ys = n"
[PROOF STATE]
proof (prove)
using this:
sum_list (xs @ ys) = n

goal (1 subgoal):
 1. sum_list xs + sum_list ys = n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sum_list xs + sum_list ys = n

goal (2 subgoals):
 1. sum_list xs \<le> n
 2. sum_list ys \<le> n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
sum_list xs + sum_list ys = n
[PROOF STEP]
show "sum_list xs \<le> n" and "sum_list ys \<le> n"
[PROOF STATE]
proof (prove)
using this:
sum_list xs + sum_list ys = n

goal (1 subgoal):
 1. sum_list xs \<le> n &&& sum_list ys \<le> n
[PROOF STEP]
by simp_all
[PROOF STATE]
proof (state)
this:
sum_list xs \<le> n
sum_list ys \<le> n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma cinner_scaleC_right [simp]: "cinner x (scaleC r y) = r * (cinner x y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cinner x (r *\<^sub>C y) = r * cinner x y
[PROOF STEP]
using cinner_scaleC_left [of r y x]
[PROOF STATE]
proof (prove)
using this:
cinner (r *\<^sub>C y) x = cnj r * cinner y x

goal (1 subgoal):
 1. cinner x (r *\<^sub>C y) = r * cinner x y
[PROOF STEP]
by (metis complex_cnj_cnj complex_cnj_mult local.cinner_commute)


[STATEMENT]
lemma inner_diff_left: "inner (x - y) z = inner x z - inner y z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inner (x - y) z = inner x z - inner y z
[PROOF STEP]
using inner_add_left [of x "- y" z]
[PROOF STATE]
proof (prove)
using this:
inner (x + - y) z = inner x z + inner (- y) z

goal (1 subgoal):
 1. inner (x - y) z = inner x z - inner y z
[PROOF STEP]
by simp


[STATEMENT]
lemma nth_elem_consecutive_indices:
  assumes "(i::nat) < j"
  assumes "k < j - i"
  shows "nth_elem {i..<j} k = i + k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nth_elem {i..<j} k = i + k
[PROOF STEP]
using nth_elem.simps[of "{i..<j}" k] sorted_list_of_set_from_up_to assms(2)
[PROOF STATE]
proof (prove)
using this:
nth_elem {i..<j} k = sorted_list_of_set {i..<j} ! k
\<lbrakk>?i < ?j; ?k < ?j - ?i\<rbrakk> \<Longrightarrow> sorted_list_of_set {?i..<?j} ! ?k = ?i + ?k
k < j - i

goal (1 subgoal):
 1. nth_elem {i..<j} k = i + k
[PROOF STEP]
by auto


[STATEMENT]
lemma from_index_geq_vector_simplex:
  assumes "x \<Turnstile>\<^sub>c\<^sub>s set (from_index_geq0_vector i v)"
  "j < dim_vec v"
  shows "x (i + j) \<ge> v$j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v $ j \<le> x (i + j)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. v $ j \<le> x (i + j)
[PROOF STEP]
have "GEQ (lp_monom 1 (i+j)) (v$j)\<in> set (from_index_geq0_vector i v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. GEQ (lp_monom 1 (i + j)) (v $ j) \<in> set (from_index_geq0_vector i v)
[PROOF STEP]
by (simp add: assms(2))
[PROOF STATE]
proof (state)
this:
GEQ (lp_monom 1 (i + j)) (v $ j) \<in> set (from_index_geq0_vector i v)

goal (1 subgoal):
 1. v $ j \<le> x (i + j)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
GEQ (lp_monom 1 (i + j)) (v $ j) \<in> set (from_index_geq0_vector i v)

goal (1 subgoal):
 1. v $ j \<le> x (i + j)
[PROOF STEP]
have "x \<Turnstile>\<^sub>c GEQ (lp_monom 1 (i+j)) (v$j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<Turnstile>\<^sub>c GEQ (lp_monom 1 (i + j)) (v $ j)
[PROOF STEP]
using calculation(1) assms
[PROOF STATE]
proof (prove)
using this:
GEQ (lp_monom 1 (i + j)) (v $ j) \<in> set (from_index_geq0_vector i v)
x \<Turnstile>\<^sub>c\<^sub>s set (from_index_geq0_vector i v)
j < dim_vec v

goal (1 subgoal):
 1. x \<Turnstile>\<^sub>c GEQ (lp_monom 1 (i + j)) (v $ j)
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
x \<Turnstile>\<^sub>c GEQ (lp_monom 1 (i + j)) (v $ j)

goal (1 subgoal):
 1. v $ j \<le> x (i + j)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
GEQ (lp_monom 1 (i + j)) (v $ j) \<in> set (from_index_geq0_vector i v)
x \<Turnstile>\<^sub>c GEQ (lp_monom 1 (i + j)) (v $ j)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
GEQ (lp_monom 1 (i + j)) (v $ j) \<in> set (from_index_geq0_vector i v)
x \<Turnstile>\<^sub>c GEQ (lp_monom 1 (i + j)) (v $ j)

goal (1 subgoal):
 1. v $ j \<le> x (i + j)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
v $ j \<le> x (i + j)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma horner_eval_Suc'[simp]:
  fixes x::"'a::{comm_monoid_add, times}"
  shows "horner_eval f x (Suc n) = f 0 + x * (horner_eval (\<lambda>i. f (Suc i)) x n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. horner_eval f x (Suc n) = f 0 + x * horner_eval (\<lambda>i. f (Suc i)) x n
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. horner_eval f x (Suc n) = f 0 + x * horner_eval (\<lambda>i. f (Suc i)) x n
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. horner_eval f x (Suc n) = f 0 + x * horner_eval (\<lambda>i. f (Suc i)) x n
[PROOF STEP]
fix v
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. horner_eval f x (Suc n) = f 0 + x * horner_eval (\<lambda>i. f (Suc i)) x n
[PROOF STEP]
have "horner_eval' f x v (Suc n) = f 0 + x * horner_eval' (\<lambda>i. f (Suc i)) x v n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. horner_eval' f x v (Suc n) = f 0 + x * horner_eval' (\<lambda>i. f (Suc i)) x v n
[PROOF STEP]
by (induction n arbitrary: v, simp_all)
[PROOF STATE]
proof (state)
this:
horner_eval' f x v (Suc n) = f 0 + x * horner_eval' (\<lambda>i. f (Suc i)) x v n

goal (1 subgoal):
 1. horner_eval f x (Suc n) = f 0 + x * horner_eval (\<lambda>i. f (Suc i)) x n
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
horner_eval' f x ?v2 (Suc n) = f 0 + x * horner_eval' (\<lambda>i. f (Suc i)) x ?v2 n

goal (1 subgoal):
 1. horner_eval f x (Suc n) = f 0 + x * horner_eval (\<lambda>i. f (Suc i)) x n
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
horner_eval' f x ?v2 (Suc n) = f 0 + x * horner_eval' (\<lambda>i. f (Suc i)) x ?v2 n

goal (1 subgoal):
 1. horner_eval f x (Suc n) = f 0 + x * horner_eval (\<lambda>i. f (Suc i)) x n
[PROOF STEP]
by (simp add: horner_eval_def)
[PROOF STATE]
proof (state)
this:
horner_eval f x (Suc n) = f 0 + x * horner_eval (\<lambda>i. f (Suc i)) x n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma random_bst_altdef:
  assumes "finite A"
  shows   "random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite A

goal (1 subgoal):
 1. random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
proof (induction A rule: finite_psubset_induct)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>A. \<lbrakk>finite A; \<And>B. B \<subset> A \<Longrightarrow> random_bst B = map_pmf bst_of_list (pmf_of_set (permutations_of_set B))\<rbrakk> \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
case (psubset A)
[PROOF STATE]
proof (state)
this:
finite A
?B \<subset> A \<Longrightarrow> random_bst ?B = map_pmf bst_of_list (pmf_of_set (permutations_of_set ?B))

goal (1 subgoal):
 1. \<And>A. \<lbrakk>finite A; \<And>B. B \<subset> A \<Longrightarrow> random_bst B = map_pmf bst_of_list (pmf_of_set (permutations_of_set B))\<rbrakk> \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
define L R where "L = (\<lambda>x. {y\<in>A. y < x})" and "R = (\<lambda>x. {y\<in>A. y > x})"
[PROOF STATE]
proof (state)
this:
L = (\<lambda>x. {y \<in> A. y < x})
R = (\<lambda>x. {y \<in> A. x < y})

goal (1 subgoal):
 1. \<And>A. \<lbrakk>finite A; \<And>B. B \<subset> A \<Longrightarrow> random_bst B = map_pmf bst_of_list (pmf_of_set (permutations_of_set B))\<rbrakk> \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
L = (\<lambda>x. {y \<in> A. y < x})
R = (\<lambda>x. {y \<in> A. x < y})

goal (1 subgoal):
 1. \<And>A. \<lbrakk>finite A; \<And>B. B \<subset> A \<Longrightarrow> random_bst B = map_pmf bst_of_list (pmf_of_set (permutations_of_set B))\<rbrakk> \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>A. \<lbrakk>finite A; \<And>B. B \<subset> A \<Longrightarrow> random_bst B = map_pmf bst_of_list (pmf_of_set (permutations_of_set B))\<rbrakk> \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
assume x: "x \<in> A"
[PROOF STATE]
proof (state)
this:
x \<in> A

goal (1 subgoal):
 1. \<And>A. \<lbrakk>finite A; \<And>B. B \<subset> A \<Longrightarrow> random_bst B = map_pmf bst_of_list (pmf_of_set (permutations_of_set B))\<rbrakk> \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
hence *: "L x \<subset> A" "R x \<subset> A"
[PROOF STATE]
proof (prove)
using this:
x \<in> A

goal (1 subgoal):
 1. L x \<subset> A &&& R x \<subset> A
[PROOF STEP]
by (auto simp: L_def R_def)
[PROOF STATE]
proof (state)
this:
L x \<subset> A
R x \<subset> A

goal (1 subgoal):
 1. \<And>A. \<lbrakk>finite A; \<And>B. B \<subset> A \<Longrightarrow> random_bst B = map_pmf bst_of_list (pmf_of_set (permutations_of_set B))\<rbrakk> \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
note this [THEN psubset.IH]
[PROOF STATE]
proof (state)
this:
random_bst (L x) = map_pmf bst_of_list (pmf_of_set (permutations_of_set (L x)))
random_bst (R x) = map_pmf bst_of_list (pmf_of_set (permutations_of_set (R x)))

goal (1 subgoal):
 1. \<And>A. \<lbrakk>finite A; \<And>B. B \<subset> A \<Longrightarrow> random_bst B = map_pmf bst_of_list (pmf_of_set (permutations_of_set B))\<rbrakk> \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?x2 \<in> A \<Longrightarrow> random_bst (L ?x2) = map_pmf bst_of_list (pmf_of_set (permutations_of_set (L ?x2)))
?x2 \<in> A \<Longrightarrow> random_bst (R ?x2) = map_pmf bst_of_list (pmf_of_set (permutations_of_set (R ?x2)))

goal (1 subgoal):
 1. \<And>A. \<lbrakk>finite A; \<And>B. B \<subset> A \<Longrightarrow> random_bst B = map_pmf bst_of_list (pmf_of_set (permutations_of_set B))\<rbrakk> \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
note IH = this
[PROOF STATE]
proof (state)
this:
?x2 \<in> A \<Longrightarrow> random_bst (L ?x2) = map_pmf bst_of_list (pmf_of_set (permutations_of_set (L ?x2)))
?x2 \<in> A \<Longrightarrow> random_bst (R ?x2) = map_pmf bst_of_list (pmf_of_set (permutations_of_set (R ?x2)))

goal (1 subgoal):
 1. \<And>A. \<lbrakk>finite A; \<And>B. B \<subset> A \<Longrightarrow> random_bst B = map_pmf bst_of_list (pmf_of_set (permutations_of_set B))\<rbrakk> \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
proof (cases "A = {}")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. A = {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
 2. A \<noteq> {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
A \<noteq> {}

goal (2 subgoals):
 1. A = {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
 2. A \<noteq> {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
note A = \<open>finite A\<close> \<open>A \<noteq> {}\<close>
[PROOF STATE]
proof (state)
this:
finite A
A \<noteq> {}

goal (2 subgoals):
 1. A = {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
 2. A \<noteq> {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
have "random_bst A =
            do {
              x \<leftarrow> pmf_of_set A;
              (l, r) \<leftarrow> pair_pmf (random_bst (L x)) (random_bst (R x));
              return_pmf (Node l x r)
            }"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. random_bst A = pmf_of_set A \<bind> (\<lambda>x. pair_pmf (random_bst (L x)) (random_bst (R x)) \<bind> (\<lambda>(l, r). return_pmf \<langle>l, x, r\<rangle>))
[PROOF STEP]
using A
[PROOF STATE]
proof (prove)
using this:
finite A
A \<noteq> {}

goal (1 subgoal):
 1. random_bst A = pmf_of_set A \<bind> (\<lambda>x. pair_pmf (random_bst (L x)) (random_bst (R x)) \<bind> (\<lambda>(l, r). return_pmf \<langle>l, x, r\<rangle>))
[PROOF STEP]
unfolding pair_pmf_def L_def R_def
[PROOF STATE]
proof (prove)
using this:
finite A
A \<noteq> {}

goal (1 subgoal):
 1. random_bst A = pmf_of_set A \<bind> (\<lambda>x. random_bst {y \<in> A. y < x} \<bind> (\<lambda>xa. random_bst {y \<in> A. x < y} \<bind> (\<lambda>y. return_pmf (xa, y))) \<bind> (\<lambda>(l, r). return_pmf \<langle>l, x, r\<rangle>))
[PROOF STEP]
by (subst random_bst.simps) (simp add: bind_return_pmf bind_assoc_pmf)
[PROOF STATE]
proof (state)
this:
random_bst A = pmf_of_set A \<bind> (\<lambda>x. pair_pmf (random_bst (L x)) (random_bst (R x)) \<bind> (\<lambda>(l, r). return_pmf \<langle>l, x, r\<rangle>))

goal (2 subgoals):
 1. A = {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
 2. A \<noteq> {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
random_bst A = pmf_of_set A \<bind> (\<lambda>x. pair_pmf (random_bst (L x)) (random_bst (R x)) \<bind> (\<lambda>(l, r). return_pmf \<langle>l, x, r\<rangle>))

goal (2 subgoals):
 1. A = {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
 2. A \<noteq> {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
have "\<dots> = do {
                      x \<leftarrow> pmf_of_set A;
                      (l, r) \<leftarrow> pair_pmf
                        (map_pmf bst_of_list (pmf_of_set (permutations_of_set (L x))))
                        (map_pmf bst_of_list (pmf_of_set (permutations_of_set (R x))));
                      return_pmf (Node l x r)
                    }"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf_of_set A \<bind> (\<lambda>x. pair_pmf (random_bst (L x)) (random_bst (R x)) \<bind> (\<lambda>(l, r). return_pmf \<langle>l, x, r\<rangle>)) = pmf_of_set A \<bind> (\<lambda>x. pair_pmf (map_pmf bst_of_list (pmf_of_set (permutations_of_set (L x)))) (map_pmf bst_of_list (pmf_of_set (permutations_of_set (R x)))) \<bind> (\<lambda>(l, r). return_pmf \<langle>l, x, r\<rangle>))
[PROOF STEP]
using A
[PROOF STATE]
proof (prove)
using this:
finite A
A \<noteq> {}

goal (1 subgoal):
 1. pmf_of_set A \<bind> (\<lambda>x. pair_pmf (random_bst (L x)) (random_bst (R x)) \<bind> (\<lambda>(l, r). return_pmf \<langle>l, x, r\<rangle>)) = pmf_of_set A \<bind> (\<lambda>x. pair_pmf (map_pmf bst_of_list (pmf_of_set (permutations_of_set (L x)))) (map_pmf bst_of_list (pmf_of_set (permutations_of_set (R x)))) \<bind> (\<lambda>(l, r). return_pmf \<langle>l, x, r\<rangle>))
[PROOF STEP]
by (intro bind_pmf_cong refl) (simp_all add: IH)
[PROOF STATE]
proof (state)
this:
pmf_of_set A \<bind> (\<lambda>x. pair_pmf (random_bst (L x)) (random_bst (R x)) \<bind> (\<lambda>(l, r). return_pmf \<langle>l, x, r\<rangle>)) = pmf_of_set A \<bind> (\<lambda>x. pair_pmf (map_pmf bst_of_list (pmf_of_set (permutations_of_set (L x)))) (map_pmf bst_of_list (pmf_of_set (permutations_of_set (R x)))) \<bind> (\<lambda>(l, r). return_pmf \<langle>l, x, r\<rangle>))

goal (2 subgoals):
 1. A = {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
 2. A \<noteq> {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
pmf_of_set A \<bind> (\<lambda>x. pair_pmf (random_bst (L x)) (random_bst (R x)) \<bind> (\<lambda>(l, r). return_pmf \<langle>l, x, r\<rangle>)) = pmf_of_set A \<bind> (\<lambda>x. pair_pmf (map_pmf bst_of_list (pmf_of_set (permutations_of_set (L x)))) (map_pmf bst_of_list (pmf_of_set (permutations_of_set (R x)))) \<bind> (\<lambda>(l, r). return_pmf \<langle>l, x, r\<rangle>))

goal (2 subgoals):
 1. A = {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
 2. A \<noteq> {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
have "\<dots> = do {
                     x \<leftarrow> pmf_of_set A;
                     (ls, rs) \<leftarrow> pair_pmf (pmf_of_set (permutations_of_set (L x)))
                                          (pmf_of_set (permutations_of_set (R x)));
                     return_pmf (Node (bst_of_list ls) x (bst_of_list rs))
                   }"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf_of_set A \<bind> (\<lambda>x. pair_pmf (map_pmf bst_of_list (pmf_of_set (permutations_of_set (L x)))) (map_pmf bst_of_list (pmf_of_set (permutations_of_set (R x)))) \<bind> (\<lambda>(l, r). return_pmf \<langle>l, x, r\<rangle>)) = pmf_of_set A \<bind> (\<lambda>x. pair_pmf (pmf_of_set (permutations_of_set (L x))) (pmf_of_set (permutations_of_set (R x))) \<bind> (\<lambda>(ls, rs). return_pmf \<langle>bst_of_list ls, x, bst_of_list rs\<rangle>))
[PROOF STEP]
unfolding map_pair [symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf_of_set A \<bind> (\<lambda>x. map_pmf (\<lambda>(a, b). (bst_of_list a, bst_of_list b)) (pair_pmf (pmf_of_set (permutations_of_set (L x))) (pmf_of_set (permutations_of_set (R x)))) \<bind> (\<lambda>(l, r). return_pmf \<langle>l, x, r\<rangle>)) = pmf_of_set A \<bind> (\<lambda>x. pair_pmf (pmf_of_set (permutations_of_set (L x))) (pmf_of_set (permutations_of_set (R x))) \<bind> (\<lambda>(ls, rs). return_pmf \<langle>bst_of_list ls, x, bst_of_list rs\<rangle>))
[PROOF STEP]
by (simp add: map_pmf_def case_prod_unfold bind_return_pmf bind_assoc_pmf)
[PROOF STATE]
proof (state)
this:
pmf_of_set A \<bind> (\<lambda>x. pair_pmf (map_pmf bst_of_list (pmf_of_set (permutations_of_set (L x)))) (map_pmf bst_of_list (pmf_of_set (permutations_of_set (R x)))) \<bind> (\<lambda>(l, r). return_pmf \<langle>l, x, r\<rangle>)) = pmf_of_set A \<bind> (\<lambda>x. pair_pmf (pmf_of_set (permutations_of_set (L x))) (pmf_of_set (permutations_of_set (R x))) \<bind> (\<lambda>(ls, rs). return_pmf \<langle>bst_of_list ls, x, bst_of_list rs\<rangle>))

goal (2 subgoals):
 1. A = {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
 2. A \<noteq> {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
pmf_of_set A \<bind> (\<lambda>x. pair_pmf (map_pmf bst_of_list (pmf_of_set (permutations_of_set (L x)))) (map_pmf bst_of_list (pmf_of_set (permutations_of_set (R x)))) \<bind> (\<lambda>(l, r). return_pmf \<langle>l, x, r\<rangle>)) = pmf_of_set A \<bind> (\<lambda>x. pair_pmf (pmf_of_set (permutations_of_set (L x))) (pmf_of_set (permutations_of_set (R x))) \<bind> (\<lambda>(ls, rs). return_pmf \<langle>bst_of_list ls, x, bst_of_list rs\<rangle>))

goal (2 subgoals):
 1. A = {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
 2. A \<noteq> {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
have "L = (\<lambda>x. {y \<in> A - {x}. y \<le> x})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. L = (\<lambda>x. {y \<in> A - {x}. y \<le> x})
[PROOF STEP]
by (auto simp: L_def)
[PROOF STATE]
proof (state)
this:
L = (\<lambda>x. {y \<in> A - {x}. y \<le> x})

goal (2 subgoals):
 1. A = {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
 2. A \<noteq> {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
L = (\<lambda>x. {y \<in> A - {x}. y \<le> x})

goal (2 subgoals):
 1. A = {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
 2. A \<noteq> {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
have "R = (\<lambda>x. {y \<in> A - {x}. \<not>y \<le> x})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. R = (\<lambda>x. {y \<in> A - {x}. \<not> y \<le> x})
[PROOF STEP]
by (auto simp: R_def)
[PROOF STATE]
proof (state)
this:
R = (\<lambda>x. {y \<in> A - {x}. \<not> y \<le> x})

goal (2 subgoals):
 1. A = {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
 2. A \<noteq> {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
R = (\<lambda>x. {y \<in> A - {x}. \<not> y \<le> x})

goal (2 subgoals):
 1. A = {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
 2. A \<noteq> {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
have "do {
                 x \<leftarrow> pmf_of_set A;
                 (ls, rs) \<leftarrow> pair_pmf (pmf_of_set (permutations_of_set {y \<in> A - {x}. y \<le> x}))
                                      (pmf_of_set (permutations_of_set {y \<in> A - {x}. \<not>y \<le> x}));
                 return_pmf (Node (bst_of_list ls) x (bst_of_list rs))
               } =
               do {
                 x \<leftarrow> pmf_of_set A;
                 (ls, rs) \<leftarrow> map_pmf (partition (\<lambda>y. y \<le> x))
                               (pmf_of_set (permutations_of_set (A - {x})));
                 return_pmf (Node (bst_of_list ls) x (bst_of_list rs))
               }"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf_of_set A \<bind> (\<lambda>x. pair_pmf (pmf_of_set (permutations_of_set {y \<in> A - {x}. y \<le> x})) (pmf_of_set (permutations_of_set {y \<in> A - {x}. \<not> y \<le> x})) \<bind> (\<lambda>(ls, rs). return_pmf \<langle>bst_of_list ls, x, bst_of_list rs\<rangle>)) = pmf_of_set A \<bind> (\<lambda>x. map_pmf (partition (\<lambda>y. y \<le> x)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf \<langle>bst_of_list ls, x, bst_of_list rs\<rangle>))
[PROOF STEP]
using \<open>finite A\<close>
[PROOF STATE]
proof (prove)
using this:
finite A

goal (1 subgoal):
 1. pmf_of_set A \<bind> (\<lambda>x. pair_pmf (pmf_of_set (permutations_of_set {y \<in> A - {x}. y \<le> x})) (pmf_of_set (permutations_of_set {y \<in> A - {x}. \<not> y \<le> x})) \<bind> (\<lambda>(ls, rs). return_pmf \<langle>bst_of_list ls, x, bst_of_list rs\<rangle>)) = pmf_of_set A \<bind> (\<lambda>x. map_pmf (partition (\<lambda>y. y \<le> x)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf \<langle>bst_of_list ls, x, bst_of_list rs\<rangle>))
[PROOF STEP]
by (intro bind_pmf_cong refl partition_random_permutations [symmetric]) auto
[PROOF STATE]
proof (state)
this:
pmf_of_set A \<bind> (\<lambda>x. pair_pmf (pmf_of_set (permutations_of_set {y \<in> A - {x}. y \<le> x})) (pmf_of_set (permutations_of_set {y \<in> A - {x}. \<not> y \<le> x})) \<bind> (\<lambda>(ls, rs). return_pmf \<langle>bst_of_list ls, x, bst_of_list rs\<rangle>)) = pmf_of_set A \<bind> (\<lambda>x. map_pmf (partition (\<lambda>y. y \<le> x)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf \<langle>bst_of_list ls, x, bst_of_list rs\<rangle>))

goal (2 subgoals):
 1. A = {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
 2. A \<noteq> {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
pmf_of_set A \<bind> (\<lambda>x. pair_pmf (pmf_of_set (permutations_of_set {y \<in> A - {x}. y \<le> x})) (pmf_of_set (permutations_of_set {y \<in> A - {x}. \<not> y \<le> x})) \<bind> (\<lambda>(ls, rs). return_pmf \<langle>bst_of_list ls, x, bst_of_list rs\<rangle>)) = pmf_of_set A \<bind> (\<lambda>x. map_pmf (partition (\<lambda>y. y \<le> x)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf \<langle>bst_of_list ls, x, bst_of_list rs\<rangle>))

goal (2 subgoals):
 1. A = {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
 2. A \<noteq> {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
have "\<dots> = do {
                      x \<leftarrow> pmf_of_set A;
                      (ls, rs) \<leftarrow> map_pmf (\<lambda>xs. ([y\<leftarrow>xs. y < x], [y\<leftarrow>xs. y > x]))
                                    (pmf_of_set (permutations_of_set (A - {x})));
                      return_pmf (Node (bst_of_list ls) x (bst_of_list rs))
                    }"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf_of_set A \<bind> (\<lambda>x. map_pmf (partition (\<lambda>y. y \<le> x)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf \<langle>bst_of_list ls, x, bst_of_list rs\<rangle>)) = pmf_of_set A \<bind> (\<lambda>x. map_pmf (\<lambda>xs. (filter (\<lambda>y. y < x) xs, filter ((<) x) xs)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf \<langle>bst_of_list ls, x, bst_of_list rs\<rangle>))
[PROOF STEP]
using A
[PROOF STATE]
proof (prove)
using this:
finite A
A \<noteq> {}

goal (1 subgoal):
 1. pmf_of_set A \<bind> (\<lambda>x. map_pmf (partition (\<lambda>y. y \<le> x)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf \<langle>bst_of_list ls, x, bst_of_list rs\<rangle>)) = pmf_of_set A \<bind> (\<lambda>x. map_pmf (\<lambda>xs. (filter (\<lambda>y. y < x) xs, filter ((<) x) xs)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf \<langle>bst_of_list ls, x, bst_of_list rs\<rangle>))
[PROOF STEP]
by (intro bind_pmf_cong refl map_pmf_cong)
         (auto intro!: filter_cong dest: permutations_of_setD simp: order.strict_iff_order)
[PROOF STATE]
proof (state)
this:
pmf_of_set A \<bind> (\<lambda>x. map_pmf (partition (\<lambda>y. y \<le> x)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf \<langle>bst_of_list ls, x, bst_of_list rs\<rangle>)) = pmf_of_set A \<bind> (\<lambda>x. map_pmf (\<lambda>xs. (filter (\<lambda>y. y < x) xs, filter ((<) x) xs)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf \<langle>bst_of_list ls, x, bst_of_list rs\<rangle>))

goal (2 subgoals):
 1. A = {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
 2. A \<noteq> {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
pmf_of_set A \<bind> (\<lambda>x. map_pmf (partition (\<lambda>y. y \<le> x)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf \<langle>bst_of_list ls, x, bst_of_list rs\<rangle>)) = pmf_of_set A \<bind> (\<lambda>x. map_pmf (\<lambda>xs. (filter (\<lambda>y. y < x) xs, filter ((<) x) xs)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf \<langle>bst_of_list ls, x, bst_of_list rs\<rangle>))

goal (2 subgoals):
 1. A = {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
 2. A \<noteq> {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
have "\<dots> = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf_of_set A \<bind> (\<lambda>x. map_pmf (\<lambda>xs. (filter (\<lambda>y. y < x) xs, filter ((<) x) xs)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf \<langle>bst_of_list ls, x, bst_of_list rs\<rangle>)) = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
using A
[PROOF STATE]
proof (prove)
using this:
finite A
A \<noteq> {}

goal (1 subgoal):
 1. pmf_of_set A \<bind> (\<lambda>x. map_pmf (\<lambda>xs. (filter (\<lambda>y. y < x) xs, filter ((<) x) xs)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf \<langle>bst_of_list ls, x, bst_of_list rs\<rangle>)) = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
by (subst random_permutation_of_set[of A])
                 (auto simp: map_pmf_def bind_return_pmf o_def bind_assoc_pmf not_le)
[PROOF STATE]
proof (state)
this:
pmf_of_set A \<bind> (\<lambda>x. map_pmf (\<lambda>xs. (filter (\<lambda>y. y < x) xs, filter ((<) x) xs)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf \<langle>bst_of_list ls, x, bst_of_list rs\<rangle>)) = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))

goal (2 subgoals):
 1. A = {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
 2. A \<noteq> {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))

goal (1 subgoal):
 1. random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))

goal (1 subgoal):
 1. A = {} \<Longrightarrow> random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))
[PROOF STEP]
qed (simp_all add: pmf_of_set_singleton)
[PROOF STATE]
proof (state)
this:
random_bst A = map_pmf bst_of_list (pmf_of_set (permutations_of_set A))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma pairwise_orthogonal_proj_set:
  assumes C: "finite C" and p: "pairwise orthogonal C"
  shows "pairwise orthogonal (insert (a - proj_onto a C) C)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pairwise orthogonal (insert (a - proj_onto a C) C)
[PROOF STEP]
by (rule pairwise_orthogonal_insert[OF p], auto simp add: orthogonal_proj_set C p)


[STATEMENT]
lemma pochhammer_nonneg:
  fixes x :: "'a :: linordered_semidom"
  shows "x > 0 \<Longrightarrow> pochhammer x n \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0::'a) < x \<Longrightarrow> (0::'a) \<le> pochhammer x n
[PROOF STEP]
by (induction n) (auto simp: pochhammer_Suc intro!: mult_nonneg_nonneg add_nonneg_nonneg)


[STATEMENT]
lemma topspace_topology\<^sub>N [simp]:
  assumes "defect N = 1" shows "topspace (topology\<^sub>N N) = UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. topspace (topology\<^sub>N N) = UNIV
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. topspace (topology\<^sub>N N) = UNIV
[PROOF STEP]
have "x \<in> topspace (topology\<^sub>N N)" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> topspace (topology\<^sub>N N)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x \<in> topspace (topology\<^sub>N N)
[PROOF STEP]
have "\<exists>e>0. \<forall>y. eNorm N (y - x') < e \<longrightarrow> eNorm N (y - x) < 1"
      if "eNorm N (x' - x) < 1" for x'
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>e>0. \<forall>y. eNorm N (y - x') < e \<longrightarrow> eNorm N (y - x) < 1
[PROOF STEP]
using eNorm_triangle_eps
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>eNorm ?N (?x' - ?x) < ?a; defect ?N = 1; \<And>e. \<lbrakk>0 < e; \<And>y. eNorm ?N (y - ?x') < e \<Longrightarrow> eNorm ?N (y - ?x) < ?a\<rbrakk> \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. \<exists>e>0. \<forall>y. eNorm N (y - x') < e \<longrightarrow> eNorm N (y - x) < 1
[PROOF STEP]
by (metis assms that)
[PROOF STATE]
proof (state)
this:
eNorm N (?x' - x) < 1 \<Longrightarrow> \<exists>e>0. \<forall>y. eNorm N (y - ?x') < e \<longrightarrow> eNorm N (y - x) < 1

goal (1 subgoal):
 1. x \<in> topspace (topology\<^sub>N N)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
eNorm N (?x' - x) < 1 \<Longrightarrow> \<exists>e>0. \<forall>y. eNorm N (y - ?x') < e \<longrightarrow> eNorm N (y - x) < 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
eNorm N (?x' - x) < 1 \<Longrightarrow> \<exists>e>0. \<forall>y. eNorm N (y - ?x') < e \<longrightarrow> eNorm N (y - x) < 1

goal (1 subgoal):
 1. x \<in> topspace (topology\<^sub>N N)
[PROOF STEP]
unfolding topspace_def
[PROOF STATE]
proof (prove)
using this:
eNorm N (?x' - x) < 1 \<Longrightarrow> \<exists>e>0. \<forall>y. eNorm N (y - ?x') < e \<longrightarrow> eNorm N (y - x) < 1

goal (1 subgoal):
 1. x \<in> \<Union> (Collect (openin (topology\<^sub>N N)))
[PROOF STEP]
by (rule_tac X="{y. eNorm N (y - x) < 1}" in UnionI) (auto intro: openin_topology\<^sub>N_I)
[PROOF STATE]
proof (state)
this:
x \<in> topspace (topology\<^sub>N N)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?x \<in> topspace (topology\<^sub>N N)

goal (1 subgoal):
 1. topspace (topology\<^sub>N N) = UNIV
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?x \<in> topspace (topology\<^sub>N N)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
?x \<in> topspace (topology\<^sub>N N)

goal (1 subgoal):
 1. topspace (topology\<^sub>N N) = UNIV
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
topspace (topology\<^sub>N N) = UNIV

goal:
No subgoals!
[PROOF STEP]
qed