[STATEMENT]
lemma nodes_height_upper_bound:
  "\<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2*k) \<le> bound (2*k) (height t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t)
[PROOF STEP]
proof(induction t rule: nodes.induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> nodes Leaf * (2 * k) \<le> bound (2 * k) (height Leaf)
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> nodes x * (2 * k) \<le> bound (2 * k) (height x); \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t); order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> nodes (Node ts t) * (2 * k) \<le> bound (2 * k) (height (Node ts t))
[PROOF STEP]
case (2 ts t)
[PROOF STATE]
proof (state)
this:
\<lbrakk>?x \<in> set (subtrees ts); order k ?x; bal ?x\<rbrakk> \<Longrightarrow> nodes ?x * (2 * k) \<le> bound (2 * k) (height ?x)
\<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t)
order k (Node ts t)
bal (Node ts t)

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> nodes Leaf * (2 * k) \<le> bound (2 * k) (height Leaf)
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> nodes x * (2 * k) \<le> bound (2 * k) (height x); \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t); order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> nodes (Node ts t) * (2 * k) \<le> bound (2 * k) (height (Node ts t))
[PROOF STEP]
let ?sub_height = "((2 * k + 1) ^ height t - 1)"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> nodes Leaf * (2 * k) \<le> bound (2 * k) (height Leaf)
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> nodes x * (2 * k) \<le> bound (2 * k) (height x); \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t); order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> nodes (Node ts t) * (2 * k) \<le> bound (2 * k) (height (Node ts t))
[PROOF STEP]
have "sum_list (map nodes (subtrees ts)) * (2*k) =
        sum_list (map (\<lambda>t. nodes t * (2 * k)) (subtrees ts))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_list (map nodes (subtrees ts)) * (2 * k) = (\<Sum>t\<leftarrow>subtrees ts. nodes t * (2 * k))
[PROOF STEP]
using sum_list_mult_const
[PROOF STATE]
proof (prove)
using this:
(\<Sum>x\<leftarrow>?xs. ?f x * ?c) = sum_list (map ?f ?xs) * ?c

goal (1 subgoal):
 1. sum_list (map nodes (subtrees ts)) * (2 * k) = (\<Sum>t\<leftarrow>subtrees ts. nodes t * (2 * k))
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
sum_list (map nodes (subtrees ts)) * (2 * k) = (\<Sum>t\<leftarrow>subtrees ts. nodes t * (2 * k))

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> nodes Leaf * (2 * k) \<le> bound (2 * k) (height Leaf)
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> nodes x * (2 * k) \<le> bound (2 * k) (height x); \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t); order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> nodes (Node ts t) * (2 * k) \<le> bound (2 * k) (height (Node ts t))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum_list (map nodes (subtrees ts)) * (2 * k) = (\<Sum>t\<leftarrow>subtrees ts. nodes t * (2 * k))

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> nodes Leaf * (2 * k) \<le> bound (2 * k) (height Leaf)
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> nodes x * (2 * k) \<le> bound (2 * k) (height x); \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t); order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> nodes (Node ts t) * (2 * k) \<le> bound (2 * k) (height (Node ts t))
[PROOF STEP]
have "\<dots> \<le> sum_list (map (\<lambda>x.?sub_height) (subtrees ts))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>t\<leftarrow>subtrees ts. nodes t * (2 * k)) \<le> (\<Sum>x\<leftarrow>subtrees ts. bound (2 * k) (height t))
[PROOF STEP]
using 2
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?x \<in> set (subtrees ts); order k ?x; bal ?x\<rbrakk> \<Longrightarrow> nodes ?x * (2 * k) \<le> bound (2 * k) (height ?x)
\<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t)
order k (Node ts t)
bal (Node ts t)

goal (1 subgoal):
 1. (\<Sum>t\<leftarrow>subtrees ts. nodes t * (2 * k)) \<le> (\<Sum>x\<leftarrow>subtrees ts. bound (2 * k) (height t))
[PROOF STEP]
using sum_list_mono[of "subtrees ts" "\<lambda>t. nodes t * (2 * k)" "\<lambda>x. bound (2 * k) (height t)"]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?x \<in> set (subtrees ts); order k ?x; bal ?x\<rbrakk> \<Longrightarrow> nodes ?x * (2 * k) \<le> bound (2 * k) (height ?x)
\<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t)
order k (Node ts t)
bal (Node ts t)
(\<And>x. x \<in> set (subtrees ts) \<Longrightarrow> nodes x * (2 * k) \<le> bound (2 * k) (height t)) \<Longrightarrow> (\<Sum>x\<leftarrow>subtrees ts. nodes x * (2 * k)) \<le> (\<Sum>x\<leftarrow>subtrees ts. bound (2 * k) (height t))

goal (1 subgoal):
 1. (\<Sum>t\<leftarrow>subtrees ts. nodes t * (2 * k)) \<le> (\<Sum>x\<leftarrow>subtrees ts. bound (2 * k) (height t))
[PROOF STEP]
by (metis bal.simps(2) order.simps(2))
[PROOF STATE]
proof (state)
this:
(\<Sum>t\<leftarrow>subtrees ts. nodes t * (2 * k)) \<le> (\<Sum>x\<leftarrow>subtrees ts. bound (2 * k) (height t))

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> nodes Leaf * (2 * k) \<le> bound (2 * k) (height Leaf)
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> nodes x * (2 * k) \<le> bound (2 * k) (height x); \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t); order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> nodes (Node ts t) * (2 * k) \<le> bound (2 * k) (height (Node ts t))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>t\<leftarrow>subtrees ts. nodes t * (2 * k)) \<le> (\<Sum>x\<leftarrow>subtrees ts. bound (2 * k) (height t))

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> nodes Leaf * (2 * k) \<le> bound (2 * k) (height Leaf)
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> nodes x * (2 * k) \<le> bound (2 * k) (height x); \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t); order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> nodes (Node ts t) * (2 * k) \<le> bound (2 * k) (height (Node ts t))
[PROOF STEP]
have "\<dots> = sum_list (replicate (length ts) ?sub_height)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<leftarrow>subtrees ts. bound (2 * k) (height t)) = sum_list (replicate (length ts) (bound (2 * k) (height t)))
[PROOF STEP]
using map_replicate_const[of ?sub_height "subtrees ts"] length_map
[PROOF STATE]
proof (prove)
using this:
map (\<lambda>x. bound (2 * k) (height t)) (subtrees ts) = replicate (length (subtrees ts)) (bound (2 * k) (height t))
length (map ?f ?xs) = length ?xs

goal (1 subgoal):
 1. (\<Sum>x\<leftarrow>subtrees ts. bound (2 * k) (height t)) = sum_list (replicate (length ts) (bound (2 * k) (height t)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<leftarrow>subtrees ts. bound (2 * k) (height t)) = sum_list (replicate (length ts) (bound (2 * k) (height t)))

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> nodes Leaf * (2 * k) \<le> bound (2 * k) (height Leaf)
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> nodes x * (2 * k) \<le> bound (2 * k) (height x); \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t); order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> nodes (Node ts t) * (2 * k) \<le> bound (2 * k) (height (Node ts t))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<leftarrow>subtrees ts. bound (2 * k) (height t)) = sum_list (replicate (length ts) (bound (2 * k) (height t)))

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> nodes Leaf * (2 * k) \<le> bound (2 * k) (height Leaf)
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> nodes x * (2 * k) \<le> bound (2 * k) (height x); \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t); order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> nodes (Node ts t) * (2 * k) \<le> bound (2 * k) (height (Node ts t))
[PROOF STEP]
have "\<dots> = (length ts)*(?sub_height)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_list (replicate (length ts) (bound (2 * k) (height t))) = length ts * bound (2 * k) (height t)
[PROOF STEP]
using sum_list_replicate
[PROOF STATE]
proof (prove)
using this:
sum_list (replicate ?n ?c) = ?n * ?c

goal (1 subgoal):
 1. sum_list (replicate (length ts) (bound (2 * k) (height t))) = length ts * bound (2 * k) (height t)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sum_list (replicate (length ts) (bound (2 * k) (height t))) = length ts * bound (2 * k) (height t)

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> nodes Leaf * (2 * k) \<le> bound (2 * k) (height Leaf)
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> nodes x * (2 * k) \<le> bound (2 * k) (height x); \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t); order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> nodes (Node ts t) * (2 * k) \<le> bound (2 * k) (height (Node ts t))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum_list (replicate (length ts) (bound (2 * k) (height t))) = length ts * bound (2 * k) (height t)

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> nodes Leaf * (2 * k) \<le> bound (2 * k) (height Leaf)
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> nodes x * (2 * k) \<le> bound (2 * k) (height x); \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t); order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> nodes (Node ts t) * (2 * k) \<le> bound (2 * k) (height (Node ts t))
[PROOF STEP]
have "\<dots> \<le> (2*k)*(?sub_height)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length ts * bound (2 * k) (height t) \<le> 2 * k * bound (2 * k) (height t)
[PROOF STEP]
using "2.prems"(1)
[PROOF STATE]
proof (prove)
using this:
order k (Node ts t)

goal (1 subgoal):
 1. length ts * bound (2 * k) (height t) \<le> 2 * k * bound (2 * k) (height t)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
length ts * bound (2 * k) (height t) \<le> 2 * k * bound (2 * k) (height t)

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> nodes Leaf * (2 * k) \<le> bound (2 * k) (height Leaf)
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> nodes x * (2 * k) \<le> bound (2 * k) (height x); \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t); order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> nodes (Node ts t) * (2 * k) \<le> bound (2 * k) (height (Node ts t))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sum_list (map nodes (subtrees ts)) * (2 * k) \<le> 2 * k * bound (2 * k) (height t)
[PROOF STEP]
have "sum_list (map nodes (subtrees ts))*(2*k) \<le> ?sub_height*(2*k)"
[PROOF STATE]
proof (prove)
using this:
sum_list (map nodes (subtrees ts)) * (2 * k) \<le> 2 * k * bound (2 * k) (height t)

goal (1 subgoal):
 1. sum_list (map nodes (subtrees ts)) * (2 * k) \<le> bound (2 * k) (height t) * (2 * k)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sum_list (map nodes (subtrees ts)) * (2 * k) \<le> bound (2 * k) (height t) * (2 * k)

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> nodes Leaf * (2 * k) \<le> bound (2 * k) (height Leaf)
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> nodes x * (2 * k) \<le> bound (2 * k) (height x); \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t); order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> nodes (Node ts t) * (2 * k) \<le> bound (2 * k) (height (Node ts t))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
sum_list (map nodes (subtrees ts)) * (2 * k) \<le> bound (2 * k) (height t) * (2 * k)

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> nodes Leaf * (2 * k) \<le> bound (2 * k) (height Leaf)
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> nodes x * (2 * k) \<le> bound (2 * k) (height x); \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t); order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> nodes (Node ts t) * (2 * k) \<le> bound (2 * k) (height (Node ts t))
[PROOF STEP]
have "(nodes t)*(2*k) \<le> ?sub_height"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nodes t * (2 * k) \<le> bound (2 * k) (height t)
[PROOF STEP]
using 2
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?x \<in> set (subtrees ts); order k ?x; bal ?x\<rbrakk> \<Longrightarrow> nodes ?x * (2 * k) \<le> bound (2 * k) (height ?x)
\<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t)
order k (Node ts t)
bal (Node ts t)

goal (1 subgoal):
 1. nodes t * (2 * k) \<le> bound (2 * k) (height t)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
nodes t * (2 * k) \<le> bound (2 * k) (height t)

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> nodes Leaf * (2 * k) \<le> bound (2 * k) (height Leaf)
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> nodes x * (2 * k) \<le> bound (2 * k) (height x); \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t); order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> nodes (Node ts t) * (2 * k) \<le> bound (2 * k) (height (Node ts t))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
sum_list (map nodes (subtrees ts)) * (2 * k) \<le> bound (2 * k) (height t) * (2 * k)
nodes t * (2 * k) \<le> bound (2 * k) (height t)
[PROOF STEP]
have "(nodes (Node ts t))*(2*k) \<le>
         2*k
        + ?sub_height * (2*k)
        + ?sub_height"
[PROOF STATE]
proof (prove)
using this:
sum_list (map nodes (subtrees ts)) * (2 * k) \<le> bound (2 * k) (height t) * (2 * k)
nodes t * (2 * k) \<le> bound (2 * k) (height t)

goal (1 subgoal):
 1. nodes (Node ts t) * (2 * k) \<le> 2 * k + bound (2 * k) (height t) * (2 * k) + bound (2 * k) (height t)
[PROOF STEP]
unfolding nodes.simps add_mult_distrib
[PROOF STATE]
proof (prove)
using this:
sum_list (map nodes (subtrees ts)) * (2 * k) \<le> bound (2 * k) (height t) * (2 * k)
nodes t * (2 * k) \<le> bound (2 * k) (height t)

goal (1 subgoal):
 1. 1 * (2 * k) + sum_list (map nodes (subtrees ts)) * (2 * k) + nodes t * (2 * k) \<le> 2 * k + bound (2 * k) (height t) * (2 * k) + bound (2 * k) (height t)
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
nodes (Node ts t) * (2 * k) \<le> 2 * k + bound (2 * k) (height t) * (2 * k) + bound (2 * k) (height t)

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> nodes Leaf * (2 * k) \<le> bound (2 * k) (height Leaf)
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> nodes x * (2 * k) \<le> bound (2 * k) (height x); \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t); order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> nodes (Node ts t) * (2 * k) \<le> bound (2 * k) (height (Node ts t))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
nodes (Node ts t) * (2 * k) \<le> 2 * k + bound (2 * k) (height t) * (2 * k) + bound (2 * k) (height t)

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> nodes Leaf * (2 * k) \<le> bound (2 * k) (height Leaf)
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> nodes x * (2 * k) \<le> bound (2 * k) (height x); \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t); order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> nodes (Node ts t) * (2 * k) \<le> bound (2 * k) (height (Node ts t))
[PROOF STEP]
have "\<dots> =  2*k + (2*k)*((2 * k + 1) ^ height t) - 2*k + (2 * k + 1) ^ height t - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * k + bound (2 * k) (height t) * (2 * k) + bound (2 * k) (height t) = 2 * k + 2 * k * (2 * k + 1) ^ height t - 2 * k + (2 * k + 1) ^ height t - 1
[PROOF STEP]
by (simp add: diff_mult_distrib2 mult.assoc mult.commute)
[PROOF STATE]
proof (state)
this:
2 * k + bound (2 * k) (height t) * (2 * k) + bound (2 * k) (height t) = 2 * k + 2 * k * (2 * k + 1) ^ height t - 2 * k + (2 * k + 1) ^ height t - 1

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> nodes Leaf * (2 * k) \<le> bound (2 * k) (height Leaf)
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> nodes x * (2 * k) \<le> bound (2 * k) (height x); \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t); order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> nodes (Node ts t) * (2 * k) \<le> bound (2 * k) (height (Node ts t))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 * k + bound (2 * k) (height t) * (2 * k) + bound (2 * k) (height t) = 2 * k + 2 * k * (2 * k + 1) ^ height t - 2 * k + (2 * k + 1) ^ height t - 1

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> nodes Leaf * (2 * k) \<le> bound (2 * k) (height Leaf)
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> nodes x * (2 * k) \<le> bound (2 * k) (height x); \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t); order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> nodes (Node ts t) * (2 * k) \<le> bound (2 * k) (height (Node ts t))
[PROOF STEP]
have "\<dots> = (2*k)*((2 * k + 1) ^ height t) + (2 * k + 1) ^ height t - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * k + 2 * k * (2 * k + 1) ^ height t - 2 * k + (2 * k + 1) ^ height t - 1 = 2 * k * (2 * k + 1) ^ height t + (2 * k + 1) ^ height t - 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 * k + 2 * k * (2 * k + 1) ^ height t - 2 * k + (2 * k + 1) ^ height t - 1 = 2 * k * (2 * k + 1) ^ height t + (2 * k + 1) ^ height t - 1

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> nodes Leaf * (2 * k) \<le> bound (2 * k) (height Leaf)
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> nodes x * (2 * k) \<le> bound (2 * k) (height x); \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t); order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> nodes (Node ts t) * (2 * k) \<le> bound (2 * k) (height (Node ts t))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 * k + 2 * k * (2 * k + 1) ^ height t - 2 * k + (2 * k + 1) ^ height t - 1 = 2 * k * (2 * k + 1) ^ height t + (2 * k + 1) ^ height t - 1

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> nodes Leaf * (2 * k) \<le> bound (2 * k) (height Leaf)
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> nodes x * (2 * k) \<le> bound (2 * k) (height x); \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t); order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> nodes (Node ts t) * (2 * k) \<le> bound (2 * k) (height (Node ts t))
[PROOF STEP]
have "\<dots> = (2*k+1)^(Suc(height t)) - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * k * (2 * k + 1) ^ height t + (2 * k + 1) ^ height t - 1 = bound (2 * k) (Suc (height t))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 * k * (2 * k + 1) ^ height t + (2 * k + 1) ^ height t - 1 = bound (2 * k) (Suc (height t))

goal (2 subgoals):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> nodes Leaf * (2 * k) \<le> bound (2 * k) (height Leaf)
 2. \<And>ts t. \<lbrakk>\<And>x. \<lbrakk>x \<in> set (subtrees ts); order k x; bal x\<rbrakk> \<Longrightarrow> nodes x * (2 * k) \<le> bound (2 * k) (height x); \<lbrakk>order k t; bal t\<rbrakk> \<Longrightarrow> nodes t * (2 * k) \<le> bound (2 * k) (height t); order k (Node ts t); bal (Node ts t)\<rbrakk> \<Longrightarrow> nodes (Node ts t) * (2 * k) \<le> bound (2 * k) (height (Node ts t))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
nodes (Node ts t) * (2 * k) \<le> bound (2 * k) (Suc (height t))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
nodes (Node ts t) * (2 * k) \<le> bound (2 * k) (Suc (height t))

goal (1 subgoal):
 1. nodes (Node ts t) * (2 * k) \<le> bound (2 * k) (height (Node ts t))
[PROOF STEP]
by (metis "2.prems"(2) height_bal_tree)
[PROOF STATE]
proof (state)
this:
nodes (Node ts t) * (2 * k) \<le> bound (2 * k) (height (Node ts t))

goal (1 subgoal):
 1. \<lbrakk>order k Leaf; bal Leaf\<rbrakk> \<Longrightarrow> nodes Leaf * (2 * k) \<le> bound (2 * k) (height Leaf)
[PROOF STEP]
qed simp


[STATEMENT]
lemma mult_zero_ow: "class.mult_zero = mult_zero_ow UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. class.mult_zero = mult_zero_ow UNIV
[PROOF STEP]
unfolding
    class.mult_zero_def mult_zero_ow_def mult_zero_ow_axioms_def
    times_ow_def zero_ow_def neutral_ow_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>times zero. (\<forall>a. times zero a = zero) \<and> (\<forall>a. times a zero = zero)) = (\<lambda>times zero. (\<forall>a b. a \<in> UNIV \<longrightarrow> b \<in> UNIV \<longrightarrow> times a b \<in> UNIV) \<and> zero \<in> UNIV \<and> (\<forall>a. a \<in> UNIV \<longrightarrow> times zero a = zero) \<and> (\<forall>a. a \<in> UNIV \<longrightarrow> times a zero = zero))
[PROOF STEP]
by simp


[STATEMENT]
lemma wordinterval_setminus_set_eq[simp]: "wordinterval_to_set (wordinterval_setminus r1 r2) =
    wordinterval_to_set r1 - wordinterval_to_set r2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. wordinterval_to_set (wordinterval_setminus r1 r2) = wordinterval_to_set r1 - wordinterval_to_set r2
[PROOF STEP]
by(simp add: wordinterval_setminus_def wordinterval_compress wordinterval_setminus'_set_eq)


[STATEMENT]
lemma integral_sin_nx:
   "integral {-pi..pi} (\<lambda>x. sin(x * real_of_int n)) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integral {- pi..pi} (\<lambda>x. sin (x * real_of_int n)) = 0
[PROOF STEP]
using has_integral_sin_nx [of n]
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. sin (real_of_int n * x)) has_integral 0) {- pi..pi}

goal (1 subgoal):
 1. integral {- pi..pi} (\<lambda>x. sin (x * real_of_int n)) = 0
[PROOF STEP]
by (force simp: mult.commute)


[STATEMENT]
lemma binomial_Suc_Suc_eq_times: "(Suc n choose Suc k) = (Suc n * (n choose k)) div Suc k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc n choose Suc k = Suc n * (n choose k) div Suc k
[PROOF STEP]
by (simp add: Suc_times_binomial_eq del: mult_Suc mult_Suc_right)


[STATEMENT]
lemma graph_map_add: "dom m1 \<inter> dom m2 = {} \<Longrightarrow> graph (m1 ++ m2) = graph m1 \<union> graph m2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dom m1 \<inter> dom m2 = {} \<Longrightarrow> graph (m1 ++ m2) = graph m1 \<union> graph m2
[PROOF STEP]
unfolding graph_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dom m1 \<inter> dom m2 = {} \<Longrightarrow> {(a, b) |a b. (m1 ++ m2) a = Some b} = {(a, b) |a b. m1 a = Some b} \<union> {(a, b) |a b. m2 a = Some b}
[PROOF STEP]
using map_add_comm
[PROOF STATE]
proof (prove)
using this:
dom ?m1.0 \<inter> dom ?m2.0 = {} \<Longrightarrow> ?m1.0 ++ ?m2.0 = ?m2.0 ++ ?m1.0

goal (1 subgoal):
 1. dom m1 \<inter> dom m2 = {} \<Longrightarrow> {(a, b) |a b. (m1 ++ m2) a = Some b} = {(a, b) |a b. m1 a = Some b} \<union> {(a, b) |a b. m2 a = Some b}
[PROOF STEP]
by force


[STATEMENT]
lemma congruent_triangleI_sss:
  fixes a1 b1 c1 :: "'a :: real_inner" and a2 b2 c2 :: "'b :: real_inner"
  assumes "dist a1 b1 = dist a2 b2"
  assumes "dist b1 c1 = dist b2 c2"
  assumes "dist a1 c1 = dist a2 c2"
  shows   "congruent_triangle a1 b1 c1 a2 b2 c2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. congruent_triangle a1 b1 c1 a2 b2 c2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. congruent_triangle a1 b1 c1 a2 b2 c2
[PROOF STEP]
have A: "angle a1 b1 c1 = angle a2 b2 c2"
    if "dist a1 b1 = dist a2 b2" "dist b1 c1 = dist b2 c2" "dist a1 c1 = dist a2 c2"
    for a1 b1 c1 :: 'a and a2 b2 c2 :: 'b
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. angle a1 b1 c1 = angle a2 b2 c2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. angle a1 b1 c1 = angle a2 b2 c2
[PROOF STEP]
from that cosine_law_triangle''[of a1 b1 c1] cosine_law_triangle''[of a2 b2 c2]
[PROOF STATE]
proof (chain)
picking this:
dist a1 b1 = dist a2 b2
dist b1 c1 = dist b2 c2
dist a1 c1 = dist a2 c2
cos (angle a1 b1 c1) = ((dist b1 a1)\<^sup>2 + (dist b1 c1)\<^sup>2 - (dist a1 c1)\<^sup>2) / (2 * dist b1 a1 * dist b1 c1)
cos (angle a2 b2 c2) = ((dist b2 a2)\<^sup>2 + (dist b2 c2)\<^sup>2 - (dist a2 c2)\<^sup>2) / (2 * dist b2 a2 * dist b2 c2)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
dist a1 b1 = dist a2 b2
dist b1 c1 = dist b2 c2
dist a1 c1 = dist a2 c2
cos (angle a1 b1 c1) = ((dist b1 a1)\<^sup>2 + (dist b1 c1)\<^sup>2 - (dist a1 c1)\<^sup>2) / (2 * dist b1 a1 * dist b1 c1)
cos (angle a2 b2 c2) = ((dist b2 a2)\<^sup>2 + (dist b2 c2)\<^sup>2 - (dist a2 c2)\<^sup>2) / (2 * dist b2 a2 * dist b2 c2)

goal (1 subgoal):
 1. angle a1 b1 c1 = angle a2 b2 c2
[PROOF STEP]
by (intro cos_angle_eqD) (simp add: dist_commute)
[PROOF STATE]
proof (state)
this:
angle a1 b1 c1 = angle a2 b2 c2

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<lbrakk>dist ?a1.0 ?b1.0 = dist ?a2.0 ?b2.0; dist ?b1.0 ?c1.0 = dist ?b2.0 ?c2.0; dist ?a1.0 ?c1.0 = dist ?a2.0 ?c2.0\<rbrakk> \<Longrightarrow> angle ?a1.0 ?b1.0 ?c1.0 = angle ?a2.0 ?b2.0 ?c2.0

goal (1 subgoal):
 1. congruent_triangle a1 b1 c1 a2 b2 c2
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
dist a1 b1 = dist a2 b2
dist b1 c1 = dist b2 c2
dist a1 c1 = dist a2 c2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
dist a1 b1 = dist a2 b2
dist b1 c1 = dist b2 c2
dist a1 c1 = dist a2 c2

goal (1 subgoal):
 1. congruent_triangle a1 b1 c1 a2 b2 c2
[PROOF STEP]
by unfold_locales (auto intro!: A simp: dist_commute)
[PROOF STATE]
proof (state)
this:
congruent_triangle a1 b1 c1 a2 b2 c2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma nat_to_sch_of_pair_by_index [simp]: "nat_to_sch (pair_by_index n1 n2) = Pair_op (nat_to_sch n1) (nat_to_sch n2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nat_to_sch (pair_by_index n1 n2) = Pair_op (nat_to_sch n1) (nat_to_sch n2)
[PROOF STEP]
by (simp add: pair_by_index_def loc_srj_4_1)


[STATEMENT]
lemma fds_abs_converges_shift [simp]:
  fixes z :: "'a :: {banach, nat_power_field, real_normed_field}"
  shows "fds_abs_converges (fds_shift c f) z \<longleftrightarrow> fds_abs_converges f (z - c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fds_abs_converges (fds_shift c f) z = fds_abs_converges f (z - c)
[PROOF STEP]
unfolding fds_abs_converges_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. summable (\<lambda>n. norm (fds_nth (fds_shift c f) n / nat_power n z)) = summable (\<lambda>n. norm (fds_nth f n / nat_power n (z - c)))
[PROOF STEP]
by (intro summable_cong)
     (auto intro: eventually_mono [OF eventually_gt_at_top[of "0::nat"]] simp: nat_power_diff)


[STATEMENT]
lemma proper_compact_cball:
  assumes "proper (UNIV::'a::metric_space set)"
  shows "compact (cball (x::'a) r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. compact (cball x r)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
proper UNIV

goal (1 subgoal):
 1. compact (cball x r)
[PROOF STEP]
unfolding proper_def
[PROOF STATE]
proof (prove)
using this:
\<forall>x r. compact (cball x r \<inter> UNIV)

goal (1 subgoal):
 1. compact (cball x r)
[PROOF STEP]
by auto


[STATEMENT]
lemma HPow_mono: "x \<le> y \<Longrightarrow> HPow x \<le> HPow y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<le> y \<Longrightarrow> HPow x \<le> HPow y
[PROOF STEP]
by (metis HPow_iff less_eq_hf_def order_trans)


[STATEMENT]
lemma max_reg_Nor: "max_reg (Nor a b) = max (max_reg a) (max_reg b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. GExp.max_reg (Nor a b) = max (GExp.max_reg a) (GExp.max_reg b)
[PROOF STEP]
apply (simp add: max_reg_def AExp.max_reg_def Let_def max_absorb2)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. GExp.enumerate_regs a \<noteq> {} \<longrightarrow> GExp.enumerate_regs b \<noteq> {} \<longrightarrow> Some (Max (GExp.enumerate_regs a \<union> GExp.enumerate_regs b)) = max (Some (Max (GExp.enumerate_regs a))) (Some (Max (GExp.enumerate_regs b)))
[PROOF STEP]
by (metis GExp.finite_enumerate_regs Max.union bot_option_def max_bot2 sup_Some sup_max)


[STATEMENT]
lemma times_mtx2: "mtx
  ([a1, b1] #
   [c1, d1] # []) * mtx
  ([a2, b2] #
   [c2, d2] # []) = ((mtx
  ([a1*a2+b1*c2, a1*b2+b1*d2] #
   [c1*a2+d1*c2, c1*b2+d1*d2] # []))::2 sq_mtx)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mtx [[a1, b1], [c1, d1]] * mtx [[a2, b2], [c2, d2]] = mtx [[a1 * a2 + b1 * c2, a1 * b2 + b1 * d2], [c1 * a2 + d1 * c2, c1 * b2 + d1 * d2]]
[PROOF STEP]
unfolding sq_mtx_times_eq UNIV_2
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. to_mtx (\<chi>i j. \<Sum>k\<in>{1, 2}. mtx [[a1, b1], [c1, d1]] $$ i $ k * mtx [[a2, b2], [c2, d2]] $$ k $ j) = mtx [[a1 * a2 + b1 * c2, a1 * b2 + b1 * d2], [c1 * a2 + d1 * c2, c1 * b2 + d1 * d2]]
[PROOF STEP]
by (simp add: sq_mtx_eq_iff)


[STATEMENT]
lemma disjCond: "[| !! x. [| x:A; x:B |] ==> False |] ==> A Int B = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>x. \<lbrakk>x \<in> A; x \<in> B\<rbrakk> \<Longrightarrow> False) \<Longrightarrow> A \<inter> B = {}
[PROOF STEP]
by fastforce


[STATEMENT]
lemma dim_row_of_tensor_gate:
  assumes "gate m G1" and "gate n G2"
  shows "dim_row (G1 \<Otimes> G2) = 2^(m+n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row (G1 \<Otimes> G2) = 2 ^ (m + n)
[PROOF STEP]
using assms dim_row_tensor_mat gate.dim_row
[PROOF STATE]
proof (prove)
using this:
gate m G1
gate n G2
dim_row (?A \<Otimes> ?B) = dim_row ?A * dim_row ?B
gate ?n ?A \<Longrightarrow> dim_row ?A = 2 ^ ?n

goal (1 subgoal):
 1. dim_row (G1 \<Otimes> G2) = 2 ^ (m + n)
[PROOF STEP]
by (simp add: power_add)


[STATEMENT]
lemma evens_odds_length:
      "length (evens_odds True xs) = (length xs+1) div 2 \<and>
       length (evens_odds False xs) = (length xs) div 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (evens_odds True xs) = (length xs + 1) div 2 \<and> length (evens_odds False xs) = length xs div 2
[PROOF STEP]
by(induction xs) simp+


[STATEMENT]
theorem Helly:
  fixes f :: "'a::euclidean_space set set"
  assumes "card f \<ge> DIM('a) + 1" "\<forall>s\<in>f. convex s"
    and "\<And>t. \<lbrakk>t\<subseteq>f; card t = DIM('a) + 1\<rbrakk> \<Longrightarrow> \<Inter>t \<noteq> {}"
  shows "\<Inter>f \<noteq> {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Inter> f \<noteq> {}
[PROOF STEP]
using Helly_induct assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>card ?f = ?n; DIM(?'a) + 1 \<le> ?n; \<forall>s\<in>?f. convex s; \<forall>t\<subseteq>?f. card t = DIM(?'a) + 1 \<longrightarrow> \<Inter> t \<noteq> {}\<rbrakk> \<Longrightarrow> \<Inter> ?f \<noteq> {}
DIM('a) + 1 \<le> card f
\<forall>s\<in>f. convex s
\<lbrakk>?t \<subseteq> f; card ?t = DIM('a) + 1\<rbrakk> \<Longrightarrow> \<Inter> ?t \<noteq> {}

goal (1 subgoal):
 1. \<Inter> f \<noteq> {}
[PROOF STEP]
by blast


[STATEMENT]
lemma
  fixes c \<epsilon> :: real
  assumes "0 < \<epsilon>" "\<epsilon> < 1" "1 < c"
    shows "(\<lambda>_::real. 1) \<in> o(\<lambda>x. ln (ln x))"
      and "(\<lambda>x::real. ln (ln x)) \<in> o(\<lambda>x. ln x)"
      and "(\<lambda>x::real. ln x) \<in> o(\<lambda>x. x powr \<epsilon>)"
      and "(\<lambda>x::real. x powr \<epsilon>) \<in> o(\<lambda>x. x powr c)"
      and "(\<lambda>x. x powr c) \<in> o(\<lambda>x. x powr ln x)"
      and "(\<lambda>x. x powr ln x) \<in> o(\<lambda>x. c powr x)"
      and "(\<lambda>x. c powr x) \<in> o(\<lambda>x. x powr x)"
      and "(\<lambda>x. x powr x) \<in> o(\<lambda>x. c powr (c powr x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (((\<lambda>_. 1) \<in> o(\<lambda>x. ln (ln x)) &&& (\<lambda>x. ln (ln x)) \<in> o(ln)) &&& ln \<in> o(\<lambda>x. x powr \<epsilon>) &&& (\<lambda>x. x powr \<epsilon>) \<in> o(\<lambda>x. x powr c)) &&& ((\<lambda>x. x powr c) \<in> o(\<lambda>x. x powr ln x) &&& (\<lambda>x. x powr ln x) \<in> o((powr) c)) &&& (powr) c \<in> o(\<lambda>x. x powr x) &&& (\<lambda>x. x powr x) \<in> o(\<lambda>x. c powr c powr x)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < \<epsilon>
\<epsilon> < 1
1 < c

goal (1 subgoal):
 1. (((\<lambda>_. 1) \<in> o(\<lambda>x. ln (ln x)) &&& (\<lambda>x. ln (ln x)) \<in> o(ln)) &&& ln \<in> o(\<lambda>x. x powr \<epsilon>) &&& (\<lambda>x. x powr \<epsilon>) \<in> o(\<lambda>x. x powr c)) &&& ((\<lambda>x. x powr c) \<in> o(\<lambda>x. x powr ln x) &&& (\<lambda>x. x powr ln x) \<in> o((powr) c)) &&& (powr) c \<in> o(\<lambda>x. x powr x) &&& (\<lambda>x. x powr x) \<in> o(\<lambda>x. c powr c powr x)
[PROOF STEP]
by (real_asymp (verbose))+


[STATEMENT]
lemma prof_max_ge_all_in_pset:
  assumes "j \<in> firms"
  assumes "Y j \<in> profit_maximisation P (production_sets j)"
  shows "\<forall>y \<in> production_sets j. P \<bullet> Y j \<ge> P \<bullet> y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>y\<in>production_sets j. P \<bullet> y \<le> P \<bullet> Y j
[PROOF STEP]
using all_leq assms(2) profit_maximisation_def
[PROOF STATE]
proof (prove)
using this:
?x \<in> arg_max_set ?f ?S \<Longrightarrow> \<forall>y\<in>?S. ?f y \<le> ?f ?x
Y j \<in> profit_maximisation P (production_sets j)
profit_maximisation ?P ?S = arg_max_set ((\<bullet>) ?P) ?S

goal (1 subgoal):
 1. \<forall>y\<in>production_sets j. P \<bullet> y \<le> P \<bullet> Y j
[PROOF STEP]
by fastforce


[STATEMENT]
lemma complement_4_language_2: "language (complement_4 A) \<subseteq> language (complement_3 A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. language (complement_4 A) \<subseteq> language (complement_3 A)
[PROOF STEP]
using language_mono complement_4_less
[PROOF STATE]
proof (prove)
using this:
mono language
complement_4 ?A \<le> complement_3 ?A

goal (1 subgoal):
 1. language (complement_4 A) \<subseteq> language (complement_3 A)
[PROOF STEP]
by (auto dest: monoD)


[STATEMENT]
lemma INF_ereal_add_right:
  assumes "I \<noteq> {}" "c \<noteq> -\<infinity>" "\<And>x. x \<in> I \<Longrightarrow> 0 \<le> f x"
  shows "(INF i\<in>I. c + f i :: ereal) = c + (INF i\<in>I. f i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (INF i\<in>I. c + f i) = c + Inf (f ` I)
[PROOF STEP]
using INF_ereal_add_left[OF assms]
[PROOF STATE]
proof (prove)
using this:
(\<And>x. x \<in> I \<Longrightarrow> ?x1 x \<in> I) \<Longrightarrow> (INF i\<in>I. f (?x1 i) + c) = (INF i\<in>I. f (?x1 i)) + c

goal (1 subgoal):
 1. (INF i\<in>I. c + f i) = c + Inf (f ` I)
[PROOF STEP]
by (simp add: ac_simps)


[STATEMENT]
lemma link_length: "size (tree_to_multiset (link t1 t2)) =
  size (tree_to_multiset t1) + size (tree_to_multiset t2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. size (tree_to_multiset (link t1 t2)) = size (tree_to_multiset t1) + size (tree_to_multiset t2)
[PROOF STEP]
apply(cases t1)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x1 x2 x3 x4. t1 = Node x1 x2 x3 x4 \<Longrightarrow> size (tree_to_multiset (link t1 t2)) = size (tree_to_multiset t1) + size (tree_to_multiset t2)
[PROOF STEP]
apply(cases t2)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x1 x2 x3 x4 x1a x2a x3a x4a. \<lbrakk>t1 = Node x1 x2 x3 x4; t2 = Node x1a x2a x3a x4a\<rbrakk> \<Longrightarrow> size (tree_to_multiset (link t1 t2)) = size (tree_to_multiset t1) + size (tree_to_multiset t2)
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma (in group) sub_subgroup_coprime:
  assumes "subgroup H G" "subgroup J G" "coprime (card H) (card J)"
  and "subgroup sH G" "subgroup sJ G" "sH \<subseteq> H" "sJ \<subseteq> J"
shows "coprime (card sH) (card sJ)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coprime (card sH) (card sJ)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
subgroup H G
subgroup J G
coprime (card H) (card J)
subgroup sH G
subgroup sJ G
sH \<subseteq> H
sJ \<subseteq> J

goal (1 subgoal):
 1. coprime (card sH) (card sJ)
[PROOF STEP]
by (meson coprime_divisors sub_subgroup_dvd_card)


[STATEMENT]
lemma analz_Un: "analz(G) \<union> analz(H) \<subseteq> analz(G \<union> H)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. analz G \<union> analz H \<subseteq> analz (G \<union> H)
[PROOF STEP]
by (intro Un_least analz_mono Un_upper1 Un_upper2)


[STATEMENT]
lemma fls_X_intpow_regpart:
  "fls_regpart (fls_X_intpow i) = (if i\<ge>0 then fps_X ^ nat i else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fls_regpart (fls_X_intpow i) = (if 0 \<le> i then fps_X ^ nat i else 0)
[PROOF STEP]
using fls_X_pow_conv_fps_X_pow[of "nat i"]
        fls_regpart_shift_conv_fps_shift[of "-i" 1]
[PROOF STATE]
proof (prove)
using this:
fls_regpart (fls_X ^ nat i) = fps_X ^ nat i
0 \<le> - i \<Longrightarrow> fls_regpart (fls_X_intpow i) = fps_shift (nat (- i)) (fls_regpart 1)

goal (1 subgoal):
 1. fls_regpart (fls_X_intpow i) = (if 0 \<le> i then fps_X ^ nat i else 0)
[PROOF STEP]
by    (auto simp: fls_X_power_conv_shift_1 fps_shift_one)


[STATEMENT]
lemma mset_pos_diff[simp]:
  "mset_pos (A - B) = (mset_pos A - mset_pos B) + (mset_neg B - mset_neg A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mset_pos (A - B) = mset_pos A - mset_pos B + (mset_neg B - mset_neg A)
[PROOF STEP]
by (rule mset_pos_plus[of A "- B", simplified])


[STATEMENT]
lemma DERIV_cdivide:
  "(f has_field_derivative D) (at x within s) \<Longrightarrow>
    ((\<lambda>x. f x / c) has_field_derivative D / c) (at x within s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f has_field_derivative D) (at x within s) \<Longrightarrow> ((\<lambda>x. f x / c) has_field_derivative D / c) (at x within s)
[PROOF STEP]
using DERIV_cmult_right[of f D x s "1 / c"]
[PROOF STATE]
proof (prove)
using this:
(f has_field_derivative D) (at x within s) \<Longrightarrow> ((\<lambda>x. f x * ((1::'a) / c)) has_field_derivative D * ((1::'a) / c)) (at x within s)

goal (1 subgoal):
 1. (f has_field_derivative D) (at x within s) \<Longrightarrow> ((\<lambda>x. f x / c) has_field_derivative D / c) (at x within s)
[PROOF STEP]
by simp


[STATEMENT]
lemma le_nhds: "F \<le> nhds a \<longleftrightarrow> (\<forall>S. open S \<and> a \<in> S \<longrightarrow> eventually (\<lambda>x. x \<in> S) F)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (F \<le> nhds a) = (\<forall>S. open S \<and> a \<in> S \<longrightarrow> (\<forall>\<^sub>F x in F. x \<in> S))
[PROOF STEP]
unfolding le_filter_def eventually_nhds
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>P. (\<exists>S. open S \<and> a \<in> S \<and> Ball S P) \<longrightarrow> eventually P F) = (\<forall>S. open S \<and> a \<in> S \<longrightarrow> (\<forall>\<^sub>F x in F. x \<in> S))
[PROOF STEP]
by (fast elim: eventually_mono)


[STATEMENT]
lemma simplex_imp_polytope:
   "n simplex S \<Longrightarrow> polytope S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n simplex S \<Longrightarrow> polytope S
[PROOF STEP]
unfolding simplex_def polytope_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>C. \<not> affine_dependent C \<and> int (card C) = n + 1 \<and> S = convex hull C \<Longrightarrow> \<exists>v. finite v \<and> S = convex hull v
[PROOF STEP]
using aff_independent_finite
[PROOF STATE]
proof (prove)
using this:
\<not> affine_dependent ?B \<Longrightarrow> finite ?B

goal (1 subgoal):
 1. \<exists>C. \<not> affine_dependent C \<and> int (card C) = n + 1 \<and> S = convex hull C \<Longrightarrow> \<exists>v. finite v \<and> S = convex hull v
[PROOF STEP]
by blast


[STATEMENT]
lemma perzeta_one_half_left: "s \<noteq> 1 \<Longrightarrow> perzeta (1 / 2) s = (2 powr (1-s) - 1) * zeta s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. s \<noteq> 1 \<Longrightarrow> perzeta (1 / 2) s = (2 powr (1 - s) - 1) * zeta s
[PROOF STEP]
using perzeta_conv_hurwitz_zeta_multiplication'[of 2 s 1]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 < 2; s \<noteq> 1\<rbrakk> \<Longrightarrow> perzeta (real_of_int 1 / real 2) s = of_nat 2 powr - s * (\<Sum>n = 1..2. exp (complex_of_real (2 * pi * real n * real_of_int 1 / real 2) * \<i>) * hurwitz_zeta (real n / real 2) s)

goal (1 subgoal):
 1. s \<noteq> 1 \<Longrightarrow> perzeta (1 / 2) s = (2 powr (1 - s) - 1) * zeta s
[PROOF STEP]
by (simp add: eval_nat_numeral hurwitz_zeta_one_half_left powr_minus
                field_simps zeta_def powr_diff)


[STATEMENT]
lemma Digamma_def:
  "Digamma z = (\<Sum>k. inverse (of_nat (Suc k)) - inverse (z + of_nat k)) - euler_mascheroni"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Digamma z = (\<Sum>k. inverse (of_nat (Suc k)) - inverse (z + of_nat k)) - euler_mascheroni
[PROOF STEP]
by (simp add: Polygamma_def)


[STATEMENT]
lemma fact_binomial:
  assumes "k \<le> n"
  shows "fact k * of_nat (n choose k) = (fact n / fact (n - k) :: 'a::field_char_0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fact k * of_nat (n choose k) = fact n / fact (n - k)
[PROOF STEP]
unfolding binomial_fact [OF assms]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fact k * (fact n / (fact k * fact (n - k))) = fact n / fact (n - k)
[PROOF STEP]
by (simp add: field_simps)


[STATEMENT]
lemma setdist_closest_point:
    "\<lbrakk>closed S; S \<noteq> {}\<rbrakk> \<Longrightarrow> setdist {a} S = dist a (closest_point S a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>closed S; S \<noteq> {}\<rbrakk> \<Longrightarrow> setdist {a} S = dist a (closest_point S a)
[PROOF STEP]
by (metis closest_point_exists(2) closest_point_in_set emptyE insert_iff setdist_unique)


[STATEMENT]
lemma S_quadratic':
  assumes "p \<noteq> 0" and "q \<noteq> 0" and "proj2_abs p \<noteq> proj2_abs q"
  shows "proj2_abs (k *\<^sub>R p + q) \<in> S
  \<longleftrightarrow> p \<bullet> (M *v p) * k\<^sup>2 + p \<bullet> (M *v q) * 2 * k + q \<bullet> (M *v q) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (proj2_abs (k *\<^sub>R p + q) \<in> S) = (p \<bullet> (M *v p) * k\<^sup>2 + p \<bullet> (M *v q) * 2 * k + q \<bullet> (M *v q) = 0)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (proj2_abs (k *\<^sub>R p + q) \<in> S) = (p \<bullet> (M *v p) * k\<^sup>2 + p \<bullet> (M *v q) * 2 * k + q \<bullet> (M *v q) = 0)
[PROOF STEP]
let ?r = "k *\<^sub>R p + q"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (proj2_abs (k *\<^sub>R p + q) \<in> S) = (p \<bullet> (M *v p) * k\<^sup>2 + p \<bullet> (M *v q) * 2 * k + q \<bullet> (M *v q) = 0)
[PROOF STEP]
from \<open>p \<noteq> 0\<close> and \<open>q \<noteq> 0\<close> and \<open>proj2_abs p \<noteq> proj2_abs q\<close>
    and dependent_proj2_abs [of p q k 1]
[PROOF STATE]
proof (chain)
picking this:
p \<noteq> 0
q \<noteq> 0
proj2_abs p \<noteq> proj2_abs q
\<lbrakk>p \<noteq> 0; q \<noteq> 0; k \<noteq> 0 \<or> 1 \<noteq> 0; k *\<^sub>R p + 1 *\<^sub>R q = 0\<rbrakk> \<Longrightarrow> proj2_abs p = proj2_abs q
[PROOF STEP]
have "?r \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
p \<noteq> 0
q \<noteq> 0
proj2_abs p \<noteq> proj2_abs q
\<lbrakk>p \<noteq> 0; q \<noteq> 0; k \<noteq> 0 \<or> 1 \<noteq> 0; k *\<^sub>R p + 1 *\<^sub>R q = 0\<rbrakk> \<Longrightarrow> proj2_abs p = proj2_abs q

goal (1 subgoal):
 1. k *\<^sub>R p + q \<noteq> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
k *\<^sub>R p + q \<noteq> 0

goal (1 subgoal):
 1. (proj2_abs (k *\<^sub>R p + q) \<in> S) = (p \<bullet> (M *v p) * k\<^sup>2 + p \<bullet> (M *v q) * 2 * k + q \<bullet> (M *v q) = 0)
[PROOF STEP]
hence "proj2_abs ?r \<in> S \<longleftrightarrow> ?r \<bullet> (M *v ?r) = 0"
[PROOF STATE]
proof (prove)
using this:
k *\<^sub>R p + q \<noteq> 0

goal (1 subgoal):
 1. (proj2_abs (k *\<^sub>R p + q) \<in> S) = ((k *\<^sub>R p + q) \<bullet> (M *v (k *\<^sub>R p + q)) = 0)
[PROOF STEP]
by (rule S_abs)
[PROOF STATE]
proof (state)
this:
(proj2_abs (k *\<^sub>R p + q) \<in> S) = ((k *\<^sub>R p + q) \<bullet> (M *v (k *\<^sub>R p + q)) = 0)

goal (1 subgoal):
 1. (proj2_abs (k *\<^sub>R p + q) \<in> S) = (p \<bullet> (M *v p) * k\<^sup>2 + p \<bullet> (M *v q) * 2 * k + q \<bullet> (M *v q) = 0)
[PROOF STEP]
with collinear_quadratic [of ?r k p q]
[PROOF STATE]
proof (chain)
picking this:
k *\<^sub>R p + q = k *\<^sub>R p + q \<Longrightarrow> (k *\<^sub>R p + q) \<bullet> (M *v (k *\<^sub>R p + q)) = p \<bullet> (M *v p) * k\<^sup>2 + 2 * (p \<bullet> (M *v q)) * k + q \<bullet> (M *v q)
(proj2_abs (k *\<^sub>R p + q) \<in> S) = ((k *\<^sub>R p + q) \<bullet> (M *v (k *\<^sub>R p + q)) = 0)
[PROOF STEP]
show "proj2_abs ?r \<in> S
    \<longleftrightarrow> p \<bullet> (M *v p) * k\<^sup>2 + p \<bullet> (M *v q) * 2 * k + q \<bullet> (M *v q) = 0"
[PROOF STATE]
proof (prove)
using this:
k *\<^sub>R p + q = k *\<^sub>R p + q \<Longrightarrow> (k *\<^sub>R p + q) \<bullet> (M *v (k *\<^sub>R p + q)) = p \<bullet> (M *v p) * k\<^sup>2 + 2 * (p \<bullet> (M *v q)) * k + q \<bullet> (M *v q)
(proj2_abs (k *\<^sub>R p + q) \<in> S) = ((k *\<^sub>R p + q) \<bullet> (M *v (k *\<^sub>R p + q)) = 0)

goal (1 subgoal):
 1. (proj2_abs (k *\<^sub>R p + q) \<in> S) = (p \<bullet> (M *v p) * k\<^sup>2 + p \<bullet> (M *v q) * 2 * k + q \<bullet> (M *v q) = 0)
[PROOF STEP]
by (simp add: dot_lmul_matrix [symmetric] algebra_simps)
[PROOF STATE]
proof (state)
this:
(proj2_abs (k *\<^sub>R p + q) \<in> S) = (p \<bullet> (M *v p) * k\<^sup>2 + p \<bullet> (M *v q) * 2 * k + q \<bullet> (M *v q) = 0)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma "(\<forall>u v. u < (0::int) \<longrightarrow> u \<noteq> \<bar>v\<bar>)
    \<longrightarrow> (\<exists>A::int set. -2 \<in> A & (\<forall>y. \<bar>y\<bar> \<notin> A))"
  \<comment> \<open>Example 8 needs a small hint.\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>u v. u < 0 \<longrightarrow> u \<noteq> \<bar>v\<bar>) \<longrightarrow> (\<exists>A. - 2 \<in> A \<and> (\<forall>y. \<bar>y\<bar> \<notin> A))
[PROOF STEP]
by force
    \<comment> \<open>not \<open>blast\<close>, which can't simplify \<open>-2 < 0\<close>\<close>


[STATEMENT]
lemma of_nat_zero:
  assumes "CARD('a::nontriv) dvd n"
  shows "(of_nat n :: 'a mod_ring) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_nat n = 0
[PROOF STEP]
apply (transfer fixing: n)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int n mod int CARD('a) = 0
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
CARD('a) dvd n

goal (1 subgoal):
 1. int n mod int CARD('a) = 0
[PROOF STEP]
by (presburger)


[STATEMENT]
lemma measure_point_measure:
  "finite \<Omega> \<Longrightarrow> A \<subseteq> \<Omega> \<Longrightarrow> (\<And>x. x \<in> \<Omega> \<Longrightarrow> 0 \<le> p x) \<Longrightarrow>
    measure (point_measure \<Omega> (\<lambda>x. ennreal (p x))) A = (\<Sum>i\<in>A. p i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite \<Omega>; A \<subseteq> \<Omega>; \<And>x. x \<in> \<Omega> \<Longrightarrow> 0 \<le> p x\<rbrakk> \<Longrightarrow> Sigma_Algebra.measure (point_measure \<Omega> (\<lambda>x. ennreal (p x))) A = sum p A
[PROOF STEP]
unfolding measure_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite \<Omega>; A \<subseteq> \<Omega>; \<And>x. x \<in> \<Omega> \<Longrightarrow> 0 \<le> p x\<rbrakk> \<Longrightarrow> enn2real (emeasure (point_measure \<Omega> (\<lambda>x. ennreal (p x))) A) = sum p A
[PROOF STEP]
by (subst emeasure_point_measure_finite) (auto simp: subset_eq sum_nonneg)


[STATEMENT]
lemma mat_mult_var: "(f \<otimes> g) = (\<lambda>i j. \<Sum> {(f i k) * (g k j) | k. k \<in> UNIV})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f \<otimes> g = (\<lambda>i j. \<Sum> {f i k * g k j |k. k \<in> UNIV})
[PROOF STEP]
by (rule ext)+ (simp add: mat_mult_def)


[STATEMENT]
lemma transfer_vars [transfer_rule]:
  assumes [transfer_rule]: "R p p'"
  shows   "(\<Union>i. vars (poly.coeff p i)) \<union> (if Polynomial.degree p = 0 then {} else {x}) = vars p'"
    (is "?A \<union> ?B = _")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Union>i. vars (poly.coeff p i)) \<union> (if Polynomial.degree p = 0 then {} else {x}) = vars p'
[PROOF STEP]
proof (intro equalityI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (\<Union>i. vars (poly.coeff p i)) \<union> (if Polynomial.degree p = 0 then {} else {x}) \<subseteq> vars p'
 2. vars p' \<subseteq> (\<Union>i. vars (poly.coeff p i)) \<union> (if Polynomial.degree p = 0 then {} else {x})
[PROOF STEP]
have "vars p' = vars (poly p (Var x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vars p' = vars (poly p (Var x))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
R p p'

goal (1 subgoal):
 1. vars p' = vars (poly p (Var x))
[PROOF STEP]
by (simp add: R_def poly_mpoly_to_mpoly_poly)
[PROOF STATE]
proof (state)
this:
vars p' = vars (poly p (Var x))

goal (2 subgoals):
 1. (\<Union>i. vars (poly.coeff p i)) \<union> (if Polynomial.degree p = 0 then {} else {x}) \<subseteq> vars p'
 2. vars p' \<subseteq> (\<Union>i. vars (poly.coeff p i)) \<union> (if Polynomial.degree p = 0 then {} else {x})
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
vars p' = vars (poly p (Var x))

goal (2 subgoals):
 1. (\<Union>i. vars (poly.coeff p i)) \<union> (if Polynomial.degree p = 0 then {} else {x}) \<subseteq> vars p'
 2. vars p' \<subseteq> (\<Union>i. vars (poly.coeff p i)) \<union> (if Polynomial.degree p = 0 then {} else {x})
[PROOF STEP]
have "poly p (Var x) = (\<Sum>i\<le>Polynomial.degree p. poly.coeff p i * Var x ^ i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly p (Var x) = (\<Sum>i\<le>Polynomial.degree p. poly.coeff p i * Var x ^ i)
[PROOF STEP]
unfolding poly_altdef
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<le>Polynomial.degree p. poly.coeff p i * Var x ^ i) = (\<Sum>i\<le>Polynomial.degree p. poly.coeff p i * Var x ^ i)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
poly p (Var x) = (\<Sum>i\<le>Polynomial.degree p. poly.coeff p i * Var x ^ i)

goal (2 subgoals):
 1. (\<Union>i. vars (poly.coeff p i)) \<union> (if Polynomial.degree p = 0 then {} else {x}) \<subseteq> vars p'
 2. vars p' \<subseteq> (\<Union>i. vars (poly.coeff p i)) \<union> (if Polynomial.degree p = 0 then {} else {x})
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
poly p (Var x) = (\<Sum>i\<le>Polynomial.degree p. poly.coeff p i * Var x ^ i)

goal (2 subgoals):
 1. (\<Union>i. vars (poly.coeff p i)) \<union> (if Polynomial.degree p = 0 then {} else {x}) \<subseteq> vars p'
 2. vars p' \<subseteq> (\<Union>i. vars (poly.coeff p i)) \<union> (if Polynomial.degree p = 0 then {} else {x})
[PROOF STEP]
have "vars \<dots> \<subseteq> (\<Union>i. vars (poly.coeff p i) \<union> (if Polynomial.degree p = 0 then {} else {x}))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vars (\<Sum>i\<le>Polynomial.degree p. poly.coeff p i * Var x ^ i) \<subseteq> (\<Union>i. vars (poly.coeff p i) \<union> (if Polynomial.degree p = 0 then {} else {x}))
[PROOF STEP]
proof (intro order.trans[OF vars_sum] UN_mono order.trans[OF vars_mult] Un_mono)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. {..Polynomial.degree p} \<subseteq> UNIV
 2. \<And>x. x \<in> {..Polynomial.degree p} \<Longrightarrow> vars (poly.coeff p x) \<subseteq> vars (poly.coeff p x)
 3. \<And>xa. xa \<in> {..Polynomial.degree p} \<Longrightarrow> vars (Var x ^ xa) \<subseteq> (if Polynomial.degree p = 0 then {} else {x})
[PROOF STEP]
fix i :: nat
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. {..Polynomial.degree p} \<subseteq> UNIV
 2. \<And>x. x \<in> {..Polynomial.degree p} \<Longrightarrow> vars (poly.coeff p x) \<subseteq> vars (poly.coeff p x)
 3. \<And>xa. xa \<in> {..Polynomial.degree p} \<Longrightarrow> vars (Var x ^ xa) \<subseteq> (if Polynomial.degree p = 0 then {} else {x})
[PROOF STEP]
assume i: "i \<in> {..Polynomial.degree p}"
[PROOF STATE]
proof (state)
this:
i \<in> {..Polynomial.degree p}

goal (3 subgoals):
 1. {..Polynomial.degree p} \<subseteq> UNIV
 2. \<And>x. x \<in> {..Polynomial.degree p} \<Longrightarrow> vars (poly.coeff p x) \<subseteq> vars (poly.coeff p x)
 3. \<And>xa. xa \<in> {..Polynomial.degree p} \<Longrightarrow> vars (Var x ^ xa) \<subseteq> (if Polynomial.degree p = 0 then {} else {x})
[PROOF STEP]
show "vars (Var x ^ i) \<subseteq> (if Polynomial.degree p = 0 then {} else {x})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vars (Var x ^ i) \<subseteq> (if Polynomial.degree p = 0 then {} else {x})
[PROOF STEP]
proof (cases "Polynomial.degree p = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Polynomial.degree p = 0 \<Longrightarrow> vars (Var x ^ i) \<subseteq> (if Polynomial.degree p = 0 then {} else {x})
 2. Polynomial.degree p \<noteq> 0 \<Longrightarrow> vars (Var x ^ i) \<subseteq> (if Polynomial.degree p = 0 then {} else {x})
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
Polynomial.degree p \<noteq> 0

goal (2 subgoals):
 1. Polynomial.degree p = 0 \<Longrightarrow> vars (Var x ^ i) \<subseteq> (if Polynomial.degree p = 0 then {} else {x})
 2. Polynomial.degree p \<noteq> 0 \<Longrightarrow> vars (Var x ^ i) \<subseteq> (if Polynomial.degree p = 0 then {} else {x})
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
Polynomial.degree p \<noteq> 0

goal (1 subgoal):
 1. vars (Var x ^ i) \<subseteq> (if Polynomial.degree p = 0 then {} else {x})
[PROOF STEP]
by (intro order.trans[OF vars_power]) (auto simp: vars_Var)
[PROOF STATE]
proof (state)
this:
vars (Var x ^ i) \<subseteq> (if Polynomial.degree p = 0 then {} else {x})

goal (1 subgoal):
 1. Polynomial.degree p = 0 \<Longrightarrow> vars (Var x ^ i) \<subseteq> (if Polynomial.degree p = 0 then {} else {x})
[PROOF STEP]
qed (use i in auto)
[PROOF STATE]
proof (state)
this:
vars (Var x ^ i) \<subseteq> (if Polynomial.degree p = 0 then {} else {x})

goal (2 subgoals):
 1. {..Polynomial.degree p} \<subseteq> UNIV
 2. \<And>x. x \<in> {..Polynomial.degree p} \<Longrightarrow> vars (poly.coeff p x) \<subseteq> vars (poly.coeff p x)
[PROOF STEP]
qed auto
[PROOF STATE]
proof (state)
this:
vars (\<Sum>i\<le>Polynomial.degree p. poly.coeff p i * Var x ^ i) \<subseteq> (\<Union>i. vars (poly.coeff p i) \<union> (if Polynomial.degree p = 0 then {} else {x}))

goal (2 subgoals):
 1. (\<Union>i. vars (poly.coeff p i)) \<union> (if Polynomial.degree p = 0 then {} else {x}) \<subseteq> vars p'
 2. vars p' \<subseteq> (\<Union>i. vars (poly.coeff p i)) \<union> (if Polynomial.degree p = 0 then {} else {x})
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
vars p' \<subseteq> (\<Union>i. vars (poly.coeff p i) \<union> (if Polynomial.degree p = 0 then {} else {x}))
[PROOF STEP]
show "vars p' \<subseteq> ?A \<union> ?B"
[PROOF STATE]
proof (prove)
using this:
vars p' \<subseteq> (\<Union>i. vars (poly.coeff p i) \<union> (if Polynomial.degree p = 0 then {} else {x}))

goal (1 subgoal):
 1. vars p' \<subseteq> (\<Union>i. vars (poly.coeff p i)) \<union> (if Polynomial.degree p = 0 then {} else {x})
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
vars p' \<subseteq> (\<Union>i. vars (poly.coeff p i)) \<union> (if Polynomial.degree p = 0 then {} else {x})

goal (1 subgoal):
 1. (\<Union>i. vars (poly.coeff p i)) \<union> (if Polynomial.degree p = 0 then {} else {x}) \<subseteq> vars p'
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Union>i. vars (poly.coeff p i)) \<union> (if Polynomial.degree p = 0 then {} else {x}) \<subseteq> vars p'
[PROOF STEP]
have "?A \<subseteq> vars p'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Union>i. vars (poly.coeff p i)) \<subseteq> vars p'
[PROOF STEP]
using assms vars_coeff_mpoly_to_mpoly_poly
[PROOF STATE]
proof (prove)
using this:
R p p'
vars (poly.coeff (mpoly_to_mpoly_poly ?x ?p) ?i) \<subseteq> vars ?p - {?x}

goal (1 subgoal):
 1. (\<Union>i. vars (poly.coeff p i)) \<subseteq> vars p'
[PROOF STEP]
by (auto simp: R_def)
[PROOF STATE]
proof (state)
this:
(\<Union>i. vars (poly.coeff p i)) \<subseteq> vars p'

goal (1 subgoal):
 1. (\<Union>i. vars (poly.coeff p i)) \<union> (if Polynomial.degree p = 0 then {} else {x}) \<subseteq> vars p'
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<Union>i. vars (poly.coeff p i)) \<subseteq> vars p'

goal (1 subgoal):
 1. (\<Union>i. vars (poly.coeff p i)) \<union> (if Polynomial.degree p = 0 then {} else {x}) \<subseteq> vars p'
[PROOF STEP]
have "?B \<subseteq> vars p'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if Polynomial.degree p = 0 then {} else {x}) \<subseteq> vars p'
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
R p p'

goal (1 subgoal):
 1. (if Polynomial.degree p = 0 then {} else {x}) \<subseteq> vars p'
[PROOF STEP]
by (auto simp: R_def degree_pos_iff)
[PROOF STATE]
proof (state)
this:
(if Polynomial.degree p = 0 then {} else {x}) \<subseteq> vars p'

goal (1 subgoal):
 1. (\<Union>i. vars (poly.coeff p i)) \<union> (if Polynomial.degree p = 0 then {} else {x}) \<subseteq> vars p'
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<Union>i. vars (poly.coeff p i)) \<subseteq> vars p'
(if Polynomial.degree p = 0 then {} else {x}) \<subseteq> vars p'
[PROOF STEP]
show "?A \<union> ?B \<subseteq> vars p'"
[PROOF STATE]
proof (prove)
using this:
(\<Union>i. vars (poly.coeff p i)) \<subseteq> vars p'
(if Polynomial.degree p = 0 then {} else {x}) \<subseteq> vars p'

goal (1 subgoal):
 1. (\<Union>i. vars (poly.coeff p i)) \<union> (if Polynomial.degree p = 0 then {} else {x}) \<subseteq> vars p'
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(\<Union>i. vars (poly.coeff p i)) \<union> (if Polynomial.degree p = 0 then {} else {x}) \<subseteq> vars p'

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Log_less_zero_cancel_iff[simp]:
  "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> Log a x < 0 \<longleftrightarrow> x < 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>1 < a; 0 < x\<rbrakk> \<Longrightarrow> (Log a x < 0) = (x < 1)
[PROOF STEP]
using Log_less_cancel_iff[of a x 1]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>1 < a; 0 < x; 0 < 1\<rbrakk> \<Longrightarrow> (Log a x < Log a 1) = (x < 1)

goal (1 subgoal):
 1. \<lbrakk>1 < a; 0 < x\<rbrakk> \<Longrightarrow> (Log a x < 0) = (x < 1)
[PROOF STEP]
by simp


[STATEMENT]
lemma (in comm_monoid) finprod_Union_disjoint:
  "\<lbrakk>finite C; \<And>A. A \<in> C \<Longrightarrow> finite A \<and> (\<forall>x\<in>A. f x \<in> carrier G); pairwise disjnt C\<rbrakk> \<Longrightarrow>
    finprod G f (\<Union>C) = finprod G (finprod G f) C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite C; \<And>A. A \<in> C \<Longrightarrow> finite A \<and> (\<forall>x\<in>A. f x \<in> carrier G); pairwise disjnt C\<rbrakk> \<Longrightarrow> finprod G f (\<Union> C) = finprod G (finprod G f) C
[PROOF STEP]
by (frule finprod_UN_disjoint [of C id f]) auto


[STATEMENT]
lemma sums_complex_iff: "f sums x \<longleftrightarrow> ((\<lambda>x. Re (f x)) sums Re x) \<and> ((\<lambda>x. Im (f x)) sums Im x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f sums x = ((\<lambda>x. Re (f x)) sums Re x \<and> (\<lambda>x. Im (f x)) sums Im x)
[PROOF STEP]
unfolding sums_def tendsto_complex_iff Im_sum Re_sum
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. \<Sum>x<x. Re (f x)) \<longlonglongrightarrow> Re x \<and> (\<lambda>x. \<Sum>x<x. Im (f x)) \<longlonglongrightarrow> Im x) = ((\<lambda>n. \<Sum>x<n. Re (f x)) \<longlonglongrightarrow> Re x \<and> (\<lambda>n. \<Sum>x<n. Im (f x)) \<longlonglongrightarrow> Im x)
[PROOF STEP]
..


[STATEMENT]
lemma less_log2_of_power: "2 ^ n < m \<Longrightarrow> n < log 2 m" for m n :: nat
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 ^ n < m \<Longrightarrow> real n < log 2 (real m)
[PROOF STEP]
using less_log_of_power[of 2]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>2 ^ ?n < ?m; 1 < 2\<rbrakk> \<Longrightarrow> real ?n < log 2 ?m

goal (1 subgoal):
 1. 2 ^ n < m \<Longrightarrow> real n < log 2 (real m)
[PROOF STEP]
by simp


[STATEMENT]
lemma param_list_bex[param]:
  "\<lbrakk>(P,P')\<in>(Ra\<rightarrow>Id); (l,l')\<in>\<langle>Ra\<rangle> list_rel\<rbrakk>
    \<Longrightarrow> (\<exists>x\<in>set l. P x, \<exists>x\<in>set l'. P' x) \<in> Id"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(P, P') \<in> Ra \<rightarrow> bool_rel; (l, l') \<in> \<langle>Ra\<rangle>list_rel\<rbrakk> \<Longrightarrow> (\<exists>x\<in>set l. P x, \<exists>x\<in>set l'. P' x) \<in> bool_rel
[PROOF STEP]
unfolding list_ex_rec_eq[abs_def]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(P, P') \<in> Ra \<rightarrow> bool_rel; (l, l') \<in> \<langle>Ra\<rangle>list_rel\<rbrakk> \<Longrightarrow> (list_ex_rec P l, list_ex_rec P' l') \<in> bool_rel
[PROOF STEP]
unfolding list_ex_rec_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>(P, P') \<in> Ra \<rightarrow> bool_rel; (l, l') \<in> \<langle>Ra\<rangle>list_rel\<rbrakk> \<Longrightarrow> (rec_list (\<lambda>P. False) (\<lambda>a l la P. P a \<or> la P) l P, rec_list (\<lambda>P. False) (\<lambda>a l la P. P a \<or> la P) l' P') \<in> bool_rel
[PROOF STEP]
by (parametricity)


[STATEMENT]
lemma Min_set_partition_disjoint:
  assumes "finite As"
  assumes "As \<subseteq> carrier (SA m)"
  assumes "As \<noteq> {}"
  assumes "is_semialgebraic m B"
  assumes "s \<in> Min_set_partition m As B"
  assumes "s' \<in> Min_set_partition m As B"
  assumes "s \<noteq>  s'"
  shows  "s \<inter> s' = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. s \<inter> s' = {}
[PROOF STEP]
apply(rule  disjointify_is_disjoint[of "((\<inter>) B ` Min_set m As ` As)" s s'])
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. finite ((\<inter>) B ` Min_set m As ` As)
 2. s \<in> disjointify ((\<inter>) B ` Min_set m As ` As)
 3. s' \<in> disjointify ((\<inter>) B ` Min_set m As ` As)
 4. s \<noteq> s'
[PROOF STEP]
using assms finite_imageI
[PROOF STATE]
proof (prove)
using this:
finite As
As \<subseteq> carrier (SA m)
As \<noteq> {}
is_semialgebraic m B
s \<in> Min_set_partition m As B
s' \<in> Min_set_partition m As B
s \<noteq> s'
finite ?F \<Longrightarrow> finite (?h ` ?F)

goal (4 subgoals):
 1. finite ((\<inter>) B ` Min_set m As ` As)
 2. s \<in> disjointify ((\<inter>) B ` Min_set m As ` As)
 3. s' \<in> disjointify ((\<inter>) B ` Min_set m As ` As)
 4. s \<noteq> s'
[PROOF STEP]
apply blast
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. s \<in> disjointify ((\<inter>) B ` Min_set m As ` As)
 2. s' \<in> disjointify ((\<inter>) B ` Min_set m As ` As)
 3. s \<noteq> s'
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite As
As \<subseteq> carrier (SA m)
As \<noteq> {}
is_semialgebraic m B
s \<in> Min_set_partition m As B
s' \<in> Min_set_partition m As B
s \<noteq> s'

goal (3 subgoals):
 1. s \<in> disjointify ((\<inter>) B ` Min_set m As ` As)
 2. s' \<in> disjointify ((\<inter>) B ` Min_set m As ` As)
 3. s \<noteq> s'
[PROOF STEP]
unfolding Min_set_partition_def
[PROOF STATE]
proof (prove)
using this:
finite As
As \<subseteq> carrier (SA m)
As \<noteq> {}
is_semialgebraic m B
s \<in> disjointify ((\<inter>) B ` Min_set m As ` As)
s' \<in> disjointify ((\<inter>) B ` Min_set m As ` As)
s \<noteq> s'

goal (3 subgoals):
 1. s \<in> disjointify ((\<inter>) B ` Min_set m As ` As)
 2. s' \<in> disjointify ((\<inter>) B ` Min_set m As ` As)
 3. s \<noteq> s'
[PROOF STEP]
apply blast
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. s' \<in> disjointify ((\<inter>) B ` Min_set m As ` As)
 2. s \<noteq> s'
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite As
As \<subseteq> carrier (SA m)
As \<noteq> {}
is_semialgebraic m B
s \<in> Min_set_partition m As B
s' \<in> Min_set_partition m As B
s \<noteq> s'

goal (2 subgoals):
 1. s' \<in> disjointify ((\<inter>) B ` Min_set m As ` As)
 2. s \<noteq> s'
[PROOF STEP]
unfolding Min_set_partition_def
[PROOF STATE]
proof (prove)
using this:
finite As
As \<subseteq> carrier (SA m)
As \<noteq> {}
is_semialgebraic m B
s \<in> disjointify ((\<inter>) B ` Min_set m As ` As)
s' \<in> disjointify ((\<inter>) B ` Min_set m As ` As)
s \<noteq> s'

goal (2 subgoals):
 1. s' \<in> disjointify ((\<inter>) B ` Min_set m As ` As)
 2. s \<noteq> s'
[PROOF STEP]
apply blast
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. s \<noteq> s'
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite As
As \<subseteq> carrier (SA m)
As \<noteq> {}
is_semialgebraic m B
s \<in> Min_set_partition m As B
s' \<in> Min_set_partition m As B
s \<noteq> s'

goal (1 subgoal):
 1. s \<noteq> s'
[PROOF STEP]
by blast


[STATEMENT]
lemma B_card_eq: "card B = nat ((int p - 1) div 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card B = nat ((int p - 1) div 2)
[PROOF STEP]
by (simp add: B_card_eq_A A_card_eq)


[STATEMENT]
lemma typeI_twoCubeImg:
  assumes "typeI_twoCube twoC"
  shows "\<exists>a b g1 g2. a < b \<and> (\<forall>x \<in> {a .. b}. g2 x \<le> g1 x) \<and>
                      cubeImage twoC = {(x,y). x \<in> {a..b} \<and> y \<in> {g2 x .. g1 x}} \<and>
                      twoC = (\<lambda>(x, y). ((1 - x) * a + x * b, (1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b))) \<and>
                      g1 piecewise_C1_differentiable_on {a .. b} \<and> g2 piecewise_C1_differentiable_on {a .. b} "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>a b g1 g2. a < b \<and> (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> cubeImage twoC = {(x, y). x \<in> {a..b} \<and> y \<in> {g2 x..g1 x}} \<and> twoC = (\<lambda>(x, y). ((1 - x) * a + x * b, (1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b))) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>a b g1 g2. a < b \<and> (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> cubeImage twoC = {(x, y). x \<in> {a..b} \<and> y \<in> {g2 x..g1 x}} \<and> twoC = (\<lambda>(x, y). ((1 - x) * a + x * b, (1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b))) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b}
[PROOF STEP]
have "\<exists>a b. a < b \<and>
          (\<exists>g1 g2. (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and>
                   twoC = (\<lambda>(x, y). ((1 - x) * a + x * b, (1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b)))\<and>
                   g1 piecewise_C1_differentiable_on {a .. b} \<and> g2 piecewise_C1_differentiable_on {a .. b})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>a b. a < b \<and> (\<exists>g1 g2. (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> twoC = (\<lambda>(x, y). ((1 - x) * a + x * b, (1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b))) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b})
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
typeI_twoCube twoC

goal (1 subgoal):
 1. \<exists>a b. a < b \<and> (\<exists>g1 g2. (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> twoC = (\<lambda>(x, y). ((1 - x) * a + x * b, (1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b))) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b})
[PROOF STEP]
by (simp add: typeI_twoCube_def)
[PROOF STATE]
proof (state)
this:
\<exists>a b. a < b \<and> (\<exists>g1 g2. (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> twoC = (\<lambda>(x, y). ((1 - x) * a + x * b, (1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b))) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b})

goal (1 subgoal):
 1. \<exists>a b g1 g2. a < b \<and> (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> cubeImage twoC = {(x, y). x \<in> {a..b} \<and> y \<in> {g2 x..g1 x}} \<and> twoC = (\<lambda>(x, y). ((1 - x) * a + x * b, (1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b))) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>a b. a < b \<and> (\<exists>g1 g2. (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> twoC = (\<lambda>(x, y). ((1 - x) * a + x * b, (1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b))) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b})
[PROOF STEP]
obtain a b g1 g2 where
    twoCisTypeI: "a < b"
        "(\<forall>x\<in>{a..b}. g2 x \<le> g1 x)"
        "twoC = (\<lambda>(x, y). ((1 - x) * a + x * b, (1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b)))"
        "g1 piecewise_C1_differentiable_on {a .. b}"
        "g2 piecewise_C1_differentiable_on {a .. b}"
[PROOF STATE]
proof (prove)
using this:
\<exists>a b. a < b \<and> (\<exists>g1 g2. (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> twoC = (\<lambda>(x, y). ((1 - x) * a + x * b, (1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b))) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b})

goal (1 subgoal):
 1. (\<And>a b g2 g1. \<lbrakk>a < b; \<forall>x\<in>{a..b}. g2 x \<le> g1 x; twoC = (\<lambda>(x, y). ((1 - x) * a + x * b, (1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b))); g1 piecewise_C1_differentiable_on {a..b}; g2 piecewise_C1_differentiable_on {a..b}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a < b
\<forall>x\<in>{a..b}. g2 x \<le> g1 x
twoC = (\<lambda>(x, y). ((1 - x) * a + x * b, (1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b)))
g1 piecewise_C1_differentiable_on {a..b}
g2 piecewise_C1_differentiable_on {a..b}

goal (1 subgoal):
 1. \<exists>a b g1 g2. a < b \<and> (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> cubeImage twoC = {(x, y). x \<in> {a..b} \<and> y \<in> {g2 x..g1 x}} \<and> twoC = (\<lambda>(x, y). ((1 - x) * a + x * b, (1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b))) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b}
[PROOF STEP]
have ex: "\<exists>z\<in>Green.unit_cube.
               (c, d) =
               (case z of
                (x, y) \<Rightarrow>
                  (a - x * a + x * b,
                   g2 (a - x * a + x * b) - y * g2 (a - x * a + x * b) + y * g1 (a - x * a + x * b)))"
    if c_bounds: "a \<le> c" "c \<le> b" and  d_bounds: "g2 c \<le> d" "d \<le> g1 c" for c d
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>z\<in>unit_cube. (c, d) = (case z of (x, y) \<Rightarrow> (a - x * a + x * b, g2 (a - x * a + x * b) - y * g2 (a - x * a + x * b) + y * g1 (a - x * a + x * b)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>z\<in>unit_cube. (c, d) = (case z of (x, y) \<Rightarrow> (a - x * a + x * b, g2 (a - x * a + x * b) - y * g2 (a - x * a + x * b) + y * g1 (a - x * a + x * b)))
[PROOF STEP]
have x_witness: "\<exists>k1. c = (1 - k1)*a + k1 * b \<and> 0 \<le> k1 \<and> k1 \<le> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>k1. c = (1 - k1) * a + k1 * b \<and> 0 \<le> k1 \<and> k1 \<le> 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>k1. c = (1 - k1) * a + k1 * b \<and> 0 \<le> k1 \<and> k1 \<le> 1
[PROOF STEP]
let ?k1 = "(c - a)/(b - a)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>k1. c = (1 - k1) * a + k1 * b \<and> 0 \<le> k1 \<and> k1 \<le> 1
[PROOF STEP]
have k1_in_bounds: "0 \<le> (c - a)/(b - a) \<and> (c - a)/(b - a) \<le> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> (c - a) / (b - a) \<and> (c - a) / (b - a) \<le> 1
[PROOF STEP]
using twoCisTypeI(1) c_bounds
[PROOF STATE]
proof (prove)
using this:
a < b
a \<le> c
c \<le> b

goal (1 subgoal):
 1. 0 \<le> (c - a) / (b - a) \<and> (c - a) / (b - a) \<le> 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 \<le> (c - a) / (b - a) \<and> (c - a) / (b - a) \<le> 1

goal (1 subgoal):
 1. \<exists>k1. c = (1 - k1) * a + k1 * b \<and> 0 \<le> k1 \<and> k1 \<le> 1
[PROOF STEP]
have "c = (1 - ?k1)*a + ?k1 * b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c = (1 - (c - a) / (b - a)) * a + (c - a) / (b - a) * b
[PROOF STEP]
using twoCisTypeI(1) sum_sqs_eq
[PROOF STATE]
proof (prove)
using this:
a < b
?x * ?x + ?y * ?y = ?x * (?y * (2::?'a)) \<Longrightarrow> ?y = ?x

goal (1 subgoal):
 1. c = (1 - (c - a) / (b - a)) * a + (c - a) / (b - a) * b
[PROOF STEP]
by (auto simp add: divide_simps algebra_simps)
[PROOF STATE]
proof (state)
this:
c = (1 - (c - a) / (b - a)) * a + (c - a) / (b - a) * b

goal (1 subgoal):
 1. \<exists>k1. c = (1 - k1) * a + k1 * b \<and> 0 \<le> k1 \<and> k1 \<le> 1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
c = (1 - (c - a) / (b - a)) * a + (c - a) / (b - a) * b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
c = (1 - (c - a) / (b - a)) * a + (c - a) / (b - a) * b

goal (1 subgoal):
 1. \<exists>k1. c = (1 - k1) * a + k1 * b \<and> 0 \<le> k1 \<and> k1 \<le> 1
[PROOF STEP]
using twoCisTypeI k1_in_bounds
[PROOF STATE]
proof (prove)
using this:
c = (1 - (c - a) / (b - a)) * a + (c - a) / (b - a) * b
a < b
\<forall>x\<in>{a..b}. g2 x \<le> g1 x
twoC = (\<lambda>(x, y). ((1 - x) * a + x * b, (1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b)))
g1 piecewise_C1_differentiable_on {a..b}
g2 piecewise_C1_differentiable_on {a..b}
0 \<le> (c - a) / (b - a) \<and> (c - a) / (b - a) \<le> 1

goal (1 subgoal):
 1. \<exists>k1. c = (1 - k1) * a + k1 * b \<and> 0 \<le> k1 \<and> k1 \<le> 1
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
\<exists>k1. c = (1 - k1) * a + k1 * b \<and> 0 \<le> k1 \<and> k1 \<le> 1

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>k1. c = (1 - k1) * a + k1 * b \<and> 0 \<le> k1 \<and> k1 \<le> 1

goal (1 subgoal):
 1. \<exists>z\<in>unit_cube. (c, d) = (case z of (x, y) \<Rightarrow> (a - x * a + x * b, g2 (a - x * a + x * b) - y * g2 (a - x * a + x * b) + y * g1 (a - x * a + x * b)))
[PROOF STEP]
have y_witness: "\<exists>k2. d = (1 - k2)*(g2 c) + k2 * (g1 c) \<and> 0 \<le> k2 \<and> k2 \<le> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
[PROOF STEP]
proof (cases "g1 c - g2 c = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. g1 c - g2 c = 0 \<Longrightarrow> \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
 2. g1 c - g2 c \<noteq> 0 \<Longrightarrow> \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
g1 c - g2 c = 0

goal (2 subgoals):
 1. g1 c - g2 c = 0 \<Longrightarrow> \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
 2. g1 c - g2 c \<noteq> 0 \<Longrightarrow> \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
[PROOF STEP]
with d_bounds
[PROOF STATE]
proof (chain)
picking this:
g2 c \<le> d
d \<le> g1 c
g1 c - g2 c = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
g2 c \<le> d
d \<le> g1 c
g1 c - g2 c = 0

goal (1 subgoal):
 1. \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
\<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1

goal (1 subgoal):
 1. g1 c - g2 c \<noteq> 0 \<Longrightarrow> \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. g1 c - g2 c \<noteq> 0 \<Longrightarrow> \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
g1 c - g2 c \<noteq> 0

goal (1 subgoal):
 1. g1 c - g2 c \<noteq> 0 \<Longrightarrow> \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
[PROOF STEP]
let ?k2 = "(d - g2 c)/(g1 c - g2 c)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. g1 c - g2 c \<noteq> 0 \<Longrightarrow> \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
[PROOF STEP]
have k2_in_bounds: "0 \<le> ?k2 \<and> ?k2 \<le> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> (d - g2 c) / (g1 c - g2 c) \<and> (d - g2 c) / (g1 c - g2 c) \<le> 1
[PROOF STEP]
using twoCisTypeI(2) c_bounds d_bounds False
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>{a..b}. g2 x \<le> g1 x
a \<le> c
c \<le> b
g2 c \<le> d
d \<le> g1 c
g1 c - g2 c \<noteq> 0

goal (1 subgoal):
 1. 0 \<le> (d - g2 c) / (g1 c - g2 c) \<and> (d - g2 c) / (g1 c - g2 c) \<le> 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 \<le> (d - g2 c) / (g1 c - g2 c) \<and> (d - g2 c) / (g1 c - g2 c) \<le> 1

goal (1 subgoal):
 1. g1 c - g2 c \<noteq> 0 \<Longrightarrow> \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
[PROOF STEP]
have "d = (1 - ?k2) * g2 c + ?k2 * g1 c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. d = (1 - (d - g2 c) / (g1 c - g2 c)) * g2 c + (d - g2 c) / (g1 c - g2 c) * g1 c
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
g1 c - g2 c \<noteq> 0

goal (1 subgoal):
 1. d = (1 - (d - g2 c) / (g1 c - g2 c)) * g2 c + (d - g2 c) / (g1 c - g2 c) * g1 c
[PROOF STEP]
apply (simp add: divide_simps algebra_simps)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g1 c \<noteq> g2 c \<Longrightarrow> g1 c * g1 c + g2 c * g2 c = g1 c * (g2 c * 2) \<longrightarrow> d = 0
[PROOF STEP]
using sum_sqs_eq
[PROOF STATE]
proof (prove)
using this:
?x * ?x + ?y * ?y = ?x * (?y * (2::?'a)) \<Longrightarrow> ?y = ?x

goal (1 subgoal):
 1. g1 c \<noteq> g2 c \<Longrightarrow> g1 c * g1 c + g2 c * g2 c = g1 c * (g2 c * 2) \<longrightarrow> d = 0
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
d = (1 - (d - g2 c) / (g1 c - g2 c)) * g2 c + (d - g2 c) / (g1 c - g2 c) * g1 c

goal (1 subgoal):
 1. g1 c - g2 c \<noteq> 0 \<Longrightarrow> \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
d = (1 - (d - g2 c) / (g1 c - g2 c)) * g2 c + (d - g2 c) / (g1 c - g2 c) * g1 c
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
d = (1 - (d - g2 c) / (g1 c - g2 c)) * g2 c + (d - g2 c) / (g1 c - g2 c) * g1 c

goal (1 subgoal):
 1. \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
[PROOF STEP]
using k2_in_bounds
[PROOF STATE]
proof (prove)
using this:
d = (1 - (d - g2 c) / (g1 c - g2 c)) * g2 c + (d - g2 c) / (g1 c - g2 c) * g1 c
0 \<le> (d - g2 c) / (g1 c - g2 c) \<and> (d - g2 c) / (g1 c - g2 c) \<le> 1

goal (1 subgoal):
 1. \<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
\<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1

goal (1 subgoal):
 1. \<exists>z\<in>unit_cube. (c, d) = (case z of (x, y) \<Rightarrow> (a - x * a + x * b, g2 (a - x * a + x * b) - y * g2 (a - x * a + x * b) + y * g1 (a - x * a + x * b)))
[PROOF STEP]
show "\<exists>x\<in>unit_cube. (c, d) =
            (case x of (x, y) \<Rightarrow> (a - x * a + x * b, g2 (a - x * a + x * b) - y * g2 (a - x * a + x * b) + y * g1 (a - x * a + x * b)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>x\<in>unit_cube. (c, d) = (case x of (x, y) \<Rightarrow> (a - x * a + x * b, g2 (a - x * a + x * b) - y * g2 (a - x * a + x * b) + y * g1 (a - x * a + x * b)))
[PROOF STEP]
using x_witness y_witness
[PROOF STATE]
proof (prove)
using this:
\<exists>k1. c = (1 - k1) * a + k1 * b \<and> 0 \<le> k1 \<and> k1 \<le> 1
\<exists>k2. d = (1 - k2) * g2 c + k2 * g1 c \<and> 0 \<le> k2 \<and> k2 \<le> 1

goal (1 subgoal):
 1. \<exists>x\<in>unit_cube. (c, d) = (case x of (x, y) \<Rightarrow> (a - x * a + x * b, g2 (a - x * a + x * b) - y * g2 (a - x * a + x * b) + y * g1 (a - x * a + x * b)))
[PROOF STEP]
by (force simp add: left_diff_distrib)
[PROOF STATE]
proof (state)
this:
\<exists>x\<in>unit_cube. (c, d) = (case x of (x, y) \<Rightarrow> (a - x * a + x * b, g2 (a - x * a + x * b) - y * g2 (a - x * a + x * b) + y * g1 (a - x * a + x * b)))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<lbrakk>a \<le> ?c; ?c \<le> b; g2 ?c \<le> ?d; ?d \<le> g1 ?c\<rbrakk> \<Longrightarrow> \<exists>z\<in>unit_cube. (?c, ?d) = (case z of (x, y) \<Rightarrow> (a - x * a + x * b, g2 (a - x * a + x * b) - y * g2 (a - x * a + x * b) + y * g1 (a - x * a + x * b)))

goal (1 subgoal):
 1. \<exists>a b g1 g2. a < b \<and> (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> cubeImage twoC = {(x, y). x \<in> {a..b} \<and> y \<in> {g2 x..g1 x}} \<and> twoC = (\<lambda>(x, y). ((1 - x) * a + x * b, (1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b))) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b}
[PROOF STEP]
have "{y. \<exists>x\<in>unit_cube. y = twoC x} = {(x, y). a \<le> x \<and> x \<le> b \<and> g2 x \<le> y \<and> y \<le> g1 x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {y. \<exists>x\<in>unit_cube. y = twoC x} = {(x, y). a \<le> x \<and> x \<le> b \<and> g2 x \<le> y \<and> y \<le> g1 x}
[PROOF STEP]
apply (auto simp add: twoCisTypeI left_diff_distrib ex)
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. \<And>aa ba. \<lbrakk>0 \<le> aa; aa \<le> 1; 0 \<le> ba; ba \<le> 1\<rbrakk> \<Longrightarrow> aa * a \<le> aa * b
 2. \<And>aa ba. \<lbrakk>0 \<le> aa; aa \<le> 1; 0 \<le> ba; ba \<le> 1\<rbrakk> \<Longrightarrow> a - aa * a + aa * b \<le> b
 3. \<And>aa ba. \<lbrakk>0 \<le> aa; aa \<le> 1; 0 \<le> ba; ba \<le> 1\<rbrakk> \<Longrightarrow> ba * g2 (a - aa * a + aa * b) \<le> ba * g1 (a - aa * a + aa * b)
 4. \<And>aa ba. \<lbrakk>0 \<le> aa; aa \<le> 1; 0 \<le> ba; ba \<le> 1\<rbrakk> \<Longrightarrow> g2 (a - aa * a + aa * b) - ba * g2 (a - aa * a + aa * b) + ba * g1 (a - aa * a + aa * b) \<le> g1 (a - aa * a + aa * b)
[PROOF STEP]
using less_eq_real_def twoCisTypeI(1)
[PROOF STATE]
proof (prove)
using this:
(?x \<le> ?y) = (?x < ?y \<or> ?x = ?y)
a < b

goal (4 subgoals):
 1. \<And>aa ba. \<lbrakk>0 \<le> aa; aa \<le> 1; 0 \<le> ba; ba \<le> 1\<rbrakk> \<Longrightarrow> aa * a \<le> aa * b
 2. \<And>aa ba. \<lbrakk>0 \<le> aa; aa \<le> 1; 0 \<le> ba; ba \<le> 1\<rbrakk> \<Longrightarrow> a - aa * a + aa * b \<le> b
 3. \<And>aa ba. \<lbrakk>0 \<le> aa; aa \<le> 1; 0 \<le> ba; ba \<le> 1\<rbrakk> \<Longrightarrow> ba * g2 (a - aa * a + aa * b) \<le> ba * g1 (a - aa * a + aa * b)
 4. \<And>aa ba. \<lbrakk>0 \<le> aa; aa \<le> 1; 0 \<le> ba; ba \<le> 1\<rbrakk> \<Longrightarrow> g2 (a - aa * a + aa * b) - ba * g2 (a - aa * a + aa * b) + ba * g1 (a - aa * a + aa * b) \<le> g1 (a - aa * a + aa * b)
[PROOF STEP]
apply auto[1]
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>aa ba. \<lbrakk>0 \<le> aa; aa \<le> 1; 0 \<le> ba; ba \<le> 1\<rbrakk> \<Longrightarrow> a - aa * a + aa * b \<le> b
 2. \<And>aa ba. \<lbrakk>0 \<le> aa; aa \<le> 1; 0 \<le> ba; ba \<le> 1\<rbrakk> \<Longrightarrow> ba * g2 (a - aa * a + aa * b) \<le> ba * g1 (a - aa * a + aa * b)
 3. \<And>aa ba. \<lbrakk>0 \<le> aa; aa \<le> 1; 0 \<le> ba; ba \<le> 1\<rbrakk> \<Longrightarrow> g2 (a - aa * a + aa * b) - ba * g2 (a - aa * a + aa * b) + ba * g1 (a - aa * a + aa * b) \<le> g1 (a - aa * a + aa * b)
[PROOF STEP]
apply (smt affine_ineq twoCisTypeI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>aa ba. \<lbrakk>0 \<le> aa; aa \<le> 1; 0 \<le> ba; ba \<le> 1\<rbrakk> \<Longrightarrow> ba * g2 (a - aa * a + aa * b) \<le> ba * g1 (a - aa * a + aa * b)
 2. \<And>aa ba. \<lbrakk>0 \<le> aa; aa \<le> 1; 0 \<le> ba; ba \<le> 1\<rbrakk> \<Longrightarrow> g2 (a - aa * a + aa * b) - ba * g2 (a - aa * a + aa * b) + ba * g1 (a - aa * a + aa * b) \<le> g1 (a - aa * a + aa * b)
[PROOF STEP]
apply (smt affine_ineq atLeastAtMost_iff mult_left_mono twoCisTypeI)+
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
{y. \<exists>x\<in>unit_cube. y = twoC x} = {(x, y). a \<le> x \<and> x \<le> b \<and> g2 x \<le> y \<and> y \<le> g1 x}

goal (1 subgoal):
 1. \<exists>a b g1 g2. a < b \<and> (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> cubeImage twoC = {(x, y). x \<in> {a..b} \<and> y \<in> {g2 x..g1 x}} \<and> twoC = (\<lambda>(x, y). ((1 - x) * a + x * b, (1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b))) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
{y. \<exists>x\<in>unit_cube. y = twoC x} = {(x, y). a \<le> x \<and> x \<le> b \<and> g2 x \<le> y \<and> y \<le> g1 x}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
{y. \<exists>x\<in>unit_cube. y = twoC x} = {(x, y). a \<le> x \<and> x \<le> b \<and> g2 x \<le> y \<and> y \<le> g1 x}

goal (1 subgoal):
 1. \<exists>a b g1 g2. a < b \<and> (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> cubeImage twoC = {(x, y). x \<in> {a..b} \<and> y \<in> {g2 x..g1 x}} \<and> twoC = (\<lambda>(x, y). ((1 - x) * a + x * b, (1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b))) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b}
[PROOF STEP]
unfolding cubeImage_def image_def
[PROOF STATE]
proof (prove)
using this:
{y. \<exists>x\<in>unit_cube. y = twoC x} = {(x, y). a \<le> x \<and> x \<le> b \<and> g2 x \<le> y \<and> y \<le> g1 x}

goal (1 subgoal):
 1. \<exists>a b g1 g2. a < b \<and> (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> {y. \<exists>x\<in>unit_cube. y = twoC x} = {(x, y). x \<in> {a..b} \<and> y \<in> {g2 x..g1 x}} \<and> twoC = (\<lambda>(x, y). ((1 - x) * a + x * b, (1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b))) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b}
[PROOF STEP]
using twoCisTypeI
[PROOF STATE]
proof (prove)
using this:
{y. \<exists>x\<in>unit_cube. y = twoC x} = {(x, y). a \<le> x \<and> x \<le> b \<and> g2 x \<le> y \<and> y \<le> g1 x}
a < b
\<forall>x\<in>{a..b}. g2 x \<le> g1 x
twoC = (\<lambda>(x, y). ((1 - x) * a + x * b, (1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b)))
g1 piecewise_C1_differentiable_on {a..b}
g2 piecewise_C1_differentiable_on {a..b}

goal (1 subgoal):
 1. \<exists>a b g1 g2. a < b \<and> (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> {y. \<exists>x\<in>unit_cube. y = twoC x} = {(x, y). x \<in> {a..b} \<and> y \<in> {g2 x..g1 x}} \<and> twoC = (\<lambda>(x, y). ((1 - x) * a + x * b, (1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b))) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>a b g1 g2. a < b \<and> (\<forall>x\<in>{a..b}. g2 x \<le> g1 x) \<and> cubeImage twoC = {(x, y). x \<in> {a..b} \<and> y \<in> {g2 x..g1 x}} \<and> twoC = (\<lambda>(x, y). ((1 - x) * a + x * b, (1 - y) * g2 ((1 - x) * a + x * b) + y * g1 ((1 - x) * a + x * b))) \<and> g1 piecewise_C1_differentiable_on {a..b} \<and> g2 piecewise_C1_differentiable_on {a..b}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma gbinomial_int_negated_upper: "(a gchoose k) = (-1) ^ k * ((int k - a - 1) gchoose k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a gchoose k = (- 1) ^ k * (int k - a - 1 gchoose k)
[PROOF STEP]
by (simp add: gbinomial_int_pochhammer pochhammer_minus algebra_simps fact_dvd_pochhammer div_mult_swap)


[STATEMENT]
lemma matrix_transpose_mul:
    "transpose(A ** B) = transpose B ** transpose (A::'a::comm_semiring_1^_^_)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Finite_Cartesian_Product.transpose (A ** B) = Finite_Cartesian_Product.transpose B ** Finite_Cartesian_Product.transpose A
[PROOF STEP]
by (simp add: matrix_matrix_mult_def transpose_def vec_eq_iff mult.commute)


[STATEMENT]
lemma add_hyperdual_parts:
  fixes a b c d :: "'a :: ring_1"
  shows "(a *\<^sub>H ba + b *\<^sub>H e1 + c *\<^sub>H e2 + d *\<^sub>H e12) + (a' *\<^sub>H ba + b' *\<^sub>H e1 + c' *\<^sub>H e2 + d' *\<^sub>H e12) =
         (a + a') *\<^sub>H ba + (b + b') *\<^sub>H e1 + (c + c') *\<^sub>H e2 + (d + d') *\<^sub>H e12"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a *\<^sub>H ba + b *\<^sub>H e1 + c *\<^sub>H e2 + d *\<^sub>H e12 + (a' *\<^sub>H ba + b' *\<^sub>H e1 + c' *\<^sub>H e2 + d' *\<^sub>H e12) = (a + a') *\<^sub>H ba + (b + b') *\<^sub>H e1 + (c + c') *\<^sub>H e2 + (d + d') *\<^sub>H e12
[PROOF STEP]
by (simp add: scaleH_add(1))