[STATEMENT]
lemma homeomorphic_rel_interiors_same_dimension:
  fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set"
  assumes "S homeomorphic T" and aff: "aff_dim S = aff_dim T"
  shows "(rel_interior S) homeomorphic (rel_interior T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rel_interior S homeomorphic rel_interior T
[PROOF STEP]
using assms [unfolded homeomorphic_minimal]
[PROOF STATE]
proof (prove)
using this:
\<exists>f g. (\<forall>x\<in>S. f x \<in> T \<and> g (f x) = x) \<and> (\<forall>y\<in>T. g y \<in> S \<and> f (g y) = y) \<and> continuous_on S f \<and> continuous_on T g
aff_dim S = aff_dim T

goal (1 subgoal):
 1. rel_interior S homeomorphic rel_interior T
[PROOF STEP]
unfolding homeomorphic_def
[PROOF STATE]
proof (prove)
using this:
\<exists>f g. (\<forall>x\<in>S. f x \<in> T \<and> g (f x) = x) \<and> (\<forall>y\<in>T. g y \<in> S \<and> f (g y) = y) \<and> continuous_on S f \<and> continuous_on T g
aff_dim S = aff_dim T

goal (1 subgoal):
 1. \<exists>f g. homeomorphism (rel_interior S) (rel_interior T) f g
[PROOF STEP]
proof (clarify elim!: ex_forward)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>f g. \<lbrakk>aff_dim S = aff_dim T; \<forall>x\<in>S. f x \<in> T \<and> g (f x) = x; \<forall>y\<in>T. g y \<in> S \<and> f (g y) = y; continuous_on S f; continuous_on T g\<rbrakk> \<Longrightarrow> homeomorphism (rel_interior S) (rel_interior T) f g
[PROOF STEP]
fix f g
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>f g. \<lbrakk>aff_dim S = aff_dim T; \<forall>x\<in>S. f x \<in> T \<and> g (f x) = x; \<forall>y\<in>T. g y \<in> S \<and> f (g y) = y; continuous_on S f; continuous_on T g\<rbrakk> \<Longrightarrow> homeomorphism (rel_interior S) (rel_interior T) f g
[PROOF STEP]
assume S: "\<forall>x\<in>S. f x \<in> T \<and> g (f x) = x" and T: "\<forall>y\<in>T. g y \<in> S \<and> f (g y) = y"
     and contf: "continuous_on S f" and contg: "continuous_on T g"
[PROOF STATE]
proof (state)
this:
\<forall>x\<in>S. f x \<in> T \<and> g (f x) = x
\<forall>y\<in>T. g y \<in> S \<and> f (g y) = y
continuous_on S f
continuous_on T g

goal (1 subgoal):
 1. \<And>f g. \<lbrakk>aff_dim S = aff_dim T; \<forall>x\<in>S. f x \<in> T \<and> g (f x) = x; \<forall>y\<in>T. g y \<in> S \<and> f (g y) = y; continuous_on S f; continuous_on T g\<rbrakk> \<Longrightarrow> homeomorphism (rel_interior S) (rel_interior T) f g
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>x\<in>S. f x \<in> T \<and> g (f x) = x
\<forall>y\<in>T. g y \<in> S \<and> f (g y) = y
continuous_on S f
continuous_on T g
[PROOF STEP]
have fST: "f ` S = T" and gTS: "g ` T = S" and "inj_on f S" "inj_on g T"
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>S. f x \<in> T \<and> g (f x) = x
\<forall>y\<in>T. g y \<in> S \<and> f (g y) = y
continuous_on S f
continuous_on T g

goal (1 subgoal):
 1. f ` S = T &&& g ` T = S &&& inj_on f S &&& inj_on g T
[PROOF STEP]
by (auto simp: inj_on_def intro: rev_image_eqI) metis+
[PROOF STATE]
proof (state)
this:
f ` S = T
g ` T = S
inj_on f S
inj_on g T

goal (1 subgoal):
 1. \<And>f g. \<lbrakk>aff_dim S = aff_dim T; \<forall>x\<in>S. f x \<in> T \<and> g (f x) = x; \<forall>y\<in>T. g y \<in> S \<and> f (g y) = y; continuous_on S f; continuous_on T g\<rbrakk> \<Longrightarrow> homeomorphism (rel_interior S) (rel_interior T) f g
[PROOF STEP]
have fim: "f ` rel_interior S \<subseteq> rel_interior T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f ` rel_interior S \<subseteq> rel_interior T
[PROOF STEP]
by (metis \<open>inj_on f S\<close> aff contf continuous_image_subset_rel_interior fST order_refl)
[PROOF STATE]
proof (state)
this:
f ` rel_interior S \<subseteq> rel_interior T

goal (1 subgoal):
 1. \<And>f g. \<lbrakk>aff_dim S = aff_dim T; \<forall>x\<in>S. f x \<in> T \<and> g (f x) = x; \<forall>y\<in>T. g y \<in> S \<and> f (g y) = y; continuous_on S f; continuous_on T g\<rbrakk> \<Longrightarrow> homeomorphism (rel_interior S) (rel_interior T) f g
[PROOF STEP]
have gim: "g ` rel_interior T \<subseteq> rel_interior S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g ` rel_interior T \<subseteq> rel_interior S
[PROOF STEP]
by (metis \<open>inj_on g T\<close> aff contg continuous_image_subset_rel_interior gTS order_refl)
[PROOF STATE]
proof (state)
this:
g ` rel_interior T \<subseteq> rel_interior S

goal (1 subgoal):
 1. \<And>f g. \<lbrakk>aff_dim S = aff_dim T; \<forall>x\<in>S. f x \<in> T \<and> g (f x) = x; \<forall>y\<in>T. g y \<in> S \<and> f (g y) = y; continuous_on S f; continuous_on T g\<rbrakk> \<Longrightarrow> homeomorphism (rel_interior S) (rel_interior T) f g
[PROOF STEP]
show "homeomorphism (rel_interior S) (rel_interior T) f g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. homeomorphism (rel_interior S) (rel_interior T) f g
[PROOF STEP]
unfolding homeomorphism_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x\<in>rel_interior S. g (f x) = x) \<and> f ` rel_interior S = rel_interior T \<and> continuous_on (rel_interior S) f \<and> (\<forall>y\<in>rel_interior T. f (g y) = y) \<and> g ` rel_interior T = rel_interior S \<and> continuous_on (rel_interior T) g
[PROOF STEP]
proof (intro conjI ballI)
[PROOF STATE]
proof (state)
goal (6 subgoals):
 1. \<And>x. x \<in> rel_interior S \<Longrightarrow> g (f x) = x
 2. f ` rel_interior S = rel_interior T
 3. continuous_on (rel_interior S) f
 4. \<And>y. y \<in> rel_interior T \<Longrightarrow> f (g y) = y
 5. g ` rel_interior T = rel_interior S
 6. continuous_on (rel_interior T) g
[PROOF STEP]
show gf: "\<And>x. x \<in> rel_interior S \<Longrightarrow> g (f x) = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> rel_interior S \<Longrightarrow> g (f x) = x
[PROOF STEP]
using S rel_interior_subset
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>S. f x \<in> T \<and> g (f x) = x
rel_interior ?S \<subseteq> ?S

goal (1 subgoal):
 1. \<And>x. x \<in> rel_interior S \<Longrightarrow> g (f x) = x
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
?x \<in> rel_interior S \<Longrightarrow> g (f ?x) = ?x

goal (5 subgoals):
 1. f ` rel_interior S = rel_interior T
 2. continuous_on (rel_interior S) f
 3. \<And>y. y \<in> rel_interior T \<Longrightarrow> f (g y) = y
 4. g ` rel_interior T = rel_interior S
 5. continuous_on (rel_interior T) g
[PROOF STEP]
show fg: "\<And>y. y \<in> rel_interior T \<Longrightarrow> f (g y) = y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>y. y \<in> rel_interior T \<Longrightarrow> f (g y) = y
[PROOF STEP]
using T mem_rel_interior_ball
[PROOF STATE]
proof (prove)
using this:
\<forall>y\<in>T. g y \<in> S \<and> f (g y) = y
(?x \<in> rel_interior ?S) = (?x \<in> ?S \<and> (\<exists>e>0. ball ?x e \<inter> affine hull ?S \<subseteq> ?S))

goal (1 subgoal):
 1. \<And>y. y \<in> rel_interior T \<Longrightarrow> f (g y) = y
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
?y \<in> rel_interior T \<Longrightarrow> f (g ?y) = ?y

goal (4 subgoals):
 1. f ` rel_interior S = rel_interior T
 2. continuous_on (rel_interior S) f
 3. g ` rel_interior T = rel_interior S
 4. continuous_on (rel_interior T) g
[PROOF STEP]
have "rel_interior T \<subseteq> f ` rel_interior S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rel_interior T \<subseteq> f ` rel_interior S
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> rel_interior T \<Longrightarrow> x \<in> f ` rel_interior S
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> rel_interior T \<Longrightarrow> x \<in> f ` rel_interior S
[PROOF STEP]
assume "x \<in> rel_interior T"
[PROOF STATE]
proof (state)
this:
x \<in> rel_interior T

goal (1 subgoal):
 1. \<And>x. x \<in> rel_interior T \<Longrightarrow> x \<in> f ` rel_interior S
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> rel_interior T
[PROOF STEP]
have "g x \<in> rel_interior S"
[PROOF STATE]
proof (prove)
using this:
x \<in> rel_interior T

goal (1 subgoal):
 1. g x \<in> rel_interior S
[PROOF STEP]
using gim
[PROOF STATE]
proof (prove)
using this:
x \<in> rel_interior T
g ` rel_interior T \<subseteq> rel_interior S

goal (1 subgoal):
 1. g x \<in> rel_interior S
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
g x \<in> rel_interior S

goal (1 subgoal):
 1. \<And>x. x \<in> rel_interior T \<Longrightarrow> x \<in> f ` rel_interior S
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
g x \<in> rel_interior S
[PROOF STEP]
show "x \<in> f ` rel_interior S"
[PROOF STATE]
proof (prove)
using this:
g x \<in> rel_interior S

goal (1 subgoal):
 1. x \<in> f ` rel_interior S
[PROOF STEP]
by (metis fg \<open>x \<in> rel_interior T\<close> imageI)
[PROOF STATE]
proof (state)
this:
x \<in> f ` rel_interior S

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
rel_interior T \<subseteq> f ` rel_interior S

goal (4 subgoals):
 1. f ` rel_interior S = rel_interior T
 2. continuous_on (rel_interior S) f
 3. g ` rel_interior T = rel_interior S
 4. continuous_on (rel_interior T) g
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
rel_interior T \<subseteq> f ` rel_interior S

goal (4 subgoals):
 1. f ` rel_interior S = rel_interior T
 2. continuous_on (rel_interior S) f
 3. g ` rel_interior T = rel_interior S
 4. continuous_on (rel_interior T) g
[PROOF STEP]
have "f ` rel_interior S \<subseteq> rel_interior T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f ` rel_interior S \<subseteq> rel_interior T
[PROOF STEP]
by (metis \<open>inj_on f S\<close> aff contf continuous_image_subset_rel_interior fST order_refl)
[PROOF STATE]
proof (state)
this:
f ` rel_interior S \<subseteq> rel_interior T

goal (4 subgoals):
 1. f ` rel_interior S = rel_interior T
 2. continuous_on (rel_interior S) f
 3. g ` rel_interior T = rel_interior S
 4. continuous_on (rel_interior T) g
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
rel_interior T \<subseteq> f ` rel_interior S
f ` rel_interior S \<subseteq> rel_interior T
[PROOF STEP]
show "f ` rel_interior S = rel_interior T"
[PROOF STATE]
proof (prove)
using this:
rel_interior T \<subseteq> f ` rel_interior S
f ` rel_interior S \<subseteq> rel_interior T

goal (1 subgoal):
 1. f ` rel_interior S = rel_interior T
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
f ` rel_interior S = rel_interior T

goal (3 subgoals):
 1. continuous_on (rel_interior S) f
 2. g ` rel_interior T = rel_interior S
 3. continuous_on (rel_interior T) g
[PROOF STEP]
show "continuous_on (rel_interior S) f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous_on (rel_interior S) f
[PROOF STEP]
using contf continuous_on_subset rel_interior_subset
[PROOF STATE]
proof (prove)
using this:
continuous_on S f
\<lbrakk>continuous_on ?s ?f; ?t \<subseteq> ?s\<rbrakk> \<Longrightarrow> continuous_on ?t ?f
rel_interior ?S \<subseteq> ?S

goal (1 subgoal):
 1. continuous_on (rel_interior S) f
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
continuous_on (rel_interior S) f

goal (2 subgoals):
 1. g ` rel_interior T = rel_interior S
 2. continuous_on (rel_interior T) g
[PROOF STEP]
have "rel_interior S \<subseteq> g ` rel_interior T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rel_interior S \<subseteq> g ` rel_interior T
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> rel_interior S \<Longrightarrow> x \<in> g ` rel_interior T
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> rel_interior S \<Longrightarrow> x \<in> g ` rel_interior T
[PROOF STEP]
assume "x \<in> rel_interior S"
[PROOF STATE]
proof (state)
this:
x \<in> rel_interior S

goal (1 subgoal):
 1. \<And>x. x \<in> rel_interior S \<Longrightarrow> x \<in> g ` rel_interior T
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> rel_interior S
[PROOF STEP]
have "f x \<in> rel_interior T"
[PROOF STATE]
proof (prove)
using this:
x \<in> rel_interior S

goal (1 subgoal):
 1. f x \<in> rel_interior T
[PROOF STEP]
using fim
[PROOF STATE]
proof (prove)
using this:
x \<in> rel_interior S
f ` rel_interior S \<subseteq> rel_interior T

goal (1 subgoal):
 1. f x \<in> rel_interior T
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
f x \<in> rel_interior T

goal (1 subgoal):
 1. \<And>x. x \<in> rel_interior S \<Longrightarrow> x \<in> g ` rel_interior T
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f x \<in> rel_interior T
[PROOF STEP]
show "x \<in> g ` rel_interior T"
[PROOF STATE]
proof (prove)
using this:
f x \<in> rel_interior T

goal (1 subgoal):
 1. x \<in> g ` rel_interior T
[PROOF STEP]
by (metis gf \<open>x \<in> rel_interior S\<close> imageI)
[PROOF STATE]
proof (state)
this:
x \<in> g ` rel_interior T

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
rel_interior S \<subseteq> g ` rel_interior T

goal (2 subgoals):
 1. g ` rel_interior T = rel_interior S
 2. continuous_on (rel_interior T) g
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
rel_interior S \<subseteq> g ` rel_interior T
[PROOF STEP]
show "g ` rel_interior T = rel_interior S"
[PROOF STATE]
proof (prove)
using this:
rel_interior S \<subseteq> g ` rel_interior T

goal (1 subgoal):
 1. g ` rel_interior T = rel_interior S
[PROOF STEP]
using gim
[PROOF STATE]
proof (prove)
using this:
rel_interior S \<subseteq> g ` rel_interior T
g ` rel_interior T \<subseteq> rel_interior S

goal (1 subgoal):
 1. g ` rel_interior T = rel_interior S
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
g ` rel_interior T = rel_interior S

goal (1 subgoal):
 1. continuous_on (rel_interior T) g
[PROOF STEP]
show "continuous_on (rel_interior T) g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous_on (rel_interior T) g
[PROOF STEP]
using contg continuous_on_subset rel_interior_subset
[PROOF STATE]
proof (prove)
using this:
continuous_on T g
\<lbrakk>continuous_on ?s ?f; ?t \<subseteq> ?s\<rbrakk> \<Longrightarrow> continuous_on ?t ?f
rel_interior ?S \<subseteq> ?S

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
homeomorphism (rel_interior S) (rel_interior T) f g

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma in_listsp_conv_set: "(listsp A xs) = (\<forall>x \<in> set xs. A x)"
\<comment> \<open>eliminate \<open>listsp\<close> in favour of \<open>set\<close>\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. listsp A xs = (\<forall>x\<in>set xs. A x)
[PROOF STEP]
by (induct xs) auto


[STATEMENT]
lemma sorted_key_list_of_set_unique:
  assumes "A \<subseteq> S" and "finite A"
  shows "sorted_wrt (\<prec>) (map f l) \<and> set l = A \<and> length l = card A
        \<longleftrightarrow> sorted_key_list_of_set f A = l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (sorted_wrt (\<prec>) (map f l) \<and> set l = A \<and> length l = card A) = (lo.sorted_key_list_of_set f A = l)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
A \<subseteq> S
finite A

goal (1 subgoal):
 1. (sorted_wrt (\<prec>) (map f l) \<and> set l = A \<and> length l = card A) = (lo.sorted_key_list_of_set f A = l)
[PROOF STEP]
by (auto simp: strict_sorted_iff card_distinct idem_if_sorted_distinct)


[STATEMENT]
theorem (in sturm_seq) count_roots_between:
  assumes [simp]: "p \<noteq> 0" "a \<le> b"
  shows "sign_changes ps a - sign_changes ps b =
             card {x. x > a \<and> x \<le> b \<and> poly p x = 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sign_changes ps a - sign_changes ps b = card {x. a < x \<and> x \<le> b \<and> poly p x = 0}
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. sign_changes ps a - sign_changes ps b = card {x. a < x \<and> x \<le> b \<and> poly p x = 0}
[PROOF STEP]
have "sign_changes ps a - int (sign_changes ps b) =
             card {x. x > a \<and> x \<le> b \<and> poly p x = 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
using \<open>a \<le> b\<close>
[PROOF STATE]
proof (prove)
using this:
a \<le> b

goal (1 subgoal):
 1. int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
proof (induction "card {x. x > a \<and> x \<le> b \<and> poly p x = 0}" arbitrary: a b
             rule: less_induct)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a b. \<lbrakk>\<And>aa ba. \<lbrakk>card {x. aa < x \<and> x \<le> ba \<and> poly p x = 0} < card {x. a < x \<and> x \<le> b \<and> poly p x = 0}; aa \<le> ba\<rbrakk> \<Longrightarrow> int (sign_changes ps aa) - int (sign_changes ps ba) = int (card {x. aa < x \<and> x \<le> ba \<and> poly p x = 0}); a \<le> b\<rbrakk> \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
case (less a b)
[PROOF STATE]
proof (state)
this:
\<lbrakk>card {x. ?a < x \<and> x \<le> ?b \<and> poly p x = 0} < card {x. a < x \<and> x \<le> b \<and> poly p x = 0}; ?a \<le> ?b\<rbrakk> \<Longrightarrow> int (sign_changes ps ?a) - int (sign_changes ps ?b) = int (card {x. ?a < x \<and> x \<le> ?b \<and> poly p x = 0})
a \<le> b

goal (1 subgoal):
 1. \<And>a b. \<lbrakk>\<And>aa ba. \<lbrakk>card {x. aa < x \<and> x \<le> ba \<and> poly p x = 0} < card {x. a < x \<and> x \<le> b \<and> poly p x = 0}; aa \<le> ba\<rbrakk> \<Longrightarrow> int (sign_changes ps aa) - int (sign_changes ps ba) = int (card {x. aa < x \<and> x \<le> ba \<and> poly p x = 0}); a \<le> b\<rbrakk> \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
proof (cases "\<exists>x. a < x \<and> x \<le> b \<and> poly p x = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
 2. \<not> (\<exists>x>a. x \<le> b \<and> poly p x = 0) \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> (\<exists>x>a. x \<le> b \<and> poly p x = 0)

goal (2 subgoals):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
 2. \<not> (\<exists>x>a. x \<le> b \<and> poly p x = 0) \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
hence no_roots: "{x. a < x \<and> x \<le> b \<and> poly p x = 0} = {}"
              (is "?roots=_")
[PROOF STATE]
proof (prove)
using this:
\<not> (\<exists>x>a. x \<le> b \<and> poly p x = 0)

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

goal (2 subgoals):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
 2. \<not> (\<exists>x>a. x \<le> b \<and> poly p x = 0) \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
hence card_roots: "card ?roots = (0::int)"
[PROOF STATE]
proof (prove)
using this:
{x. a < x \<and> x \<le> b \<and> poly p x = 0} = {}

goal (1 subgoal):
 1. int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0}) = 0
[PROOF STEP]
by (subst no_roots, simp)
[PROOF STATE]
proof (state)
this:
int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0}) = 0

goal (2 subgoals):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
 2. \<not> (\<exists>x>a. x \<le> b \<and> poly p x = 0) \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
proof (simp only: card_roots eq_iff_diff_eq_0[symmetric] of_nat_eq_iff,
                 cases "poly p a = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. poly p a = 0 \<Longrightarrow> sign_changes ps a = sign_changes ps b
 2. poly p a \<noteq> 0 \<Longrightarrow> sign_changes ps a = sign_changes ps b
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
poly p a \<noteq> 0

goal (2 subgoals):
 1. poly p a = 0 \<Longrightarrow> sign_changes ps a = sign_changes ps b
 2. poly p a \<noteq> 0 \<Longrightarrow> sign_changes ps a = sign_changes ps b
[PROOF STEP]
with no_roots
[PROOF STATE]
proof (chain)
picking this:
{x. a < x \<and> x \<le> b \<and> poly p x = 0} = {}
poly p a \<noteq> 0
[PROOF STEP]
show "sign_changes ps a = sign_changes ps b"
[PROOF STATE]
proof (prove)
using this:
{x. a < x \<and> x \<le> b \<and> poly p x = 0} = {}
poly p a \<noteq> 0

goal (1 subgoal):
 1. sign_changes ps a = sign_changes ps b
[PROOF STEP]
by (force intro: fun_eq_in_ivl \<open>a \<le> b\<close>
                                   p_nonzero_imp_sign_changes_const)
[PROOF STATE]
proof (state)
this:
sign_changes ps a = sign_changes ps b

goal (1 subgoal):
 1. poly p a = 0 \<Longrightarrow> sign_changes ps a = sign_changes ps b
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. poly p a = 0 \<Longrightarrow> sign_changes ps a = sign_changes ps b
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
poly p a = 0

goal (1 subgoal):
 1. poly p a = 0 \<Longrightarrow> sign_changes ps a = sign_changes ps b
[PROOF STEP]
have A: "\<forall>x. a < x \<and> x \<le> b \<longrightarrow> sign_changes ps x = sign_changes ps b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x. a < x \<and> x \<le> b \<longrightarrow> sign_changes ps x = sign_changes ps b
[PROOF STEP]
apply (rule count_roots_between_aux, fact, clarify)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>a < x; x \<le> b\<rbrakk> \<Longrightarrow> \<forall>\<^sub>F \<xi> in at x. sign_changes ps \<xi> = sign_changes ps x
[PROOF STEP]
apply (rule p_nonzero_imp_sign_changes_const)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>a < x; x \<le> b\<rbrakk> \<Longrightarrow> poly p x \<noteq> 0
[PROOF STEP]
apply (insert False, simp)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
\<forall>x. a < x \<and> x \<le> b \<longrightarrow> sign_changes ps x = sign_changes ps b

goal (1 subgoal):
 1. poly p a = 0 \<Longrightarrow> sign_changes ps a = sign_changes ps b
[PROOF STEP]
have "eventually (\<lambda>x. x > a \<longrightarrow>
                        sign_changes ps x = sign_changes ps a) (at a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in at a. a < x \<longrightarrow> sign_changes ps x = sign_changes ps a
[PROOF STEP]
apply (rule eventually_mono [OF p_zero[OF \<open>poly p a = 0\<close> \<open>p \<noteq> 0\<close>]])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. sign_changes ps x = sign_changes ps a + (if x < a then 1 else 0) \<Longrightarrow> a < x \<longrightarrow> sign_changes ps x = sign_changes ps a
[PROOF STEP]
apply force
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in at a. a < x \<longrightarrow> sign_changes ps x = sign_changes ps a

goal (1 subgoal):
 1. poly p a = 0 \<Longrightarrow> sign_changes ps a = sign_changes ps b
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>\<^sub>F x in at a. a < x \<longrightarrow> sign_changes ps x = sign_changes ps a
[PROOF STEP]
obtain \<delta> where \<delta>_props:
                  "\<delta> > 0" "\<forall>x. x > a \<and> x < a+\<delta> \<longrightarrow>
                                   sign_changes ps x = sign_changes ps a"
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in at a. a < x \<longrightarrow> sign_changes ps x = sign_changes ps a

goal (1 subgoal):
 1. (\<And>\<delta>. \<lbrakk>0 < \<delta>; \<forall>x. a < x \<and> x < a + \<delta> \<longrightarrow> sign_changes ps x = sign_changes ps a\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: eventually_at dist_real_def)
[PROOF STATE]
proof (state)
this:
0 < \<delta>
\<forall>x. a < x \<and> x < a + \<delta> \<longrightarrow> sign_changes ps x = sign_changes ps a

goal (1 subgoal):
 1. poly p a = 0 \<Longrightarrow> sign_changes ps a = sign_changes ps b
[PROOF STEP]
show "sign_changes ps a = sign_changes ps b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sign_changes ps a = sign_changes ps b
[PROOF STEP]
proof (cases "a = b")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. a = b \<Longrightarrow> sign_changes ps a = sign_changes ps b
 2. a \<noteq> b \<Longrightarrow> sign_changes ps a = sign_changes ps b
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
a \<noteq> b

goal (2 subgoals):
 1. a = b \<Longrightarrow> sign_changes ps a = sign_changes ps b
 2. a \<noteq> b \<Longrightarrow> sign_changes ps a = sign_changes ps b
[PROOF STEP]
define x where "x = min (a+\<delta>/2) b"
[PROOF STATE]
proof (state)
this:
x = min (a + \<delta> / 2) b

goal (2 subgoals):
 1. a = b \<Longrightarrow> sign_changes ps a = sign_changes ps b
 2. a \<noteq> b \<Longrightarrow> sign_changes ps a = sign_changes ps b
[PROOF STEP]
with False
[PROOF STATE]
proof (chain)
picking this:
a \<noteq> b
x = min (a + \<delta> / 2) b
[PROOF STEP]
have "a < x" "x < a+\<delta>" "x \<le> b"
[PROOF STATE]
proof (prove)
using this:
a \<noteq> b
x = min (a + \<delta> / 2) b

goal (1 subgoal):
 1. a < x &&& x < a + \<delta> &&& x \<le> b
[PROOF STEP]
using \<open>\<delta> > 0\<close> \<open>a \<le> b\<close>
[PROOF STATE]
proof (prove)
using this:
a \<noteq> b
x = min (a + \<delta> / 2) b
0 < \<delta>
a \<le> b

goal (1 subgoal):
 1. a < x &&& x < a + \<delta> &&& x \<le> b
[PROOF STEP]
by simp_all
[PROOF STATE]
proof (state)
this:
a < x
x < a + \<delta>
x \<le> b

goal (2 subgoals):
 1. a = b \<Longrightarrow> sign_changes ps a = sign_changes ps b
 2. a \<noteq> b \<Longrightarrow> sign_changes ps a = sign_changes ps b
[PROOF STEP]
from \<delta>_props \<open>a < x\<close> \<open>x < a+\<delta>\<close>
[PROOF STATE]
proof (chain)
picking this:
0 < \<delta>
\<forall>x. a < x \<and> x < a + \<delta> \<longrightarrow> sign_changes ps x = sign_changes ps a
a < x
x < a + \<delta>
[PROOF STEP]
have "sign_changes ps a = sign_changes ps x"
[PROOF STATE]
proof (prove)
using this:
0 < \<delta>
\<forall>x. a < x \<and> x < a + \<delta> \<longrightarrow> sign_changes ps x = sign_changes ps a
a < x
x < a + \<delta>

goal (1 subgoal):
 1. sign_changes ps a = sign_changes ps x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sign_changes ps a = sign_changes ps x

goal (2 subgoals):
 1. a = b \<Longrightarrow> sign_changes ps a = sign_changes ps b
 2. a \<noteq> b \<Longrightarrow> sign_changes ps a = sign_changes ps b
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sign_changes ps a = sign_changes ps x

goal (2 subgoals):
 1. a = b \<Longrightarrow> sign_changes ps a = sign_changes ps b
 2. a \<noteq> b \<Longrightarrow> sign_changes ps a = sign_changes ps b
[PROOF STEP]
from A \<open>a < x\<close> \<open>x \<le> b\<close>
[PROOF STATE]
proof (chain)
picking this:
\<forall>x. a < x \<and> x \<le> b \<longrightarrow> sign_changes ps x = sign_changes ps b
a < x
x \<le> b
[PROOF STEP]
have "... = sign_changes ps b"
[PROOF STATE]
proof (prove)
using this:
\<forall>x. a < x \<and> x \<le> b \<longrightarrow> sign_changes ps x = sign_changes ps b
a < x
x \<le> b

goal (1 subgoal):
 1. sign_changes ps x = sign_changes ps b
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
sign_changes ps x = sign_changes ps b

goal (2 subgoals):
 1. a = b \<Longrightarrow> sign_changes ps a = sign_changes ps b
 2. a \<noteq> b \<Longrightarrow> sign_changes ps a = sign_changes ps b
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sign_changes ps a = sign_changes ps b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
sign_changes ps a = sign_changes ps b

goal (1 subgoal):
 1. sign_changes ps a = sign_changes ps b
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
sign_changes ps a = sign_changes ps b

goal (1 subgoal):
 1. a = b \<Longrightarrow> sign_changes ps a = sign_changes ps b
[PROOF STEP]
qed simp
[PROOF STATE]
proof (state)
this:
sign_changes ps a = sign_changes ps b

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
\<exists>x>a. x \<le> b \<and> poly p x = 0

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
from poly_roots_finite[OF assms(1)]
[PROOF STATE]
proof (chain)
picking this:
finite {x. poly p x = 0}
[PROOF STEP]
have fin: "finite {x. x > a \<and> x \<le> b \<and> poly p x = 0}"
[PROOF STATE]
proof (prove)
using this:
finite {x. poly p x = 0}

goal (1 subgoal):
 1. finite {x. a < x \<and> x \<le> b \<and> poly p x = 0}
[PROOF STEP]
by (force intro: finite_subset)
[PROOF STATE]
proof (state)
this:
finite {x. a < x \<and> x \<le> b \<and> poly p x = 0}

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
from True
[PROOF STATE]
proof (chain)
picking this:
\<exists>x>a. x \<le> b \<and> poly p x = 0
[PROOF STEP]
have "{x. x > a \<and> x \<le> b \<and> poly p x = 0} \<noteq> {}"
[PROOF STATE]
proof (prove)
using this:
\<exists>x>a. x \<le> b \<and> poly p x = 0

goal (1 subgoal):
 1. {x. a < x \<and> x \<le> b \<and> poly p x = 0} \<noteq> {}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
{x. a < x \<and> x \<le> b \<and> poly p x = 0} \<noteq> {}

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
with fin
[PROOF STATE]
proof (chain)
picking this:
finite {x. a < x \<and> x \<le> b \<and> poly p x = 0}
{x. a < x \<and> x \<le> b \<and> poly p x = 0} \<noteq> {}
[PROOF STEP]
have card_greater_0:
              "card {x. x > a \<and> x \<le> b \<and> poly p x = 0} > 0"
[PROOF STATE]
proof (prove)
using this:
finite {x. a < x \<and> x \<le> b \<and> poly p x = 0}
{x. a < x \<and> x \<le> b \<and> poly p x = 0} \<noteq> {}

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

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
define x\<^sub>2 where "x\<^sub>2 = Min {x. x > a \<and> x \<le> b \<and> poly p x = 0}"
[PROOF STATE]
proof (state)
this:
x\<^sub>2 = Min {x. a < x \<and> x \<le> b \<and> poly p x = 0}

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
from Min_in[OF fin] and True
[PROOF STATE]
proof (chain)
picking this:
{x. a < x \<and> x \<le> b \<and> poly p x = 0} \<noteq> {} \<Longrightarrow> Min {x. a < x \<and> x \<le> b \<and> poly p x = 0} \<in> {x. a < x \<and> x \<le> b \<and> poly p x = 0}
\<exists>x>a. x \<le> b \<and> poly p x = 0
[PROOF STEP]
have x\<^sub>2_props: "x\<^sub>2 > a" "x\<^sub>2 \<le> b" "poly p x\<^sub>2 = 0"
[PROOF STATE]
proof (prove)
using this:
{x. a < x \<and> x \<le> b \<and> poly p x = 0} \<noteq> {} \<Longrightarrow> Min {x. a < x \<and> x \<le> b \<and> poly p x = 0} \<in> {x. a < x \<and> x \<le> b \<and> poly p x = 0}
\<exists>x>a. x \<le> b \<and> poly p x = 0

goal (1 subgoal):
 1. a < x\<^sub>2 &&& x\<^sub>2 \<le> b &&& poly p x\<^sub>2 = 0
[PROOF STEP]
unfolding x\<^sub>2_def
[PROOF STATE]
proof (prove)
using this:
{x. a < x \<and> x \<le> b \<and> poly p x = 0} \<noteq> {} \<Longrightarrow> Min {x. a < x \<and> x \<le> b \<and> poly p x = 0} \<in> {x. a < x \<and> x \<le> b \<and> poly p x = 0}
\<exists>x>a. x \<le> b \<and> poly p x = 0

goal (1 subgoal):
 1. a < Min {x. a < x \<and> x \<le> b \<and> poly p x = 0} &&& Min {x. a < x \<and> x \<le> b \<and> poly p x = 0} \<le> b &&& poly p (Min {x. a < x \<and> x \<le> b \<and> poly p x = 0}) = 0
[PROOF STEP]
by blast+
[PROOF STATE]
proof (state)
this:
a < x\<^sub>2
x\<^sub>2 \<le> b
poly p x\<^sub>2 = 0

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
from Min_le[OF fin] x\<^sub>2_props
[PROOF STATE]
proof (chain)
picking this:
?x \<in> {x. a < x \<and> x \<le> b \<and> poly p x = 0} \<Longrightarrow> Min {x. a < x \<and> x \<le> b \<and> poly p x = 0} \<le> ?x
a < x\<^sub>2
x\<^sub>2 \<le> b
poly p x\<^sub>2 = 0
[PROOF STEP]
have x\<^sub>2_le: "\<And>x'. \<lbrakk>x' > a; x' \<le> b; poly p x' = 0\<rbrakk> \<Longrightarrow> x\<^sub>2 \<le> x'"
[PROOF STATE]
proof (prove)
using this:
?x \<in> {x. a < x \<and> x \<le> b \<and> poly p x = 0} \<Longrightarrow> Min {x. a < x \<and> x \<le> b \<and> poly p x = 0} \<le> ?x
a < x\<^sub>2
x\<^sub>2 \<le> b
poly p x\<^sub>2 = 0

goal (1 subgoal):
 1. \<And>x'. \<lbrakk>a < x'; x' \<le> b; poly p x' = 0\<rbrakk> \<Longrightarrow> x\<^sub>2 \<le> x'
[PROOF STEP]
unfolding x\<^sub>2_def
[PROOF STATE]
proof (prove)
using this:
?x \<in> {x. a < x \<and> x \<le> b \<and> poly p x = 0} \<Longrightarrow> Min {x. a < x \<and> x \<le> b \<and> poly p x = 0} \<le> ?x
a < Min {x. a < x \<and> x \<le> b \<and> poly p x = 0}
Min {x. a < x \<and> x \<le> b \<and> poly p x = 0} \<le> b
poly p (Min {x. a < x \<and> x \<le> b \<and> poly p x = 0}) = 0

goal (1 subgoal):
 1. \<And>x'. \<lbrakk>a < x'; x' \<le> b; poly p x' = 0\<rbrakk> \<Longrightarrow> Min {x. a < x \<and> x \<le> b \<and> poly p x = 0} \<le> x'
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<lbrakk>a < ?x'; ?x' \<le> b; poly p ?x' = 0\<rbrakk> \<Longrightarrow> x\<^sub>2 \<le> ?x'

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
have left: "{x. a < x \<and> x \<le> x\<^sub>2 \<and> poly p x = 0} = {x\<^sub>2}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x. a < x \<and> x \<le> x\<^sub>2 \<and> poly p x = 0} = {x\<^sub>2}
[PROOF STEP]
using x\<^sub>2_props x\<^sub>2_le
[PROOF STATE]
proof (prove)
using this:
a < x\<^sub>2
x\<^sub>2 \<le> b
poly p x\<^sub>2 = 0
\<lbrakk>a < ?x'; ?x' \<le> b; poly p ?x' = 0\<rbrakk> \<Longrightarrow> x\<^sub>2 \<le> ?x'

goal (1 subgoal):
 1. {x. a < x \<and> x \<le> x\<^sub>2 \<and> poly p x = 0} = {x\<^sub>2}
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
{x. a < x \<and> x \<le> x\<^sub>2 \<and> poly p x = 0} = {x\<^sub>2}

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
hence [simp]: "card {x. a < x \<and> x \<le> x\<^sub>2 \<and> poly p x = 0} = 1"
[PROOF STATE]
proof (prove)
using this:
{x. a < x \<and> x \<le> x\<^sub>2 \<and> poly p x = 0} = {x\<^sub>2}

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

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
from p_zero[OF \<open>poly p x\<^sub>2 = 0\<close> \<open>p \<noteq> 0\<close>,
              unfolded eventually_at dist_real_def]
[PROOF STATE]
proof (chain)
picking this:
\<exists>d>0. \<forall>x\<in>UNIV. x \<noteq> x\<^sub>2 \<and> \<bar>x - x\<^sub>2\<bar> < d \<longrightarrow> sign_changes ps x = sign_changes ps x\<^sub>2 + (if x < x\<^sub>2 then 1 else 0)
[PROOF STEP]
guess \<epsilon>
[PROOF STATE]
proof (prove)
using this:
\<exists>d>0. \<forall>x\<in>UNIV. x \<noteq> x\<^sub>2 \<and> \<bar>x - x\<^sub>2\<bar> < d \<longrightarrow> sign_changes ps x = sign_changes ps x\<^sub>2 + (if x < x\<^sub>2 then 1 else 0)

goal (1 subgoal):
 1. thesis
goal instantiation:
PROP ?guess \<leadsto> thesis
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
0 < \<epsilon> \<and> (\<forall>x\<in>UNIV. x \<noteq> x\<^sub>2 \<and> \<bar>x - x\<^sub>2\<bar> < \<epsilon> \<longrightarrow> sign_changes ps x = sign_changes ps x\<^sub>2 + (if x < x\<^sub>2 then 1 else 0))

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
hence \<epsilon>_props: "\<epsilon> > 0"
              "\<forall>x. x \<noteq> x\<^sub>2 \<and> \<bar>x - x\<^sub>2\<bar> < \<epsilon> \<longrightarrow>
                   sign_changes ps x = sign_changes ps x\<^sub>2 +
                       (if x < x\<^sub>2 then 1 else 0)"
[PROOF STATE]
proof (prove)
using this:
0 < \<epsilon> \<and> (\<forall>x\<in>UNIV. x \<noteq> x\<^sub>2 \<and> \<bar>x - x\<^sub>2\<bar> < \<epsilon> \<longrightarrow> sign_changes ps x = sign_changes ps x\<^sub>2 + (if x < x\<^sub>2 then 1 else 0))

goal (1 subgoal):
 1. 0 < \<epsilon> &&& \<forall>x. x \<noteq> x\<^sub>2 \<and> \<bar>x - x\<^sub>2\<bar> < \<epsilon> \<longrightarrow> sign_changes ps x = sign_changes ps x\<^sub>2 + (if x < x\<^sub>2 then 1 else 0)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < \<epsilon>
\<forall>x. x \<noteq> x\<^sub>2 \<and> \<bar>x - x\<^sub>2\<bar> < \<epsilon> \<longrightarrow> sign_changes ps x = sign_changes ps x\<^sub>2 + (if x < x\<^sub>2 then 1 else 0)

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
define x\<^sub>1 where "x\<^sub>1 = max (x\<^sub>2 - \<epsilon> / 2) a"
[PROOF STATE]
proof (state)
this:
x\<^sub>1 = max (x\<^sub>2 - \<epsilon> / 2) a

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
have "\<bar>x\<^sub>1 - x\<^sub>2\<bar> < \<epsilon>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>x\<^sub>1 - x\<^sub>2\<bar> < \<epsilon>
[PROOF STEP]
using \<open>\<epsilon> > 0\<close> x\<^sub>2_props
[PROOF STATE]
proof (prove)
using this:
0 < \<epsilon>
a < x\<^sub>2
x\<^sub>2 \<le> b
poly p x\<^sub>2 = 0

goal (1 subgoal):
 1. \<bar>x\<^sub>1 - x\<^sub>2\<bar> < \<epsilon>
[PROOF STEP]
by (simp add: x\<^sub>1_def)
[PROOF STATE]
proof (state)
this:
\<bar>x\<^sub>1 - x\<^sub>2\<bar> < \<epsilon>

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
hence "sign_changes ps x\<^sub>1 =
              (if x\<^sub>1 < x\<^sub>2 then sign_changes ps x\<^sub>2 + 1 else sign_changes ps x\<^sub>2)"
[PROOF STATE]
proof (prove)
using this:
\<bar>x\<^sub>1 - x\<^sub>2\<bar> < \<epsilon>

goal (1 subgoal):
 1. sign_changes ps x\<^sub>1 = (if x\<^sub>1 < x\<^sub>2 then sign_changes ps x\<^sub>2 + 1 else sign_changes ps x\<^sub>2)
[PROOF STEP]
using \<epsilon>_props(2)
[PROOF STATE]
proof (prove)
using this:
\<bar>x\<^sub>1 - x\<^sub>2\<bar> < \<epsilon>
\<forall>x. x \<noteq> x\<^sub>2 \<and> \<bar>x - x\<^sub>2\<bar> < \<epsilon> \<longrightarrow> sign_changes ps x = sign_changes ps x\<^sub>2 + (if x < x\<^sub>2 then 1 else 0)

goal (1 subgoal):
 1. sign_changes ps x\<^sub>1 = (if x\<^sub>1 < x\<^sub>2 then sign_changes ps x\<^sub>2 + 1 else sign_changes ps x\<^sub>2)
[PROOF STEP]
by (cases "x\<^sub>1 = x\<^sub>2", auto)
[PROOF STATE]
proof (state)
this:
sign_changes ps x\<^sub>1 = (if x\<^sub>1 < x\<^sub>2 then sign_changes ps x\<^sub>2 + 1 else sign_changes ps x\<^sub>2)

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
hence "sign_changes ps x\<^sub>1 - sign_changes ps x\<^sub>2 = 1"
[PROOF STATE]
proof (prove)
using this:
sign_changes ps x\<^sub>1 = (if x\<^sub>1 < x\<^sub>2 then sign_changes ps x\<^sub>2 + 1 else sign_changes ps x\<^sub>2)

goal (1 subgoal):
 1. sign_changes ps x\<^sub>1 - sign_changes ps x\<^sub>2 = 1
[PROOF STEP]
unfolding x\<^sub>1_def
[PROOF STATE]
proof (prove)
using this:
sign_changes ps (max (x\<^sub>2 - \<epsilon> / 2) a) = (if max (x\<^sub>2 - \<epsilon> / 2) a < x\<^sub>2 then sign_changes ps x\<^sub>2 + 1 else sign_changes ps x\<^sub>2)

goal (1 subgoal):
 1. sign_changes ps (max (x\<^sub>2 - \<epsilon> / 2) a) - sign_changes ps x\<^sub>2 = 1
[PROOF STEP]
using x\<^sub>2_props \<open>\<epsilon> > 0\<close>
[PROOF STATE]
proof (prove)
using this:
sign_changes ps (max (x\<^sub>2 - \<epsilon> / 2) a) = (if max (x\<^sub>2 - \<epsilon> / 2) a < x\<^sub>2 then sign_changes ps x\<^sub>2 + 1 else sign_changes ps x\<^sub>2)
a < x\<^sub>2
x\<^sub>2 \<le> b
poly p x\<^sub>2 = 0
0 < \<epsilon>

goal (1 subgoal):
 1. sign_changes ps (max (x\<^sub>2 - \<epsilon> / 2) a) - sign_changes ps x\<^sub>2 = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sign_changes ps x\<^sub>1 - sign_changes ps x\<^sub>2 = 1

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sign_changes ps x\<^sub>1 - sign_changes ps x\<^sub>2 = 1

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
have "x\<^sub>2 \<notin> {x. a < x \<and> x \<le> x\<^sub>1 \<and> poly p x = 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x\<^sub>2 \<notin> {x. a < x \<and> x \<le> x\<^sub>1 \<and> poly p x = 0}
[PROOF STEP]
unfolding x\<^sub>1_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x\<^sub>2 \<notin> {x. a < x \<and> x \<le> max (x\<^sub>2 - \<epsilon> / 2) a \<and> poly p x = 0}
[PROOF STEP]
using \<open>\<epsilon> > 0\<close>
[PROOF STATE]
proof (prove)
using this:
0 < \<epsilon>

goal (1 subgoal):
 1. x\<^sub>2 \<notin> {x. a < x \<and> x \<le> max (x\<^sub>2 - \<epsilon> / 2) a \<and> poly p x = 0}
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
x\<^sub>2 \<notin> {x. a < x \<and> x \<le> x\<^sub>1 \<and> poly p x = 0}

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
with left
[PROOF STATE]
proof (chain)
picking this:
{x. a < x \<and> x \<le> x\<^sub>2 \<and> poly p x = 0} = {x\<^sub>2}
x\<^sub>2 \<notin> {x. a < x \<and> x \<le> x\<^sub>1 \<and> poly p x = 0}
[PROOF STEP]
have "{x. a < x \<and> x \<le> x\<^sub>1 \<and> poly p x = 0} = {}"
[PROOF STATE]
proof (prove)
using this:
{x. a < x \<and> x \<le> x\<^sub>2 \<and> poly p x = 0} = {x\<^sub>2}
x\<^sub>2 \<notin> {x. a < x \<and> x \<le> x\<^sub>1 \<and> poly p x = 0}

goal (1 subgoal):
 1. {x. a < x \<and> x \<le> x\<^sub>1 \<and> poly p x = 0} = {}
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
{x. a < x \<and> x \<le> x\<^sub>1 \<and> poly p x = 0} = {}

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
with less(1)[of a x\<^sub>1]
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>card {x. a < x \<and> x \<le> x\<^sub>1 \<and> poly p x = 0} < card {x. a < x \<and> x \<le> b \<and> poly p x = 0}; a \<le> x\<^sub>1\<rbrakk> \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps x\<^sub>1) = int (card {x. a < x \<and> x \<le> x\<^sub>1 \<and> poly p x = 0})
{x. a < x \<and> x \<le> x\<^sub>1 \<and> poly p x = 0} = {}
[PROOF STEP]
have "sign_changes ps x\<^sub>1 = sign_changes ps a"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>card {x. a < x \<and> x \<le> x\<^sub>1 \<and> poly p x = 0} < card {x. a < x \<and> x \<le> b \<and> poly p x = 0}; a \<le> x\<^sub>1\<rbrakk> \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps x\<^sub>1) = int (card {x. a < x \<and> x \<le> x\<^sub>1 \<and> poly p x = 0})
{x. a < x \<and> x \<le> x\<^sub>1 \<and> poly p x = 0} = {}

goal (1 subgoal):
 1. sign_changes ps x\<^sub>1 = sign_changes ps a
[PROOF STEP]
unfolding x\<^sub>1_def \<open>\<epsilon> > 0\<close>
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>card {x. a < x \<and> x \<le> max (x\<^sub>2 - \<epsilon> / 2) a \<and> poly p x = 0} < card {x. a < x \<and> x \<le> b \<and> poly p x = 0}; a \<le> max (x\<^sub>2 - \<epsilon> / 2) a\<rbrakk> \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps (max (x\<^sub>2 - \<epsilon> / 2) a)) = int (card {x. a < x \<and> x \<le> max (x\<^sub>2 - \<epsilon> / 2) a \<and> poly p x = 0})
{x. a < x \<and> x \<le> max (x\<^sub>2 - \<epsilon> / 2) a \<and> poly p x = 0} = {}

goal (1 subgoal):
 1. sign_changes ps (max (x\<^sub>2 - \<epsilon> / 2) a) = sign_changes ps a
[PROOF STEP]
by (force simp: card_greater_0)
[PROOF STATE]
proof (state)
this:
sign_changes ps x\<^sub>1 = sign_changes ps a

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sign_changes ps a - sign_changes ps x\<^sub>2 = 1
[PROOF STEP]
have signs_left:
              "sign_changes ps a - int (sign_changes ps x\<^sub>2) = 1"
[PROOF STATE]
proof (prove)
using this:
sign_changes ps a - sign_changes ps x\<^sub>2 = 1

goal (1 subgoal):
 1. int (sign_changes ps a) - int (sign_changes ps x\<^sub>2) = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
int (sign_changes ps a) - int (sign_changes ps x\<^sub>2) = 1

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
have "{x. x > a \<and> x \<le> b \<and> poly p x = 0} =
                {x. a < x \<and> x \<le> x\<^sub>2 \<and> poly p x = 0} \<union>
                {x. x\<^sub>2 < x \<and> x \<le> b \<and> poly p x = 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x. a < x \<and> x \<le> b \<and> poly p x = 0} = {x. a < x \<and> x \<le> x\<^sub>2 \<and> poly p x = 0} \<union> {x. x\<^sub>2 < x \<and> x \<le> b \<and> poly p x = 0}
[PROOF STEP]
using x\<^sub>2_props
[PROOF STATE]
proof (prove)
using this:
a < x\<^sub>2
x\<^sub>2 \<le> b
poly p x\<^sub>2 = 0

goal (1 subgoal):
 1. {x. a < x \<and> x \<le> b \<and> poly p x = 0} = {x. a < x \<and> x \<le> x\<^sub>2 \<and> poly p x = 0} \<union> {x. x\<^sub>2 < x \<and> x \<le> b \<and> poly p x = 0}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{x. a < x \<and> x \<le> b \<and> poly p x = 0} = {x. a < x \<and> x \<le> x\<^sub>2 \<and> poly p x = 0} \<union> {x. x\<^sub>2 < x \<and> x \<le> b \<and> poly p x = 0}

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
{x. a < x \<and> x \<le> b \<and> poly p x = 0} = {x. a < x \<and> x \<le> x\<^sub>2 \<and> poly p x = 0} \<union> {x. x\<^sub>2 < x \<and> x \<le> b \<and> poly p x = 0}

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
note left
[PROOF STATE]
proof (state)
this:
{x. a < x \<and> x \<le> x\<^sub>2 \<and> poly p x = 0} = {x\<^sub>2}

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
{x. a < x \<and> x \<le> b \<and> poly p x = 0} = {x\<^sub>2} \<union> {x. x\<^sub>2 < x \<and> x \<le> b \<and> poly p x = 0}
[PROOF STEP]
have A: "card {x. x\<^sub>2 < x \<and> x \<le> b \<and> poly p x = 0} + 1 =
              card {x. a < x \<and> x \<le> b \<and> poly p x = 0}"
[PROOF STATE]
proof (prove)
using this:
{x. a < x \<and> x \<le> b \<and> poly p x = 0} = {x\<^sub>2} \<union> {x. x\<^sub>2 < x \<and> x \<le> b \<and> poly p x = 0}

goal (1 subgoal):
 1. card {x. x\<^sub>2 < x \<and> x \<le> b \<and> poly p x = 0} + 1 = card {x. a < x \<and> x \<le> b \<and> poly p x = 0}
[PROOF STEP]
using fin
[PROOF STATE]
proof (prove)
using this:
{x. a < x \<and> x \<le> b \<and> poly p x = 0} = {x\<^sub>2} \<union> {x. x\<^sub>2 < x \<and> x \<le> b \<and> poly p x = 0}
finite {x. a < x \<and> x \<le> b \<and> poly p x = 0}

goal (1 subgoal):
 1. card {x. x\<^sub>2 < x \<and> x \<le> b \<and> poly p x = 0} + 1 = card {x. a < x \<and> x \<le> b \<and> poly p x = 0}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card {x. x\<^sub>2 < x \<and> x \<le> b \<and> poly p x = 0} + 1 = card {x. a < x \<and> x \<le> b \<and> poly p x = 0}

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
hence "card {x. x\<^sub>2 < x \<and> x \<le> b \<and> poly p x = 0} <
                 card {x. a < x \<and> x \<le> b \<and> poly p x = 0}"
[PROOF STATE]
proof (prove)
using this:
card {x. x\<^sub>2 < x \<and> x \<le> b \<and> poly p x = 0} + 1 = card {x. a < x \<and> x \<le> b \<and> poly p x = 0}

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

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
from less(1)[OF this x\<^sub>2_props(2)] and A
[PROOF STATE]
proof (chain)
picking this:
int (sign_changes ps x\<^sub>2) - int (sign_changes ps b) = int (card {x. x\<^sub>2 < x \<and> x \<le> b \<and> poly p x = 0})
card {x. x\<^sub>2 < x \<and> x \<le> b \<and> poly p x = 0} + 1 = card {x. a < x \<and> x \<le> b \<and> poly p x = 0}
[PROOF STEP]
have signs_right: "sign_changes ps x\<^sub>2 - int (sign_changes ps b) + 1 =
                  card {x. a < x \<and> x \<le> b \<and> poly p x = 0}"
[PROOF STATE]
proof (prove)
using this:
int (sign_changes ps x\<^sub>2) - int (sign_changes ps b) = int (card {x. x\<^sub>2 < x \<and> x \<le> b \<and> poly p x = 0})
card {x. x\<^sub>2 < x \<and> x \<le> b \<and> poly p x = 0} + 1 = card {x. a < x \<and> x \<le> b \<and> poly p x = 0}

goal (1 subgoal):
 1. int (sign_changes ps x\<^sub>2) - int (sign_changes ps b) + 1 = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
int (sign_changes ps x\<^sub>2) - int (sign_changes ps b) + 1 = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})

goal (1 subgoal):
 1. \<exists>x>a. x \<le> b \<and> poly p x = 0 \<Longrightarrow> int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
from signs_left and signs_right
[PROOF STATE]
proof (chain)
picking this:
int (sign_changes ps a) - int (sign_changes ps x\<^sub>2) = 1
int (sign_changes ps x\<^sub>2) - int (sign_changes ps b) + 1 = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
int (sign_changes ps a) - int (sign_changes ps x\<^sub>2) = 1
int (sign_changes ps x\<^sub>2) - int (sign_changes ps b) + 1 = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})

goal (1 subgoal):
 1. int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})

goal (1 subgoal):
 1. sign_changes ps a - sign_changes ps b = card {x. a < x \<and> x \<le> b \<and> poly p x = 0}
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
int (sign_changes ps a) - int (sign_changes ps b) = int (card {x. a < x \<and> x \<le> b \<and> poly p x = 0})

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sub_mult_one_circ:
  "x * 1\<^sup>\<circ> \<le> 1\<^sup>\<circ> * x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x * (1::'a)\<^sup>\<circ> \<le> (1::'a)\<^sup>\<circ> * x
[PROOF STEP]
by (metis L_split_sup sup_commute mult_1_right one_circ_mult_split)


[STATEMENT]
lemma iMOD_div_right_strict_mono_on: "
  \<lbrakk> 0 < k; k \<le> m \<rbrakk> \<Longrightarrow> strict_mono_on (\<lambda>x. x div k) [r, mod m]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < k; k \<le> m\<rbrakk> \<Longrightarrow> SetInterval2.strict_mono_on (\<lambda>x. x div k) [ r, mod m ]
[PROOF STEP]
apply (rule div_right_strict_mono_on, assumption)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < k; k \<le> m\<rbrakk> \<Longrightarrow> \<forall>x\<in>[ r, mod m ]. \<forall>y\<in>[ r, mod m ]. x < y \<longrightarrow> x + k \<le> y
[PROOF STEP]
apply (clarsimp simp: iT_iff)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>0 < k; k \<le> m; y mod m = r mod m; x < y; x mod m = r mod m; r \<le> x\<rbrakk> \<Longrightarrow> x + k \<le> y
[PROOF STEP]
apply (drule_tac s="y mod m" in sym, simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>0 < k; k \<le> m; x < y; x mod m = y mod m; r \<le> x; r mod m = y mod m\<rbrakk> \<Longrightarrow> x + k \<le> y
[PROOF STEP]
apply (rule_tac y="x + m" in order_trans, simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>0 < k; k \<le> m; x < y; x mod m = y mod m; r \<le> x; r mod m = y mod m\<rbrakk> \<Longrightarrow> x + m \<le> y
[PROOF STEP]
apply (simp add: less_mod_eq_imp_add_divisor_le)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma mem_in_image:"\<lbrakk> f \<in> A \<rightarrow> B; a \<in> A\<rbrakk> \<Longrightarrow> f a \<in> f ` A "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f \<in> A \<rightarrow> B; a \<in> A\<rbrakk> \<Longrightarrow> f a \<in> f ` A
[PROOF STEP]
apply (simp add:image_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f \<in> A \<rightarrow> B; a \<in> A\<rbrakk> \<Longrightarrow> \<exists>x\<in>A. f a = f x
[PROOF STEP]
apply blast
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma arctan_ms_aux_neg_inf:
  assumes "\<exists>e>0. ms_aux_hd_exp xs = Some e" "fst (dominant_term_ms_aux xs) < 0" "trimmed_ms_aux xs"
          "basis_wf basis" "is_expansion_aux xs f basis"
  shows   "is_expansion_aux (minus_ms_aux (const_ms_aux (-pi / 2))
             (arctan_ms_aux (inverse_ms_aux xs))) (\<lambda>x. arctan (f x)) basis"
    (is "is_expansion_aux ?xs' _ _")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_expansion_aux (minus_ms_aux (const_ms_aux (- pi / 2)) (arctan_ms_aux (inverse_ms_aux xs))) (\<lambda>x. arctan (f x)) basis
[PROOF STEP]
proof (rule is_expansion_aux_cong)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. is_expansion_aux (minus_ms_aux (const_ms_aux (- pi / 2)) (arctan_ms_aux (inverse_ms_aux xs))) ?f basis
 2. \<forall>\<^sub>F x in at_top. ?f x = arctan (f x)
[PROOF STEP]
from \<open>trimmed_ms_aux xs\<close>
[PROOF STATE]
proof (chain)
picking this:
trimmed_ms_aux xs
[PROOF STEP]
have [simp]: "xs \<noteq> MSLNil"
[PROOF STATE]
proof (prove)
using this:
trimmed_ms_aux xs

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

goal (2 subgoals):
 1. is_expansion_aux (minus_ms_aux (const_ms_aux (- pi / 2)) (arctan_ms_aux (inverse_ms_aux xs))) ?f basis
 2. \<forall>\<^sub>F x in at_top. ?f x = arctan (f x)
[PROOF STEP]
thus "is_expansion_aux ?xs' (\<lambda>x. -pi / 2 - arctan (inverse (f x))) basis"
[PROOF STATE]
proof (prove)
using this:
xs \<noteq> MSLNil

goal (1 subgoal):
 1. is_expansion_aux (minus_ms_aux (const_ms_aux (- pi / 2)) (arctan_ms_aux (inverse_ms_aux xs))) (\<lambda>x. - pi / 2 - arctan (inverse (f x))) basis
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
xs \<noteq> MSLNil
\<exists>e>0. ms_aux_hd_exp xs = Some e
fst (dominant_term_ms_aux xs) < 0
trimmed_ms_aux xs
basis_wf basis
is_expansion_aux xs f basis

goal (1 subgoal):
 1. is_expansion_aux (minus_ms_aux (const_ms_aux (- pi / 2)) (arctan_ms_aux (inverse_ms_aux xs))) (\<lambda>x. - pi / 2 - arctan (inverse (f x))) basis
[PROOF STEP]
by (intro minus_ms_aux arctan_ms_aux_0 inverse_ms_aux const_ms_aux)
       (auto simp: hd_exp_inverse is_expansion_aux_expansion_level)
[PROOF STATE]
proof (state)
this:
is_expansion_aux (minus_ms_aux (const_ms_aux (- pi / 2)) (arctan_ms_aux (inverse_ms_aux xs))) (\<lambda>x. - pi / 2 - arctan (inverse (f x))) basis

goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_top. - pi / 2 - arctan (inverse (f x)) = arctan (f x)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_top. - pi / 2 - arctan (inverse (f x)) = arctan (f x)
[PROOF STEP]
from assms(2-5)
[PROOF STATE]
proof (chain)
picking this:
fst (dominant_term_ms_aux xs) < 0
trimmed_ms_aux xs
basis_wf basis
is_expansion_aux xs f basis
[PROOF STEP]
have "eventually (\<lambda>x. f x < 0) at_top"
[PROOF STATE]
proof (prove)
using this:
fst (dominant_term_ms_aux xs) < 0
trimmed_ms_aux xs
basis_wf basis
is_expansion_aux xs f basis

goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_top. f x < 0
[PROOF STEP]
by (intro eval_neg_if_dominant_term_neg') simp_all
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in at_top. f x < 0

goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_top. - pi / 2 - arctan (inverse (f x)) = arctan (f x)
[PROOF STEP]
thus "eventually (\<lambda>x. ((\<lambda>x. -pi/2 - arctan (inverse (f x)))) x = arctan (f x)) at_top"
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in at_top. f x < 0

goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_top. - pi / 2 - arctan (inverse (f x)) = arctan (f x)
[PROOF STEP]
unfolding o_def
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in at_top. f x < 0

goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_top. - pi / 2 - arctan (inverse (f x)) = arctan (f x)
[PROOF STEP]
by eventually_elim (subst arctan_inverse_neg, simp_all)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in at_top. - pi / 2 - arctan (inverse (f x)) = arctan (f x)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Lim_ident_at: "\<not> trivial_limit (at x within s) \<Longrightarrow> Lim (at x within s) (\<lambda>x. x) = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. at x within s \<noteq> bot \<Longrightarrow> Lim (at x within s) (\<lambda>x. x) = x
[PROOF STEP]
by (rule tendsto_Lim[OF _ tendsto_ident_at]) auto


[STATEMENT]
lemma False_map2_and: "\<lbrakk>set xs \<subseteq> {False}; length ys = length xs\<rbrakk> \<Longrightarrow> map2 (\<and>) xs ys = xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>set xs \<subseteq> {False}; length ys = length xs\<rbrakk> \<Longrightarrow> map2 (\<and>) xs ys = xs
[PROOF STEP]
by (induction xs arbitrary: ys) (auto simp: length_Suc_conv)


[STATEMENT]
lemma approx_add_left_iff [simp]: "a + b \<approx> a + c \<longleftrightarrow> b \<approx> c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a + b \<approx> a + c) = (b \<approx> c)
[PROOF STEP]
by (fast elim: approx_add_left_cancel approx_add_mono1)


[STATEMENT]
lemma mcont_contD:
  "\<lbrakk> mcont luba orda lubb ordb f; Complete_Partial_Order.chain orda Y; Y \<noteq> {} \<rbrakk>
  \<Longrightarrow> f (luba Y) = lubb (f ` Y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>mcont luba orda lubb ordb f; Complete_Partial_Order.chain orda Y; Y \<noteq> {}\<rbrakk> \<Longrightarrow> f (luba Y) = lubb (f ` Y)
[PROOF STEP]
by(auto simp add: mcont_def dest: contD)


[STATEMENT]
lemma plus_matrix_def' [simp]:
  "Matrix A + Matrix B = Matrix (\<lambda>i j. A i j + B i j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix A + Matrix B = Matrix (\<lambda>i j. A i j + B i j)
[PROOF STEP]
by (simp add: plus_matrix_def)


[STATEMENT]
lemma card_fset_1:
  shows "card_fset S = 1 \<longleftrightarrow> (\<exists>x. S = {|x|})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (card_fset S = 1) = (\<exists>x. S = {|x|})
[PROOF STEP]
by (descending) (auto simp add: card_Suc_eq)


[STATEMENT]
lemma hoare_if: "hoare p (If b then x else y) q = (hoare (p \<sqinter> b) x q \<and> hoare (p \<sqinter> -b) y q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. hoare p (If b then x else y) q = (hoare (p \<sqinter> b) x q \<and> hoare (p \<sqinter> - b) y q)
[PROOF STEP]
by (simp add: hoare_def if_stm_def wp_choice inf_fun_def wp_comp wp_assume sup_neg_inf)


[STATEMENT]
lemma finished_imp_back_edge:
    "\<lbrakk>w \<in> succ v; v \<in> dom (finished s); w \<in> dom (finished s);
      \<delta> s w \<le> \<delta> s v; \<phi> s v \<le> \<phi> s w\<rbrakk>
     \<Longrightarrow> (v, w) \<in> back_edges s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>w \<in> E `` {v}; v \<in> dom (finished s); w \<in> dom (finished s); \<delta> s w \<le> \<delta> s v; \<phi> s v \<le> \<phi> s w\<rbrakk> \<Longrightarrow> (v, w) \<in> back_edges s
[PROOF STEP]
using disc_imp_back_edge_or_pending finished_discovered finished_no_pending
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?w \<in> E `` {?v}; ?v \<in> dom (discovered s); ?w \<in> dom (discovered s); \<delta> s ?w \<le> \<delta> s ?v; ?w \<in> dom (finished s) \<Longrightarrow> ?v \<in> dom (finished s) \<and> \<phi> s ?v \<le> \<phi> s ?w\<rbrakk> \<Longrightarrow> (?v, ?w) \<in> back_edges s \<or> (?v, ?w) \<in> pending s
dom (finished s) \<subseteq> dom (discovered s)
?v \<in> dom (finished s) \<Longrightarrow> pending s `` {?v} = {}

goal (1 subgoal):
 1. \<lbrakk>w \<in> E `` {v}; v \<in> dom (finished s); w \<in> dom (finished s); \<delta> s w \<le> \<delta> s v; \<phi> s v \<le> \<phi> s w\<rbrakk> \<Longrightarrow> (v, w) \<in> back_edges s
[PROOF STEP]
by fast


[STATEMENT]
lemma subst_typ'_rename_tvars_cancel:
  assumes "y \<notin> fst ` tvs t" assumes "y \<notin> fst ` tvsT \<tau>"
  shows "subst_typ' [((y,S), Tv x S)] ((bind_fv2 (x, subst_typ [((x,S), Tv y S)] \<tau>))
    lev (subst_typ' [((x,S), Tv y S)] t))
  = bind_fv2 (x, \<tau>) lev t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t)) = bind_fv2 (x, \<tau>) lev t
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
y \<notin> fst ` tvs t
y \<notin> fst ` tvsT \<tau>

goal (1 subgoal):
 1. subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t)) = bind_fv2 (x, \<tau>) lev t
[PROOF STEP]
proof (induction t arbitrary: lev)
[PROOF STATE]
proof (state)
goal (5 subgoals):
 1. \<And>x1 x2 lev. \<lbrakk>y \<notin> fst ` tvs (Ct x1 x2); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Ct x1 x2))) = bind_fv2 (x, \<tau>) lev (Ct x1 x2)
 2. \<And>x1 x2 lev. \<lbrakk>y \<notin> fst ` tvs (Fv x1 x2); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Fv x1 x2))) = bind_fv2 (x, \<tau>) lev (Fv x1 x2)
 3. \<And>xa lev. \<lbrakk>y \<notin> fst ` tvs (Bv xa); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Bv xa))) = bind_fv2 (x, \<tau>) lev (Bv xa)
 4. \<And>x1 t lev. \<lbrakk>\<And>lev. \<lbrakk>y \<notin> fst ` tvs t; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t)) = bind_fv2 (x, \<tau>) lev t; y \<notin> fst ` tvs (Abs x1 t); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Abs x1 t))) = bind_fv2 (x, \<tau>) lev (Abs x1 t)
 5. \<And>t1 t2 lev. \<lbrakk>\<And>lev. \<lbrakk>y \<notin> fst ` tvs t1; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t1)) = bind_fv2 (x, \<tau>) lev t1; \<And>lev. \<lbrakk>y \<notin> fst ` tvs t2; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t2)) = bind_fv2 (x, \<tau>) lev t2; y \<notin> fst ` tvs (t1 $ t2); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (t1 $ t2))) = bind_fv2 (x, \<tau>) lev (t1 $ t2)
[PROOF STEP]
case (Ct n T)
[PROOF STATE]
proof (state)
this:
y \<notin> fst ` tvs (Ct n T)
y \<notin> fst ` tvsT \<tau>

goal (5 subgoals):
 1. \<And>x1 x2 lev. \<lbrakk>y \<notin> fst ` tvs (Ct x1 x2); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Ct x1 x2))) = bind_fv2 (x, \<tau>) lev (Ct x1 x2)
 2. \<And>x1 x2 lev. \<lbrakk>y \<notin> fst ` tvs (Fv x1 x2); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Fv x1 x2))) = bind_fv2 (x, \<tau>) lev (Fv x1 x2)
 3. \<And>xa lev. \<lbrakk>y \<notin> fst ` tvs (Bv xa); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Bv xa))) = bind_fv2 (x, \<tau>) lev (Bv xa)
 4. \<And>x1 t lev. \<lbrakk>\<And>lev. \<lbrakk>y \<notin> fst ` tvs t; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t)) = bind_fv2 (x, \<tau>) lev t; y \<notin> fst ` tvs (Abs x1 t); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Abs x1 t))) = bind_fv2 (x, \<tau>) lev (Abs x1 t)
 5. \<And>t1 t2 lev. \<lbrakk>\<And>lev. \<lbrakk>y \<notin> fst ` tvs t1; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t1)) = bind_fv2 (x, \<tau>) lev t1; \<And>lev. \<lbrakk>y \<notin> fst ` tvs t2; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t2)) = bind_fv2 (x, \<tau>) lev t2; y \<notin> fst ` tvs (t1 $ t2); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (t1 $ t2))) = bind_fv2 (x, \<tau>) lev (t1 $ t2)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
y \<notin> fst ` tvs (Ct n T)
y \<notin> fst ` tvsT \<tau>
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
y \<notin> fst ` tvs (Ct n T)
y \<notin> fst ` tvsT \<tau>

goal (1 subgoal):
 1. subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Ct n T))) = bind_fv2 (x, \<tau>) lev (Ct n T)
[PROOF STEP]
by (simp add: subst_typ_rename_vars_cancel)
[PROOF STATE]
proof (state)
this:
subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Ct n T))) = bind_fv2 (x, \<tau>) lev (Ct n T)

goal (4 subgoals):
 1. \<And>x1 x2 lev. \<lbrakk>y \<notin> fst ` tvs (Fv x1 x2); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Fv x1 x2))) = bind_fv2 (x, \<tau>) lev (Fv x1 x2)
 2. \<And>xa lev. \<lbrakk>y \<notin> fst ` tvs (Bv xa); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Bv xa))) = bind_fv2 (x, \<tau>) lev (Bv xa)
 3. \<And>x1 t lev. \<lbrakk>\<And>lev. \<lbrakk>y \<notin> fst ` tvs t; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t)) = bind_fv2 (x, \<tau>) lev t; y \<notin> fst ` tvs (Abs x1 t); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Abs x1 t))) = bind_fv2 (x, \<tau>) lev (Abs x1 t)
 4. \<And>t1 t2 lev. \<lbrakk>\<And>lev. \<lbrakk>y \<notin> fst ` tvs t1; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t1)) = bind_fv2 (x, \<tau>) lev t1; \<And>lev. \<lbrakk>y \<notin> fst ` tvs t2; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t2)) = bind_fv2 (x, \<tau>) lev t2; y \<notin> fst ` tvs (t1 $ t2); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (t1 $ t2))) = bind_fv2 (x, \<tau>) lev (t1 $ t2)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. \<And>x1 x2 lev. \<lbrakk>y \<notin> fst ` tvs (Fv x1 x2); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Fv x1 x2))) = bind_fv2 (x, \<tau>) lev (Fv x1 x2)
 2. \<And>xa lev. \<lbrakk>y \<notin> fst ` tvs (Bv xa); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Bv xa))) = bind_fv2 (x, \<tau>) lev (Bv xa)
 3. \<And>x1 t lev. \<lbrakk>\<And>lev. \<lbrakk>y \<notin> fst ` tvs t; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t)) = bind_fv2 (x, \<tau>) lev t; y \<notin> fst ` tvs (Abs x1 t); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Abs x1 t))) = bind_fv2 (x, \<tau>) lev (Abs x1 t)
 4. \<And>t1 t2 lev. \<lbrakk>\<And>lev. \<lbrakk>y \<notin> fst ` tvs t1; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t1)) = bind_fv2 (x, \<tau>) lev t1; \<And>lev. \<lbrakk>y \<notin> fst ` tvs t2; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t2)) = bind_fv2 (x, \<tau>) lev t2; y \<notin> fst ` tvs (t1 $ t2); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (t1 $ t2))) = bind_fv2 (x, \<tau>) lev (t1 $ t2)
[PROOF STEP]
case (Fv idn T)
[PROOF STATE]
proof (state)
this:
y \<notin> fst ` tvs (Fv idn T)
y \<notin> fst ` tvsT \<tau>

goal (4 subgoals):
 1. \<And>x1 x2 lev. \<lbrakk>y \<notin> fst ` tvs (Fv x1 x2); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Fv x1 x2))) = bind_fv2 (x, \<tau>) lev (Fv x1 x2)
 2. \<And>xa lev. \<lbrakk>y \<notin> fst ` tvs (Bv xa); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Bv xa))) = bind_fv2 (x, \<tau>) lev (Bv xa)
 3. \<And>x1 t lev. \<lbrakk>\<And>lev. \<lbrakk>y \<notin> fst ` tvs t; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t)) = bind_fv2 (x, \<tau>) lev t; y \<notin> fst ` tvs (Abs x1 t); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Abs x1 t))) = bind_fv2 (x, \<tau>) lev (Abs x1 t)
 4. \<And>t1 t2 lev. \<lbrakk>\<And>lev. \<lbrakk>y \<notin> fst ` tvs t1; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t1)) = bind_fv2 (x, \<tau>) lev t1; \<And>lev. \<lbrakk>y \<notin> fst ` tvs t2; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t2)) = bind_fv2 (x, \<tau>) lev t2; y \<notin> fst ` tvs (t1 $ t2); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (t1 $ t2))) = bind_fv2 (x, \<tau>) lev (t1 $ t2)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
y \<notin> fst ` tvs (Fv idn T)
y \<notin> fst ` tvsT \<tau>
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
y \<notin> fst ` tvs (Fv idn T)
y \<notin> fst ` tvsT \<tau>

goal (1 subgoal):
 1. subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Fv idn T))) = bind_fv2 (x, \<tau>) lev (Fv idn T)
[PROOF STEP]
by (clarsimp simp add: subst_typ_rename_vars_cancel) (metis subst_typ_rename_vars_cancel)
[PROOF STATE]
proof (state)
this:
subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Fv idn T))) = bind_fv2 (x, \<tau>) lev (Fv idn T)

goal (3 subgoals):
 1. \<And>xa lev. \<lbrakk>y \<notin> fst ` tvs (Bv xa); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Bv xa))) = bind_fv2 (x, \<tau>) lev (Bv xa)
 2. \<And>x1 t lev. \<lbrakk>\<And>lev. \<lbrakk>y \<notin> fst ` tvs t; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t)) = bind_fv2 (x, \<tau>) lev t; y \<notin> fst ` tvs (Abs x1 t); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Abs x1 t))) = bind_fv2 (x, \<tau>) lev (Abs x1 t)
 3. \<And>t1 t2 lev. \<lbrakk>\<And>lev. \<lbrakk>y \<notin> fst ` tvs t1; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t1)) = bind_fv2 (x, \<tau>) lev t1; \<And>lev. \<lbrakk>y \<notin> fst ` tvs t2; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t2)) = bind_fv2 (x, \<tau>) lev t2; y \<notin> fst ` tvs (t1 $ t2); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (t1 $ t2))) = bind_fv2 (x, \<tau>) lev (t1 $ t2)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>xa lev. \<lbrakk>y \<notin> fst ` tvs (Bv xa); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Bv xa))) = bind_fv2 (x, \<tau>) lev (Bv xa)
 2. \<And>x1 t lev. \<lbrakk>\<And>lev. \<lbrakk>y \<notin> fst ` tvs t; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t)) = bind_fv2 (x, \<tau>) lev t; y \<notin> fst ` tvs (Abs x1 t); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Abs x1 t))) = bind_fv2 (x, \<tau>) lev (Abs x1 t)
 3. \<And>t1 t2 lev. \<lbrakk>\<And>lev. \<lbrakk>y \<notin> fst ` tvs t1; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t1)) = bind_fv2 (x, \<tau>) lev t1; \<And>lev. \<lbrakk>y \<notin> fst ` tvs t2; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t2)) = bind_fv2 (x, \<tau>) lev t2; y \<notin> fst ` tvs (t1 $ t2); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (t1 $ t2))) = bind_fv2 (x, \<tau>) lev (t1 $ t2)
[PROOF STEP]
case (Abs T t)
[PROOF STATE]
proof (state)
this:
\<lbrakk>y \<notin> fst ` tvs t; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) ?lev (subst_typ' [((x, S), Tv y S)] t)) = bind_fv2 (x, \<tau>) ?lev t
y \<notin> fst ` tvs (Abs T t)
y \<notin> fst ` tvsT \<tau>

goal (3 subgoals):
 1. \<And>xa lev. \<lbrakk>y \<notin> fst ` tvs (Bv xa); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Bv xa))) = bind_fv2 (x, \<tau>) lev (Bv xa)
 2. \<And>x1 t lev. \<lbrakk>\<And>lev. \<lbrakk>y \<notin> fst ` tvs t; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t)) = bind_fv2 (x, \<tau>) lev t; y \<notin> fst ` tvs (Abs x1 t); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Abs x1 t))) = bind_fv2 (x, \<tau>) lev (Abs x1 t)
 3. \<And>t1 t2 lev. \<lbrakk>\<And>lev. \<lbrakk>y \<notin> fst ` tvs t1; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t1)) = bind_fv2 (x, \<tau>) lev t1; \<And>lev. \<lbrakk>y \<notin> fst ` tvs t2; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t2)) = bind_fv2 (x, \<tau>) lev t2; y \<notin> fst ` tvs (t1 $ t2); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (t1 $ t2))) = bind_fv2 (x, \<tau>) lev (t1 $ t2)
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>y \<notin> fst ` tvs t; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) ?lev (subst_typ' [((x, S), Tv y S)] t)) = bind_fv2 (x, \<tau>) ?lev t
y \<notin> fst ` tvs (Abs T t)
y \<notin> fst ` tvsT \<tau>

goal (1 subgoal):
 1. subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Abs T t))) = bind_fv2 (x, \<tau>) lev (Abs T t)
[PROOF STEP]
by (simp add: image_Un subst_typ_rename_vars_cancel)
[PROOF STATE]
proof (state)
this:
subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Abs T t))) = bind_fv2 (x, \<tau>) lev (Abs T t)

goal (2 subgoals):
 1. \<And>xa lev. \<lbrakk>y \<notin> fst ` tvs (Bv xa); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Bv xa))) = bind_fv2 (x, \<tau>) lev (Bv xa)
 2. \<And>t1 t2 lev. \<lbrakk>\<And>lev. \<lbrakk>y \<notin> fst ` tvs t1; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t1)) = bind_fv2 (x, \<tau>) lev t1; \<And>lev. \<lbrakk>y \<notin> fst ` tvs t2; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t2)) = bind_fv2 (x, \<tau>) lev t2; y \<notin> fst ` tvs (t1 $ t2); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (t1 $ t2))) = bind_fv2 (x, \<tau>) lev (t1 $ t2)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>xa lev. \<lbrakk>y \<notin> fst ` tvs (Bv xa); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Bv xa))) = bind_fv2 (x, \<tau>) lev (Bv xa)
 2. \<And>t1 t2 lev. \<lbrakk>\<And>lev. \<lbrakk>y \<notin> fst ` tvs t1; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t1)) = bind_fv2 (x, \<tau>) lev t1; \<And>lev. \<lbrakk>y \<notin> fst ` tvs t2; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t2)) = bind_fv2 (x, \<tau>) lev t2; y \<notin> fst ` tvs (t1 $ t2); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (t1 $ t2))) = bind_fv2 (x, \<tau>) lev (t1 $ t2)
[PROOF STEP]
case (App t1 t2)
[PROOF STATE]
proof (state)
this:
\<lbrakk>y \<notin> fst ` tvs t1; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) ?lev (subst_typ' [((x, S), Tv y S)] t1)) = bind_fv2 (x, \<tau>) ?lev t1
\<lbrakk>y \<notin> fst ` tvs t2; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) ?lev (subst_typ' [((x, S), Tv y S)] t2)) = bind_fv2 (x, \<tau>) ?lev t2
y \<notin> fst ` tvs (t1 $ t2)
y \<notin> fst ` tvsT \<tau>

goal (2 subgoals):
 1. \<And>xa lev. \<lbrakk>y \<notin> fst ` tvs (Bv xa); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Bv xa))) = bind_fv2 (x, \<tau>) lev (Bv xa)
 2. \<And>t1 t2 lev. \<lbrakk>\<And>lev. \<lbrakk>y \<notin> fst ` tvs t1; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t1)) = bind_fv2 (x, \<tau>) lev t1; \<And>lev. \<lbrakk>y \<notin> fst ` tvs t2; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] t2)) = bind_fv2 (x, \<tau>) lev t2; y \<notin> fst ` tvs (t1 $ t2); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (t1 $ t2))) = bind_fv2 (x, \<tau>) lev (t1 $ t2)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>y \<notin> fst ` tvs t1; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) ?lev (subst_typ' [((x, S), Tv y S)] t1)) = bind_fv2 (x, \<tau>) ?lev t1
\<lbrakk>y \<notin> fst ` tvs t2; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) ?lev (subst_typ' [((x, S), Tv y S)] t2)) = bind_fv2 (x, \<tau>) ?lev t2
y \<notin> fst ` tvs (t1 $ t2)
y \<notin> fst ` tvsT \<tau>
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>y \<notin> fst ` tvs t1; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) ?lev (subst_typ' [((x, S), Tv y S)] t1)) = bind_fv2 (x, \<tau>) ?lev t1
\<lbrakk>y \<notin> fst ` tvs t2; y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) ?lev (subst_typ' [((x, S), Tv y S)] t2)) = bind_fv2 (x, \<tau>) ?lev t2
y \<notin> fst ` tvs (t1 $ t2)
y \<notin> fst ` tvsT \<tau>

goal (1 subgoal):
 1. subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (t1 $ t2))) = bind_fv2 (x, \<tau>) lev (t1 $ t2)
[PROOF STEP]
by (simp add: image_Un)
[PROOF STATE]
proof (state)
this:
subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (t1 $ t2))) = bind_fv2 (x, \<tau>) lev (t1 $ t2)

goal (1 subgoal):
 1. \<And>xa lev. \<lbrakk>y \<notin> fst ` tvs (Bv xa); y \<notin> fst ` tvsT \<tau>\<rbrakk> \<Longrightarrow> subst_typ' [((y, S), Tv x S)] (bind_fv2 (x, subst_typ [((x, S), Tv y S)] \<tau>) lev (subst_typ' [((x, S), Tv y S)] (Bv xa))) = bind_fv2 (x, \<tau>) lev (Bv xa)
[PROOF STEP]
qed auto


[STATEMENT]
lemma asymp_equiv_eventually_zeros:
  fixes f g :: "'a \<Rightarrow> 'b :: real_normed_field"
  assumes "f \<sim>[F] g"
  shows   "eventually (\<lambda>x. f x = 0 \<longleftrightarrow> g x = 0) F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. (f x = (0::'b)) = (g x = (0::'b))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. (f x = (0::'b)) = (g x = (0::'b))
[PROOF STEP]
let ?h = "\<lambda>x. if f x = 0 \<and> g x = 0 then 1 else f x / g x"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. (f x = (0::'b)) = (g x = (0::'b))
[PROOF STEP]
have "eventually (\<lambda>x. x \<noteq> 0) (nhds (1::'b))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in nhds (1::'b). x \<noteq> (0::'b)
[PROOF STEP]
by (rule t1_space_nhds) auto
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in nhds (1::'b). x \<noteq> (0::'b)

goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. (f x = (0::'b)) = (g x = (0::'b))
[PROOF STEP]
hence "eventually (\<lambda>x. x \<noteq> 0) (filtermap ?h F)"
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in nhds (1::'b). x \<noteq> (0::'b)

goal (1 subgoal):
 1. \<forall>\<^sub>F x in filtermap (\<lambda>x. if f x = (0::'b) \<and> g x = (0::'b) then 1::'b else f x / g x) F. x \<noteq> (0::'b)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in nhds (1::'b). x \<noteq> (0::'b)
f \<sim>[F] g

goal (1 subgoal):
 1. \<forall>\<^sub>F x in filtermap (\<lambda>x. if f x = (0::'b) \<and> g x = (0::'b) then 1::'b else f x / g x) F. x \<noteq> (0::'b)
[PROOF STEP]
unfolding asymp_equiv_def filterlim_def
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in nhds (1::'b). x \<noteq> (0::'b)
filtermap (\<lambda>x. if f x = (0::'b) \<and> g x = (0::'b) then 1::'b else f x / g x) F \<le> nhds (1::'b)

goal (1 subgoal):
 1. \<forall>\<^sub>F x in filtermap (\<lambda>x. if f x = (0::'b) \<and> g x = (0::'b) then 1::'b else f x / g x) F. x \<noteq> (0::'b)
[PROOF STEP]
by (rule filter_leD [rotated])
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in filtermap (\<lambda>x. if f x = (0::'b) \<and> g x = (0::'b) then 1::'b else f x / g x) F. x \<noteq> (0::'b)

goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. (f x = (0::'b)) = (g x = (0::'b))
[PROOF STEP]
hence "eventually (\<lambda>x. ?h x \<noteq> 0) F"
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in filtermap (\<lambda>x. if f x = (0::'b) \<and> g x = (0::'b) then 1::'b else f x / g x) F. x \<noteq> (0::'b)

goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. (if f x = (0::'b) \<and> g x = (0::'b) then 1::'b else f x / g x) \<noteq> (0::'b)
[PROOF STEP]
by (simp add: eventually_filtermap)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in F. (if f x = (0::'b) \<and> g x = (0::'b) then 1::'b else f x / g x) \<noteq> (0::'b)

goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. (f x = (0::'b)) = (g x = (0::'b))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in F. (if f x = (0::'b) \<and> g x = (0::'b) then 1::'b else f x / g x) \<noteq> (0::'b)

goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. (f x = (0::'b)) = (g x = (0::'b))
[PROOF STEP]
by eventually_elim (auto split: if_splits)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in F. (f x = (0::'b)) = (g x = (0::'b))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Tn_quasi_measure_preserving:
  "T^^n \<in> quasi_measure_preserving M M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. T ^^ n \<in> quasi_measure_preserving M M
[PROOF STEP]
proof (induction n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. T ^^ 0 \<in> quasi_measure_preserving M M
 2. \<And>n. T ^^ n \<in> quasi_measure_preserving M M \<Longrightarrow> T ^^ Suc n \<in> quasi_measure_preserving M M
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. T ^^ 0 \<in> quasi_measure_preserving M M
 2. \<And>n. T ^^ n \<in> quasi_measure_preserving M M \<Longrightarrow> T ^^ Suc n \<in> quasi_measure_preserving M M
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. T ^^ 0 \<in> quasi_measure_preserving M M
[PROOF STEP]
using id_quasi_measure_preserving
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. x) \<in> quasi_measure_preserving ?M ?M

goal (1 subgoal):
 1. T ^^ 0 \<in> quasi_measure_preserving M M
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
T ^^ 0 \<in> quasi_measure_preserving M M

goal (1 subgoal):
 1. \<And>n. T ^^ n \<in> quasi_measure_preserving M M \<Longrightarrow> T ^^ Suc n \<in> quasi_measure_preserving M M
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. T ^^ n \<in> quasi_measure_preserving M M \<Longrightarrow> T ^^ Suc n \<in> quasi_measure_preserving M M
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
T ^^ n \<in> quasi_measure_preserving M M

goal (1 subgoal):
 1. \<And>n. T ^^ n \<in> quasi_measure_preserving M M \<Longrightarrow> T ^^ Suc n \<in> quasi_measure_preserving M M
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
T ^^ n \<in> quasi_measure_preserving M M
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
T ^^ n \<in> quasi_measure_preserving M M

goal (1 subgoal):
 1. T ^^ Suc n \<in> quasi_measure_preserving M M
[PROOF STEP]
using Tqm quasi_measure_preserving_comp
[PROOF STATE]
proof (prove)
using this:
T ^^ n \<in> quasi_measure_preserving M M
T \<in> quasi_measure_preserving M M
\<lbrakk>?f \<in> quasi_measure_preserving ?M ?N; ?g \<in> quasi_measure_preserving ?N ?P\<rbrakk> \<Longrightarrow> ?g \<circ> ?f \<in> quasi_measure_preserving ?M ?P

goal (1 subgoal):
 1. T ^^ Suc n \<in> quasi_measure_preserving M M
[PROOF STEP]
by (metis funpow_Suc_right)
[PROOF STATE]
proof (state)
this:
T ^^ Suc n \<in> quasi_measure_preserving M M

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ltrm_cfs:
  assumes "f \<in> carrier P"
  shows "(ltrm f) n  = (if (n = degree f) then (f (degree f)) else \<zero>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. monom P (f (deg R f)) (deg R f) n = (if n = deg R f then f (deg R f) else \<zero>)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f \<in> carrier P

goal (1 subgoal):
 1. monom P (f (deg R f)) (deg R f) n = (if n = deg R f then f (deg R f) else \<zero>)
[PROOF STEP]
by (simp add: cfs_closed cfs_monom)


[STATEMENT]
lemma is_pole_inverse_power: "n > 0 \<Longrightarrow> is_pole (\<lambda>z::complex. 1 / (z - a) ^ n) a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < n \<Longrightarrow> is_pole (\<lambda>z. 1 / (z - a) ^ n) a
[PROOF STEP]
unfolding is_pole_def inverse_eq_divide [symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < n \<Longrightarrow> LIM z at a. inverse ((z - a) ^ n) :> at_infinity
[PROOF STEP]
by (intro filterlim_compose[OF filterlim_inverse_at_infinity] tendsto_intros)
     (auto simp: filterlim_at eventually_at intro!: exI[of _ 1] tendsto_eq_intros)


[STATEMENT]
lemma sorted_sorted_list_of_multiset: "sorted (sorted_list_of_multiset M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted (sorted_list_of_multiset M)
[PROOF STEP]
by (induction M, auto simp:sorted_insort)


[STATEMENT]
lemma image_fst_zip: "length ys = length xs \<Longrightarrow> fst ` set (zip ys xs) = set ys"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length ys = length xs \<Longrightarrow> fst ` set (zip ys xs) = set ys
[PROOF STEP]
by (metis dom_map_of_conv_image_fst dom_map_of_zip)


[STATEMENT]
lemma expands_to_zero:
    "basis_wf basis \<Longrightarrow> length basis = expansion_level TYPE('a) \<Longrightarrow>
       ((\<lambda>_. 0) expands_to (zero_expansion :: 'a :: multiseries)) basis"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>basis_wf basis; length basis = expansion_level TYPE('a)\<rbrakk> \<Longrightarrow> ((\<lambda>_. 0) expands_to zero_expansion) basis
[PROOF STEP]
by (auto simp add: expands_to.simps is_expansion_zero)