[STATEMENT]
theorem caratheodory:
  "convex hull p =
    {x::'a::euclidean_space. \<exists>S. finite S \<and> S \<subseteq> p \<and> card S \<le> DIM('a) + 1 \<and> x \<in> convex hull S}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. convex hull p = {x. \<exists>S. finite S \<and> S \<subseteq> p \<and> card S \<le> DIM('a) + 1 \<and> x \<in> convex hull S}
[PROOF STEP]
proof safe
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>x. x \<in> convex hull p \<Longrightarrow> \<exists>S. finite S \<and> S \<subseteq> p \<and> card S \<le> DIM('a) + 1 \<and> x \<in> convex hull S
 2. \<And>x S. \<lbrakk>finite S; S \<subseteq> p; card S \<le> DIM('a) + 1; x \<in> convex hull S\<rbrakk> \<Longrightarrow> x \<in> convex hull p
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>x. x \<in> convex hull p \<Longrightarrow> \<exists>S. finite S \<and> S \<subseteq> p \<and> card S \<le> DIM('a) + 1 \<and> x \<in> convex hull S
 2. \<And>x S. \<lbrakk>finite S; S \<subseteq> p; card S \<le> DIM('a) + 1; x \<in> convex hull S\<rbrakk> \<Longrightarrow> x \<in> convex hull p
[PROOF STEP]
assume "x \<in> convex hull p"
[PROOF STATE]
proof (state)
this:
x \<in> convex hull p

goal (2 subgoals):
 1. \<And>x. x \<in> convex hull p \<Longrightarrow> \<exists>S. finite S \<and> S \<subseteq> p \<and> card S \<le> DIM('a) + 1 \<and> x \<in> convex hull S
 2. \<And>x S. \<lbrakk>finite S; S \<subseteq> p; card S \<le> DIM('a) + 1; x \<in> convex hull S\<rbrakk> \<Longrightarrow> x \<in> convex hull p
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> convex hull p
[PROOF STEP]
obtain S u where "finite S" "S \<subseteq> p" "card S \<le> DIM('a) + 1"
    "\<forall>x\<in>S. 0 \<le> u x" "sum u S = 1" "(\<Sum>v\<in>S. u v *\<^sub>R v) = x"
[PROOF STATE]
proof (prove)
using this:
x \<in> convex hull p

goal (1 subgoal):
 1. (\<And>S u. \<lbrakk>finite S; S \<subseteq> p; card S \<le> DIM('a) + 1; \<forall>x\<in>S. 0 \<le> u x; sum u S = 1; (\<Sum>v\<in>S. u v *\<^sub>R v) = x\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding convex_hull_caratheodory
[PROOF STATE]
proof (prove)
using this:
x \<in> {y. \<exists>S u. finite S \<and> S \<subseteq> p \<and> card S \<le> DIM('a) + 1 \<and> (\<forall>x\<in>S. 0 \<le> u x) \<and> sum u S = 1 \<and> (\<Sum>v\<in>S. u v *\<^sub>R v) = y}

goal (1 subgoal):
 1. (\<And>S u. \<lbrakk>finite S; S \<subseteq> p; card S \<le> DIM('a) + 1; \<forall>x\<in>S. 0 \<le> u x; sum u S = 1; (\<Sum>v\<in>S. u v *\<^sub>R v) = x\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite S
S \<subseteq> p
card S \<le> DIM('a) + 1
\<forall>x\<in>S. 0 \<le> u x
sum u S = 1
(\<Sum>v\<in>S. u v *\<^sub>R v) = x

goal (2 subgoals):
 1. \<And>x. x \<in> convex hull p \<Longrightarrow> \<exists>S. finite S \<and> S \<subseteq> p \<and> card S \<le> DIM('a) + 1 \<and> x \<in> convex hull S
 2. \<And>x S. \<lbrakk>finite S; S \<subseteq> p; card S \<le> DIM('a) + 1; x \<in> convex hull S\<rbrakk> \<Longrightarrow> x \<in> convex hull p
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
finite S
S \<subseteq> p
card S \<le> DIM('a) + 1
\<forall>x\<in>S. 0 \<le> u x
sum u S = 1
(\<Sum>v\<in>S. u v *\<^sub>R v) = x
[PROOF STEP]
show "\<exists>S. finite S \<and> S \<subseteq> p \<and> card S \<le> DIM('a) + 1 \<and> x \<in> convex hull S"
[PROOF STATE]
proof (prove)
using this:
finite S
S \<subseteq> p
card S \<le> DIM('a) + 1
\<forall>x\<in>S. 0 \<le> u x
sum u S = 1
(\<Sum>v\<in>S. u v *\<^sub>R v) = x

goal (1 subgoal):
 1. \<exists>S. finite S \<and> S \<subseteq> p \<and> card S \<le> DIM('a) + 1 \<and> x \<in> convex hull S
[PROOF STEP]
using convex_hull_finite
[PROOF STATE]
proof (prove)
using this:
finite S
S \<subseteq> p
card S \<le> DIM('a) + 1
\<forall>x\<in>S. 0 \<le> u x
sum u S = 1
(\<Sum>v\<in>S. u v *\<^sub>R v) = x
finite ?S \<Longrightarrow> convex hull ?S = {y. \<exists>u. (\<forall>x\<in>?S. 0 \<le> u x) \<and> sum u ?S = 1 \<and> (\<Sum>x\<in>?S. u x *\<^sub>R x) = y}

goal (1 subgoal):
 1. \<exists>S. finite S \<and> S \<subseteq> p \<and> card S \<le> DIM('a) + 1 \<and> x \<in> convex hull S
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
\<exists>S. finite S \<and> S \<subseteq> p \<and> card S \<le> DIM('a) + 1 \<and> x \<in> convex hull S

goal (1 subgoal):
 1. \<And>x S. \<lbrakk>finite S; S \<subseteq> p; card S \<le> DIM('a) + 1; x \<in> convex hull S\<rbrakk> \<Longrightarrow> x \<in> convex hull p
[PROOF STEP]
qed (use hull_mono in force)


[STATEMENT]
lemma unitary_diagI:
  assumes "similar_mat_wit A B U (Complex_Matrix.adjoint U)"
  and "diagonal_mat B"
  and "unitary U"
shows "unitary_diag A B U"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unitary_diag A B U
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
similar_mat_wit A B U (Complex_Matrix.adjoint U)
diagonal_mat B
Complex_Matrix.unitary U

goal (1 subgoal):
 1. unitary_diag A B U
[PROOF STEP]
unfolding unitary_diag_def unitarily_equiv_def
[PROOF STATE]
proof (prove)
using this:
similar_mat_wit A B U (Complex_Matrix.adjoint U)
diagonal_mat B
Complex_Matrix.unitary U

goal (1 subgoal):
 1. (Complex_Matrix.unitary U \<and> similar_mat_wit A B U (Complex_Matrix.adjoint U)) \<and> diagonal_mat B
[PROOF STEP]
by simp


[STATEMENT]
lemma and_list_semantic: "w \<Turnstile>\<^sub>n and_list xs \<longleftrightarrow> (\<forall>x \<in> set xs. w \<Turnstile>\<^sub>n x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. w \<Turnstile>\<^sub>n and_list xs = (\<forall>x\<in>set xs. w \<Turnstile>\<^sub>n x)
[PROOF STEP]
by (induction xs rule: rev_induct) auto


[STATEMENT]
lemma group_closure_add:
  "s + t \<in> group_closure S" if "s \<in> group_closure S" and "t \<in> group_closure S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. s + t \<in> group_closure S
[PROOF STEP]
using that group_closure.diff [of s S "- t"]
[PROOF STATE]
proof (prove)
using this:
s \<in> group_closure S
t \<in> group_closure S
\<lbrakk>s \<in> group_closure S; - t \<in> group_closure S\<rbrakk> \<Longrightarrow> s - - t \<in> group_closure S

goal (1 subgoal):
 1. s + t \<in> group_closure S
[PROOF STEP]
by auto


[STATEMENT]
lemma subst_compose_assoc:
  "\<sigma> \<circ>\<^sub>s \<tau> \<circ>\<^sub>s \<mu> = \<sigma> \<circ>\<^sub>s (\<tau> \<circ>\<^sub>s \<mu>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<sigma> \<circ>\<^sub>s \<tau> \<circ>\<^sub>s \<mu> = \<sigma> \<circ>\<^sub>s (\<tau> \<circ>\<^sub>s \<mu>)
[PROOF STEP]
proof (rule ext)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. (\<sigma> \<circ>\<^sub>s \<tau> \<circ>\<^sub>s \<mu>) x = (\<sigma> \<circ>\<^sub>s (\<tau> \<circ>\<^sub>s \<mu>)) x
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. (\<sigma> \<circ>\<^sub>s \<tau> \<circ>\<^sub>s \<mu>) x = (\<sigma> \<circ>\<^sub>s (\<tau> \<circ>\<^sub>s \<mu>)) x
[PROOF STEP]
show "(\<sigma> \<circ>\<^sub>s \<tau> \<circ>\<^sub>s \<mu>) x = (\<sigma> \<circ>\<^sub>s (\<tau> \<circ>\<^sub>s \<mu>)) x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<sigma> \<circ>\<^sub>s \<tau> \<circ>\<^sub>s \<mu>) x = (\<sigma> \<circ>\<^sub>s (\<tau> \<circ>\<^sub>s \<mu>)) x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<sigma> \<circ>\<^sub>s \<tau> \<circ>\<^sub>s \<mu>) x = (\<sigma> \<circ>\<^sub>s (\<tau> \<circ>\<^sub>s \<mu>)) x
[PROOF STEP]
have "(\<sigma> \<circ>\<^sub>s \<tau> \<circ>\<^sub>s \<mu>) x = \<sigma>(x) \<cdot> \<tau> \<cdot> \<mu>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<sigma> \<circ>\<^sub>s \<tau> \<circ>\<^sub>s \<mu>) x = \<sigma> x \<cdot> \<tau> \<cdot> \<mu>
[PROOF STEP]
by (simp add: subst_compose_def)
[PROOF STATE]
proof (state)
this:
(\<sigma> \<circ>\<^sub>s \<tau> \<circ>\<^sub>s \<mu>) x = \<sigma> x \<cdot> \<tau> \<cdot> \<mu>

goal (1 subgoal):
 1. (\<sigma> \<circ>\<^sub>s \<tau> \<circ>\<^sub>s \<mu>) x = (\<sigma> \<circ>\<^sub>s (\<tau> \<circ>\<^sub>s \<mu>)) x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<sigma> \<circ>\<^sub>s \<tau> \<circ>\<^sub>s \<mu>) x = \<sigma> x \<cdot> \<tau> \<cdot> \<mu>

goal (1 subgoal):
 1. (\<sigma> \<circ>\<^sub>s \<tau> \<circ>\<^sub>s \<mu>) x = (\<sigma> \<circ>\<^sub>s (\<tau> \<circ>\<^sub>s \<mu>)) x
[PROOF STEP]
have "\<dots> = \<sigma>(x) \<cdot> (\<tau> \<circ>\<^sub>s \<mu>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<sigma> x \<cdot> \<tau> \<cdot> \<mu> = \<sigma> x \<cdot> \<tau> \<circ>\<^sub>s \<mu>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<sigma> x \<cdot> \<tau> \<cdot> \<mu> = \<sigma> x \<cdot> \<tau> \<circ>\<^sub>s \<mu>

goal (1 subgoal):
 1. (\<sigma> \<circ>\<^sub>s \<tau> \<circ>\<^sub>s \<mu>) x = (\<sigma> \<circ>\<^sub>s (\<tau> \<circ>\<^sub>s \<mu>)) x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<sigma> \<circ>\<^sub>s \<tau> \<circ>\<^sub>s \<mu>) x = \<sigma> x \<cdot> \<tau> \<circ>\<^sub>s \<mu>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<sigma> \<circ>\<^sub>s \<tau> \<circ>\<^sub>s \<mu>) x = \<sigma> x \<cdot> \<tau> \<circ>\<^sub>s \<mu>

goal (1 subgoal):
 1. (\<sigma> \<circ>\<^sub>s \<tau> \<circ>\<^sub>s \<mu>) x = (\<sigma> \<circ>\<^sub>s (\<tau> \<circ>\<^sub>s \<mu>)) x
[PROOF STEP]
by (simp add: subst_compose_def)
[PROOF STATE]
proof (state)
this:
(\<sigma> \<circ>\<^sub>s \<tau> \<circ>\<^sub>s \<mu>) x = (\<sigma> \<circ>\<^sub>s (\<tau> \<circ>\<^sub>s \<mu>)) x

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<sigma> \<circ>\<^sub>s \<tau> \<circ>\<^sub>s \<mu>) x = (\<sigma> \<circ>\<^sub>s (\<tau> \<circ>\<^sub>s \<mu>)) x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma inf_cvec_z2_zero_iff:
  assumes "(z1, z2) \<noteq> vec_zero"
  shows "(z1, z2) \<approx>\<^sub>v \<infinity>\<^sub>v \<longleftrightarrow> z2 = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((z1, z2) \<approx>\<^sub>v \<infinity>\<^sub>v) = (z2 = 0)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
(z1, z2) \<noteq> vec_zero

goal (1 subgoal):
 1. ((z1, z2) \<approx>\<^sub>v \<infinity>\<^sub>v) = (z2 = 0)
[PROOF STEP]
by auto


[STATEMENT]
lemma representation_diff:
  assumes basis: "independent basis" and v: "v \<in> span basis" and u: "u \<in> span basis"
  shows "representation basis (u - v) = (\<lambda>b. representation basis u b - representation basis v b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. representation basis (u - v) = (\<lambda>b. representation basis u b - representation basis v b)
[PROOF STEP]
proof (rule representation_eqI[OF basis span_diff[OF u v]])
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>b. representation basis u b - representation basis v b \<noteq> (0::'a) \<Longrightarrow> b \<in> basis
 2. finite {b. representation basis u b - representation basis v b \<noteq> (0::'a)}
 3. (\<Sum>b | representation basis u b - representation basis v b \<noteq> (0::'a). (representation basis u b - representation basis v b) *s b) = u - v
[PROOF STEP]
let ?R = "representation basis"
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>b. representation basis u b - representation basis v b \<noteq> (0::'a) \<Longrightarrow> b \<in> basis
 2. finite {b. representation basis u b - representation basis v b \<noteq> (0::'a)}
 3. (\<Sum>b | representation basis u b - representation basis v b \<noteq> (0::'a). (representation basis u b - representation basis v b) *s b) = u - v
[PROOF STEP]
note finite_representation[simp] u[simp] v[simp]
[PROOF STATE]
proof (state)
this:
finite {b. representation ?basis ?v b \<noteq> (0::'a)}
u \<in> span basis
v \<in> span basis

goal (3 subgoals):
 1. \<And>b. representation basis u b - representation basis v b \<noteq> (0::'a) \<Longrightarrow> b \<in> basis
 2. finite {b. representation basis u b - representation basis v b \<noteq> (0::'a)}
 3. (\<Sum>b | representation basis u b - representation basis v b \<noteq> (0::'a). (representation basis u b - representation basis v b) *s b) = u - v
[PROOF STEP]
have *: "{b. ?R u b - ?R v b \<noteq> 0} \<subseteq> {b. ?R u b \<noteq> 0} \<union> {b. ?R v b \<noteq> 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {b. representation basis u b - representation basis v b \<noteq> (0::'a)} \<subseteq> {b. representation basis u b \<noteq> (0::'a)} \<union> {b. representation basis v b \<noteq> (0::'a)}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{b. representation basis u b - representation basis v b \<noteq> (0::'a)} \<subseteq> {b. representation basis u b \<noteq> (0::'a)} \<union> {b. representation basis v b \<noteq> (0::'a)}

goal (3 subgoals):
 1. \<And>b. representation basis u b - representation basis v b \<noteq> (0::'a) \<Longrightarrow> b \<in> basis
 2. finite {b. representation basis u b - representation basis v b \<noteq> (0::'a)}
 3. (\<Sum>b | representation basis u b - representation basis v b \<noteq> (0::'a). (representation basis u b - representation basis v b) *s b) = u - v
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
{b. representation basis u b - representation basis v b \<noteq> (0::'a)} \<subseteq> {b. representation basis u b \<noteq> (0::'a)} \<union> {b. representation basis v b \<noteq> (0::'a)}
[PROOF STEP]
show "?R u b - ?R v b \<noteq> 0 \<Longrightarrow> b \<in> basis" for b
[PROOF STATE]
proof (prove)
using this:
{b. representation basis u b - representation basis v b \<noteq> (0::'a)} \<subseteq> {b. representation basis u b \<noteq> (0::'a)} \<union> {b. representation basis v b \<noteq> (0::'a)}

goal (1 subgoal):
 1. representation basis u b - representation basis v b \<noteq> (0::'a) \<Longrightarrow> b \<in> basis
[PROOF STEP]
by (auto dest: representation_ne_zero)
[PROOF STATE]
proof (state)
this:
representation basis u ?b - representation basis v ?b \<noteq> (0::'a) \<Longrightarrow> ?b \<in> basis

goal (2 subgoals):
 1. finite {b. representation basis u b - representation basis v b \<noteq> (0::'a)}
 2. (\<Sum>b | representation basis u b - representation basis v b \<noteq> (0::'a). (representation basis u b - representation basis v b) *s b) = u - v
[PROOF STEP]
show "finite {b. ?R u b - ?R v b \<noteq> 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {b. representation basis u b - representation basis v b \<noteq> (0::'a)}
[PROOF STEP]
by (intro finite_subset[OF *]) simp_all
[PROOF STATE]
proof (state)
this:
finite {b. representation basis u b - representation basis v b \<noteq> (0::'a)}

goal (1 subgoal):
 1. (\<Sum>b | representation basis u b - representation basis v b \<noteq> (0::'a). (representation basis u b - representation basis v b) *s b) = u - v
[PROOF STEP]
have "(\<Sum>b | ?R u b - ?R v b \<noteq> 0. (?R u b - ?R v b) *s b) =
      (\<Sum>b\<in>{b. ?R u b \<noteq> 0} \<union> {b. ?R v b \<noteq> 0}. (?R u b - ?R v b) *s b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>b | representation basis u b - representation basis v b \<noteq> (0::'a). (representation basis u b - representation basis v b) *s b) = (\<Sum>b\<in>{b. representation basis u b \<noteq> (0::'a)} \<union> {b. representation basis v b \<noteq> (0::'a)}. (representation basis u b - representation basis v b) *s b)
[PROOF STEP]
by (intro sum.mono_neutral_cong_left *) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>b | representation basis u b - representation basis v b \<noteq> (0::'a). (representation basis u b - representation basis v b) *s b) = (\<Sum>b\<in>{b. representation basis u b \<noteq> (0::'a)} \<union> {b. representation basis v b \<noteq> (0::'a)}. (representation basis u b - representation basis v b) *s b)

goal (1 subgoal):
 1. (\<Sum>b | representation basis u b - representation basis v b \<noteq> (0::'a). (representation basis u b - representation basis v b) *s b) = u - v
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>b | representation basis u b - representation basis v b \<noteq> (0::'a). (representation basis u b - representation basis v b) *s b) = (\<Sum>b\<in>{b. representation basis u b \<noteq> (0::'a)} \<union> {b. representation basis v b \<noteq> (0::'a)}. (representation basis u b - representation basis v b) *s b)

goal (1 subgoal):
 1. (\<Sum>b | representation basis u b - representation basis v b \<noteq> (0::'a). (representation basis u b - representation basis v b) *s b) = u - v
[PROOF STEP]
have "... =
      (\<Sum>b\<in>{b. ?R u b \<noteq> 0} \<union> {b. ?R v b \<noteq> 0}. ?R u b *s b) - (\<Sum>b\<in>{b. ?R u b \<noteq> 0} \<union> {b. ?R v b \<noteq> 0}. ?R v b *s b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>b\<in>{b. representation basis u b \<noteq> (0::'a)} \<union> {b. representation basis v b \<noteq> (0::'a)}. (representation basis u b - representation basis v b) *s b) = (\<Sum>b\<in>{b. representation basis u b \<noteq> (0::'a)} \<union> {b. representation basis v b \<noteq> (0::'a)}. representation basis u b *s b) - (\<Sum>b\<in>{b. representation basis u b \<noteq> (0::'a)} \<union> {b. representation basis v b \<noteq> (0::'a)}. representation basis v b *s b)
[PROOF STEP]
by (simp add: algebra_simps sum_subtractf)
[PROOF STATE]
proof (state)
this:
(\<Sum>b\<in>{b. representation basis u b \<noteq> (0::'a)} \<union> {b. representation basis v b \<noteq> (0::'a)}. (representation basis u b - representation basis v b) *s b) = (\<Sum>b\<in>{b. representation basis u b \<noteq> (0::'a)} \<union> {b. representation basis v b \<noteq> (0::'a)}. representation basis u b *s b) - (\<Sum>b\<in>{b. representation basis u b \<noteq> (0::'a)} \<union> {b. representation basis v b \<noteq> (0::'a)}. representation basis v b *s b)

goal (1 subgoal):
 1. (\<Sum>b | representation basis u b - representation basis v b \<noteq> (0::'a). (representation basis u b - representation basis v b) *s b) = u - v
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>b\<in>{b. representation basis u b \<noteq> (0::'a)} \<union> {b. representation basis v b \<noteq> (0::'a)}. (representation basis u b - representation basis v b) *s b) = (\<Sum>b\<in>{b. representation basis u b \<noteq> (0::'a)} \<union> {b. representation basis v b \<noteq> (0::'a)}. representation basis u b *s b) - (\<Sum>b\<in>{b. representation basis u b \<noteq> (0::'a)} \<union> {b. representation basis v b \<noteq> (0::'a)}. representation basis v b *s b)

goal (1 subgoal):
 1. (\<Sum>b | representation basis u b - representation basis v b \<noteq> (0::'a). (representation basis u b - representation basis v b) *s b) = u - v
[PROOF STEP]
have "... = (\<Sum>b | ?R u b \<noteq> 0. ?R u b *s b) - (\<Sum>b | ?R v b \<noteq> 0. ?R v b *s b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>b\<in>{b. representation basis u b \<noteq> (0::'a)} \<union> {b. representation basis v b \<noteq> (0::'a)}. representation basis u b *s b) - (\<Sum>b\<in>{b. representation basis u b \<noteq> (0::'a)} \<union> {b. representation basis v b \<noteq> (0::'a)}. representation basis v b *s b) = (\<Sum>b | representation basis u b \<noteq> (0::'a). representation basis u b *s b) - (\<Sum>b | representation basis v b \<noteq> (0::'a). representation basis v b *s b)
[PROOF STEP]
by (intro arg_cong2[where f= "(-)"] sum.mono_neutral_cong_right) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>b\<in>{b. representation basis u b \<noteq> (0::'a)} \<union> {b. representation basis v b \<noteq> (0::'a)}. representation basis u b *s b) - (\<Sum>b\<in>{b. representation basis u b \<noteq> (0::'a)} \<union> {b. representation basis v b \<noteq> (0::'a)}. representation basis v b *s b) = (\<Sum>b | representation basis u b \<noteq> (0::'a). representation basis u b *s b) - (\<Sum>b | representation basis v b \<noteq> (0::'a). representation basis v b *s b)

goal (1 subgoal):
 1. (\<Sum>b | representation basis u b - representation basis v b \<noteq> (0::'a). (representation basis u b - representation basis v b) *s b) = u - v
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>b | representation basis u b - representation basis v b \<noteq> (0::'a). (representation basis u b - representation basis v b) *s b) = (\<Sum>b | representation basis u b \<noteq> (0::'a). representation basis u b *s b) - (\<Sum>b | representation basis v b \<noteq> (0::'a). representation basis v b *s b)
[PROOF STEP]
show "(\<Sum>b | ?R u b - ?R v b \<noteq> 0. (?R u b - ?R v b) *s b) = u - v"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>b | representation basis u b - representation basis v b \<noteq> (0::'a). (representation basis u b - representation basis v b) *s b) = (\<Sum>b | representation basis u b \<noteq> (0::'a). representation basis u b *s b) - (\<Sum>b | representation basis v b \<noteq> (0::'a). representation basis v b *s b)

goal (1 subgoal):
 1. (\<Sum>b | representation basis u b - representation basis v b \<noteq> (0::'a). (representation basis u b - representation basis v b) *s b) = u - v
[PROOF STEP]
by (simp add: sum_nonzero_representation_eq[OF basis])
[PROOF STATE]
proof (state)
this:
(\<Sum>b | representation basis u b - representation basis v b \<noteq> (0::'a). (representation basis u b - representation basis v b) *s b) = u - v

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma self_inner_prod_real:
  fixes v::"complex Matrix.vec"
  shows "Complex_Matrix.inner_prod v v \<in> Reals"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex_Matrix.inner_prod v v \<in> \<real>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Complex_Matrix.inner_prod v v \<in> \<real>
[PROOF STEP]
have "Im (Complex_Matrix.inner_prod v v) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Im (Complex_Matrix.inner_prod v v) = 0
[PROOF STEP]
using self_cscalar_prod_geq_0
[PROOF STATE]
proof (prove)
using this:
(0::?'a) \<le> Complex_Matrix.inner_prod ?v ?v

goal (1 subgoal):
 1. Im (Complex_Matrix.inner_prod v v) = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Im (Complex_Matrix.inner_prod v v) = 0

goal (1 subgoal):
 1. Complex_Matrix.inner_prod v v \<in> \<real>
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
Im (Complex_Matrix.inner_prod v v) = 0

goal (1 subgoal):
 1. Complex_Matrix.inner_prod v v \<in> \<real>
[PROOF STEP]
using complex_is_Real_iff
[PROOF STATE]
proof (prove)
using this:
Im (Complex_Matrix.inner_prod v v) = 0
(?z \<in> \<real>) = (Im ?z = 0)

goal (1 subgoal):
 1. Complex_Matrix.inner_prod v v \<in> \<real>
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Complex_Matrix.inner_prod v v \<in> \<real>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma transpose_column_length:
  fixes xs :: "'a list list"
  assumes sorted: "sorted (rev (map length xs))" and "i < length xs"
  shows "length (filter (\<lambda>ys. i < length ys) (transpose xs)) = length (xs ! i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (filter (\<lambda>ys. i < length ys) (transpose xs)) = length (xs ! i)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. length (filter (\<lambda>ys. i < length ys) (transpose xs)) = length (xs ! i)
[PROOF STEP]
have "xs \<noteq> []"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. xs \<noteq> []
[PROOF STEP]
using \<open>i < length xs\<close>
[PROOF STATE]
proof (prove)
using this:
i < length xs

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

goal (1 subgoal):
 1. length (filter (\<lambda>ys. i < length ys) (transpose xs)) = length (xs ! i)
[PROOF STEP]
note filter_equals_takeWhile_sorted_rev[OF sorted, simp]
[PROOF STATE]
proof (state)
this:
filter (\<lambda>x. ?t < length x) xs = takeWhile (\<lambda>x. ?t < length x) xs

goal (1 subgoal):
 1. length (filter (\<lambda>ys. i < length ys) (transpose xs)) = length (xs ! i)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
filter (\<lambda>x. ?t < length x) xs = takeWhile (\<lambda>x. ?t < length x) xs

goal (1 subgoal):
 1. length (filter (\<lambda>ys. i < length ys) (transpose xs)) = length (xs ! i)
[PROOF STEP]
fix j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. length (filter (\<lambda>ys. i < length ys) (transpose xs)) = length (xs ! i)
[PROOF STEP]
assume "j \<le> i"
[PROOF STATE]
proof (state)
this:
j \<le> i

goal (1 subgoal):
 1. length (filter (\<lambda>ys. i < length ys) (transpose xs)) = length (xs ! i)
[PROOF STEP]
note sorted_rev_nth_mono[OF sorted, of j i, simplified, OF this \<open>i < length xs\<close>]
[PROOF STATE]
proof (state)
this:
length (xs ! i) \<le> length (xs ! j)

goal (1 subgoal):
 1. length (filter (\<lambda>ys. i < length ys) (transpose xs)) = length (xs ! i)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?j2 \<le> i \<Longrightarrow> length (xs ! i) \<le> length (xs ! ?j2)

goal (1 subgoal):
 1. length (filter (\<lambda>ys. i < length ys) (transpose xs)) = length (xs ! i)
[PROOF STEP]
note sortedE = this[consumes 1]
[PROOF STATE]
proof (state)
this:
?j2 \<le> i \<Longrightarrow> length (xs ! i) \<le> length (xs ! ?j2)

goal (1 subgoal):
 1. length (filter (\<lambda>ys. i < length ys) (transpose xs)) = length (xs ! i)
[PROOF STEP]
have "{j. j < length (transpose xs) \<and> i < length (transpose xs ! j)}
    = {..< length (xs ! i)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {j. j < length (transpose xs) \<and> i < length (transpose xs ! j)} = {..<length (xs ! i)}
[PROOF STEP]
proof safe
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>x. \<lbrakk>x < length (transpose xs); i < length (transpose xs ! x)\<rbrakk> \<Longrightarrow> x < length (xs ! i)
 2. \<And>x. x < length (xs ! i) \<Longrightarrow> x < length (transpose xs)
 3. \<And>x. x < length (xs ! i) \<Longrightarrow> i < length (transpose xs ! x)
[PROOF STEP]
fix j
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>x. \<lbrakk>x < length (transpose xs); i < length (transpose xs ! x)\<rbrakk> \<Longrightarrow> x < length (xs ! i)
 2. \<And>x. x < length (xs ! i) \<Longrightarrow> x < length (transpose xs)
 3. \<And>x. x < length (xs ! i) \<Longrightarrow> i < length (transpose xs ! x)
[PROOF STEP]
assume "j < length (transpose xs)" and "i < length (transpose xs ! j)"
[PROOF STATE]
proof (state)
this:
j < length (transpose xs)
i < length (transpose xs ! j)

goal (3 subgoals):
 1. \<And>x. \<lbrakk>x < length (transpose xs); i < length (transpose xs ! x)\<rbrakk> \<Longrightarrow> x < length (xs ! i)
 2. \<And>x. x < length (xs ! i) \<Longrightarrow> x < length (transpose xs)
 3. \<And>x. x < length (xs ! i) \<Longrightarrow> i < length (transpose xs ! x)
[PROOF STEP]
with this(2) nth_transpose[OF this(1)]
[PROOF STATE]
proof (chain)
picking this:
i < length (transpose xs ! j)
transpose xs ! j = map (\<lambda>xs. xs ! j) (filter (\<lambda>ys. j < length ys) xs)
j < length (transpose xs)
i < length (transpose xs ! j)
[PROOF STEP]
have "i < length (takeWhile (\<lambda>ys. j < length ys) xs)"
[PROOF STATE]
proof (prove)
using this:
i < length (transpose xs ! j)
transpose xs ! j = map (\<lambda>xs. xs ! j) (filter (\<lambda>ys. j < length ys) xs)
j < length (transpose xs)
i < length (transpose xs ! j)

goal (1 subgoal):
 1. i < length (takeWhile (\<lambda>ys. j < length ys) xs)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
i < length (takeWhile (\<lambda>ys. j < length ys) xs)

goal (3 subgoals):
 1. \<And>x. \<lbrakk>x < length (transpose xs); i < length (transpose xs ! x)\<rbrakk> \<Longrightarrow> x < length (xs ! i)
 2. \<And>x. x < length (xs ! i) \<Longrightarrow> x < length (transpose xs)
 3. \<And>x. x < length (xs ! i) \<Longrightarrow> i < length (transpose xs ! x)
[PROOF STEP]
from nth_mem[OF this] takeWhile_nth[OF this]
[PROOF STATE]
proof (chain)
picking this:
takeWhile (\<lambda>ys. j < length ys) xs ! i \<in> set (takeWhile (\<lambda>ys. j < length ys) xs)
takeWhile (\<lambda>ys. j < length ys) xs ! i = xs ! i
[PROOF STEP]
show "j < length (xs ! i)"
[PROOF STATE]
proof (prove)
using this:
takeWhile (\<lambda>ys. j < length ys) xs ! i \<in> set (takeWhile (\<lambda>ys. j < length ys) xs)
takeWhile (\<lambda>ys. j < length ys) xs ! i = xs ! i

goal (1 subgoal):
 1. j < length (xs ! i)
[PROOF STEP]
by (auto dest: set_takeWhileD)
[PROOF STATE]
proof (state)
this:
j < length (xs ! i)

goal (2 subgoals):
 1. \<And>x. x < length (xs ! i) \<Longrightarrow> x < length (transpose xs)
 2. \<And>x. x < length (xs ! i) \<Longrightarrow> i < length (transpose xs ! x)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>x. x < length (xs ! i) \<Longrightarrow> x < length (transpose xs)
 2. \<And>x. x < length (xs ! i) \<Longrightarrow> i < length (transpose xs ! x)
[PROOF STEP]
fix j
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>x. x < length (xs ! i) \<Longrightarrow> x < length (transpose xs)
 2. \<And>x. x < length (xs ! i) \<Longrightarrow> i < length (transpose xs ! x)
[PROOF STEP]
assume "j < length (xs ! i)"
[PROOF STATE]
proof (state)
this:
j < length (xs ! i)

goal (2 subgoals):
 1. \<And>x. x < length (xs ! i) \<Longrightarrow> x < length (transpose xs)
 2. \<And>x. x < length (xs ! i) \<Longrightarrow> i < length (transpose xs ! x)
[PROOF STEP]
thus "j < length (transpose xs)"
[PROOF STATE]
proof (prove)
using this:
j < length (xs ! i)

goal (1 subgoal):
 1. j < length (transpose xs)
[PROOF STEP]
using foldr_max_sorted[OF sorted] \<open>xs \<noteq> []\<close> sortedE[OF le0]
[PROOF STATE]
proof (prove)
using this:
j < length (xs ! i)
foldr max (map length xs) ?y = (if map length xs = [] then ?y else max (map length xs ! 0) ?y)
xs \<noteq> []
length (xs ! i) \<le> length (xs ! 0)

goal (1 subgoal):
 1. j < length (transpose xs)
[PROOF STEP]
by (auto simp: length_transpose comp_def foldr_map)
[PROOF STATE]
proof (state)
this:
j < length (transpose xs)

goal (1 subgoal):
 1. \<And>x. x < length (xs ! i) \<Longrightarrow> i < length (transpose xs ! x)
[PROOF STEP]
have "Suc i \<le> length (takeWhile (\<lambda>ys. j < length ys) xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc i \<le> length (takeWhile (\<lambda>ys. j < length ys) xs)
[PROOF STEP]
using \<open>i < length xs\<close> \<open>j < length (xs ! i)\<close> less_Suc_eq_le
[PROOF STATE]
proof (prove)
using this:
i < length xs
j < length (xs ! i)
(?m < Suc ?n) = (?m \<le> ?n)

goal (1 subgoal):
 1. Suc i \<le> length (takeWhile (\<lambda>ys. j < length ys) xs)
[PROOF STEP]
by (auto intro!: length_takeWhile_less_P_nth dest!: sortedE)
[PROOF STATE]
proof (state)
this:
Suc i \<le> length (takeWhile (\<lambda>ys. j < length ys) xs)

goal (1 subgoal):
 1. \<And>x. x < length (xs ! i) \<Longrightarrow> i < length (transpose xs ! x)
[PROOF STEP]
with nth_transpose[OF \<open>j < length (transpose xs)\<close>]
[PROOF STATE]
proof (chain)
picking this:
transpose xs ! j = map (\<lambda>xs. xs ! j) (filter (\<lambda>ys. j < length ys) xs)
Suc i \<le> length (takeWhile (\<lambda>ys. j < length ys) xs)
[PROOF STEP]
show "i < length (transpose xs ! j)"
[PROOF STATE]
proof (prove)
using this:
transpose xs ! j = map (\<lambda>xs. xs ! j) (filter (\<lambda>ys. j < length ys) xs)
Suc i \<le> length (takeWhile (\<lambda>ys. j < length ys) xs)

goal (1 subgoal):
 1. i < length (transpose xs ! j)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
i < length (transpose xs ! j)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
{j. j < length (transpose xs) \<and> i < length (transpose xs ! j)} = {..<length (xs ! i)}

goal (1 subgoal):
 1. length (filter (\<lambda>ys. i < length ys) (transpose xs)) = length (xs ! i)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
{j. j < length (transpose xs) \<and> i < length (transpose xs ! j)} = {..<length (xs ! i)}

goal (1 subgoal):
 1. length (filter (\<lambda>ys. i < length ys) (transpose xs)) = length (xs ! i)
[PROOF STEP]
by (simp add: length_filter_conv_card)
[PROOF STATE]
proof (state)
this:
length (filter (\<lambda>ys. i < length ys) (transpose xs)) = length (xs ! i)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma perms_inv:
  assumes f: "f \<in> perms"
  shows "inv f \<in> perms"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inv f \<in> perms
[PROOF STEP]
apply (rule permsI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. bij (inv f)
 2. \<forall>\<^sub>\<infinity>x. inv f x = x
[PROOF STEP]
apply (rule bij_imp_bij_inv)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. bij f
 2. \<forall>\<^sub>\<infinity>x. inv f x = x
[PROOF STEP]
apply (rule perms_imp_bij [OF f])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>\<infinity>x. inv f x = x
[PROOF STEP]
apply (rule MOST_mono [OF perms_imp_MOST_eq [OF f]])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. f x = x \<Longrightarrow> inv f x = x
[PROOF STEP]
apply (erule subst, rule inv_f_f)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. inj f
[PROOF STEP]
apply (rule bij_is_inj [OF perms_imp_bij [OF f]])
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma distinct_pps_to_list: "distinct (pps_to_list S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct (pps_to_list S)
[PROOF STEP]
unfolding pps_to_list_def distinct_rev
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct (ord_term_lin.sorted_list_of_set S)
[PROOF STEP]
by (rule ord_term_lin.distinct_sorted_list_of_set)


[STATEMENT]
lemma vars_add_monom:
assumes "p2 = monom m a" "m \<notin> keys (mapping_of p1)"
shows "vars (p1 + p2) = vars p1 \<union> vars p2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vars (p1 + p2) = vars p1 \<union> vars p2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. vars (p1 + p2) = vars p1 \<union> vars p2
[PROOF STEP]
have "keys (mapping_of p2) \<subseteq> {m}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. keys (mapping_of p2) \<subseteq> {m}
[PROOF STEP]
using monom_def keys_single assms
[PROOF STATE]
proof (prove)
using this:
monom \<equiv> map_fun id (map_fun id MPoly) Poly_Mapping.single
keys (Poly_Mapping.single ?k ?v) = (if ?v = (0::?'b) then {} else {?k})
p2 = monom m a
m \<notin> keys (mapping_of p1)

goal (1 subgoal):
 1. keys (mapping_of p2) \<subseteq> {m}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
keys (mapping_of p2) \<subseteq> {m}

goal (1 subgoal):
 1. vars (p1 + p2) = vars p1 \<union> vars p2
[PROOF STEP]
have "keys (mapping_of (p1+p2)) = keys (mapping_of p1) \<union> keys (mapping_of p2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. keys (mapping_of (p1 + p2)) = keys (mapping_of p1) \<union> keys (mapping_of p2)
[PROOF STEP]
using keys_add
[PROOF STATE]
proof (prove)
using this:
keys ?f \<inter> keys ?g = {} \<Longrightarrow> keys ?f \<union> keys ?g = keys (?f + ?g)

goal (1 subgoal):
 1. keys (mapping_of (p1 + p2)) = keys (mapping_of p1) \<union> keys (mapping_of p2)
[PROOF STEP]
by (metis Int_insert_right_if0 \<open>keys (mapping_of p2) \<subseteq> {m}\<close> assms(2) inf_bot_right plus_mpoly.rep_eq subset_singletonD)
[PROOF STATE]
proof (state)
this:
keys (mapping_of (p1 + p2)) = keys (mapping_of p1) \<union> keys (mapping_of p2)

goal (1 subgoal):
 1. vars (p1 + p2) = vars p1 \<union> vars p2
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
keys (mapping_of (p1 + p2)) = keys (mapping_of p1) \<union> keys (mapping_of p2)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
keys (mapping_of (p1 + p2)) = keys (mapping_of p1) \<union> keys (mapping_of p2)

goal (1 subgoal):
 1. vars (p1 + p2) = vars p1 \<union> vars p2
[PROOF STEP]
unfolding vars_def
[PROOF STATE]
proof (prove)
using this:
keys (mapping_of (p1 + p2)) = keys (mapping_of p1) \<union> keys (mapping_of p2)

goal (1 subgoal):
 1. \<Union> (keys ` keys (mapping_of (p1 + p2))) = \<Union> (keys ` keys (mapping_of p1)) \<union> \<Union> (keys ` keys (mapping_of p2))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
vars (p1 + p2) = vars p1 \<union> vars p2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma indexlt_simp: "indexlt k' u' k u = (k' < k \<or> (k' = k \<and> u' < u))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. indexlt k' u' k u = (k' < k \<or> k' = k \<and> u' < u)
[PROOF STEP]
by (auto simp add: indexlt_def indexlt_rel_def)


[STATEMENT]
lemma map_vec_vCons: "vCons (f a) (map_vec f v) = map_vec f (vCons a v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vCons (f a) (map_vec f v) = map_vec f (vCons a v)
[PROOF STEP]
by (intro eq_vecI, simp_all add: vec_index_vCons)


[STATEMENT]
lemma convex_on_convex_hull_bound:
  assumes "convex_on (convex hull S) f"
    and "\<forall>x\<in>S. f x \<le> b"
  shows "\<forall>x\<in> convex hull S. f x \<le> b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>convex hull S. f x \<le> b
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> convex hull S \<Longrightarrow> f x \<le> b
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> convex hull S \<Longrightarrow> f x \<le> b
[PROOF STEP]
assume "x \<in> convex hull S"
[PROOF STATE]
proof (state)
this:
x \<in> convex hull S

goal (1 subgoal):
 1. \<And>x. x \<in> convex hull S \<Longrightarrow> f x \<le> b
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> convex hull S
[PROOF STEP]
obtain k u v where
    u: "\<forall>i\<in>{1..k::nat}. 0 \<le> u i \<and> v i \<in> S" "sum u {1..k} = 1" "(\<Sum>i = 1..k. u i *\<^sub>R v i) = x"
[PROOF STATE]
proof (prove)
using this:
x \<in> convex hull S

goal (1 subgoal):
 1. (\<And>k u v. \<lbrakk>\<forall>i\<in>{1..k}. 0 \<le> u i \<and> v i \<in> S; sum u {1..k} = 1; (\<Sum>i = 1..k. u i *\<^sub>R v i) = x\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding convex_hull_indexed mem_Collect_eq
[PROOF STATE]
proof (prove)
using this:
\<exists>k u xa. (\<forall>i\<in>{1..k}. 0 \<le> u i \<and> xa i \<in> S) \<and> sum u {1..k} = 1 \<and> (\<Sum>i = 1..k. u i *\<^sub>R xa i) = x

goal (1 subgoal):
 1. (\<And>k u v. \<lbrakk>\<forall>i\<in>{1..k}. 0 \<le> u i \<and> v i \<in> S; sum u {1..k} = 1; (\<Sum>i = 1..k. u i *\<^sub>R v i) = x\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>i\<in>{1..k}. 0 \<le> u i \<and> v i \<in> S
sum u {1..k} = 1
(\<Sum>i = 1..k. u i *\<^sub>R v i) = x

goal (1 subgoal):
 1. \<And>x. x \<in> convex hull S \<Longrightarrow> f x \<le> b
[PROOF STEP]
have "(\<Sum>i = 1..k. u i * f (v i)) \<le> b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 1..k. u i * f (v i)) \<le> b
[PROOF STEP]
using sum_mono[of "{1..k}" "\<lambda>i. u i * f (v i)" "\<lambda>i. u i * b"]
[PROOF STATE]
proof (prove)
using this:
(\<And>i. i \<in> {1..k} \<Longrightarrow> u i * f (v i) \<le> u i * b) \<Longrightarrow> (\<Sum>i = 1..k. u i * f (v i)) \<le> (\<Sum>i = 1..k. u i * b)

goal (1 subgoal):
 1. (\<Sum>i = 1..k. u i * f (v i)) \<le> b
[PROOF STEP]
unfolding sum_distrib_right[symmetric] u(2) mult_1
[PROOF STATE]
proof (prove)
using this:
(\<And>i. i \<in> {1..k} \<Longrightarrow> u i * f (v i) \<le> u i * b) \<Longrightarrow> (\<Sum>i = 1..k. u i * f (v i)) \<le> b

goal (1 subgoal):
 1. (\<Sum>i = 1..k. u i * f (v i)) \<le> b
[PROOF STEP]
using assms(2) mult_left_mono u(1)
[PROOF STATE]
proof (prove)
using this:
(\<And>i. i \<in> {1..k} \<Longrightarrow> u i * f (v i) \<le> u i * b) \<Longrightarrow> (\<Sum>i = 1..k. u i * f (v i)) \<le> b
\<forall>x\<in>S. f x \<le> b
\<lbrakk>?a \<le> ?b; (0::?'a) \<le> ?c\<rbrakk> \<Longrightarrow> ?c * ?a \<le> ?c * ?b
\<forall>i\<in>{1..k}. 0 \<le> u i \<and> v i \<in> S

goal (1 subgoal):
 1. (\<Sum>i = 1..k. u i * f (v i)) \<le> b
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 1..k. u i * f (v i)) \<le> b

goal (1 subgoal):
 1. \<And>x. x \<in> convex hull S \<Longrightarrow> f x \<le> b
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>i = 1..k. u i * f (v i)) \<le> b
[PROOF STEP]
show "f x \<le> b"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i = 1..k. u i * f (v i)) \<le> b

goal (1 subgoal):
 1. f x \<le> b
[PROOF STEP]
using assms(1)[unfolded convex_on[OF convex_convex_hull], rule_format, of k u v]
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i = 1..k. u i * f (v i)) \<le> b
(\<forall>i\<in>{1..k}. 0 \<le> u i \<and> v i \<in> convex hull S) \<and> sum u {1..k} = 1 \<Longrightarrow> f (\<Sum>i = 1..k. u i *\<^sub>R v i) \<le> (\<Sum>i = 1..k. u i * f (v i))

goal (1 subgoal):
 1. f x \<le> b
[PROOF STEP]
using hull_inc u
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i = 1..k. u i * f (v i)) \<le> b
(\<forall>i\<in>{1..k}. 0 \<le> u i \<and> v i \<in> convex hull S) \<and> sum u {1..k} = 1 \<Longrightarrow> f (\<Sum>i = 1..k. u i *\<^sub>R v i) \<le> (\<Sum>i = 1..k. u i * f (v i))
?x \<in> ?S \<Longrightarrow> ?x \<in> ?P hull ?S
\<forall>i\<in>{1..k}. 0 \<le> u i \<and> v i \<in> S
sum u {1..k} = 1
(\<Sum>i = 1..k. u i *\<^sub>R v i) = x

goal (1 subgoal):
 1. f x \<le> b
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
f x \<le> b

goal:
No subgoals!
[PROOF STEP]
qed


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

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

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

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma foldl_f_commute: "f a (foldl (\<lambda>a b. f b a) b xs) = foldl (\<lambda>a b. f b a) (f a b) xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f a (foldl (\<lambda>a b. f b a) b xs) = foldl (\<lambda>a b. f b a) (f a b) xs
[PROOF STEP]
by(induct xs arbitrary: b)(simp_all add: fun_left_comm)


[STATEMENT]
lemma poly_add_gt_mono: assumes "p1 >p p2" shows "poly_add p1 q >p poly_add p2 q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_add p1 q >p poly_add p2 q
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
p1 >p p2

goal (1 subgoal):
 1. poly_add p1 q >p poly_add p2 q
[PROOF STEP]
unfolding poly_gt_def
[PROOF STATE]
proof (prove)
using this:
\<forall>\<alpha>. pos_assign \<alpha> \<longrightarrow> eval_poly \<alpha> p1 \<succ> eval_poly \<alpha> p2

goal (1 subgoal):
 1. \<forall>\<alpha>. pos_assign \<alpha> \<longrightarrow> eval_poly \<alpha> (poly_add p1 q) \<succ> eval_poly \<alpha> (poly_add p2 q)
[PROOF STEP]
by (auto simp: field_simps plus_gt_left_mono)