[STATEMENT]
lemma convex_hull_finite_union:
  assumes "finite I"
  assumes "\<forall>i\<in>I. convex (S i) \<and> (S i) \<noteq> {}"
  shows "convex hull (\<Union>(S ` I)) =
    {sum (\<lambda>i. c i *\<^sub>R s i) I | c s. (\<forall>i\<in>I. c i \<ge> 0) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}"
  (is "?lhs = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
have "?lhs \<supseteq> ?rhs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)} \<subseteq> convex hull \<Union> (S ` I)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)} \<Longrightarrow> x \<in> convex hull \<Union> (S ` I)
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)} \<Longrightarrow> x \<in> convex hull \<Union> (S ` I)
[PROOF STEP]
assume "x \<in> ?rhs"
[PROOF STATE]
proof (state)
this:
x \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}

goal (1 subgoal):
 1. \<And>x. x \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)} \<Longrightarrow> x \<in> convex hull \<Union> (S ` I)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
obtain c s where *: "sum (\<lambda>i. c i *\<^sub>R s i) I = x" "sum c I = 1"
      "(\<forall>i\<in>I. c i \<ge> 0) \<and> (\<forall>i\<in>I. s i \<in> S i)"
[PROOF STATE]
proof (prove)
using this:
x \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}

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

goal (1 subgoal):
 1. \<And>x. x \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)} \<Longrightarrow> x \<in> convex hull \<Union> (S ` I)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>i\<in>I. c i *\<^sub>R s i) = x
sum c I = 1
(\<forall>i\<in>I. 0 \<le> c i) \<and> (\<forall>i\<in>I. s i \<in> S i)
[PROOF STEP]
have "\<forall>i\<in>I. s i \<in> convex hull (\<Union>(S ` I))"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i\<in>I. c i *\<^sub>R s i) = x
sum c I = 1
(\<forall>i\<in>I. 0 \<le> c i) \<and> (\<forall>i\<in>I. s i \<in> S i)

goal (1 subgoal):
 1. \<forall>i\<in>I. s i \<in> convex hull \<Union> (S ` I)
[PROOF STEP]
using hull_subset[of "\<Union>(S ` I)" convex]
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i\<in>I. c i *\<^sub>R s i) = x
sum c I = 1
(\<forall>i\<in>I. 0 \<le> c i) \<and> (\<forall>i\<in>I. s i \<in> S i)
\<Union> (S ` I) \<subseteq> convex hull \<Union> (S ` I)

goal (1 subgoal):
 1. \<forall>i\<in>I. s i \<in> convex hull \<Union> (S ` I)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>i\<in>I. s i \<in> convex hull \<Union> (S ` I)

goal (1 subgoal):
 1. \<And>x. x \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)} \<Longrightarrow> x \<in> convex hull \<Union> (S ` I)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>i\<in>I. s i \<in> convex hull \<Union> (S ` I)
[PROOF STEP]
show "x \<in> ?lhs"
[PROOF STATE]
proof (prove)
using this:
\<forall>i\<in>I. s i \<in> convex hull \<Union> (S ` I)

goal (1 subgoal):
 1. x \<in> convex hull \<Union> (S ` I)
[PROOF STEP]
unfolding *(1)[symmetric]
[PROOF STATE]
proof (prove)
using this:
\<forall>i\<in>I. s i \<in> convex hull \<Union> (S ` I)

goal (1 subgoal):
 1. (\<Sum>i\<in>I. c i *\<^sub>R s i) \<in> convex hull \<Union> (S ` I)
[PROOF STEP]
using * assms convex_convex_hull
[PROOF STATE]
proof (prove)
using this:
\<forall>i\<in>I. s i \<in> convex hull \<Union> (S ` I)
(\<Sum>i\<in>I. c i *\<^sub>R s i) = x
sum c I = 1
(\<forall>i\<in>I. 0 \<le> c i) \<and> (\<forall>i\<in>I. s i \<in> S i)
finite I
\<forall>i\<in>I. convex (S i) \<and> S i \<noteq> {}
convex (convex hull ?s)

goal (1 subgoal):
 1. (\<Sum>i\<in>I. c i *\<^sub>R s i) \<in> convex hull \<Union> (S ` I)
[PROOF STEP]
by (subst convex_sum) auto
[PROOF STATE]
proof (state)
this:
x \<in> convex hull \<Union> (S ` I)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
{\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)} \<subseteq> convex hull \<Union> (S ` I)

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
{\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)} \<subseteq> convex hull \<Union> (S ` I)

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
assume "i \<in> I"
[PROOF STATE]
proof (state)
this:
i \<in> I

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
finite I
\<forall>i\<in>I. convex (S i) \<and> S i \<noteq> {}
i \<in> I
[PROOF STEP]
have "\<exists>p. p \<in> S i"
[PROOF STATE]
proof (prove)
using this:
finite I
\<forall>i\<in>I. convex (S i) \<and> S i \<noteq> {}
i \<in> I

goal (1 subgoal):
 1. \<exists>p. p \<in> S i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>p. p \<in> S i

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?i2 \<in> I \<Longrightarrow> \<exists>p. p \<in> S ?i2

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?i2 \<in> I \<Longrightarrow> \<exists>p. p \<in> S ?i2
[PROOF STEP]
obtain p where p: "\<forall>i\<in>I. p i \<in> S i"
[PROOF STATE]
proof (prove)
using this:
?i2 \<in> I \<Longrightarrow> \<exists>p. p \<in> S ?i2

goal (1 subgoal):
 1. (\<And>p. \<forall>i\<in>I. p i \<in> S i \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
\<forall>i\<in>I. p i \<in> S i

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
\<forall>i\<in>I. p i \<in> S i

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
assume "i \<in> I"
[PROOF STATE]
proof (state)
this:
i \<in> I

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
i \<in> I

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
assume "x \<in> S i"
[PROOF STATE]
proof (state)
this:
x \<in> S i

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
define c where "c j = (if j = i then 1::real else 0)" for j
[PROOF STATE]
proof (state)
this:
c ?j = (if ?j = i then 1 else 0)

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
c ?j = (if ?j = i then 1 else 0)
[PROOF STEP]
have *: "sum c I = 1"
[PROOF STATE]
proof (prove)
using this:
c ?j = (if ?j = i then 1 else 0)

goal (1 subgoal):
 1. sum c I = 1
[PROOF STEP]
using \<open>finite I\<close> \<open>i \<in> I\<close> sum.delta[of I i "\<lambda>j::'a. 1::real"]
[PROOF STATE]
proof (prove)
using this:
c ?j = (if ?j = i then 1 else 0)
finite I
i \<in> I
finite I \<Longrightarrow> (\<Sum>k\<in>I. if k = i then 1 else 0) = (if i \<in> I then 1 else 0)

goal (1 subgoal):
 1. sum c I = 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
sum c I = 1

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
define s where "s j = (if j = i then x else p j)" for j
[PROOF STATE]
proof (state)
this:
s ?j = (if ?j = i then x else p ?j)

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
s ?j = (if ?j = i then x else p ?j)
[PROOF STEP]
have "\<forall>j. c j *\<^sub>R s j = (if j = i then x else 0)"
[PROOF STATE]
proof (prove)
using this:
s ?j = (if ?j = i then x else p ?j)

goal (1 subgoal):
 1. \<forall>j. c j *\<^sub>R s j = (if j = i then x else (0::'b))
[PROOF STEP]
using c_def
[PROOF STATE]
proof (prove)
using this:
s ?j = (if ?j = i then x else p ?j)
c ?j = (if ?j = i then 1 else 0)

goal (1 subgoal):
 1. \<forall>j. c j *\<^sub>R s j = (if j = i then x else (0::'b))
[PROOF STEP]
by (auto simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
\<forall>j. c j *\<^sub>R s j = (if j = i then x else (0::'b))

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>j. c j *\<^sub>R s j = (if j = i then x else (0::'b))
[PROOF STEP]
have "x = sum (\<lambda>i. c i *\<^sub>R s i) I"
[PROOF STATE]
proof (prove)
using this:
\<forall>j. c j *\<^sub>R s j = (if j = i then x else (0::'b))

goal (1 subgoal):
 1. x = (\<Sum>i\<in>I. c i *\<^sub>R s i)
[PROOF STEP]
using s_def c_def \<open>finite I\<close> \<open>i \<in> I\<close> sum.delta[of I i "\<lambda>j::'a. x"]
[PROOF STATE]
proof (prove)
using this:
\<forall>j. c j *\<^sub>R s j = (if j = i then x else (0::'b))
s ?j = (if ?j = i then x else p ?j)
c ?j = (if ?j = i then 1 else 0)
finite I
i \<in> I
finite I \<Longrightarrow> (\<Sum>k\<in>I. if k = i then x else (0::'b)) = (if i \<in> I then x else (0::'b))

goal (1 subgoal):
 1. x = (\<Sum>i\<in>I. c i *\<^sub>R s i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x = (\<Sum>i\<in>I. c i *\<^sub>R s i)

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
x = (\<Sum>i\<in>I. c i *\<^sub>R s i)

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
have "(\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)
[PROOF STEP]
using * c_def s_def p \<open>x \<in> S i\<close>
[PROOF STATE]
proof (prove)
using this:
sum c I = 1
c ?j = (if ?j = i then 1 else 0)
s ?j = (if ?j = i then x else p ?j)
\<forall>i\<in>I. p i \<in> S i
x \<in> S i

goal (1 subgoal):
 1. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
x = (\<Sum>i\<in>I. c i *\<^sub>R s i)
(\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)
[PROOF STEP]
have "x \<in> ?rhs"
[PROOF STATE]
proof (prove)
using this:
x = (\<Sum>i\<in>I. c i *\<^sub>R s i)
(\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)

goal (1 subgoal):
 1. x \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
x \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?x2 \<in> S i \<Longrightarrow> ?x2 \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?x2 \<in> S i \<Longrightarrow> ?x2 \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
have "?rhs \<supseteq> S i"
[PROOF STATE]
proof (prove)
using this:
?x2 \<in> S i \<Longrightarrow> ?x2 \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}

goal (1 subgoal):
 1. S i \<subseteq> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
S i \<subseteq> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?i2 \<in> I \<Longrightarrow> S ?i2 \<subseteq> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?i2 \<in> I \<Longrightarrow> S ?i2 \<subseteq> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
have *: "?rhs \<supseteq> \<Union>(S ` I)"
[PROOF STATE]
proof (prove)
using this:
?i2 \<in> I \<Longrightarrow> S ?i2 \<subseteq> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}

goal (1 subgoal):
 1. \<Union> (S ` I) \<subseteq> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<Union> (S ` I) \<subseteq> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
\<Union> (S ` I) \<subseteq> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
fix u v :: real
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
assume uv: "u \<ge> 0 \<and> v \<ge> 0 \<and> u + v = 1"
[PROOF STATE]
proof (state)
this:
0 \<le> u \<and> 0 \<le> v \<and> u + v = 1

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
fix x y
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
assume xy: "x \<in> ?rhs \<and> y \<in> ?rhs"
[PROOF STATE]
proof (state)
this:
x \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)} \<and> y \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
from xy
[PROOF STATE]
proof (chain)
picking this:
x \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)} \<and> y \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
obtain c s where
      xc: "x = sum (\<lambda>i. c i *\<^sub>R s i) I \<and> (\<forall>i\<in>I. c i \<ge> 0) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)"
[PROOF STATE]
proof (prove)
using this:
x \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)} \<and> y \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}

goal (1 subgoal):
 1. (\<And>c s. x = (\<Sum>i\<in>I. c i *\<^sub>R s i) \<and> (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x = (\<Sum>i\<in>I. c i *\<^sub>R s i) \<and> (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
from xy
[PROOF STATE]
proof (chain)
picking this:
x \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)} \<and> y \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
obtain d t where
      yc: "y = sum (\<lambda>i. d i *\<^sub>R t i) I \<and> (\<forall>i\<in>I. d i \<ge> 0) \<and> sum d I = 1 \<and> (\<forall>i\<in>I. t i \<in> S i)"
[PROOF STATE]
proof (prove)
using this:
x \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)} \<and> y \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}

goal (1 subgoal):
 1. (\<And>d t. y = (\<Sum>i\<in>I. d i *\<^sub>R t i) \<and> (\<forall>i\<in>I. 0 \<le> d i) \<and> sum d I = 1 \<and> (\<forall>i\<in>I. t i \<in> S i) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
y = (\<Sum>i\<in>I. d i *\<^sub>R t i) \<and> (\<forall>i\<in>I. 0 \<le> d i) \<and> sum d I = 1 \<and> (\<forall>i\<in>I. t i \<in> S i)

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
define e where "e i = u * c i + v * d i" for i
[PROOF STATE]
proof (state)
this:
e ?i = u * c ?i + v * d ?i

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
have ge0: "\<forall>i\<in>I. e i \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i\<in>I. 0 \<le> e i
[PROOF STEP]
using e_def xc yc uv
[PROOF STATE]
proof (prove)
using this:
e ?i = u * c ?i + v * d ?i
x = (\<Sum>i\<in>I. c i *\<^sub>R s i) \<and> (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)
y = (\<Sum>i\<in>I. d i *\<^sub>R t i) \<and> (\<forall>i\<in>I. 0 \<le> d i) \<and> sum d I = 1 \<and> (\<forall>i\<in>I. t i \<in> S i)
0 \<le> u \<and> 0 \<le> v \<and> u + v = 1

goal (1 subgoal):
 1. \<forall>i\<in>I. 0 \<le> e i
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<forall>i\<in>I. 0 \<le> e i

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
have "sum (\<lambda>i. u * c i) I = u * sum c I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>I. u * c i) = u * sum c I
[PROOF STEP]
by (simp add: sum_distrib_left)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>I. u * c i) = u * sum c I

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>I. u * c i) = u * sum c I

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
have "sum (\<lambda>i. v * d i) I = v * sum d I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>I. v * d i) = v * sum d I
[PROOF STEP]
by (simp add: sum_distrib_left)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>I. v * d i) = v * sum d I

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>i\<in>I. u * c i) = u * sum c I
(\<Sum>i\<in>I. v * d i) = v * sum d I
[PROOF STEP]
have sum1: "sum e I = 1"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i\<in>I. u * c i) = u * sum c I
(\<Sum>i\<in>I. v * d i) = v * sum d I

goal (1 subgoal):
 1. sum e I = 1
[PROOF STEP]
using e_def xc yc uv
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i\<in>I. u * c i) = u * sum c I
(\<Sum>i\<in>I. v * d i) = v * sum d I
e ?i = u * c ?i + v * d ?i
x = (\<Sum>i\<in>I. c i *\<^sub>R s i) \<and> (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)
y = (\<Sum>i\<in>I. d i *\<^sub>R t i) \<and> (\<forall>i\<in>I. 0 \<le> d i) \<and> sum d I = 1 \<and> (\<forall>i\<in>I. t i \<in> S i)
0 \<le> u \<and> 0 \<le> v \<and> u + v = 1

goal (1 subgoal):
 1. sum e I = 1
[PROOF STEP]
by (simp add: sum.distrib)
[PROOF STATE]
proof (state)
this:
sum e I = 1

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
define q where "q i = (if e i = 0 then p i else (u * c i / e i) *\<^sub>R s i + (v * d i / e i) *\<^sub>R t i)"
      for i
[PROOF STATE]
proof (state)
this:
q ?i = (if e ?i = 0 then p ?i else (u * c ?i / e ?i) *\<^sub>R s ?i + (v * d ?i / e ?i) *\<^sub>R t ?i)

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
q ?i = (if e ?i = 0 then p ?i else (u * c ?i / e ?i) *\<^sub>R s ?i + (v * d ?i / e ?i) *\<^sub>R t ?i)

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
assume i: "i \<in> I"
[PROOF STATE]
proof (state)
this:
i \<in> I

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
have "q i \<in> S i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. q i \<in> S i
[PROOF STEP]
proof (cases "e i = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. e i = 0 \<Longrightarrow> q i \<in> S i
 2. e i \<noteq> 0 \<Longrightarrow> q i \<in> S i
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
e i = 0

goal (2 subgoals):
 1. e i = 0 \<Longrightarrow> q i \<in> S i
 2. e i \<noteq> 0 \<Longrightarrow> q i \<in> S i
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
e i = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
e i = 0

goal (1 subgoal):
 1. q i \<in> S i
[PROOF STEP]
using i p q_def
[PROOF STATE]
proof (prove)
using this:
e i = 0
i \<in> I
\<forall>i\<in>I. p i \<in> S i
q ?i = (if e ?i = 0 then p ?i else (u * c ?i / e ?i) *\<^sub>R s ?i + (v * d ?i / e ?i) *\<^sub>R t ?i)

goal (1 subgoal):
 1. q i \<in> S i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
q i \<in> S i

goal (1 subgoal):
 1. e i \<noteq> 0 \<Longrightarrow> q i \<in> S i
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. e i \<noteq> 0 \<Longrightarrow> q i \<in> S i
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
e i \<noteq> 0

goal (1 subgoal):
 1. e i \<noteq> 0 \<Longrightarrow> q i \<in> S i
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
e i \<noteq> 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
e i \<noteq> 0

goal (1 subgoal):
 1. q i \<in> S i
[PROOF STEP]
using mem_convex_alt[of "S i" "s i" "t i" "u * (c i)" "v * (d i)"]
            mult_nonneg_nonneg[of u "c i"] mult_nonneg_nonneg[of v "d i"]
            assms q_def e_def i False xc yc uv
[PROOF STATE]
proof (prove)
using this:
e i \<noteq> 0
\<lbrakk>convex (S i); s i \<in> S i; t i \<in> S i; 0 \<le> u * c i; 0 \<le> v * d i; 0 < u * c i + v * d i\<rbrakk> \<Longrightarrow> (u * c i / (u * c i + v * d i)) *\<^sub>R s i + (v * d i / (u * c i + v * d i)) *\<^sub>R t i \<in> S i
\<lbrakk>0 \<le> u; 0 \<le> c i\<rbrakk> \<Longrightarrow> 0 \<le> u * c i
\<lbrakk>0 \<le> v; 0 \<le> d i\<rbrakk> \<Longrightarrow> 0 \<le> v * d i
finite I
\<forall>i\<in>I. convex (S i) \<and> S i \<noteq> {}
q ?i = (if e ?i = 0 then p ?i else (u * c ?i / e ?i) *\<^sub>R s ?i + (v * d ?i / e ?i) *\<^sub>R t ?i)
e ?i = u * c ?i + v * d ?i
i \<in> I
e i \<noteq> 0
x = (\<Sum>i\<in>I. c i *\<^sub>R s i) \<and> (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)
y = (\<Sum>i\<in>I. d i *\<^sub>R t i) \<and> (\<forall>i\<in>I. 0 \<le> d i) \<and> sum d I = 1 \<and> (\<forall>i\<in>I. t i \<in> S i)
0 \<le> u \<and> 0 \<le> v \<and> u + v = 1

goal (1 subgoal):
 1. q i \<in> S i
[PROOF STEP]
by (auto simp del: mult_nonneg_nonneg)
[PROOF STATE]
proof (state)
this:
q i \<in> S i

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
q i \<in> S i

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?i2 \<in> I \<Longrightarrow> q ?i2 \<in> S ?i2

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?i2 \<in> I \<Longrightarrow> q ?i2 \<in> S ?i2
[PROOF STEP]
have qs: "\<forall>i\<in>I. q i \<in> S i"
[PROOF STATE]
proof (prove)
using this:
?i2 \<in> I \<Longrightarrow> q ?i2 \<in> S ?i2

goal (1 subgoal):
 1. \<forall>i\<in>I. q i \<in> S i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>i\<in>I. q i \<in> S i

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
\<forall>i\<in>I. q i \<in> S i

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
assume i: "i \<in> I"
[PROOF STATE]
proof (state)
this:
i \<in> I

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
have "(u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i
[PROOF STEP]
proof (cases "e i = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. e i = 0 \<Longrightarrow> (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i
 2. e i \<noteq> 0 \<Longrightarrow> (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
e i = 0

goal (2 subgoals):
 1. e i = 0 \<Longrightarrow> (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i
 2. e i \<noteq> 0 \<Longrightarrow> (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i
[PROOF STEP]
have ge: "u * (c i) \<ge> 0 \<and> v * d i \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> u * c i \<and> 0 \<le> v * d i
[PROOF STEP]
using xc yc uv i
[PROOF STATE]
proof (prove)
using this:
x = (\<Sum>i\<in>I. c i *\<^sub>R s i) \<and> (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)
y = (\<Sum>i\<in>I. d i *\<^sub>R t i) \<and> (\<forall>i\<in>I. 0 \<le> d i) \<and> sum d I = 1 \<and> (\<forall>i\<in>I. t i \<in> S i)
0 \<le> u \<and> 0 \<le> v \<and> u + v = 1
i \<in> I

goal (1 subgoal):
 1. 0 \<le> u * c i \<and> 0 \<le> v * d i
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 \<le> u * c i \<and> 0 \<le> v * d i

goal (2 subgoals):
 1. e i = 0 \<Longrightarrow> (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i
 2. e i \<noteq> 0 \<Longrightarrow> (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
0 \<le> u * c i \<and> 0 \<le> v * d i

goal (2 subgoals):
 1. e i = 0 \<Longrightarrow> (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i
 2. e i \<noteq> 0 \<Longrightarrow> (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i
[PROOF STEP]
from ge
[PROOF STATE]
proof (chain)
picking this:
0 \<le> u * c i \<and> 0 \<le> v * d i
[PROOF STEP]
have "u * c i \<le> 0 \<and> v * d i \<le> 0"
[PROOF STATE]
proof (prove)
using this:
0 \<le> u * c i \<and> 0 \<le> v * d i

goal (1 subgoal):
 1. u * c i \<le> 0 \<and> v * d i \<le> 0
[PROOF STEP]
using True e_def i
[PROOF STATE]
proof (prove)
using this:
0 \<le> u * c i \<and> 0 \<le> v * d i
e i = 0
e ?i = u * c ?i + v * d ?i
i \<in> I

goal (1 subgoal):
 1. u * c i \<le> 0 \<and> v * d i \<le> 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
u * c i \<le> 0 \<and> v * d i \<le> 0

goal (2 subgoals):
 1. e i = 0 \<Longrightarrow> (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i
 2. e i \<noteq> 0 \<Longrightarrow> (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
0 \<le> u * c i \<and> 0 \<le> v * d i
u * c i \<le> 0 \<and> v * d i \<le> 0
[PROOF STEP]
have "u * c i = 0 \<and> v * d i = 0"
[PROOF STATE]
proof (prove)
using this:
0 \<le> u * c i \<and> 0 \<le> v * d i
u * c i \<le> 0 \<and> v * d i \<le> 0

goal (1 subgoal):
 1. u * c i = 0 \<and> v * d i = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
u * c i = 0 \<and> v * d i = 0

goal (2 subgoals):
 1. e i = 0 \<Longrightarrow> (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i
 2. e i \<noteq> 0 \<Longrightarrow> (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i
[PROOF STEP]
with True
[PROOF STATE]
proof (chain)
picking this:
e i = 0
u * c i = 0 \<and> v * d i = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
e i = 0
u * c i = 0 \<and> v * d i = 0

goal (1 subgoal):
 1. (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i

goal (1 subgoal):
 1. e i \<noteq> 0 \<Longrightarrow> (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. e i \<noteq> 0 \<Longrightarrow> (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
e i \<noteq> 0

goal (1 subgoal):
 1. e i \<noteq> 0 \<Longrightarrow> (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
e i \<noteq> 0
[PROOF STEP]
have "(u * (c i)/(e i))*\<^sub>R (s i)+(v * (d i)/(e i))*\<^sub>R (t i) = q i"
[PROOF STATE]
proof (prove)
using this:
e i \<noteq> 0

goal (1 subgoal):
 1. (u * c i / e i) *\<^sub>R s i + (v * d i / e i) *\<^sub>R t i = q i
[PROOF STEP]
using q_def
[PROOF STATE]
proof (prove)
using this:
e i \<noteq> 0
q ?i = (if e ?i = 0 then p ?i else (u * c ?i / e ?i) *\<^sub>R s ?i + (v * d ?i / e ?i) *\<^sub>R t ?i)

goal (1 subgoal):
 1. (u * c i / e i) *\<^sub>R s i + (v * d i / e i) *\<^sub>R t i = q i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(u * c i / e i) *\<^sub>R s i + (v * d i / e i) *\<^sub>R t i = q i

goal (1 subgoal):
 1. e i \<noteq> 0 \<Longrightarrow> (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(u * c i / e i) *\<^sub>R s i + (v * d i / e i) *\<^sub>R t i = q i
[PROOF STEP]
have "e i *\<^sub>R ((u * (c i)/(e i))*\<^sub>R (s i)+(v * (d i)/(e i))*\<^sub>R (t i))
               = (e i) *\<^sub>R (q i)"
[PROOF STATE]
proof (prove)
using this:
(u * c i / e i) *\<^sub>R s i + (v * d i / e i) *\<^sub>R t i = q i

goal (1 subgoal):
 1. e i *\<^sub>R ((u * c i / e i) *\<^sub>R s i + (v * d i / e i) *\<^sub>R t i) = e i *\<^sub>R q i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
e i *\<^sub>R ((u * c i / e i) *\<^sub>R s i + (v * d i / e i) *\<^sub>R t i) = e i *\<^sub>R q i

goal (1 subgoal):
 1. e i \<noteq> 0 \<Longrightarrow> (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i
[PROOF STEP]
with False
[PROOF STATE]
proof (chain)
picking this:
e i \<noteq> 0
e i *\<^sub>R ((u * c i / e i) *\<^sub>R s i + (v * d i / e i) *\<^sub>R t i) = e i *\<^sub>R q i
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
e i \<noteq> 0
e i *\<^sub>R ((u * c i / e i) *\<^sub>R s i + (v * d i / e i) *\<^sub>R t i) = e i *\<^sub>R q i

goal (1 subgoal):
 1. (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i
[PROOF STEP]
by (simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
(u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?i2 \<in> I \<Longrightarrow> (u * c ?i2) *\<^sub>R s ?i2 + (v * d ?i2) *\<^sub>R t ?i2 = e ?i2 *\<^sub>R q ?i2

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?i2 \<in> I \<Longrightarrow> (u * c ?i2) *\<^sub>R s ?i2 + (v * d ?i2) *\<^sub>R t ?i2 = e ?i2 *\<^sub>R q ?i2
[PROOF STEP]
have *: "\<forall>i\<in>I. (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i"
[PROOF STATE]
proof (prove)
using this:
?i2 \<in> I \<Longrightarrow> (u * c ?i2) *\<^sub>R s ?i2 + (v * d ?i2) *\<^sub>R t ?i2 = e ?i2 *\<^sub>R q ?i2

goal (1 subgoal):
 1. \<forall>i\<in>I. (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>i\<in>I. (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
have "u *\<^sub>R x + v *\<^sub>R y = sum (\<lambda>i. (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i) I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. u *\<^sub>R x + v *\<^sub>R y = (\<Sum>i\<in>I. (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i)
[PROOF STEP]
using xc yc
[PROOF STATE]
proof (prove)
using this:
x = (\<Sum>i\<in>I. c i *\<^sub>R s i) \<and> (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)
y = (\<Sum>i\<in>I. d i *\<^sub>R t i) \<and> (\<forall>i\<in>I. 0 \<le> d i) \<and> sum d I = 1 \<and> (\<forall>i\<in>I. t i \<in> S i)

goal (1 subgoal):
 1. u *\<^sub>R x + v *\<^sub>R y = (\<Sum>i\<in>I. (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i)
[PROOF STEP]
by (simp add: algebra_simps scaleR_right.sum sum.distrib)
[PROOF STATE]
proof (state)
this:
u *\<^sub>R x + v *\<^sub>R y = (\<Sum>i\<in>I. (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i)

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
u *\<^sub>R x + v *\<^sub>R y = (\<Sum>i\<in>I. (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i)

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
have "\<dots> = sum (\<lambda>i. e i *\<^sub>R q i) I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>I. (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i) = (\<Sum>i\<in>I. e i *\<^sub>R q i)
[PROOF STEP]
using *
[PROOF STATE]
proof (prove)
using this:
\<forall>i\<in>I. (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i

goal (1 subgoal):
 1. (\<Sum>i\<in>I. (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i) = (\<Sum>i\<in>I. e i *\<^sub>R q i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>I. (u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i) = (\<Sum>i\<in>I. e i *\<^sub>R q i)

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
u *\<^sub>R x + v *\<^sub>R y = (\<Sum>i\<in>I. e i *\<^sub>R q i)
[PROOF STEP]
have "u *\<^sub>R x + v *\<^sub>R y = sum (\<lambda>i. (e i) *\<^sub>R (q i)) I"
[PROOF STATE]
proof (prove)
using this:
u *\<^sub>R x + v *\<^sub>R y = (\<Sum>i\<in>I. e i *\<^sub>R q i)

goal (1 subgoal):
 1. u *\<^sub>R x + v *\<^sub>R y = (\<Sum>i\<in>I. e i *\<^sub>R q i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
u *\<^sub>R x + v *\<^sub>R y = (\<Sum>i\<in>I. e i *\<^sub>R q i)

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
u *\<^sub>R x + v *\<^sub>R y = (\<Sum>i\<in>I. e i *\<^sub>R q i)
[PROOF STEP]
have "u *\<^sub>R x + v *\<^sub>R y \<in> ?rhs"
[PROOF STATE]
proof (prove)
using this:
u *\<^sub>R x + v *\<^sub>R y = (\<Sum>i\<in>I. e i *\<^sub>R q i)

goal (1 subgoal):
 1. u *\<^sub>R x + v *\<^sub>R y \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
using ge0 sum1 qs
[PROOF STATE]
proof (prove)
using this:
u *\<^sub>R x + v *\<^sub>R y = (\<Sum>i\<in>I. e i *\<^sub>R q i)
\<forall>i\<in>I. 0 \<le> e i
sum e I = 1
\<forall>i\<in>I. q i \<in> S i

goal (1 subgoal):
 1. u *\<^sub>R x + v *\<^sub>R y \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
u *\<^sub>R x + v *\<^sub>R y \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>0 \<le> ?u2 \<and> 0 \<le> ?v2 \<and> ?u2 + ?v2 = 1; ?x2 \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)} \<and> ?y2 \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}\<rbrakk> \<Longrightarrow> ?u2 *\<^sub>R ?x2 + ?v2 *\<^sub>R ?y2 \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>0 \<le> ?u2 \<and> 0 \<le> ?v2 \<and> ?u2 + ?v2 = 1; ?x2 \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)} \<and> ?y2 \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}\<rbrakk> \<Longrightarrow> ?u2 *\<^sub>R ?x2 + ?v2 *\<^sub>R ?y2 \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
have "convex ?rhs"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 \<le> ?u2 \<and> 0 \<le> ?v2 \<and> ?u2 + ?v2 = 1; ?x2 \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)} \<and> ?y2 \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}\<rbrakk> \<Longrightarrow> ?u2 *\<^sub>R ?x2 + ?v2 *\<^sub>R ?y2 \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}

goal (1 subgoal):
 1. convex {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
unfolding convex_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 \<le> ?u2 \<and> 0 \<le> ?v2 \<and> ?u2 + ?v2 = 1; ?x2 \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)} \<and> ?y2 \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}\<rbrakk> \<Longrightarrow> ?u2 *\<^sub>R ?x2 + ?v2 *\<^sub>R ?y2 \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}

goal (1 subgoal):
 1. \<forall>x\<in>{\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}. \<forall>y\<in>{\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}. \<forall>u\<ge>0. \<forall>v\<ge>0. u + v = 1 \<longrightarrow> u *\<^sub>R x + v *\<^sub>R y \<in> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
convex {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
convex {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
convex {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
using \<open>?lhs \<supseteq> ?rhs\<close> * hull_minimal[of "\<Union>(S ` I)" ?rhs convex]
[PROOF STATE]
proof (prove)
using this:
convex {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
{\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)} \<subseteq> convex hull \<Union> (S ` I)
\<Union> (S ` I) \<subseteq> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
\<lbrakk>\<Union> (S ` I) \<subseteq> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}; convex {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}\<rbrakk> \<Longrightarrow> convex hull \<Union> (S ` I) \<subseteq> {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}

goal (1 subgoal):
 1. convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
convex hull \<Union> (S ` I) = {\<Sum>i\<in>I. c i *\<^sub>R s i |c s. (\<forall>i\<in>I. 0 \<le> c i) \<and> sum c I = 1 \<and> (\<forall>i\<in>I. s i \<in> S i)}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma in_mlex_iff:
  "(x,y) \<in> f <*mlex*> r = (f x < f y \<or> (f x=f y \<and> (x,y) \<in> r))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((x, y) \<in> f <*mlex*> r) = (f x < f y \<or> f x = f y \<and> (x, y) \<in> r)
[PROOF STEP]
by (simp add: measure_lex_prod_def' in_measure_iff)


[STATEMENT]
lemma measurable_differentiable_image_alt:
  fixes f :: "real^'n::{finite,wellorder} \<Rightarrow> real^'n::_"
  assumes "S \<in> sets lebesgue"
    and "\<And>x. x \<in> S \<Longrightarrow> (f has_derivative f' x) (at x within S)"
    and "inj_on f S"
  shows "f ` S \<in> lmeasurable \<longleftrightarrow> (\<lambda>x. \<bar>det (matrix (f' x))\<bar>) absolutely_integrable_on S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f ` S \<in> lmeasurable) = ((\<lambda>x. \<bar>det (matrix (f' x))\<bar>) absolutely_integrable_on S)
[PROOF STEP]
using measurable_differentiable_image_eq [OF assms]
[PROOF STATE]
proof (prove)
using this:
(\<And>x. x \<in> S \<Longrightarrow> x \<in> S) \<Longrightarrow> (f ` S \<in> lmeasurable) = ((\<lambda>x. \<bar>det (matrix (f' x))\<bar>) integrable_on S)

goal (1 subgoal):
 1. (f ` S \<in> lmeasurable) = ((\<lambda>x. \<bar>det (matrix (f' x))\<bar>) absolutely_integrable_on S)
[PROOF STEP]
by (simp only: absolutely_integrable_on_iff_nonneg)


[STATEMENT]
lemma insertion_fun_mult:
  fixes f p q
  shows "insertion_fun f (Poly_Mapping.lookup (p * q)) =
    insertion_fun f (Poly_Mapping.lookup p) *
      insertion_fun f (Poly_Mapping.lookup q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
fix m :: "nat \<Rightarrow>\<^sub>0 nat"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
have "finite {v. Poly_Mapping.lookup m v \<noteq> 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {v. poly_mapping.lookup m v \<noteq> 0}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
finite {v. poly_mapping.lookup m v \<noteq> 0}

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
finite {v. poly_mapping.lookup m v \<noteq> 0}
[PROOF STEP]
have "finite {v. f v ^ Poly_Mapping.lookup m v \<noteq> 1}"
[PROOF STATE]
proof (prove)
using this:
finite {v. poly_mapping.lookup m v \<noteq> 0}

goal (1 subgoal):
 1. finite {v. f v ^ poly_mapping.lookup m v \<noteq> (1::'a)}
[PROOF STEP]
by (rule rev_finite_subset) (auto intro: ccontr)
[PROOF STATE]
proof (state)
this:
finite {v. f v ^ poly_mapping.lookup m v \<noteq> (1::'a)}

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
finite {v. f v ^ poly_mapping.lookup ?m2 v \<noteq> (1::'a)}

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
finite {v. f v ^ poly_mapping.lookup ?m2 v \<noteq> (1::'a)}

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
define g where "g m = (\<Prod>v. f v ^ Poly_Mapping.lookup m v)" for m
[PROOF STATE]
proof (state)
this:
g ?m = (\<Prod>v. f v ^ poly_mapping.lookup ?m v)

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
finite {v. f v ^ poly_mapping.lookup ?m2 v \<noteq> (1::'a)}
g ?m = (\<Prod>v. f v ^ poly_mapping.lookup ?m v)
[PROOF STEP]
have *: "\<And>a b. g (a + b) = g a * g b"
[PROOF STATE]
proof (prove)
using this:
finite {v. f v ^ poly_mapping.lookup ?m2 v \<noteq> (1::'a)}
g ?m = (\<Prod>v. f v ^ poly_mapping.lookup ?m v)

goal (1 subgoal):
 1. \<And>a b. g (a + b) = g a * g b
[PROOF STEP]
by (simp add: plus_poly_mapping.rep_eq power_add Prod_any.distrib)
[PROOF STATE]
proof (state)
this:
g (?a + ?b) = g ?a * g ?b

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
have bij: "bij (\<lambda>(l, n, m). (m, l, n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij (\<lambda>(l, n, m). (m, l, n))
[PROOF STEP]
by (auto intro!: bijI injI simp add: image_def)
[PROOF STATE]
proof (state)
this:
bij (\<lambda>(l, n, m). (m, l, n))

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
let ?P = "{l. Poly_Mapping.lookup p l \<noteq> 0}"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
let ?Q = "{n. Poly_Mapping.lookup q n \<noteq> 0}"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
let ?PQ = "{l + n | l n. l \<in> Poly_Mapping.keys p \<and> n \<in> Poly_Mapping.keys q}"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
have "finite {l + n | l n. Poly_Mapping.lookup p l \<noteq> 0 \<and> Poly_Mapping.lookup q n \<noteq> 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {l + n |l n. poly_mapping.lookup p l \<noteq> (0::'a) \<and> poly_mapping.lookup q n \<noteq> (0::'a)}
[PROOF STEP]
by (rule finite_not_eq_zero_sumI) simp_all
[PROOF STATE]
proof (state)
this:
finite {l + n |l n. poly_mapping.lookup p l \<noteq> (0::'a) \<and> poly_mapping.lookup q n \<noteq> (0::'a)}

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
finite {l + n |l n. poly_mapping.lookup p l \<noteq> (0::'a) \<and> poly_mapping.lookup q n \<noteq> (0::'a)}
[PROOF STEP]
have fin_PQ: "finite ?PQ"
[PROOF STATE]
proof (prove)
using this:
finite {l + n |l n. poly_mapping.lookup p l \<noteq> (0::'a) \<and> poly_mapping.lookup q n \<noteq> (0::'a)}

goal (1 subgoal):
 1. finite {l + n |l n. l \<in> Poly_Mapping.keys p \<and> n \<in> Poly_Mapping.keys q}
[PROOF STEP]
by (simp add: in_keys_iff)
[PROOF STATE]
proof (state)
this:
finite {l + n |l n. l \<in> Poly_Mapping.keys p \<and> n \<in> Poly_Mapping.keys q}

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
have "(\<Sum>m. Poly_Mapping.lookup (p * q) m * g m) =
    (\<Sum>m. (\<Sum>l. Poly_Mapping.lookup p l * (\<Sum>n. Poly_Mapping.lookup q n when m = l + n)) * g m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m. poly_mapping.lookup (p * q) m * g m) = (\<Sum>m. (\<Sum>l. poly_mapping.lookup p l * (\<Sum>n. poly_mapping.lookup q n when m = l + n)) * g m)
[PROOF STEP]
by (simp add: times_poly_mapping.rep_eq prod_fun_def)
[PROOF STATE]
proof (state)
this:
(\<Sum>m. poly_mapping.lookup (p * q) m * g m) = (\<Sum>m. (\<Sum>l. poly_mapping.lookup p l * (\<Sum>n. poly_mapping.lookup q n when m = l + n)) * g m)

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>m. poly_mapping.lookup (p * q) m * g m) = (\<Sum>m. (\<Sum>l. poly_mapping.lookup p l * (\<Sum>n. poly_mapping.lookup q n when m = l + n)) * g m)

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
have "\<dots> = (\<Sum>m. (\<Sum>l. (\<Sum>n. g m * (Poly_Mapping.lookup p l * Poly_Mapping.lookup q n) when m = l + n)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m. (\<Sum>l. poly_mapping.lookup p l * (\<Sum>n. poly_mapping.lookup q n when m = l + n)) * g m) = (\<Sum>m. \<Sum>l. \<Sum>n. g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n)
[PROOF STEP]
apply (subst Sum_any_left_distrib)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>m. finite {a. poly_mapping.lookup p a * (\<Sum>n. poly_mapping.lookup q n when m = a + n) \<noteq> (0::'a)}
 2. (\<Sum>m. \<Sum>n. poly_mapping.lookup p n * (\<Sum>na. poly_mapping.lookup q na when m = n + na) * g m) = (\<Sum>m. \<Sum>l. \<Sum>n. g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n)
[PROOF STEP]
apply (auto intro: finite_mult_not_eq_zero_rightI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m. \<Sum>n. poly_mapping.lookup p n * (\<Sum>na. poly_mapping.lookup q na when m = n + na) * g m) = (\<Sum>m. \<Sum>l. \<Sum>n. g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n)
[PROOF STEP]
apply (subst Sum_any_right_distrib)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>n m. finite {a. (poly_mapping.lookup q a when m = n + a) \<noteq> (0::'a)}
 2. (\<Sum>m. \<Sum>n. (\<Sum>na. poly_mapping.lookup p n * (poly_mapping.lookup q na when m = n + na)) * g m) = (\<Sum>m. \<Sum>l. \<Sum>n. g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n)
[PROOF STEP]
apply (auto intro: finite_mult_not_eq_zero_rightI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m. \<Sum>n. (\<Sum>na. poly_mapping.lookup p n * (poly_mapping.lookup q na when m = n + na)) * g m) = (\<Sum>m. \<Sum>l. \<Sum>n. g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n)
[PROOF STEP]
apply (subst Sum_any_left_distrib)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>n m. finite {a. poly_mapping.lookup p n * (poly_mapping.lookup q a when m = n + a) \<noteq> (0::'a)}
 2. (\<Sum>m. \<Sum>n. \<Sum>na. poly_mapping.lookup p n * (poly_mapping.lookup q na when m = n + na) * g m) = (\<Sum>m. \<Sum>l. \<Sum>n. g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n)
[PROOF STEP]
apply (auto intro: finite_mult_not_eq_zero_leftI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m. \<Sum>n. \<Sum>na. poly_mapping.lookup p n * (poly_mapping.lookup q na when m = n + na) * g m) = (\<Sum>m. \<Sum>l. \<Sum>n. g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n)
[PROOF STEP]
apply (simp add: ac_simps mult_when)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
(\<Sum>m. (\<Sum>l. poly_mapping.lookup p l * (\<Sum>n. poly_mapping.lookup q n when m = l + n)) * g m) = (\<Sum>m. \<Sum>l. \<Sum>n. g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n)

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>m. (\<Sum>l. poly_mapping.lookup p l * (\<Sum>n. poly_mapping.lookup q n when m = l + n)) * g m) = (\<Sum>m. \<Sum>l. \<Sum>n. g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n)

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
have "\<dots> = (\<Sum>m. (\<Sum>(l, n). g m * (Poly_Mapping.lookup p l * Poly_Mapping.lookup q n) when m = l + n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m. \<Sum>l. \<Sum>n. g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n) = (\<Sum>m. \<Sum>(l, n). g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n)
[PROOF STEP]
apply (subst (2) Sum_any.cartesian_product [of "?P \<times> ?Q"])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>m. finite ({l. poly_mapping.lookup p l \<noteq> (0::'a)} \<times> {n. poly_mapping.lookup q n \<noteq> (0::'a)})
 2. \<And>m. {a. \<exists>b. (g m * (poly_mapping.lookup p a * poly_mapping.lookup q b) when m = a + b) \<noteq> (0::'a)} \<times> {b. \<exists>a. (g m * (poly_mapping.lookup p a * poly_mapping.lookup q b) when m = a + b) \<noteq> (0::'a)} \<subseteq> {l. poly_mapping.lookup p l \<noteq> (0::'a)} \<times> {n. poly_mapping.lookup q n \<noteq> (0::'a)}
 3. (\<Sum>m. \<Sum>(a, b). g m * (poly_mapping.lookup p a * poly_mapping.lookup q b) when m = a + b) = (\<Sum>m. \<Sum>(l, n). g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n)
[PROOF STEP]
apply (auto dest!: mult_not_zero)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
(\<Sum>m. \<Sum>l. \<Sum>n. g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n) = (\<Sum>m. \<Sum>(l, n). g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n)

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>m. \<Sum>l. \<Sum>n. g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n) = (\<Sum>m. \<Sum>(l, n). g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n)

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
have "\<dots> = (\<Sum>(m, l, n). g m * (Poly_Mapping.lookup p l * Poly_Mapping.lookup q n) when m = l + n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m. \<Sum>(l, n). g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n) = (\<Sum>(m, l, n). g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n)
[PROOF STEP]
apply (subst Sum_any.cartesian_product [of "?PQ \<times> (?P \<times> ?Q)"])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. finite ({l + n |l n. l \<in> Poly_Mapping.keys p \<and> n \<in> Poly_Mapping.keys q} \<times> {l. poly_mapping.lookup p l \<noteq> (0::'a)} \<times> {n. poly_mapping.lookup q n \<noteq> (0::'a)})
 2. {a. \<exists>b. (case b of (l, n) \<Rightarrow> g a * (poly_mapping.lookup p l * poly_mapping.lookup q n) when a = l + n) \<noteq> (0::'a)} \<times> {b. \<exists>a. (case b of (l, n) \<Rightarrow> g a * (poly_mapping.lookup p l * poly_mapping.lookup q n) when a = l + n) \<noteq> (0::'a)} \<subseteq> {l + n |l n. l \<in> Poly_Mapping.keys p \<and> n \<in> Poly_Mapping.keys q} \<times> {l. poly_mapping.lookup p l \<noteq> (0::'a)} \<times> {n. poly_mapping.lookup q n \<noteq> (0::'a)}
 3. (\<Sum>(a, l, n). g a * (poly_mapping.lookup p l * poly_mapping.lookup q n) when a = l + n) = (\<Sum>(m, l, n). g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n)
[PROOF STEP]
apply (auto dest!: mult_not_zero simp add: fin_PQ)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>aa b ab ba. \<lbrakk>g (ab + ba) \<noteq> (0::'a); poly_mapping.lookup p ab \<noteq> (0::'a); poly_mapping.lookup q ba \<noteq> (0::'a); g (aa + b) \<noteq> (0::'a); poly_mapping.lookup p aa \<noteq> (0::'a); poly_mapping.lookup q b \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> \<exists>l n. ab + ba = l + n \<and> l \<in> Poly_Mapping.keys p \<and> n \<in> Poly_Mapping.keys q
[PROOF STEP]
apply (auto simp: in_keys_iff)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
(\<Sum>m. \<Sum>(l, n). g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n) = (\<Sum>(m, l, n). g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n)

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>m. \<Sum>(l, n). g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n) = (\<Sum>(m, l, n). g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n)

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
have "\<dots> = (\<Sum>(l, n, m). g m * (Poly_Mapping.lookup p l * Poly_Mapping.lookup q n) when m = l + n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>(m, l, n). g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n) = (\<Sum>(l, n, m). g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n)
[PROOF STEP]
using bij
[PROOF STATE]
proof (prove)
using this:
bij (\<lambda>(l, n, m). (m, l, n))

goal (1 subgoal):
 1. (\<Sum>(m, l, n). g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n) = (\<Sum>(l, n, m). g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n)
[PROOF STEP]
by (rule Sum_any.reindex_cong [of "\<lambda>(l, n, m). (m, l, n)"]) (simp add: fun_eq_iff)
[PROOF STATE]
proof (state)
this:
(\<Sum>(m, l, n). g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n) = (\<Sum>(l, n, m). g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n)

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>(m, l, n). g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n) = (\<Sum>(l, n, m). g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n)

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
have "\<dots> = (\<Sum>(l, n). \<Sum>m. g m * (Poly_Mapping.lookup p l * Poly_Mapping.lookup q n) when m = l + n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>(l, n, m). g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n) = (\<Sum>(l, n). \<Sum>m. g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n)
[PROOF STEP]
apply (subst Sum_any.cartesian_product2 [of "(?P \<times> ?Q) \<times> ?PQ"])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. finite (({l. poly_mapping.lookup p l \<noteq> (0::'a)} \<times> {n. poly_mapping.lookup q n \<noteq> (0::'a)}) \<times> {l + n |l n. l \<in> Poly_Mapping.keys p \<and> n \<in> Poly_Mapping.keys q})
 2. {(a, b). \<exists>c. (g c * (poly_mapping.lookup p a * poly_mapping.lookup q b) when c = a + b) \<noteq> (0::'a)} \<times> {c. \<exists>a b. (g c * (poly_mapping.lookup p a * poly_mapping.lookup q b) when c = a + b) \<noteq> (0::'a)} \<subseteq> ({l. poly_mapping.lookup p l \<noteq> (0::'a)} \<times> {n. poly_mapping.lookup q n \<noteq> (0::'a)}) \<times> {l + n |l n. l \<in> Poly_Mapping.keys p \<and> n \<in> Poly_Mapping.keys q}
 3. (\<Sum>(l, n, m). g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n) = (\<Sum>(a, b, c). g c * (poly_mapping.lookup p a * poly_mapping.lookup q b) when c = a + b)
[PROOF STEP]
apply (auto dest!: mult_not_zero simp add: fin_PQ )
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a b aa bb. \<lbrakk>g (a + b) \<noteq> (0::'a); poly_mapping.lookup p a \<noteq> (0::'a); poly_mapping.lookup q b \<noteq> (0::'a); g (aa + bb) \<noteq> (0::'a); poly_mapping.lookup p aa \<noteq> (0::'a); poly_mapping.lookup q bb \<noteq> (0::'a)\<rbrakk> \<Longrightarrow> \<exists>l n. aa + bb = l + n \<and> l \<in> Poly_Mapping.keys p \<and> n \<in> Poly_Mapping.keys q
[PROOF STEP]
apply (auto simp: in_keys_iff)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
(\<Sum>(l, n, m). g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n) = (\<Sum>(l, n). \<Sum>m. g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n)

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>(l, n, m). g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n) = (\<Sum>(l, n). \<Sum>m. g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n)

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
have "\<dots> = (\<Sum>(l, n). (g l * g n) * (Poly_Mapping.lookup p l * Poly_Mapping.lookup q n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>(l, n). \<Sum>m. g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n) = (\<Sum>(l, n). g l * g n * (poly_mapping.lookup p l * poly_mapping.lookup q n))
[PROOF STEP]
by (simp add: *)
[PROOF STATE]
proof (state)
this:
(\<Sum>(l, n). \<Sum>m. g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n) = (\<Sum>(l, n). g l * g n * (poly_mapping.lookup p l * poly_mapping.lookup q n))

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>(l, n). \<Sum>m. g m * (poly_mapping.lookup p l * poly_mapping.lookup q n) when m = l + n) = (\<Sum>(l, n). g l * g n * (poly_mapping.lookup p l * poly_mapping.lookup q n))

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
have "\<dots> = (\<Sum>l. \<Sum>n. (g l * g n) * (Poly_Mapping.lookup p l * Poly_Mapping.lookup q n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>(l, n). g l * g n * (poly_mapping.lookup p l * poly_mapping.lookup q n)) = (\<Sum>l. \<Sum>n. g l * g n * (poly_mapping.lookup p l * poly_mapping.lookup q n))
[PROOF STEP]
apply (subst Sum_any.cartesian_product [of "?P \<times> ?Q"])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. finite ({l. poly_mapping.lookup p l \<noteq> (0::'a)} \<times> {n. poly_mapping.lookup q n \<noteq> (0::'a)})
 2. {a. \<exists>b. g a * g b * (poly_mapping.lookup p a * poly_mapping.lookup q b) \<noteq> (0::'a)} \<times> {b. \<exists>a. g a * g b * (poly_mapping.lookup p a * poly_mapping.lookup q b) \<noteq> (0::'a)} \<subseteq> {l. poly_mapping.lookup p l \<noteq> (0::'a)} \<times> {n. poly_mapping.lookup q n \<noteq> (0::'a)}
 3. (\<Sum>(l, n). g l * g n * (poly_mapping.lookup p l * poly_mapping.lookup q n)) = (\<Sum>(a, b). g a * g b * (poly_mapping.lookup p a * poly_mapping.lookup q b))
[PROOF STEP]
apply (auto dest!: mult_not_zero)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
(\<Sum>(l, n). g l * g n * (poly_mapping.lookup p l * poly_mapping.lookup q n)) = (\<Sum>l. \<Sum>n. g l * g n * (poly_mapping.lookup p l * poly_mapping.lookup q n))

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>(l, n). g l * g n * (poly_mapping.lookup p l * poly_mapping.lookup q n)) = (\<Sum>l. \<Sum>n. g l * g n * (poly_mapping.lookup p l * poly_mapping.lookup q n))

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
have "\<dots> = (\<Sum>l. \<Sum>n. (Poly_Mapping.lookup p l * g l) * (Poly_Mapping.lookup q n * g n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>l. \<Sum>n. g l * g n * (poly_mapping.lookup p l * poly_mapping.lookup q n)) = (\<Sum>l. \<Sum>n. poly_mapping.lookup p l * g l * (poly_mapping.lookup q n * g n))
[PROOF STEP]
by (simp add: ac_simps)
[PROOF STATE]
proof (state)
this:
(\<Sum>l. \<Sum>n. g l * g n * (poly_mapping.lookup p l * poly_mapping.lookup q n)) = (\<Sum>l. \<Sum>n. poly_mapping.lookup p l * g l * (poly_mapping.lookup q n * g n))

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>l. \<Sum>n. g l * g n * (poly_mapping.lookup p l * poly_mapping.lookup q n)) = (\<Sum>l. \<Sum>n. poly_mapping.lookup p l * g l * (poly_mapping.lookup q n * g n))

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
have "\<dots> =
    (\<Sum>m. Poly_Mapping.lookup p m * g m) *
    (\<Sum>m. Poly_Mapping.lookup q m * g m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>l. \<Sum>n. poly_mapping.lookup p l * g l * (poly_mapping.lookup q n * g n)) = (\<Sum>m. poly_mapping.lookup p m * g m) * (\<Sum>m. poly_mapping.lookup q m * g m)
[PROOF STEP]
by (rule Sum_any_product [symmetric]) (auto intro: finite_mult_not_eq_zero_rightI)
[PROOF STATE]
proof (state)
this:
(\<Sum>l. \<Sum>n. poly_mapping.lookup p l * g l * (poly_mapping.lookup q n * g n)) = (\<Sum>m. poly_mapping.lookup p m * g m) * (\<Sum>m. poly_mapping.lookup q m * g m)

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>m. poly_mapping.lookup (p * q) m * g m) = (\<Sum>m. poly_mapping.lookup p m * g m) * (\<Sum>m. poly_mapping.lookup q m * g m)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>m. poly_mapping.lookup (p * q) m * g m) = (\<Sum>m. poly_mapping.lookup p m * g m) * (\<Sum>m. poly_mapping.lookup q m * g m)

goal (1 subgoal):
 1. insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)
[PROOF STEP]
by (simp add: insertion_fun_def g_def)
[PROOF STATE]
proof (state)
this:
insertion_fun f (poly_mapping.lookup (p * q)) = insertion_fun f (poly_mapping.lookup p) * insertion_fun f (poly_mapping.lookup q)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma restrict_ext: "(\<And>x. x \<in> A \<Longrightarrow> f x = g x) \<Longrightarrow> (\<lambda>x\<in>A. f x) = (\<lambda>x\<in>A. g x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>x. x \<in> A \<Longrightarrow> f x = g x) \<Longrightarrow> restrict f A = restrict g A
[PROOF STEP]
by (simp add: fun_eq_iff Pi_def restrict_def)


[STATEMENT]
theorem inorder_delete:
  "\<lbrakk>invar t; sorted1(inorder t)\<rbrakk> \<Longrightarrow>
  inorder (delete x t) = del_list x (inorder t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>invar t; sorted1 (Tree2.inorder t)\<rbrakk> \<Longrightarrow> Tree2.inorder (AA_Map.delete x t) = AList_Upd_Del.del_list x (Tree2.inorder t)
[PROOF STEP]
by(induction t)
  (auto simp: del_list_simps inorder_adjust pre_adj_if_postL pre_adj_if_postR
              post_split_max post_delete split_maxD split: prod.splits)


[STATEMENT]
lemma inext_nth_card_Max: "
  \<lbrakk> finite I; I \<noteq> {}; card I \<le> Suc n \<rbrakk> \<Longrightarrow> I \<rightarrow> n = Max I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite I; I \<noteq> {}; card I \<le> Suc n\<rbrakk> \<Longrightarrow> I \<rightarrow> n = Max I
[PROOF STEP]
apply (rule inext_nth_Max_fix[of _ "card I - Suc 0"], assumption+)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>finite I; I \<noteq> {}; card I \<le> Suc n\<rbrakk> \<Longrightarrow> I \<rightarrow> (card I - Suc 0) = Max I
 2. \<lbrakk>finite I; I \<noteq> {}; card I \<le> Suc n\<rbrakk> \<Longrightarrow> card I - Suc 0 \<le> n
[PROOF STEP]
apply (simp add: inext_nth_card_Max_aux')
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite I; I \<noteq> {}; card I \<le> Suc n\<rbrakk> \<Longrightarrow> card I - Suc 0 \<le> n
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
theorem join_connection: "(x \<sqsubseteq> y) = (x \<squnion> y = y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x \<sqsubseteq> y) = (x \<squnion> y = y)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x \<sqsubseteq> y \<Longrightarrow> x \<squnion> y = y
 2. x \<squnion> y = y \<Longrightarrow> x \<sqsubseteq> y
[PROOF STEP]
assume "x \<sqsubseteq> y"
[PROOF STATE]
proof (state)
this:
x \<sqsubseteq> y

goal (2 subgoals):
 1. x \<sqsubseteq> y \<Longrightarrow> x \<squnion> y = y
 2. x \<squnion> y = y \<Longrightarrow> x \<sqsubseteq> y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<sqsubseteq> y
[PROOF STEP]
have "is_sup x y y"
[PROOF STATE]
proof (prove)
using this:
x \<sqsubseteq> y

goal (1 subgoal):
 1. is_sup x y y
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
is_sup x y y

goal (2 subgoals):
 1. x \<sqsubseteq> y \<Longrightarrow> x \<squnion> y = y
 2. x \<squnion> y = y \<Longrightarrow> x \<sqsubseteq> y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
is_sup x y y
[PROOF STEP]
show "x \<squnion> y = y"
[PROOF STATE]
proof (prove)
using this:
is_sup x y y

goal (1 subgoal):
 1. x \<squnion> y = y
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
x \<squnion> y = y

goal (1 subgoal):
 1. x \<squnion> y = y \<Longrightarrow> x \<sqsubseteq> y
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x \<squnion> y = y \<Longrightarrow> x \<sqsubseteq> y
[PROOF STEP]
have "x \<sqsubseteq> x \<squnion> y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<sqsubseteq> x \<squnion> y
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
x \<sqsubseteq> x \<squnion> y

goal (1 subgoal):
 1. x \<squnion> y = y \<Longrightarrow> x \<sqsubseteq> y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
x \<sqsubseteq> x \<squnion> y

goal (1 subgoal):
 1. x \<squnion> y = y \<Longrightarrow> x \<sqsubseteq> y
[PROOF STEP]
assume "x \<squnion> y = y"
[PROOF STATE]
proof (state)
this:
x \<squnion> y = y

goal (1 subgoal):
 1. x \<squnion> y = y \<Longrightarrow> x \<sqsubseteq> y
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
x \<sqsubseteq> y
[PROOF STEP]
show "x \<sqsubseteq> y"
[PROOF STATE]
proof (prove)
using this:
x \<sqsubseteq> y

goal (1 subgoal):
 1. x \<sqsubseteq> y
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
x \<sqsubseteq> y

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma weight_le_less_iff: "weight_le s t \<Longrightarrow> weight_less s t \<longleftrightarrow> weight s < weight t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. weight_le s t \<Longrightarrow> weight_less s t = (weight s < weight t)
[PROOF STEP]
by (auto simp: weight_le_def weight_less_def)


[STATEMENT]
lemma approx_lower_bound:
  "1.142857139 \<le> v 0.125"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1142857139 / 10 ^ 9 \<le> v (125 / 10 ^ 3)
[PROOF STEP]
unfolding v_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1142857139 / 10 ^ 9 \<le> 1 / (1 - 125 / 10 ^ 3)
[PROOF STEP]
by (approximation 40)


[STATEMENT]
lemma unsynlr_sup: "unsynlr (sup x y) = unsynlr x \<union> unsynlr y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unsynlr (sup x y) = unsynlr x \<union> unsynlr y
[PROOF STEP]
unfolding sup_synlr_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unsynlr (mksynlr (unsynlr x \<union> unsynlr y)) = unsynlr x \<union> unsynlr y
[PROOF STEP]
by (simp add: admS_def synlr_def)


[STATEMENT]
lemma nextl_Un: "nextl (Q1 \<union> Q2) xs = nextl Q1 xs \<union> nextl Q2 xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nextl (Q1 \<union> Q2) xs = nextl Q1 xs \<union> nextl Q2 xs
[PROOF STEP]
by (induct xs arbitrary: Q1 Q2) auto


[STATEMENT]
lemma "eval_ternary_Imp a b = eval_ternary_Or (eval_ternary_Not a) b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eval_ternary_Imp a b = eval_ternary_Or (eval_ternary_Not a) b
[PROOF STEP]
apply(cases a)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. a = TernaryTrue \<Longrightarrow> eval_ternary_Imp a b = eval_ternary_Or (eval_ternary_Not a) b
 2. a = TernaryFalse \<Longrightarrow> eval_ternary_Imp a b = eval_ternary_Or (eval_ternary_Not a) b
 3. a = TernaryUnknown \<Longrightarrow> eval_ternary_Imp a b = eval_ternary_Or (eval_ternary_Not a) b
[PROOF STEP]
apply(case_tac [!] b)
[PROOF STATE]
proof (prove)
goal (9 subgoals):
 1. \<lbrakk>a = TernaryTrue; b = TernaryTrue\<rbrakk> \<Longrightarrow> eval_ternary_Imp a b = eval_ternary_Or (eval_ternary_Not a) b
 2. \<lbrakk>a = TernaryTrue; b = TernaryFalse\<rbrakk> \<Longrightarrow> eval_ternary_Imp a b = eval_ternary_Or (eval_ternary_Not a) b
 3. \<lbrakk>a = TernaryTrue; b = TernaryUnknown\<rbrakk> \<Longrightarrow> eval_ternary_Imp a b = eval_ternary_Or (eval_ternary_Not a) b
 4. \<lbrakk>a = TernaryFalse; b = TernaryTrue\<rbrakk> \<Longrightarrow> eval_ternary_Imp a b = eval_ternary_Or (eval_ternary_Not a) b
 5. \<lbrakk>a = TernaryFalse; b = TernaryFalse\<rbrakk> \<Longrightarrow> eval_ternary_Imp a b = eval_ternary_Or (eval_ternary_Not a) b
 6. \<lbrakk>a = TernaryFalse; b = TernaryUnknown\<rbrakk> \<Longrightarrow> eval_ternary_Imp a b = eval_ternary_Or (eval_ternary_Not a) b
 7. \<lbrakk>a = TernaryUnknown; b = TernaryTrue\<rbrakk> \<Longrightarrow> eval_ternary_Imp a b = eval_ternary_Or (eval_ternary_Not a) b
 8. \<lbrakk>a = TernaryUnknown; b = TernaryFalse\<rbrakk> \<Longrightarrow> eval_ternary_Imp a b = eval_ternary_Or (eval_ternary_Not a) b
 9. \<lbrakk>a = TernaryUnknown; b = TernaryUnknown\<rbrakk> \<Longrightarrow> eval_ternary_Imp a b = eval_ternary_Or (eval_ternary_Not a) b
[PROOF STEP]
apply(simp_all)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma (in domain) canonical_embedding_ring_hom:
  assumes "subring K R" shows "ring_hom_ring (R \<lparr> carrier := K \<rparr>) (K[X]) poly_of_const"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ring_hom_ring (R\<lparr>carrier := K\<rparr>) (K [X]) poly_of_const
[PROOF STEP]
using canonical_embedding_is_hom[OF assms]
[PROOF STATE]
proof (prove)
using this:
poly_of_const \<in> ring_hom (R\<lparr>carrier := K\<rparr>) (K [X])

goal (1 subgoal):
 1. ring_hom_ring (R\<lparr>carrier := K\<rparr>) (K [X]) poly_of_const
[PROOF STEP]
unfolding symmetric[OF ring_hom_ring_axioms_def]
[PROOF STATE]
proof (prove)
using this:
ring_hom_ring_axioms (R\<lparr>carrier := K\<rparr>) (K [X]) poly_of_const

goal (1 subgoal):
 1. ring_hom_ring (R\<lparr>carrier := K\<rparr>) (K [X]) poly_of_const
[PROOF STEP]
by (rule ring_hom_ring.intro[OF subring_is_ring[OF assms] univ_poly_is_ring[OF assms]])


[STATEMENT]
lemma exp_golomb_bit_count_exact:
  "bit_count (N\<^sub>e n) = 2 * \<lfloor>log 2 (n+1)\<rfloor> + 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bit_count (N\<^sub>e n) = ereal (real_of_int (2 * \<lfloor>log 2 (real (n + 1))\<rfloor> + 1))
[PROOF STEP]
by (simp add:N\<^sub>e_def elias_gamma_bit_count)


[STATEMENT]
lemma similar_matrix_charpoly: "similar_matrix A B \<Longrightarrow> charpoly A = charpoly B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. similar_matrix A B \<Longrightarrow> charpoly A = charpoly B
[PROOF STEP]
by (transfer_hma rule: char_poly_similar)


[STATEMENT]
lemma inorder_map: "inorder (map_tree f t) = map f (inorder t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inorder (map_tree f t) = map f (inorder t)
[PROOF STEP]
by (induction t) auto


[STATEMENT]
lemma subst_UINF [usubst]: "\<sigma> \<dagger> (\<Sqinter> i | P(i) \<bullet> Q(i)) = (\<Sqinter> i | (\<sigma> \<dagger> P(i)) \<bullet> (\<sigma> \<dagger> Q(i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<sigma> \<dagger> UINF P Q = (\<Sqinter> i | \<sigma> \<dagger> P i \<bullet> \<sigma> \<dagger> Q i)
[PROOF STEP]
by (pred_auto)


[STATEMENT]
lemma create_optim_in_sols:
  assumes "create_optimal_solutions A b c = Sat X"
  assumes "(x, y) = split_n_m_x (dim_vec c) (dim_vec b) X"
  shows "c \<bullet> x \<in> {c \<bullet> x |x. [A *\<^sub>v x]\<le>b}"
    "b \<bullet> y \<in> {b \<bullet> y |y. [y \<^sub>v* A]=c \<and> (\<forall>i < dim_vec y. y$i \<ge> 0)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c \<bullet> x \<in> {c \<bullet> x |x. [A*\<^sub>vx]\<le>b} &&& b \<bullet> y \<in> {b \<bullet> y |y. [y\<^sub>v*A]=c \<and> (\<forall>i<dim_vec y. 0 \<le> y $ i)}
[PROOF STEP]
using assms(1) assms(2) create_opt_sol_in_LP(1)
[PROOF STATE]
proof (prove)
using this:
create_optimal_solutions A b c = Inr X
(x, y) = split_n_m_x (dim_vec c) (dim_vec b) X
\<lbrakk>create_optimal_solutions A b c = Inr ?X; (?x, ?y) = split_n_m_x (dim_vec c) (dim_vec b) ?X\<rbrakk> \<Longrightarrow> [A*\<^sub>v?x]\<le>b

goal (1 subgoal):
 1. c \<bullet> x \<in> {c \<bullet> x |x. [A*\<^sub>vx]\<le>b} &&& b \<bullet> y \<in> {b \<bullet> y |y. [y\<^sub>v*A]=c \<and> (\<forall>i<dim_vec y. 0 \<le> y $ i)}
[PROOF STEP]
apply blast
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b \<bullet> y \<in> {b \<bullet> y |y. [y\<^sub>v*A]=c \<and> (\<forall>i<dim_vec y. 0 \<le> y $ i)}
[PROOF STEP]
using assms(1) assms(2) create_opt_sol_in_LP(2) create_opt_sol_in_LP(4)
[PROOF STATE]
proof (prove)
using this:
create_optimal_solutions A b c = Inr X
(x, y) = split_n_m_x (dim_vec c) (dim_vec b) X
\<lbrakk>create_optimal_solutions A b c = Inr ?X; (?x, ?y) = split_n_m_x (dim_vec c) (dim_vec b) ?X\<rbrakk> \<Longrightarrow> [?y\<^sub>v*A]=c
\<lbrakk>create_optimal_solutions A b c = Inr ?X; (?x, ?y) = split_n_m_x (dim_vec c) (dim_vec b) ?X; ?i < dim_vec ?y\<rbrakk> \<Longrightarrow> 0 \<le> ?y $ ?i

goal (1 subgoal):
 1. b \<bullet> y \<in> {b \<bullet> y |y. [y\<^sub>v*A]=c \<and> (\<forall>i<dim_vec y. 0 \<le> y $ i)}
[PROOF STEP]
by blast


[STATEMENT]
lemma positively_invariant_y:
  shows "g.positively_invariant {p . - snd p \<le> 0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g.positively_invariant {p. - snd p \<le> 0}
[PROOF STEP]
apply (rule g.positively_invariant_le[of "\<lambda>p. -(0.08 + (fst p)^2)" _ "\<lambda>x p. - snd p"])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. continuous_on UNIV (\<lambda>p. - (8 / 10\<^sup>2 + (fst p)\<^sup>2))
 2. \<And>x. ((\<lambda>x. - snd x) has_derivative (\<lambda>p. - snd p)) (at x)
 3. \<And>s. - snd (case s of (x, y) \<Rightarrow> (gx x y, gy x y)) \<le> - (8 / 10\<^sup>2 + (fst s)\<^sup>2) * - snd s
[PROOF STEP]
apply (auto intro!: continuous_intros derivative_eq_intros)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a b. (- (2 / 25) - a\<^sup>2) * b \<le> gy a b
[PROOF STEP]
unfolding gy_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a b. (- (2 / 25) - a\<^sup>2) * b \<le> 6 / 10 - 8 / 10\<^sup>2 * b - a\<^sup>2 * b
[PROOF STEP]
by (sos "()")


[STATEMENT]
lemma aff_dim_halfspace_lt:
  fixes a :: "'a::euclidean_space"
  shows "aff_dim {x. a \<bullet> x < r} =
        (if a = 0 \<and> r \<le> 0 then -1 else DIM('a))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. aff_dim {x. a \<bullet> x < r} = (if a = (0::'a) \<and> r \<le> 0 then - 1 else int DIM('a))
[PROOF STEP]
by simp (metis aff_dim_open halfspace_eq_empty_lt open_halfspace_lt)


[STATEMENT]
lemma parts_two: "\<lbrakk>x \<in> parts {e1, e2}; x \<notin> parts {e1}\<rbrakk>\<Longrightarrow> x \<in> parts {e2}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x \<in> parts {e1, e2}; x \<notin> parts {e1}\<rbrakk> \<Longrightarrow> x \<in> parts {e2}
[PROOF STEP]
by (simp add: parts_insert2)


[STATEMENT]
lemma one_not_primepow [simp]: "\<not>primepow 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> primepow (1::'a)
[PROOF STEP]
by (auto simp: primepow_def prime_power_not_one)


[STATEMENT]
lemma diff_sum_integral_has_integral_int':
  "((\<lambda>t. pbernpoly 1 t *\<^sub>R f' t) has_integral (S - I - (f b - f a) /\<^sub>R 2 )) {a..b}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>t. pbernpoly 1 t *\<^sub>R f' t) has_integral S - I - (f (real_of_int b) - f (real_of_int a)) /\<^sub>R 2) {real_of_int a..real_of_int b}
[PROOF STEP]
using diff_sum_integral_has_integral_int
[PROOF STATE]
proof (prove)
using this:
((\<lambda>t. (frac t - 1 / 2) *\<^sub>R f' t) has_integral S - I - (f (real_of_int b) - f (real_of_int a)) /\<^sub>R 2) {real_of_int a..real_of_int b}

goal (1 subgoal):
 1. ((\<lambda>t. pbernpoly 1 t *\<^sub>R f' t) has_integral S - I - (f (real_of_int b) - f (real_of_int a)) /\<^sub>R 2) {real_of_int a..real_of_int b}
[PROOF STEP]
by (simp add: pbernpoly_def bernpoly_def)


[STATEMENT]
lemma LIMSEQ_imp_Suc: "(\<lambda>n. f (Suc n)) \<longlonglongrightarrow> l \<Longrightarrow> f \<longlonglongrightarrow> l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. f (Suc n)) \<longlonglongrightarrow> l \<Longrightarrow> f \<longlonglongrightarrow> l
[PROOF STEP]
by (rule LIMSEQ_offset [where k="Suc 0"]) simp


[STATEMENT]
lemma FDOM_pre_subset_FDOM_valid_states:
  fixes p e s
  assumes "(p, e) \<in> PROB" "s \<in> valid_states PROB"
  shows "fmdom' p \<subseteq> fmdom' s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fmdom' p \<subseteq> fmdom' s
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. fmdom' p \<subseteq> fmdom' s
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. fmdom' p \<subseteq> fmdom' s
[PROOF STEP]
have "fmdom' p \<subseteq> (\<lambda>(s1, s2). action_dom s1 s2) (p, e)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fmdom' p \<subseteq> (case (p, e) of (s1, s2) \<Rightarrow> action_dom s1 s2)
[PROOF STEP]
using action_dom_def
[PROOF STATE]
proof (prove)
using this:
action_dom ?s1.0 ?s2.0 \<equiv> fmdom' ?s1.0 \<union> fmdom' ?s2.0

goal (1 subgoal):
 1. fmdom' p \<subseteq> (case (p, e) of (s1, s2) \<Rightarrow> action_dom s1 s2)
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
fmdom' p \<subseteq> (case (p, e) of (s1, s2) \<Rightarrow> action_dom s1 s2)

goal (1 subgoal):
 1. fmdom' p \<subseteq> fmdom' s
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
fmdom' p \<subseteq> (case (p, e) of (s1, s2) \<Rightarrow> action_dom s1 s2)

goal (1 subgoal):
 1. fmdom' p \<subseteq> fmdom' s
[PROOF STEP]
have "\<dots> \<subseteq> prob_dom PROB"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (case (p, e) of (s1, s2) \<Rightarrow> action_dom s1 s2) \<subseteq> prob_dom PROB
[PROOF STEP]
using assms(1)
[PROOF STATE]
proof (prove)
using this:
(p, e) \<in> PROB

goal (1 subgoal):
 1. (case (p, e) of (s1, s2) \<Rightarrow> action_dom s1 s2) \<subseteq> prob_dom PROB
[PROOF STEP]
by (simp add: Sup_upper pair_imageI prob_dom_def)
[PROOF STATE]
proof (state)
this:
(case (p, e) of (s1, s2) \<Rightarrow> action_dom s1 s2) \<subseteq> prob_dom PROB

goal (1 subgoal):
 1. fmdom' p \<subseteq> fmdom' s
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
fmdom' p \<subseteq> prob_dom PROB
[PROOF STEP]
have "fmdom' p \<subseteq> fmdom' s"
[PROOF STATE]
proof (prove)
using this:
fmdom' p \<subseteq> prob_dom PROB

goal (1 subgoal):
 1. fmdom' p \<subseteq> fmdom' s
[PROOF STEP]
using assms(2) valid_states_def
[PROOF STATE]
proof (prove)
using this:
fmdom' p \<subseteq> prob_dom PROB
s \<in> valid_states PROB
valid_states ?prob \<equiv> {s. fmdom' s = prob_dom ?prob}

goal (1 subgoal):
 1. fmdom' p \<subseteq> fmdom' s
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
fmdom' p \<subseteq> fmdom' s

goal (1 subgoal):
 1. fmdom' p \<subseteq> fmdom' s
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
fmdom' p \<subseteq> fmdom' s

goal (1 subgoal):
 1. fmdom' p \<subseteq> fmdom' s
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
fmdom' p \<subseteq> fmdom' s
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
fmdom' p \<subseteq> fmdom' s

goal (1 subgoal):
 1. fmdom' p \<subseteq> fmdom' s
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
fmdom' p \<subseteq> fmdom' s

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma round_altdef: "round x = (if frac x \<ge> 1/2 then \<lceil>x\<rceil> else \<lfloor>x\<rfloor>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. round x = (if (1::'a) / (2::'a) \<le> frac x then \<lceil>x\<rceil> else \<lfloor>x\<rfloor>)
[PROOF STEP]
by (cases "frac x \<ge> 1/2")
    (rule round_unique, ((simp add: frac_def field_simps ceiling_altdef; linarith)+)[2])+


[STATEMENT]
lemma (in abelian_subgroup) a_rcos_module_minus:
  assumes "ring G"
  assumes carr: "x \<in> carrier G" "x' \<in> carrier G"
  shows "(x' \<in> H +> x) = (x' \<ominus> x \<in> H)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x' \<in> H +> x) = (x' \<ominus> x \<in> H)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (x' \<in> H +> x) = (x' \<ominus> x \<in> H)
[PROOF STEP]
interpret G: ring G
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ring G
[PROOF STEP]
by fact
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (x' \<in> H +> x) = (x' \<ominus> x \<in> H)
[PROOF STEP]
from carr
[PROOF STATE]
proof (chain)
picking this:
x \<in> carrier G
x' \<in> carrier G
[PROOF STEP]
have "(x' \<in> H +> x) = (x' \<oplus> \<ominus>x \<in> H)"
[PROOF STATE]
proof (prove)
using this:
x \<in> carrier G
x' \<in> carrier G

goal (1 subgoal):
 1. (x' \<in> H +> x) = (x' \<oplus> \<ominus> x \<in> H)
[PROOF STEP]
by (rule a_rcos_module)
[PROOF STATE]
proof (state)
this:
(x' \<in> H +> x) = (x' \<oplus> \<ominus> x \<in> H)

goal (1 subgoal):
 1. (x' \<in> H +> x) = (x' \<ominus> x \<in> H)
[PROOF STEP]
with carr
[PROOF STATE]
proof (chain)
picking this:
x \<in> carrier G
x' \<in> carrier G
(x' \<in> H +> x) = (x' \<oplus> \<ominus> x \<in> H)
[PROOF STEP]
show "(x' \<in> H +> x) = (x' \<ominus> x \<in> H)"
[PROOF STATE]
proof (prove)
using this:
x \<in> carrier G
x' \<in> carrier G
(x' \<in> H +> x) = (x' \<oplus> \<ominus> x \<in> H)

goal (1 subgoal):
 1. (x' \<in> H +> x) = (x' \<ominus> x \<in> H)
[PROOF STEP]
by (simp add: minus_eq)
[PROOF STATE]
proof (state)
this:
(x' \<in> H +> x) = (x' \<ominus> x \<in> H)

goal:
No subgoals!
[PROOF STEP]
qed