[STATEMENT]
lemma n_leaves_append [simp]:
     "n_leaves (append t1 t2) = n_leaves t1 * n_leaves t2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n_leaves (Binary_Tree.append t1 t2) = n_leaves t1 * n_leaves t2
[PROOF STEP]
apply (induct t1)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. n_leaves (Binary_Tree.append Lf t2) = n_leaves Lf * n_leaves t2
 2. \<And>x1 t11 t12. \<lbrakk>n_leaves (Binary_Tree.append t11 t2) = n_leaves t11 * n_leaves t2; n_leaves (Binary_Tree.append t12 t2) = n_leaves t12 * n_leaves t2\<rbrakk> \<Longrightarrow> n_leaves (Binary_Tree.append (Br x1 t11 t12) t2) = n_leaves (Br x1 t11 t12) * n_leaves t2
[PROOF STEP]
apply (metis append.simps(1) n_leaves.simps(1) nat_mult_1 plus_nat.simps(1)
              Suc_eq_plus1)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x1 t11 t12. \<lbrakk>n_leaves (Binary_Tree.append t11 t2) = n_leaves t11 * n_leaves t2; n_leaves (Binary_Tree.append t12 t2) = n_leaves t12 * n_leaves t2\<rbrakk> \<Longrightarrow> n_leaves (Binary_Tree.append (Br x1 t11 t12) t2) = n_leaves (Br x1 t11 t12) * n_leaves t2
[PROOF STEP]
by (simp add: distrib_right)


[STATEMENT]
lemma norm_dot:
 "\<parallel>v\<parallel> = sqrt (v\<cdot>v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>v\<parallel> = sqrt (v \<cdot> v)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<parallel>v\<parallel> = sqrt (v \<cdot> v)
[PROOF STEP]
have "sqrt (v\<cdot>v) = sqrt (\<Sum>j\<in>{1..(vlen v)}. v\<^bsub>j\<^esub>*v\<^bsub>j\<^esub>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sqrt (v \<cdot> v) = sqrt (\<Sum>j = 1..vlen v. v\<^bsub>j\<^esub> * v\<^bsub>j\<^esub>)
[PROOF STEP]
unfolding dot_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sqrt (\<Sum>j = 1..vlen v. v\<^bsub>j\<^esub> * v\<^bsub>j\<^esub>) = sqrt (\<Sum>j = 1..vlen v. v\<^bsub>j\<^esub> * v\<^bsub>j\<^esub>)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sqrt (v \<cdot> v) = sqrt (\<Sum>j = 1..vlen v. v\<^bsub>j\<^esub> * v\<^bsub>j\<^esub>)

goal (1 subgoal):
 1. \<parallel>v\<parallel> = sqrt (v \<cdot> v)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sqrt (v \<cdot> v) = sqrt (\<Sum>j = 1..vlen v. v\<^bsub>j\<^esub> * v\<^bsub>j\<^esub>)

goal (1 subgoal):
 1. \<parallel>v\<parallel> = sqrt (v \<cdot> v)
[PROOF STEP]
with real_sq
[PROOF STATE]
proof (chain)
picking this:
?a * ?a = ?a\<^sup>2
sqrt (v \<cdot> v) = sqrt (\<Sum>j = 1..vlen v. v\<^bsub>j\<^esub> * v\<^bsub>j\<^esub>)
[PROOF STEP]
have "\<dots> = sqrt (\<Sum>j\<in>{1..(vlen v)}. v\<^bsub>j\<^esub>^2)"
[PROOF STATE]
proof (prove)
using this:
?a * ?a = ?a\<^sup>2
sqrt (v \<cdot> v) = sqrt (\<Sum>j = 1..vlen v. v\<^bsub>j\<^esub> * v\<^bsub>j\<^esub>)

goal (1 subgoal):
 1. sqrt (\<Sum>j = 1..vlen v. v\<^bsub>j\<^esub> * v\<^bsub>j\<^esub>) = sqrt (\<Sum>j = 1..vlen v. (v\<^bsub>j\<^esub>)\<^sup>2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sqrt (\<Sum>j = 1..vlen v. v\<^bsub>j\<^esub> * v\<^bsub>j\<^esub>) = sqrt (\<Sum>j = 1..vlen v. (v\<^bsub>j\<^esub>)\<^sup>2)

goal (1 subgoal):
 1. \<parallel>v\<parallel> = sqrt (v \<cdot> v)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sqrt (\<Sum>j = 1..vlen v. v\<^bsub>j\<^esub> * v\<^bsub>j\<^esub>) = sqrt (\<Sum>j = 1..vlen v. (v\<^bsub>j\<^esub>)\<^sup>2)

goal (1 subgoal):
 1. \<parallel>v\<parallel> = sqrt (v \<cdot> v)
[PROOF STEP]
have "\<dots> = \<parallel>v\<parallel>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sqrt (\<Sum>j = 1..vlen v. (v\<^bsub>j\<^esub>)\<^sup>2) = \<parallel>v\<parallel>
[PROOF STEP]
unfolding norm_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sqrt (\<Sum>j = 1..vlen v. (v\<^bsub>j\<^esub>)\<^sup>2) = sqrt (\<Sum>j = 1..vlen v. (v\<^bsub>j\<^esub>)\<^sup>2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sqrt (\<Sum>j = 1..vlen v. (v\<^bsub>j\<^esub>)\<^sup>2) = \<parallel>v\<parallel>

goal (1 subgoal):
 1. \<parallel>v\<parallel> = sqrt (v \<cdot> v)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sqrt (v \<cdot> v) = \<parallel>v\<parallel>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
sqrt (v \<cdot> v) = \<parallel>v\<parallel>

goal (1 subgoal):
 1. \<parallel>v\<parallel> = sqrt (v \<cdot> v)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
\<parallel>v\<parallel> = sqrt (v \<cdot> v)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma convex_hull_list_combination:
  assumes Vs: "set Vs \<subseteq> carrier_vec n"
    and x: "x \<in> convex_hull_list Vs"
    and y: "y \<in> convex_hull_list Vs"
    and l0: "0 \<le> l" and l1: "l \<le> 1"
  shows "l \<cdot>\<^sub>v x + (1 - l) \<cdot>\<^sub>v y \<in> convex_hull_list Vs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. l \<cdot>\<^sub>v x + ((1::'a) - l) \<cdot>\<^sub>v y \<in> convex_hull_list Vs
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. l \<cdot>\<^sub>v x + ((1::'a) - l) \<cdot>\<^sub>v y \<in> convex_hull_list Vs
[PROOF STEP]
from x
[PROOF STATE]
proof (chain)
picking this:
x \<in> convex_hull_list Vs
[PROOF STEP]
obtain cx where x: "lincomb_list cx Vs = x" and cx0: "\<forall> i < length Vs. cx i \<ge> 0"
    and cx1: "sum cx {0..<length Vs} = 1"
[PROOF STATE]
proof (prove)
using this:
x \<in> convex_hull_list Vs

goal (1 subgoal):
 1. (\<And>cx. \<lbrakk>lincomb_list cx Vs = x; \<forall>i<length Vs. (0::'a) \<le> cx i; sum cx {0..<length Vs} = (1::'a)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding convex_hull_list_def convex_lincomb_list_def nonneg_lincomb_list_def
[PROOF STATE]
proof (prove)
using this:
x \<in> {x. \<exists>c. (lincomb_list c Vs = x \<and> (\<forall>i<length Vs. (0::'a) \<le> c i)) \<and> sum c {0..<length Vs} = (1::'a)}

goal (1 subgoal):
 1. (\<And>cx. \<lbrakk>lincomb_list cx Vs = x; \<forall>i<length Vs. (0::'a) \<le> cx i; sum cx {0..<length Vs} = (1::'a)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
lincomb_list cx Vs = x
\<forall>i<length Vs. (0::'a) \<le> cx i
sum cx {0..<length Vs} = (1::'a)

goal (1 subgoal):
 1. l \<cdot>\<^sub>v x + ((1::'a) - l) \<cdot>\<^sub>v y \<in> convex_hull_list Vs
[PROOF STEP]
from y
[PROOF STATE]
proof (chain)
picking this:
y \<in> convex_hull_list Vs
[PROOF STEP]
obtain cy where y: "lincomb_list cy Vs = y" and cy0: "\<forall> i < length Vs. cy i \<ge> 0"
    and cy1: "sum cy {0..<length Vs} = 1"
[PROOF STATE]
proof (prove)
using this:
y \<in> convex_hull_list Vs

goal (1 subgoal):
 1. (\<And>cy. \<lbrakk>lincomb_list cy Vs = y; \<forall>i<length Vs. (0::'a) \<le> cy i; sum cy {0..<length Vs} = (1::'a)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding convex_hull_list_def convex_lincomb_list_def nonneg_lincomb_list_def
[PROOF STATE]
proof (prove)
using this:
y \<in> {x. \<exists>c. (lincomb_list c Vs = x \<and> (\<forall>i<length Vs. (0::'a) \<le> c i)) \<and> sum c {0..<length Vs} = (1::'a)}

goal (1 subgoal):
 1. (\<And>cy. \<lbrakk>lincomb_list cy Vs = y; \<forall>i<length Vs. (0::'a) \<le> cy i; sum cy {0..<length Vs} = (1::'a)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
lincomb_list cy Vs = y
\<forall>i<length Vs. (0::'a) \<le> cy i
sum cy {0..<length Vs} = (1::'a)

goal (1 subgoal):
 1. l \<cdot>\<^sub>v x + ((1::'a) - l) \<cdot>\<^sub>v y \<in> convex_hull_list Vs
[PROOF STEP]
let ?c = "\<lambda> i. l * cx i + (1 - l) * cy i"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. l \<cdot>\<^sub>v x + ((1::'a) - l) \<cdot>\<^sub>v y \<in> convex_hull_list Vs
[PROOF STEP]
have "set Vs \<subseteq> carrier_vec n \<Longrightarrow>
        lincomb_list ?c Vs = l \<cdot>\<^sub>v lincomb_list cx Vs + (1 - l) \<cdot>\<^sub>v lincomb_list cy Vs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set Vs \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) Vs = l \<cdot>\<^sub>v lincomb_list cx Vs + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy Vs
[PROOF STEP]
proof (induction Vs rule: rev_induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. set [] \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) [] = l \<cdot>\<^sub>v lincomb_list cx [] + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy []
 2. \<And>x xs. \<lbrakk>set xs \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) xs = l \<cdot>\<^sub>v lincomb_list cx xs + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy xs; set (xs @ [x]) \<subseteq> carrier_vec n\<rbrakk> \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) (xs @ [x]) = l \<cdot>\<^sub>v lincomb_list cx (xs @ [x]) + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy (xs @ [x])
[PROOF STEP]
case (snoc v Vs)
[PROOF STATE]
proof (state)
this:
set Vs \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) Vs = l \<cdot>\<^sub>v lincomb_list cx Vs + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy Vs
set (Vs @ [v]) \<subseteq> carrier_vec n

goal (2 subgoals):
 1. set [] \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) [] = l \<cdot>\<^sub>v lincomb_list cx [] + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy []
 2. \<And>x xs. \<lbrakk>set xs \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) xs = l \<cdot>\<^sub>v lincomb_list cx xs + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy xs; set (xs @ [x]) \<subseteq> carrier_vec n\<rbrakk> \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) (xs @ [x]) = l \<cdot>\<^sub>v lincomb_list cx (xs @ [x]) + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy (xs @ [x])
[PROOF STEP]
have v: "v \<in> carrier_vec n" and Vs: "set Vs \<subseteq> carrier_vec n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v \<in> carrier_vec n &&& set Vs \<subseteq> carrier_vec n
[PROOF STEP]
using snoc.prems
[PROOF STATE]
proof (prove)
using this:
set (Vs @ [v]) \<subseteq> carrier_vec n

goal (1 subgoal):
 1. v \<in> carrier_vec n &&& set Vs \<subseteq> carrier_vec n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
v \<in> carrier_vec n
set Vs \<subseteq> carrier_vec n

goal (2 subgoals):
 1. set [] \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) [] = l \<cdot>\<^sub>v lincomb_list cx [] + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy []
 2. \<And>x xs. \<lbrakk>set xs \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) xs = l \<cdot>\<^sub>v lincomb_list cx xs + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy xs; set (xs @ [x]) \<subseteq> carrier_vec n\<rbrakk> \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) (xs @ [x]) = l \<cdot>\<^sub>v lincomb_list cx (xs @ [x]) + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy (xs @ [x])
[PROOF STEP]
have "lincomb_list ?c (Vs @ [v]) = lincomb_list ?c Vs + ?c (length Vs) \<cdot>\<^sub>v v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) (Vs @ [v]) = lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) Vs + (l * cx (length Vs) + ((1::'a) - l) * cy (length Vs)) \<cdot>\<^sub>v v
[PROOF STEP]
using snoc.prems
[PROOF STATE]
proof (prove)
using this:
set (Vs @ [v]) \<subseteq> carrier_vec n

goal (1 subgoal):
 1. lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) (Vs @ [v]) = lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) Vs + (l * cx (length Vs) + ((1::'a) - l) * cy (length Vs)) \<cdot>\<^sub>v v
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) (Vs @ [v]) = lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) Vs + (l * cx (length Vs) + ((1::'a) - l) * cy (length Vs)) \<cdot>\<^sub>v v

goal (2 subgoals):
 1. set [] \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) [] = l \<cdot>\<^sub>v lincomb_list cx [] + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy []
 2. \<And>x xs. \<lbrakk>set xs \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) xs = l \<cdot>\<^sub>v lincomb_list cx xs + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy xs; set (xs @ [x]) \<subseteq> carrier_vec n\<rbrakk> \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) (xs @ [x]) = l \<cdot>\<^sub>v lincomb_list cx (xs @ [x]) + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy (xs @ [x])
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) (Vs @ [v]) = lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) Vs + (l * cx (length Vs) + ((1::'a) - l) * cy (length Vs)) \<cdot>\<^sub>v v

goal (2 subgoals):
 1. set [] \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) [] = l \<cdot>\<^sub>v lincomb_list cx [] + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy []
 2. \<And>x xs. \<lbrakk>set xs \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) xs = l \<cdot>\<^sub>v lincomb_list cx xs + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy xs; set (xs @ [x]) \<subseteq> carrier_vec n\<rbrakk> \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) (xs @ [x]) = l \<cdot>\<^sub>v lincomb_list cx (xs @ [x]) + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy (xs @ [x])
[PROOF STEP]
have "lincomb_list ?c Vs =
               l \<cdot>\<^sub>v lincomb_list cx Vs + (1 - l) \<cdot>\<^sub>v lincomb_list cy Vs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) Vs = l \<cdot>\<^sub>v lincomb_list cx Vs + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy Vs
[PROOF STEP]
by (rule snoc.IH[OF Vs])
[PROOF STATE]
proof (state)
this:
lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) Vs = l \<cdot>\<^sub>v lincomb_list cx Vs + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy Vs

goal (2 subgoals):
 1. set [] \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) [] = l \<cdot>\<^sub>v lincomb_list cx [] + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy []
 2. \<And>x xs. \<lbrakk>set xs \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) xs = l \<cdot>\<^sub>v lincomb_list cx xs + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy xs; set (xs @ [x]) \<subseteq> carrier_vec n\<rbrakk> \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) (xs @ [x]) = l \<cdot>\<^sub>v lincomb_list cx (xs @ [x]) + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy (xs @ [x])
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) Vs = l \<cdot>\<^sub>v lincomb_list cx Vs + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy Vs

goal (2 subgoals):
 1. set [] \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) [] = l \<cdot>\<^sub>v lincomb_list cx [] + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy []
 2. \<And>x xs. \<lbrakk>set xs \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) xs = l \<cdot>\<^sub>v lincomb_list cx xs + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy xs; set (xs @ [x]) \<subseteq> carrier_vec n\<rbrakk> \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) (xs @ [x]) = l \<cdot>\<^sub>v lincomb_list cx (xs @ [x]) + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy (xs @ [x])
[PROOF STEP]
have "?c (length Vs) \<cdot>\<^sub>v v =
               l \<cdot>\<^sub>v (cx (length Vs) \<cdot>\<^sub>v v) + (1 - l) \<cdot>\<^sub>v (cy (length Vs) \<cdot>\<^sub>v v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (l * cx (length Vs) + ((1::'a) - l) * cy (length Vs)) \<cdot>\<^sub>v v = l \<cdot>\<^sub>v (cx (length Vs) \<cdot>\<^sub>v v) + ((1::'a) - l) \<cdot>\<^sub>v (cy (length Vs) \<cdot>\<^sub>v v)
[PROOF STEP]
using add_smult_distrib_vec smult_smult_assoc
[PROOF STATE]
proof (prove)
using this:
(?a + ?b) \<cdot>\<^sub>v ?v = ?a \<cdot>\<^sub>v ?v + ?b \<cdot>\<^sub>v ?v
?a \<cdot>\<^sub>v (?b \<cdot>\<^sub>v ?v) = ?a * ?b \<cdot>\<^sub>v ?v

goal (1 subgoal):
 1. (l * cx (length Vs) + ((1::'a) - l) * cy (length Vs)) \<cdot>\<^sub>v v = l \<cdot>\<^sub>v (cx (length Vs) \<cdot>\<^sub>v v) + ((1::'a) - l) \<cdot>\<^sub>v (cy (length Vs) \<cdot>\<^sub>v v)
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
(l * cx (length Vs) + ((1::'a) - l) * cy (length Vs)) \<cdot>\<^sub>v v = l \<cdot>\<^sub>v (cx (length Vs) \<cdot>\<^sub>v v) + ((1::'a) - l) \<cdot>\<^sub>v (cy (length Vs) \<cdot>\<^sub>v v)

goal (2 subgoals):
 1. set [] \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) [] = l \<cdot>\<^sub>v lincomb_list cx [] + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy []
 2. \<And>x xs. \<lbrakk>set xs \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) xs = l \<cdot>\<^sub>v lincomb_list cx xs + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy xs; set (xs @ [x]) \<subseteq> carrier_vec n\<rbrakk> \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) (xs @ [x]) = l \<cdot>\<^sub>v lincomb_list cx (xs @ [x]) + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy (xs @ [x])
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(l * cx (length Vs) + ((1::'a) - l) * cy (length Vs)) \<cdot>\<^sub>v v = l \<cdot>\<^sub>v (cx (length Vs) \<cdot>\<^sub>v v) + ((1::'a) - l) \<cdot>\<^sub>v (cy (length Vs) \<cdot>\<^sub>v v)

goal (2 subgoals):
 1. set [] \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) [] = l \<cdot>\<^sub>v lincomb_list cx [] + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy []
 2. \<And>x xs. \<lbrakk>set xs \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) xs = l \<cdot>\<^sub>v lincomb_list cx xs + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy xs; set (xs @ [x]) \<subseteq> carrier_vec n\<rbrakk> \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) (xs @ [x]) = l \<cdot>\<^sub>v lincomb_list cx (xs @ [x]) + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy (xs @ [x])
[PROOF STEP]
have "l \<cdot>\<^sub>v lincomb_list cx Vs + (1 - l) \<cdot>\<^sub>v lincomb_list cy Vs + \<dots> =
                  l \<cdot>\<^sub>v (lincomb_list cx Vs + cx (length Vs) \<cdot>\<^sub>v v) +
                  (1 - l) \<cdot>\<^sub>v (lincomb_list cy Vs + cy (length Vs) \<cdot>\<^sub>v v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. l \<cdot>\<^sub>v lincomb_list cx Vs + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy Vs + (l \<cdot>\<^sub>v (cx (length Vs) \<cdot>\<^sub>v v) + ((1::'a) - l) \<cdot>\<^sub>v (cy (length Vs) \<cdot>\<^sub>v v)) = l \<cdot>\<^sub>v (lincomb_list cx Vs + cx (length Vs) \<cdot>\<^sub>v v) + ((1::'a) - l) \<cdot>\<^sub>v (lincomb_list cy Vs + cy (length Vs) \<cdot>\<^sub>v v)
[PROOF STEP]
using lincomb_list_carrier[OF Vs] v
[PROOF STATE]
proof (prove)
using this:
lincomb_list ?c Vs \<in> carrier_vec n
v \<in> carrier_vec n

goal (1 subgoal):
 1. l \<cdot>\<^sub>v lincomb_list cx Vs + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy Vs + (l \<cdot>\<^sub>v (cx (length Vs) \<cdot>\<^sub>v v) + ((1::'a) - l) \<cdot>\<^sub>v (cy (length Vs) \<cdot>\<^sub>v v)) = l \<cdot>\<^sub>v (lincomb_list cx Vs + cx (length Vs) \<cdot>\<^sub>v v) + ((1::'a) - l) \<cdot>\<^sub>v (lincomb_list cy Vs + cy (length Vs) \<cdot>\<^sub>v v)
[PROOF STEP]
by (simp add: M.add.m_assoc M.add.m_lcomm smult_r_distr)
[PROOF STATE]
proof (state)
this:
l \<cdot>\<^sub>v lincomb_list cx Vs + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy Vs + (l \<cdot>\<^sub>v (cx (length Vs) \<cdot>\<^sub>v v) + ((1::'a) - l) \<cdot>\<^sub>v (cy (length Vs) \<cdot>\<^sub>v v)) = l \<cdot>\<^sub>v (lincomb_list cx Vs + cx (length Vs) \<cdot>\<^sub>v v) + ((1::'a) - l) \<cdot>\<^sub>v (lincomb_list cy Vs + cy (length Vs) \<cdot>\<^sub>v v)

goal (2 subgoals):
 1. set [] \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) [] = l \<cdot>\<^sub>v lincomb_list cx [] + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy []
 2. \<And>x xs. \<lbrakk>set xs \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) xs = l \<cdot>\<^sub>v lincomb_list cx xs + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy xs; set (xs @ [x]) \<subseteq> carrier_vec n\<rbrakk> \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) (xs @ [x]) = l \<cdot>\<^sub>v lincomb_list cx (xs @ [x]) + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy (xs @ [x])
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) (Vs @ [v]) = l \<cdot>\<^sub>v (lincomb_list cx Vs + cx (length Vs) \<cdot>\<^sub>v v) + ((1::'a) - l) \<cdot>\<^sub>v (lincomb_list cy Vs + cy (length Vs) \<cdot>\<^sub>v v)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) (Vs @ [v]) = l \<cdot>\<^sub>v (lincomb_list cx Vs + cx (length Vs) \<cdot>\<^sub>v v) + ((1::'a) - l) \<cdot>\<^sub>v (lincomb_list cy Vs + cy (length Vs) \<cdot>\<^sub>v v)

goal (1 subgoal):
 1. lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) (Vs @ [v]) = l \<cdot>\<^sub>v lincomb_list cx (Vs @ [v]) + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy (Vs @ [v])
[PROOF STEP]
using Vs v
[PROOF STATE]
proof (prove)
using this:
lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) (Vs @ [v]) = l \<cdot>\<^sub>v (lincomb_list cx Vs + cx (length Vs) \<cdot>\<^sub>v v) + ((1::'a) - l) \<cdot>\<^sub>v (lincomb_list cy Vs + cy (length Vs) \<cdot>\<^sub>v v)
set Vs \<subseteq> carrier_vec n
v \<in> carrier_vec n

goal (1 subgoal):
 1. lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) (Vs @ [v]) = l \<cdot>\<^sub>v lincomb_list cx (Vs @ [v]) + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy (Vs @ [v])
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) (Vs @ [v]) = l \<cdot>\<^sub>v lincomb_list cx (Vs @ [v]) + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy (Vs @ [v])

goal (1 subgoal):
 1. set [] \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) [] = l \<cdot>\<^sub>v lincomb_list cx [] + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy []
[PROOF STEP]
qed simp
[PROOF STATE]
proof (state)
this:
set Vs \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) Vs = l \<cdot>\<^sub>v lincomb_list cx Vs + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy Vs

goal (1 subgoal):
 1. l \<cdot>\<^sub>v x + ((1::'a) - l) \<cdot>\<^sub>v y \<in> convex_hull_list Vs
[PROOF STEP]
hence "lincomb_list ?c Vs = l \<cdot>\<^sub>v x + (1 - l) \<cdot>\<^sub>v y"
[PROOF STATE]
proof (prove)
using this:
set Vs \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) Vs = l \<cdot>\<^sub>v lincomb_list cx Vs + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy Vs

goal (1 subgoal):
 1. lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) Vs = l \<cdot>\<^sub>v x + ((1::'a) - l) \<cdot>\<^sub>v y
[PROOF STEP]
using Vs x y
[PROOF STATE]
proof (prove)
using this:
set Vs \<subseteq> carrier_vec n \<Longrightarrow> lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) Vs = l \<cdot>\<^sub>v lincomb_list cx Vs + ((1::'a) - l) \<cdot>\<^sub>v lincomb_list cy Vs
set Vs \<subseteq> carrier_vec n
lincomb_list cx Vs = x
lincomb_list cy Vs = y

goal (1 subgoal):
 1. lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) Vs = l \<cdot>\<^sub>v x + ((1::'a) - l) \<cdot>\<^sub>v y
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) Vs = l \<cdot>\<^sub>v x + ((1::'a) - l) \<cdot>\<^sub>v y

goal (1 subgoal):
 1. l \<cdot>\<^sub>v x + ((1::'a) - l) \<cdot>\<^sub>v y \<in> convex_hull_list Vs
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) Vs = l \<cdot>\<^sub>v x + ((1::'a) - l) \<cdot>\<^sub>v y

goal (1 subgoal):
 1. l \<cdot>\<^sub>v x + ((1::'a) - l) \<cdot>\<^sub>v y \<in> convex_hull_list Vs
[PROOF STEP]
have "\<forall> i < length Vs. ?c i \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i<length Vs. (0::'a) \<le> l * cx i + ((1::'a) - l) * cy i
[PROOF STEP]
using cx0 cy0 l0 l1
[PROOF STATE]
proof (prove)
using this:
\<forall>i<length Vs. (0::'a) \<le> cx i
\<forall>i<length Vs. (0::'a) \<le> cy i
(0::'a) \<le> l
l \<le> (1::'a)

goal (1 subgoal):
 1. \<forall>i<length Vs. (0::'a) \<le> l * cx i + ((1::'a) - l) * cy i
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<forall>i<length Vs. (0::'a) \<le> l * cx i + ((1::'a) - l) * cy i

goal (1 subgoal):
 1. l \<cdot>\<^sub>v x + ((1::'a) - l) \<cdot>\<^sub>v y \<in> convex_hull_list Vs
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<forall>i<length Vs. (0::'a) \<le> l * cx i + ((1::'a) - l) * cy i

goal (1 subgoal):
 1. l \<cdot>\<^sub>v x + ((1::'a) - l) \<cdot>\<^sub>v y \<in> convex_hull_list Vs
[PROOF STEP]
have "sum ?c {0..<length Vs} = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<length Vs. l * cx i + ((1::'a) - l) * cy i) = (1::'a)
[PROOF STEP]
proof(simp add: sum.distrib)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>i = 0..<length Vs. l * cx i) + (\<Sum>i = 0..<length Vs. ((1::'a) - l) * cy i) = (1::'a)
[PROOF STEP]
have "(\<Sum>i = 0..<length Vs. (1 - l) * cy i) = (1 - l) * sum cy {0..<length Vs}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<length Vs. ((1::'a) - l) * cy i) = ((1::'a) - l) * sum cy {0..<length Vs}
[PROOF STEP]
using sum_distrib_left
[PROOF STATE]
proof (prove)
using this:
?r * sum ?f ?A = (\<Sum>n\<in>?A. ?r * ?f n)

goal (1 subgoal):
 1. (\<Sum>i = 0..<length Vs. ((1::'a) - l) * cy i) = ((1::'a) - l) * sum cy {0..<length Vs}
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<length Vs. ((1::'a) - l) * cy i) = ((1::'a) - l) * sum cy {0..<length Vs}

goal (1 subgoal):
 1. (\<Sum>i = 0..<length Vs. l * cx i) + (\<Sum>i = 0..<length Vs. ((1::'a) - l) * cy i) = (1::'a)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<length Vs. ((1::'a) - l) * cy i) = ((1::'a) - l) * sum cy {0..<length Vs}

goal (1 subgoal):
 1. (\<Sum>i = 0..<length Vs. l * cx i) + (\<Sum>i = 0..<length Vs. ((1::'a) - l) * cy i) = (1::'a)
[PROOF STEP]
have "(\<Sum>i = 0..<length Vs. l * cx i) = l * sum cx {0..<length Vs}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<length Vs. l * cx i) = l * sum cx {0..<length Vs}
[PROOF STEP]
using sum_distrib_left
[PROOF STATE]
proof (prove)
using this:
?r * sum ?f ?A = (\<Sum>n\<in>?A. ?r * ?f n)

goal (1 subgoal):
 1. (\<Sum>i = 0..<length Vs. l * cx i) = l * sum cx {0..<length Vs}
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<length Vs. l * cx i) = l * sum cx {0..<length Vs}

goal (1 subgoal):
 1. (\<Sum>i = 0..<length Vs. l * cx i) + (\<Sum>i = 0..<length Vs. ((1::'a) - l) * cy i) = (1::'a)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>i = 0..<length Vs. ((1::'a) - l) * cy i) = ((1::'a) - l) * sum cy {0..<length Vs}
(\<Sum>i = 0..<length Vs. l * cx i) = l * sum cx {0..<length Vs}
[PROOF STEP]
show "(\<Sum>i = 0..<length Vs. l * cx i) + (\<Sum>i = 0..<length Vs. (1 - l) * cy i) = 1"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i = 0..<length Vs. ((1::'a) - l) * cy i) = ((1::'a) - l) * sum cy {0..<length Vs}
(\<Sum>i = 0..<length Vs. l * cx i) = l * sum cx {0..<length Vs}

goal (1 subgoal):
 1. (\<Sum>i = 0..<length Vs. l * cx i) + (\<Sum>i = 0..<length Vs. ((1::'a) - l) * cy i) = (1::'a)
[PROOF STEP]
using cx1 cy1
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i = 0..<length Vs. ((1::'a) - l) * cy i) = ((1::'a) - l) * sum cy {0..<length Vs}
(\<Sum>i = 0..<length Vs. l * cx i) = l * sum cx {0..<length Vs}
sum cx {0..<length Vs} = (1::'a)
sum cy {0..<length Vs} = (1::'a)

goal (1 subgoal):
 1. (\<Sum>i = 0..<length Vs. l * cx i) + (\<Sum>i = 0..<length Vs. ((1::'a) - l) * cy i) = (1::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<length Vs. l * cx i) + (\<Sum>i = 0..<length Vs. ((1::'a) - l) * cy i) = (1::'a)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..<length Vs. l * cx i + ((1::'a) - l) * cy i) = (1::'a)

goal (1 subgoal):
 1. l \<cdot>\<^sub>v x + ((1::'a) - l) \<cdot>\<^sub>v y \<in> convex_hull_list Vs
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) Vs = l \<cdot>\<^sub>v x + ((1::'a) - l) \<cdot>\<^sub>v y
\<forall>i<length Vs. (0::'a) \<le> l * cx i + ((1::'a) - l) * cy i
(\<Sum>i = 0..<length Vs. l * cx i + ((1::'a) - l) * cy i) = (1::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) Vs = l \<cdot>\<^sub>v x + ((1::'a) - l) \<cdot>\<^sub>v y
\<forall>i<length Vs. (0::'a) \<le> l * cx i + ((1::'a) - l) * cy i
(\<Sum>i = 0..<length Vs. l * cx i + ((1::'a) - l) * cy i) = (1::'a)

goal (1 subgoal):
 1. l \<cdot>\<^sub>v x + ((1::'a) - l) \<cdot>\<^sub>v y \<in> convex_hull_list Vs
[PROOF STEP]
unfolding convex_hull_list_def convex_lincomb_list_def nonneg_lincomb_list_def
[PROOF STATE]
proof (prove)
using this:
lincomb_list (\<lambda>i. l * cx i + ((1::'a) - l) * cy i) Vs = l \<cdot>\<^sub>v x + ((1::'a) - l) \<cdot>\<^sub>v y
\<forall>i<length Vs. (0::'a) \<le> l * cx i + ((1::'a) - l) * cy i
(\<Sum>i = 0..<length Vs. l * cx i + ((1::'a) - l) * cy i) = (1::'a)

goal (1 subgoal):
 1. l \<cdot>\<^sub>v x + ((1::'a) - l) \<cdot>\<^sub>v y \<in> {x. \<exists>c. (lincomb_list c Vs = x \<and> (\<forall>i<length Vs. (0::'a) \<le> c i)) \<and> sum c {0..<length Vs} = (1::'a)}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
l \<cdot>\<^sub>v x + ((1::'a) - l) \<cdot>\<^sub>v y \<in> convex_hull_list Vs

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma bijective_map_preimage:
  assumes "bijective_map f S T"
  shows "bijective_map (inverse_map f S T) T S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bijective_map (inverse_map f S T) T S
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. inverse_map f S T \<in> T \<rightarrow>\<^sub>E S
 2. bij_betw (inverse_map f S T) T S
[PROOF STEP]
show "inverse_map f S T \<in> T \<rightarrow>\<^sub>E S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inverse_map f S T \<in> T \<rightarrow>\<^sub>E S
[PROOF STEP]
by (simp add: assms bij_betw_imp_funcset bij_betw_inv_into bijective.bijective bijective_map.axioms(2) inverse_map_def)
[PROOF STATE]
proof (state)
this:
inverse_map f S T \<in> T \<rightarrow>\<^sub>E S

goal (1 subgoal):
 1. bij_betw (inverse_map f S T) T S
[PROOF STEP]
show "bij_betw (inverse_map f S T) T S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij_betw (inverse_map f S T) T S
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
bijective_map f S T

goal (1 subgoal):
 1. bij_betw (inverse_map f S T) T S
[PROOF STEP]
by (simp add: bij_betw_inv_into bijective_def bijective_map_def inverse_map_def)
[PROOF STATE]
proof (state)
this:
bij_betw (inverse_map f S T) T S

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma inter_sorted_correct :
  assumes l1_OK: "sorted (rev l1)"
  assumes l2_OK: "sorted (rev l2)"
    shows "sorted (rev (inter_sorted_rev l1 l2)) \<and> set (inter_sorted_rev l1 l2) = set l1 \<inter> set l2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Sorted_Less.sorted (rev (inter_sorted_rev l1 l2)) \<and> set (inter_sorted_rev l1 l2) = set l1 \<inter> set l2
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
Sorted_Less.sorted (rev l1)
Sorted_Less.sorted (rev l2)

goal (1 subgoal):
 1. Sorted_Less.sorted (rev (inter_sorted_rev l1 l2)) \<and> set (inter_sorted_rev l1 l2) = set l1 \<inter> set l2
[PROOF STEP]
proof (induct l1 arbitrary: l2)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>l2. \<lbrakk>Sorted_Less.sorted (rev []); Sorted_Less.sorted (rev l2)\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev [] l2)) \<and> set (inter_sorted_rev [] l2) = set [] \<inter> set l2
 2. \<And>a l1 l2. \<lbrakk>\<And>l2. \<lbrakk>Sorted_Less.sorted (rev l1); Sorted_Less.sorted (rev l2)\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev l1 l2)) \<and> set (inter_sorted_rev l1 l2) = set l1 \<inter> set l2; Sorted_Less.sorted (rev (a # l1)); Sorted_Less.sorted (rev l2)\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (a # l1) l2)) \<and> set (inter_sorted_rev (a # l1) l2) = set (a # l1) \<inter> set l2
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
Sorted_Less.sorted (rev [])
Sorted_Less.sorted (rev l2)

goal (2 subgoals):
 1. \<And>l2. \<lbrakk>Sorted_Less.sorted (rev []); Sorted_Less.sorted (rev l2)\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev [] l2)) \<and> set (inter_sorted_rev [] l2) = set [] \<inter> set l2
 2. \<And>a l1 l2. \<lbrakk>\<And>l2. \<lbrakk>Sorted_Less.sorted (rev l1); Sorted_Less.sorted (rev l2)\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev l1 l2)) \<and> set (inter_sorted_rev l1 l2) = set l1 \<inter> set l2; Sorted_Less.sorted (rev (a # l1)); Sorted_Less.sorted (rev l2)\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (a # l1) l2)) \<and> set (inter_sorted_rev (a # l1) l2) = set (a # l1) \<inter> set l2
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
Sorted_Less.sorted (rev [])
Sorted_Less.sorted (rev l2)

goal (1 subgoal):
 1. Sorted_Less.sorted (rev (inter_sorted_rev [] l2)) \<and> set (inter_sorted_rev [] l2) = set [] \<inter> set l2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Sorted_Less.sorted (rev (inter_sorted_rev [] l2)) \<and> set (inter_sorted_rev [] l2) = set [] \<inter> set l2

goal (1 subgoal):
 1. \<And>a l1 l2. \<lbrakk>\<And>l2. \<lbrakk>Sorted_Less.sorted (rev l1); Sorted_Less.sorted (rev l2)\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev l1 l2)) \<and> set (inter_sorted_rev l1 l2) = set l1 \<inter> set l2; Sorted_Less.sorted (rev (a # l1)); Sorted_Less.sorted (rev l2)\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (a # l1) l2)) \<and> set (inter_sorted_rev (a # l1) l2) = set (a # l1) \<inter> set l2
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a l1 l2. \<lbrakk>\<And>l2. \<lbrakk>Sorted_Less.sorted (rev l1); Sorted_Less.sorted (rev l2)\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev l1 l2)) \<and> set (inter_sorted_rev l1 l2) = set l1 \<inter> set l2; Sorted_Less.sorted (rev (a # l1)); Sorted_Less.sorted (rev l2)\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (a # l1) l2)) \<and> set (inter_sorted_rev (a # l1) l2) = set (a # l1) \<inter> set l2
[PROOF STEP]
case (Cons x1 l1 l2)
[PROOF STATE]
proof (state)
this:
\<lbrakk>Sorted_Less.sorted (rev l1); Sorted_Less.sorted (rev ?l2.0)\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev l1 ?l2.0)) \<and> set (inter_sorted_rev l1 ?l2.0) = set l1 \<inter> set ?l2.0
Sorted_Less.sorted (rev (x1 # l1))
Sorted_Less.sorted (rev l2)

goal (1 subgoal):
 1. \<And>a l1 l2. \<lbrakk>\<And>l2. \<lbrakk>Sorted_Less.sorted (rev l1); Sorted_Less.sorted (rev l2)\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev l1 l2)) \<and> set (inter_sorted_rev l1 l2) = set l1 \<inter> set l2; Sorted_Less.sorted (rev (a # l1)); Sorted_Less.sorted (rev l2)\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (a # l1) l2)) \<and> set (inter_sorted_rev (a # l1) l2) = set (a # l1) \<inter> set l2
[PROOF STEP]
note x1_l1_props = Cons(2)
[PROOF STATE]
proof (state)
this:
Sorted_Less.sorted (rev (x1 # l1))

goal (1 subgoal):
 1. \<And>a l1 l2. \<lbrakk>\<And>l2. \<lbrakk>Sorted_Less.sorted (rev l1); Sorted_Less.sorted (rev l2)\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev l1 l2)) \<and> set (inter_sorted_rev l1 l2) = set l1 \<inter> set l2; Sorted_Less.sorted (rev (a # l1)); Sorted_Less.sorted (rev l2)\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (a # l1) l2)) \<and> set (inter_sorted_rev (a # l1) l2) = set (a # l1) \<inter> set l2
[PROOF STEP]
note l2_props = Cons(3)
[PROOF STATE]
proof (state)
this:
Sorted_Less.sorted (rev l2)

goal (1 subgoal):
 1. \<And>a l1 l2. \<lbrakk>\<And>l2. \<lbrakk>Sorted_Less.sorted (rev l1); Sorted_Less.sorted (rev l2)\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev l1 l2)) \<and> set (inter_sorted_rev l1 l2) = set l1 \<inter> set l2; Sorted_Less.sorted (rev (a # l1)); Sorted_Less.sorted (rev l2)\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (a # l1) l2)) \<and> set (inter_sorted_rev (a # l1) l2) = set (a # l1) \<inter> set l2
[PROOF STEP]
from x1_l1_props
[PROOF STATE]
proof (chain)
picking this:
Sorted_Less.sorted (rev (x1 # l1))
[PROOF STEP]
have l1_props: "sorted (rev l1)"
                    and x1_nin_l1: "x1 \<notin> set l1"
                    and x1_gt: "\<And>x. x \<in> set l1 \<Longrightarrow> x1 > x"
[PROOF STATE]
proof (prove)
using this:
Sorted_Less.sorted (rev (x1 # l1))

goal (1 subgoal):
 1. Sorted_Less.sorted (rev l1) &&& x1 \<notin> set l1 &&& (\<And>x. x \<in> set l1 \<Longrightarrow> x < x1)
[PROOF STEP]
by (auto simp add: Ball_def sorted_wrt_append)
[PROOF STATE]
proof (state)
this:
Sorted_Less.sorted (rev l1)
x1 \<notin> set l1
?x \<in> set l1 \<Longrightarrow> ?x < x1

goal (1 subgoal):
 1. \<And>a l1 l2. \<lbrakk>\<And>l2. \<lbrakk>Sorted_Less.sorted (rev l1); Sorted_Less.sorted (rev l2)\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev l1 l2)) \<and> set (inter_sorted_rev l1 l2) = set l1 \<inter> set l2; Sorted_Less.sorted (rev (a # l1)); Sorted_Less.sorted (rev l2)\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (a # l1) l2)) \<and> set (inter_sorted_rev (a # l1) l2) = set (a # l1) \<inter> set l2
[PROOF STEP]
note ind_hyp_l1 = Cons(1)[OF l1_props]
[PROOF STATE]
proof (state)
this:
Sorted_Less.sorted (rev ?l2.0) \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev l1 ?l2.0)) \<and> set (inter_sorted_rev l1 ?l2.0) = set l1 \<inter> set ?l2.0

goal (1 subgoal):
 1. \<And>a l1 l2. \<lbrakk>\<And>l2. \<lbrakk>Sorted_Less.sorted (rev l1); Sorted_Less.sorted (rev l2)\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev l1 l2)) \<and> set (inter_sorted_rev l1 l2) = set l1 \<inter> set l2; Sorted_Less.sorted (rev (a # l1)); Sorted_Less.sorted (rev l2)\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (a # l1) l2)) \<and> set (inter_sorted_rev (a # l1) l2) = set (a # l1) \<inter> set l2
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) l2)) \<and> set (inter_sorted_rev (x1 # l1) l2) = set (x1 # l1) \<inter> set l2
[PROOF STEP]
using l2_props
[PROOF STATE]
proof (prove)
using this:
Sorted_Less.sorted (rev l2)

goal (1 subgoal):
 1. Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) l2)) \<and> set (inter_sorted_rev (x1 # l1) l2) = set (x1 # l1) \<inter> set l2
[PROOF STEP]
proof (induct l2)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Sorted_Less.sorted (rev []) \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) [])) \<and> set (inter_sorted_rev (x1 # l1) []) = set (x1 # l1) \<inter> set []
 2. \<And>a l2. \<lbrakk>Sorted_Less.sorted (rev l2) \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) l2)) \<and> set (inter_sorted_rev (x1 # l1) l2) = set (x1 # l1) \<inter> set l2; Sorted_Less.sorted (rev (a # l2))\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (a # l2))) \<and> set (inter_sorted_rev (x1 # l1) (a # l2)) = set (x1 # l1) \<inter> set (a # l2)
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
Sorted_Less.sorted (rev [])

goal (2 subgoals):
 1. Sorted_Less.sorted (rev []) \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) [])) \<and> set (inter_sorted_rev (x1 # l1) []) = set (x1 # l1) \<inter> set []
 2. \<And>a l2. \<lbrakk>Sorted_Less.sorted (rev l2) \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) l2)) \<and> set (inter_sorted_rev (x1 # l1) l2) = set (x1 # l1) \<inter> set l2; Sorted_Less.sorted (rev (a # l2))\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (a # l2))) \<and> set (inter_sorted_rev (x1 # l1) (a # l2)) = set (x1 # l1) \<inter> set (a # l2)
[PROOF STEP]
with x1_l1_props
[PROOF STATE]
proof (chain)
picking this:
Sorted_Less.sorted (rev (x1 # l1))
Sorted_Less.sorted (rev [])
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
Sorted_Less.sorted (rev (x1 # l1))
Sorted_Less.sorted (rev [])

goal (1 subgoal):
 1. Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) [])) \<and> set (inter_sorted_rev (x1 # l1) []) = set (x1 # l1) \<inter> set []
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) [])) \<and> set (inter_sorted_rev (x1 # l1) []) = set (x1 # l1) \<inter> set []

goal (1 subgoal):
 1. \<And>a l2. \<lbrakk>Sorted_Less.sorted (rev l2) \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) l2)) \<and> set (inter_sorted_rev (x1 # l1) l2) = set (x1 # l1) \<inter> set l2; Sorted_Less.sorted (rev (a # l2))\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (a # l2))) \<and> set (inter_sorted_rev (x1 # l1) (a # l2)) = set (x1 # l1) \<inter> set (a # l2)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a l2. \<lbrakk>Sorted_Less.sorted (rev l2) \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) l2)) \<and> set (inter_sorted_rev (x1 # l1) l2) = set (x1 # l1) \<inter> set l2; Sorted_Less.sorted (rev (a # l2))\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (a # l2))) \<and> set (inter_sorted_rev (x1 # l1) (a # l2)) = set (x1 # l1) \<inter> set (a # l2)
[PROOF STEP]
case (Cons x2 l2)
[PROOF STATE]
proof (state)
this:
Sorted_Less.sorted (rev l2) \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) l2)) \<and> set (inter_sorted_rev (x1 # l1) l2) = set (x1 # l1) \<inter> set l2
Sorted_Less.sorted (rev (x2 # l2))

goal (1 subgoal):
 1. \<And>a l2. \<lbrakk>Sorted_Less.sorted (rev l2) \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) l2)) \<and> set (inter_sorted_rev (x1 # l1) l2) = set (x1 # l1) \<inter> set l2; Sorted_Less.sorted (rev (a # l2))\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (a # l2))) \<and> set (inter_sorted_rev (x1 # l1) (a # l2)) = set (x1 # l1) \<inter> set (a # l2)
[PROOF STEP]
note x2_l2_props = Cons(2)
[PROOF STATE]
proof (state)
this:
Sorted_Less.sorted (rev (x2 # l2))

goal (1 subgoal):
 1. \<And>a l2. \<lbrakk>Sorted_Less.sorted (rev l2) \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) l2)) \<and> set (inter_sorted_rev (x1 # l1) l2) = set (x1 # l1) \<inter> set l2; Sorted_Less.sorted (rev (a # l2))\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (a # l2))) \<and> set (inter_sorted_rev (x1 # l1) (a # l2)) = set (x1 # l1) \<inter> set (a # l2)
[PROOF STEP]
(* sorted (rev (x2 # l2))*)
[PROOF STATE]
proof (state)
this:
Sorted_Less.sorted (rev (x2 # l2))

goal (1 subgoal):
 1. \<And>a l2. \<lbrakk>Sorted_Less.sorted (rev l2) \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) l2)) \<and> set (inter_sorted_rev (x1 # l1) l2) = set (x1 # l1) \<inter> set l2; Sorted_Less.sorted (rev (a # l2))\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (a # l2))) \<and> set (inter_sorted_rev (x1 # l1) (a # l2)) = set (x1 # l1) \<inter> set (a # l2)
[PROOF STEP]
from x2_l2_props
[PROOF STATE]
proof (chain)
picking this:
Sorted_Less.sorted (rev (x2 # l2))
[PROOF STEP]
have l2_props: "sorted (rev l2)"
                    and x2_nin_l2: "x2 \<notin> set l2"
                    and x2_gt: "\<And>x. x \<in> set l2 \<Longrightarrow> x2 > x"
[PROOF STATE]
proof (prove)
using this:
Sorted_Less.sorted (rev (x2 # l2))

goal (1 subgoal):
 1. Sorted_Less.sorted (rev l2) &&& x2 \<notin> set l2 &&& (\<And>x. x \<in> set l2 \<Longrightarrow> x < x2)
[PROOF STEP]
by (auto simp  add: Ball_def sorted_wrt_append )
[PROOF STATE]
proof (state)
this:
Sorted_Less.sorted (rev l2)
x2 \<notin> set l2
?x \<in> set l2 \<Longrightarrow> ?x < x2

goal (1 subgoal):
 1. \<And>a l2. \<lbrakk>Sorted_Less.sorted (rev l2) \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) l2)) \<and> set (inter_sorted_rev (x1 # l1) l2) = set (x1 # l1) \<inter> set l2; Sorted_Less.sorted (rev (a # l2))\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (a # l2))) \<and> set (inter_sorted_rev (x1 # l1) (a # l2)) = set (x1 # l1) \<inter> set (a # l2)
[PROOF STEP]
note ind_hyp_l2 = Cons(1)[OF l2_props]
[PROOF STATE]
proof (state)
this:
Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) l2)) \<and> set (inter_sorted_rev (x1 # l1) l2) = set (x1 # l1) \<inter> set l2

goal (1 subgoal):
 1. \<And>a l2. \<lbrakk>Sorted_Less.sorted (rev l2) \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) l2)) \<and> set (inter_sorted_rev (x1 # l1) l2) = set (x1 # l1) \<inter> set l2; Sorted_Less.sorted (rev (a # l2))\<rbrakk> \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (a # l2))) \<and> set (inter_sorted_rev (x1 # l1) (a # l2)) = set (x1 # l1) \<inter> set (a # l2)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
proof (cases "x1 > x2")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x2 < x1 \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
 2. \<not> x2 < x1 \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
x2 < x1

goal (2 subgoals):
 1. x2 < x1 \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
 2. \<not> x2 < x1 \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
note x1_gt_x2 = this
[PROOF STATE]
proof (state)
this:
x2 < x1

goal (2 subgoals):
 1. x2 < x1 \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
 2. \<not> x2 < x1 \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
have "set l1 \<inter> set (x2 # l2) = set (x1 # l1)\<inter> set (x2 # l2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set l1 \<inter> set (x2 # l2) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
using x1_gt_x2 x1_nin_l1 x2_nin_l2 x1_gt x2_gt
[PROOF STATE]
proof (prove)
using this:
x2 < x1
x1 \<notin> set l1
x2 \<notin> set l2
?x \<in> set l1 \<Longrightarrow> ?x < x1
?x \<in> set l2 \<Longrightarrow> ?x < x2

goal (1 subgoal):
 1. set l1 \<inter> set (x2 # l2) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
set l1 \<inter> set (x2 # l2) = set (x1 # l1) \<inter> set (x2 # l2)

goal (2 subgoals):
 1. x2 < x1 \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
 2. \<not> x2 < x1 \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
set l1 \<inter> set (x2 # l2) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
set l1 \<inter> set (x2 # l2) = set (x1 # l1) \<inter> set (x2 # l2)

goal (1 subgoal):
 1. Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
using ind_hyp_l1[OF x2_l2_props]
[PROOF STATE]
proof (prove)
using this:
set l1 \<inter> set (x2 # l2) = set (x1 # l1) \<inter> set (x2 # l2)
Sorted_Less.sorted (rev (inter_sorted_rev l1 (x2 # l2))) \<and> set (inter_sorted_rev l1 (x2 # l2)) = set l1 \<inter> set (x2 # l2)

goal (1 subgoal):
 1. Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
using x1_gt_x2 x1_nin_l1 x2_nin_l2 x1_gt x2_gt
[PROOF STATE]
proof (prove)
using this:
set l1 \<inter> set (x2 # l2) = set (x1 # l1) \<inter> set (x2 # l2)
Sorted_Less.sorted (rev (inter_sorted_rev l1 (x2 # l2))) \<and> set (inter_sorted_rev l1 (x2 # l2)) = set l1 \<inter> set (x2 # l2)
x2 < x1
x1 \<notin> set l1
x2 \<notin> set l2
?x \<in> set l1 \<Longrightarrow> ?x < x1
?x \<in> set l2 \<Longrightarrow> ?x < x2

goal (1 subgoal):
 1. Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
by (auto simp add:Ball_def sorted_wrt_append)
[PROOF STATE]
proof (state)
this:
Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)

goal (1 subgoal):
 1. \<not> x2 < x1 \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> x2 < x1 \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> x2 < x1

goal (1 subgoal):
 1. \<not> x2 < x1 \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
note x2_ge_x1 = this
[PROOF STATE]
proof (state)
this:
\<not> x2 < x1

goal (1 subgoal):
 1. \<not> x2 < x1 \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
proof (cases "x1 = x2")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x1 = x2 \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
 2. x1 \<noteq> x2 \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
x1 = x2

goal (2 subgoals):
 1. x1 = x2 \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
 2. x1 \<noteq> x2 \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
note x1_eq_x2 = this
[PROOF STATE]
proof (state)
this:
x1 = x2

goal (2 subgoals):
 1. x1 = x2 \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
 2. x1 \<noteq> x2 \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x1 = x2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
x1 = x2

goal (1 subgoal):
 1. Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
using ind_hyp_l1[OF l2_props]
[PROOF STATE]
proof (prove)
using this:
x1 = x2
Sorted_Less.sorted (rev (inter_sorted_rev l1 l2)) \<and> set (inter_sorted_rev l1 l2) = set l1 \<inter> set l2

goal (1 subgoal):
 1. Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
using x1_eq_x2  x1_nin_l1 x2_nin_l2 x1_gt x2_gt
[PROOF STATE]
proof (prove)
using this:
x1 = x2
Sorted_Less.sorted (rev (inter_sorted_rev l1 l2)) \<and> set (inter_sorted_rev l1 l2) = set l1 \<inter> set l2
x1 = x2
x1 \<notin> set l1
x2 \<notin> set l2
?x \<in> set l1 \<Longrightarrow> ?x < x1
?x \<in> set l2 \<Longrightarrow> ?x < x2

goal (1 subgoal):
 1. Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
by (auto simp add:Ball_def sorted_wrt_append)
[PROOF STATE]
proof (state)
this:
Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)

goal (1 subgoal):
 1. x1 \<noteq> x2 \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x1 \<noteq> x2 \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
x1 \<noteq> x2

goal (1 subgoal):
 1. x1 \<noteq> x2 \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
note x1_neq_x2 = this
[PROOF STATE]
proof (state)
this:
x1 \<noteq> x2

goal (1 subgoal):
 1. x1 \<noteq> x2 \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
with x2_ge_x1
[PROOF STATE]
proof (chain)
picking this:
\<not> x2 < x1
x1 \<noteq> x2
[PROOF STEP]
have x2_gt_x1 : "x2 > x1"
[PROOF STATE]
proof (prove)
using this:
\<not> x2 < x1
x1 \<noteq> x2

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

goal (1 subgoal):
 1. x1 \<noteq> x2 \<Longrightarrow> Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
from ind_hyp_l2 x2_ge_x1 x1_neq_x2 x2_gt x2_nin_l2 x1_gt
[PROOF STATE]
proof (chain)
picking this:
Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) l2)) \<and> set (inter_sorted_rev (x1 # l1) l2) = set (x1 # l1) \<inter> set l2
\<not> x2 < x1
x1 \<noteq> x2
?x \<in> set l2 \<Longrightarrow> ?x < x2
x2 \<notin> set l2
?x \<in> set l1 \<Longrightarrow> ?x < x1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) l2)) \<and> set (inter_sorted_rev (x1 # l1) l2) = set (x1 # l1) \<inter> set l2
\<not> x2 < x1
x1 \<noteq> x2
?x \<in> set l2 \<Longrightarrow> ?x < x2
x2 \<notin> set l2
?x \<in> set l1 \<Longrightarrow> ?x < x1

goal (1 subgoal):
 1. Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) (x2 # l2))) \<and> set (inter_sorted_rev (x1 # l1) (x2 # l2)) = set (x1 # l1) \<inter> set (x2 # l2)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Sorted_Less.sorted (rev (inter_sorted_rev (x1 # l1) l2)) \<and> set (inter_sorted_rev (x1 # l1) l2) = set (x1 # l1) \<inter> set l2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fixes p1 :: "'a::comm_ring" shows
  "(sq p1 + sq q1 + sq r1 + sq s1 + sq t1 + sq u1 + sq v1 + sq w1) *
   (sq p2 + sq q2 + sq r2 + sq s2 + sq t2 + sq u2 + sq v2 + sq w2)
    = sq (p1*p2 - q1*q2 - r1*r2 - s1*s2 - t1*t2 - u1*u2 - v1*v2 - w1*w2) +
      sq (p1*q2 + q1*p2 + r1*s2 - s1*r2 + t1*u2 - u1*t2 - v1*w2 + w1*v2) +
      sq (p1*r2 - q1*s2 + r1*p2 + s1*q2 + t1*v2 + u1*w2 - v1*t2 - w1*u2) +
      sq (p1*s2 + q1*r2 - r1*q2 + s1*p2 + t1*w2 - u1*v2 + v1*u2 - w1*t2) +
      sq (p1*t2 - q1*u2 - r1*v2 - s1*w2 + t1*p2 + u1*q2 + v1*r2 + w1*s2) +
      sq (p1*u2 + q1*t2 - r1*w2 + s1*v2 - t1*q2 + u1*p2 - v1*s2 + w1*r2) +
      sq (p1*v2 + q1*w2 + r1*t2 - s1*u2 - t1*r2 + u1*s2 + v1*p2 - w1*q2) +
      sq (p1*w2 - q1*v2 + r1*u2 + s1*t2 - t1*s2 - u1*r2 + v1*q2 + w1*p2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (sq p1 + sq q1 + sq r1 + sq s1 + sq t1 + sq u1 + sq v1 + sq w1) * (sq p2 + sq q2 + sq r2 + sq s2 + sq t2 + sq u2 + sq v2 + sq w2) = sq (p1 * p2 - q1 * q2 - r1 * r2 - s1 * s2 - t1 * t2 - u1 * u2 - v1 * v2 - w1 * w2) + sq (p1 * q2 + q1 * p2 + r1 * s2 - s1 * r2 + t1 * u2 - u1 * t2 - v1 * w2 + w1 * v2) + sq (p1 * r2 - q1 * s2 + r1 * p2 + s1 * q2 + t1 * v2 + u1 * w2 - v1 * t2 - w1 * u2) + sq (p1 * s2 + q1 * r2 - r1 * q2 + s1 * p2 + t1 * w2 - u1 * v2 + v1 * u2 - w1 * t2) + sq (p1 * t2 - q1 * u2 - r1 * v2 - s1 * w2 + t1 * p2 + u1 * q2 + v1 * r2 + w1 * s2) + sq (p1 * u2 + q1 * t2 - r1 * w2 + s1 * v2 - t1 * q2 + u1 * p2 - v1 * s2 + w1 * r2) + sq (p1 * v2 + q1 * w2 + r1 * t2 - s1 * u2 - t1 * r2 + u1 * s2 + v1 * p2 - w1 * q2) + sq (p1 * w2 - q1 * v2 + r1 * u2 + s1 * t2 - t1 * s2 - u1 * r2 + v1 * q2 + w1 * p2)
[PROOF STEP]
by (simp only: sq_def algebra_simps)


[STATEMENT]
lemma prod_not_prime:
  assumes "prime (x::nat)"
    and "prime y"
    and "x > 2"
    and "y > 2"
  shows "\<not> prime ((x-1)*(y-1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> prime ((x - 1) * (y - 1))
[PROOF STEP]
by (metis assms One_nat_def Suc_diff_1 nat_neq_iff numeral_2_eq_2 prime_gt_0_nat prime_product)


[STATEMENT]
lemma norm_pos:
  "\<parallel>v\<parallel> \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> \<parallel>v\<parallel>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 0 \<le> \<parallel>v\<parallel>
[PROOF STEP]
have "\<forall>j. v\<^bsub>j\<^esub>^2 \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>j. 0 \<le> (v\<^bsub>j\<^esub>)\<^sup>2
[PROOF STEP]
unfolding ith_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>j. 0 \<le> (fst v j)\<^sup>2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>j. 0 \<le> (v\<^bsub>j\<^esub>)\<^sup>2

goal (1 subgoal):
 1. 0 \<le> \<parallel>v\<parallel>
[PROOF STEP]
have "(\<Sum>j\<in>{1..(vlen v)}. v\<^bsub>j\<^esub>^2) \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> (\<Sum>j = 1..vlen v. (v\<^bsub>j\<^esub>)\<^sup>2)
[PROOF STEP]
by (simp add: sum_nonneg)
[PROOF STATE]
proof (state)
this:
0 \<le> (\<Sum>j = 1..vlen v. (v\<^bsub>j\<^esub>)\<^sup>2)

goal (1 subgoal):
 1. 0 \<le> \<parallel>v\<parallel>
[PROOF STEP]
with real_sqrt_ge_zero
[PROOF STATE]
proof (chain)
picking this:
0 \<le> ?x \<Longrightarrow> 0 \<le> sqrt ?x
0 \<le> (\<Sum>j = 1..vlen v. (v\<^bsub>j\<^esub>)\<^sup>2)
[PROOF STEP]
have "sqrt (\<Sum>j\<in>{1..(vlen v)}. v\<^bsub>j\<^esub>^2) \<ge> 0"
[PROOF STATE]
proof (prove)
using this:
0 \<le> ?x \<Longrightarrow> 0 \<le> sqrt ?x
0 \<le> (\<Sum>j = 1..vlen v. (v\<^bsub>j\<^esub>)\<^sup>2)

goal (1 subgoal):
 1. 0 \<le> sqrt (\<Sum>j = 1..vlen v. (v\<^bsub>j\<^esub>)\<^sup>2)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
0 \<le> sqrt (\<Sum>j = 1..vlen v. (v\<^bsub>j\<^esub>)\<^sup>2)

goal (1 subgoal):
 1. 0 \<le> \<parallel>v\<parallel>
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
0 \<le> sqrt (\<Sum>j = 1..vlen v. (v\<^bsub>j\<^esub>)\<^sup>2)

goal (1 subgoal):
 1. 0 \<le> \<parallel>v\<parallel>
[PROOF STEP]
unfolding norm_def
[PROOF STATE]
proof (prove)
using this:
0 \<le> sqrt (\<Sum>j = 1..vlen v. (v\<^bsub>j\<^esub>)\<^sup>2)

goal (1 subgoal):
 1. 0 \<le> sqrt (\<Sum>j = 1..vlen v. (v\<^bsub>j\<^esub>)\<^sup>2)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
0 \<le> \<parallel>v\<parallel>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma inner_prod_of_unit_vec:
  fixes n i:: nat
  assumes "i < n"
  shows "\<langle>unit_vec n i| unit_vec n i\<rangle> = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<langle>unit_vec n i|unit_vec n i\<rangle> = 1
[PROOF STEP]
by (auto simp add: inner_prod_def unit_vec_def)
    (simp add: assms sum.cong[of "{0..<n}" "{0..<n}"
        "\<lambda>j. cnj (if j = i then 1 else 0) * (if j = i then 1 else 0)" "\<lambda>j. (if j = i then 1 else 0)"])


[STATEMENT]
lemma horner_sum_eq_sum:
  \<open>horner_sum f a xs = (\<Sum>n = 0..<length xs. f (xs ! n) * a ^ n)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. horner_sum f a xs = (\<Sum>n = 0..<length xs. f (xs ! n) * a ^ n)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. horner_sum f a xs = (\<Sum>n = 0..<length xs. f (xs ! n) * a ^ n)
[PROOF STEP]
have \<open>(*) a ^^ n = (*) (a ^ n)\<close> for n
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (*) a ^^ n = (*) (a ^ n)
[PROOF STEP]
by (induction n) (simp_all add: ac_simps)
[PROOF STATE]
proof (state)
this:
(*) a ^^ ?n1 = (*) (a ^ ?n1)

goal (1 subgoal):
 1. horner_sum f a xs = (\<Sum>n = 0..<length xs. f (xs ! n) * a ^ n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(*) a ^^ ?n1 = (*) (a ^ ?n1)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(*) a ^^ ?n1 = (*) (a ^ ?n1)

goal (1 subgoal):
 1. horner_sum f a xs = (\<Sum>n = 0..<length xs. f (xs ! n) * a ^ n)
[PROOF STEP]
by (simp add: horner_sum_eq_sum_funpow ac_simps)
[PROOF STATE]
proof (state)
this:
horner_sum f a xs = (\<Sum>n = 0..<length xs. f (xs ! n) * a ^ n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma real_of_int_div_aux:
  "(real_of_int x) / (real_of_int d) =
    real_of_int (x div d) + (real_of_int (x mod d)) / (real_of_int d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_of_int x / real_of_int d = real_of_int (x div d) + real_of_int (x mod d) / real_of_int d
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. real_of_int x / real_of_int d = real_of_int (x div d) + real_of_int (x mod d) / real_of_int d
[PROOF STEP]
have "x = (x div d) * d + x mod d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x = x div d * d + x mod d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x = x div d * d + x mod d

goal (1 subgoal):
 1. real_of_int x / real_of_int d = real_of_int (x div d) + real_of_int (x mod d) / real_of_int d
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x = x div d * d + x mod d
[PROOF STEP]
have "real_of_int x = real_of_int (x div d) * real_of_int d + real_of_int(x mod d)"
[PROOF STATE]
proof (prove)
using this:
x = x div d * d + x mod d

goal (1 subgoal):
 1. real_of_int x = real_of_int (x div d) * real_of_int d + real_of_int (x mod d)
[PROOF STEP]
by (metis of_int_add of_int_mult)
[PROOF STATE]
proof (state)
this:
real_of_int x = real_of_int (x div d) * real_of_int d + real_of_int (x mod d)

goal (1 subgoal):
 1. real_of_int x / real_of_int d = real_of_int (x div d) + real_of_int (x mod d) / real_of_int d
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
real_of_int x = real_of_int (x div d) * real_of_int d + real_of_int (x mod d)
[PROOF STEP]
have "real_of_int x / real_of_int d = \<dots> / real_of_int d"
[PROOF STATE]
proof (prove)
using this:
real_of_int x = real_of_int (x div d) * real_of_int d + real_of_int (x mod d)

goal (1 subgoal):
 1. real_of_int x / real_of_int d = (real_of_int (x div d) * real_of_int d + real_of_int (x mod d)) / real_of_int d
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
real_of_int x / real_of_int d = (real_of_int (x div d) * real_of_int d + real_of_int (x mod d)) / real_of_int d

goal (1 subgoal):
 1. real_of_int x / real_of_int d = real_of_int (x div d) + real_of_int (x mod d) / real_of_int d
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
real_of_int x / real_of_int d = (real_of_int (x div d) * real_of_int d + real_of_int (x mod d)) / real_of_int d
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
real_of_int x / real_of_int d = (real_of_int (x div d) * real_of_int d + real_of_int (x mod d)) / real_of_int d

goal (1 subgoal):
 1. real_of_int x / real_of_int d = real_of_int (x div d) + real_of_int (x mod d) / real_of_int d
[PROOF STEP]
by (auto simp add: add_divide_distrib algebra_simps)
[PROOF STATE]
proof (state)
this:
real_of_int x / real_of_int d = real_of_int (x div d) + real_of_int (x mod d) / real_of_int d

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma lin_indpt_cols_imp_det_not_0:
  fixes A::"'a mat"
  assumes A: "A \<in> carrier_mat n n" and li: "lin_indpt (set (cols A))" and d: "distinct (cols A)"
  shows "det A \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det A \<noteq> (0::'a)
[PROOF STEP]
using A li d det_rank_iff lin_indpt_full_rank
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n n
lin_indpt (set (cols A))
distinct (cols A)
?A \<in> carrier_mat n n \<Longrightarrow> (det ?A \<noteq> (0::'a)) = (local.rank ?A = n)
\<lbrakk>?A \<in> carrier_mat n ?nc; distinct (cols ?A); lin_indpt (set (cols ?A))\<rbrakk> \<Longrightarrow> local.rank ?A = ?nc

goal (1 subgoal):
 1. det A \<noteq> (0::'a)
[PROOF STEP]
by blast


[STATEMENT]
lemma set_to_nat_mono: "\<lbrakk> finite B; A \<subseteq> B\<rbrakk> \<Longrightarrow> set_to_nat A \<le> set_to_nat B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite B; A \<subseteq> B\<rbrakk> \<Longrightarrow> set_to_nat A \<le> set_to_nat B
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>finite B; A \<subseteq> B\<rbrakk> \<Longrightarrow> set_to_nat A \<le> set_to_nat B
[PROOF STEP]
assume b_finite: "finite B"
[PROOF STATE]
proof (state)
this:
finite B

goal (1 subgoal):
 1. \<lbrakk>finite B; A \<subseteq> B\<rbrakk> \<Longrightarrow> set_to_nat A \<le> set_to_nat B
[PROOF STEP]
assume a_le_b: "A \<subseteq> B"
[PROOF STATE]
proof (state)
this:
A \<subseteq> B

goal (1 subgoal):
 1. \<lbrakk>finite B; A \<subseteq> B\<rbrakk> \<Longrightarrow> set_to_nat A \<le> set_to_nat B
[PROOF STEP]
let ?f = "\<lambda> (x::nat). (2::nat) ^ x"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>finite B; A \<subseteq> B\<rbrakk> \<Longrightarrow> set_to_nat A \<le> set_to_nat B
[PROOF STEP]
have S1: "set_to_nat A = sum ?f A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set_to_nat A = sum ((^) 2) A
[PROOF STEP]
by (simp add: set_to_nat_def)
[PROOF STATE]
proof (state)
this:
set_to_nat A = sum ((^) 2) A

goal (1 subgoal):
 1. \<lbrakk>finite B; A \<subseteq> B\<rbrakk> \<Longrightarrow> set_to_nat A \<le> set_to_nat B
[PROOF STEP]
have S2: "set_to_nat B = sum ?f B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set_to_nat B = sum ((^) 2) B
[PROOF STEP]
by (simp add: set_to_nat_def)
[PROOF STATE]
proof (state)
this:
set_to_nat B = sum ((^) 2) B

goal (1 subgoal):
 1. \<lbrakk>finite B; A \<subseteq> B\<rbrakk> \<Longrightarrow> set_to_nat A \<le> set_to_nat B
[PROOF STEP]
have S3: "\<And> x. x  \<in> B - A \<Longrightarrow> 0 \<le> ?f x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> B - A \<Longrightarrow> 0 \<le> 2 ^ x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?x \<in> B - A \<Longrightarrow> 0 \<le> 2 ^ ?x

goal (1 subgoal):
 1. \<lbrakk>finite B; A \<subseteq> B\<rbrakk> \<Longrightarrow> set_to_nat A \<le> set_to_nat B
[PROOF STEP]
from b_finite a_le_b S3
[PROOF STATE]
proof (chain)
picking this:
finite B
A \<subseteq> B
?x \<in> B - A \<Longrightarrow> 0 \<le> 2 ^ ?x
[PROOF STEP]
have "sum ?f A \<le> sum ?f B"
[PROOF STATE]
proof (prove)
using this:
finite B
A \<subseteq> B
?x \<in> B - A \<Longrightarrow> 0 \<le> 2 ^ ?x

goal (1 subgoal):
 1. sum ((^) 2) A \<le> sum ((^) 2) B
[PROOF STEP]
by (rule sum_mono2)
[PROOF STATE]
proof (state)
this:
sum ((^) 2) A \<le> sum ((^) 2) B

goal (1 subgoal):
 1. \<lbrakk>finite B; A \<subseteq> B\<rbrakk> \<Longrightarrow> set_to_nat A \<le> set_to_nat B
[PROOF STEP]
with S1 S2
[PROOF STATE]
proof (chain)
picking this:
set_to_nat A = sum ((^) 2) A
set_to_nat B = sum ((^) 2) B
sum ((^) 2) A \<le> sum ((^) 2) B
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
set_to_nat A = sum ((^) 2) A
set_to_nat B = sum ((^) 2) B
sum ((^) 2) A \<le> sum ((^) 2) B

goal (1 subgoal):
 1. set_to_nat A \<le> set_to_nat B
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set_to_nat A \<le> set_to_nat B

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem simplify_sum_of_powers: "(x - 1::nat) * (\<Sum>i=0 .. n . x^i)  = x^(n + 1) - 1" (is "?l = ?r")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x - 1) * sum ((^) x) {0..n} = x ^ (n + 1) - 1
[PROOF STEP]
proof (cases)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ?P \<Longrightarrow> (x - 1) * sum ((^) x) {0..n} = x ^ (n + 1) - 1
 2. \<not> ?P \<Longrightarrow> (x - 1) * sum ((^) x) {0..n} = x ^ (n + 1) - 1
[PROOF STEP]
assume "n = 0"
[PROOF STATE]
proof (state)
this:
n = 0

goal (2 subgoals):
 1. ?P \<Longrightarrow> (x - 1) * sum ((^) x) {0..n} = x ^ (n + 1) - 1
 2. \<not> ?P \<Longrightarrow> (x - 1) * sum ((^) x) {0..n} = x ^ (n + 1) - 1
[PROOF STEP]
thus "?l = x^(n+1) - 1"
[PROOF STATE]
proof (prove)
using this:
n = 0

goal (1 subgoal):
 1. (x - 1) * sum ((^) x) {0..n} = x ^ (n + 1) - 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(x - 1) * sum ((^) x) {0..n} = x ^ (n + 1) - 1

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (x - 1) * sum ((^) x) {0..n} = x ^ (n + 1) - 1
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (x - 1) * sum ((^) x) {0..n} = x ^ (n + 1) - 1
[PROOF STEP]
assume "n\<noteq>0"
[PROOF STATE]
proof (state)
this:
n \<noteq> 0

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (x - 1) * sum ((^) x) {0..n} = x ^ (n + 1) - 1
[PROOF STEP]
hence n0: "n>0"
[PROOF STATE]
proof (prove)
using this:
n \<noteq> 0

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

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (x - 1) * sum ((^) x) {0..n} = x ^ (n + 1) - 1
[PROOF STEP]
have "?l  = (x::nat)*(\<Sum>i=0 .. n . x^i) - (\<Sum>i=0 .. n . x^i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x - 1) * sum ((^) x) {0..n} = x * sum ((^) x) {0..n} - sum ((^) x) {0..n}
[PROOF STEP]
by (metis diff_mult_distrib nat_mult_1)
[PROOF STATE]
proof (state)
this:
(x - 1) * sum ((^) x) {0..n} = x * sum ((^) x) {0..n} - sum ((^) x) {0..n}

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (x - 1) * sum ((^) x) {0..n} = x ^ (n + 1) - 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(x - 1) * sum ((^) x) {0..n} = x * sum ((^) x) {0..n} - sum ((^) x) {0..n}

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (x - 1) * sum ((^) x) {0..n} = x ^ (n + 1) - 1
[PROOF STEP]
have "... = (\<Sum>i=0 .. n . x^(Suc i))    - (\<Sum>i=0 .. n . x^i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x * sum ((^) x) {0..n} - sum ((^) x) {0..n} = (\<Sum>i = 0..n. x ^ Suc i) - sum ((^) x) {0..n}
[PROOF STEP]
by (simp add: sum_distrib_left)
[PROOF STATE]
proof (state)
this:
x * sum ((^) x) {0..n} - sum ((^) x) {0..n} = (\<Sum>i = 0..n. x ^ Suc i) - sum ((^) x) {0..n}

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (x - 1) * sum ((^) x) {0..n} = x ^ (n + 1) - 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
x * sum ((^) x) {0..n} - sum ((^) x) {0..n} = (\<Sum>i = 0..n. x ^ Suc i) - sum ((^) x) {0..n}

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (x - 1) * sum ((^) x) {0..n} = x ^ (n + 1) - 1
[PROOF STEP]
have "... = (\<Sum>i=Suc 0 .. Suc n . x^i)  - (\<Sum>i=0 .. n . x^i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..n. x ^ Suc i) - sum ((^) x) {0..n} = sum ((^) x) {Suc 0..Suc n} - sum ((^) x) {0..n}
[PROOF STEP]
by (metis sum.shift_bounds_cl_Suc_ivl)
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..n. x ^ Suc i) - sum ((^) x) {0..n} = sum ((^) x) {Suc 0..Suc n} - sum ((^) x) {0..n}

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (x - 1) * sum ((^) x) {0..n} = x ^ (n + 1) - 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..n. x ^ Suc i) - sum ((^) x) {0..n} = sum ((^) x) {Suc 0..Suc n} - sum ((^) x) {0..n}

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (x - 1) * sum ((^) x) {0..n} = x ^ (n + 1) - 1
[PROOF STEP]
have "... = ((\<Sum>i=Suc 0 .. n. x^i)+x^(Suc n)) - (x^0 + (\<Sum>i=Suc 0 .. n. x^i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum ((^) x) {Suc 0..Suc n} - sum ((^) x) {0..n} = sum ((^) x) {Suc 0..n} + x ^ Suc n - (x ^ 0 + sum ((^) x) {Suc 0..n})
[PROOF STEP]
by (simp add: sum.union_disjoint diff_add_inverse sum.atLeast_Suc_atMost)
[PROOF STATE]
proof (state)
this:
sum ((^) x) {Suc 0..Suc n} - sum ((^) x) {0..n} = sum ((^) x) {Suc 0..n} + x ^ Suc n - (x ^ 0 + sum ((^) x) {Suc 0..n})

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (x - 1) * sum ((^) x) {0..n} = x ^ (n + 1) - 1
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(x - 1) * sum ((^) x) {0..n} = sum ((^) x) {Suc 0..n} + x ^ Suc n - (x ^ 0 + sum ((^) x) {Suc 0..n})
[PROOF STEP]
show "?thesis"
[PROOF STATE]
proof (prove)
using this:
(x - 1) * sum ((^) x) {0..n} = sum ((^) x) {Suc 0..n} + x ^ Suc n - (x ^ 0 + sum ((^) x) {Suc 0..n})

goal (1 subgoal):
 1. (x - 1) * sum ((^) x) {0..n} = x ^ (n + 1) - 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(x - 1) * sum ((^) x) {0..n} = x ^ (n + 1) - 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma integrable_I:
  "(\<lambda>x. x powr (of_nat n - 1/2) * sqrt (4 - x)) integrable_on {0..4}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. x powr (real n - 1 / 2) * sqrt (4 - x)) integrable_on {0..4}
[PROOF STEP]
proof (cases "n = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 0 \<Longrightarrow> (\<lambda>x. x powr (real n - 1 / 2) * sqrt (4 - x)) integrable_on {0..4}
 2. n \<noteq> 0 \<Longrightarrow> (\<lambda>x. x powr (real n - 1 / 2) * sqrt (4 - x)) integrable_on {0..4}
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
n = 0

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> (\<lambda>x. x powr (real n - 1 / 2) * sqrt (4 - x)) integrable_on {0..4}
 2. n \<noteq> 0 \<Longrightarrow> (\<lambda>x. x powr (real n - 1 / 2) * sqrt (4 - x)) integrable_on {0..4}
[PROOF STEP]
with has_integral_I0
[PROOF STATE]
proof (chain)
picking this:
((\<lambda>x. x powr - (1 / 2) * sqrt (4 - x)) has_integral 2 * pi) {0..4}
n = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. x powr - (1 / 2) * sqrt (4 - x)) has_integral 2 * pi) {0..4}
n = 0

goal (1 subgoal):
 1. (\<lambda>x. x powr (real n - 1 / 2) * sqrt (4 - x)) integrable_on {0..4}
[PROOF STEP]
by (simp add: has_integral_integrable)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. x powr (real n - 1 / 2) * sqrt (4 - x)) integrable_on {0..4}

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (\<lambda>x. x powr (real n - 1 / 2) * sqrt (4 - x)) integrable_on {0..4}
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (\<lambda>x. x powr (real n - 1 / 2) * sqrt (4 - x)) integrable_on {0..4}
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
n \<noteq> 0

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> (\<lambda>x. x powr (real n - 1 / 2) * sqrt (4 - x)) integrable_on {0..4}
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
n \<noteq> 0

goal (1 subgoal):
 1. (\<lambda>x. x powr (real n - 1 / 2) * sqrt (4 - x)) integrable_on {0..4}
[PROOF STEP]
by (intro integrable_continuous_real continuous_on_mult continuous_on_powr')
                  (auto intro!: continuous_intros)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. x powr (real n - 1 / 2) * sqrt (4 - x)) integrable_on {0..4}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma frequently_eventually_at_top:
  fixes P Q::"'a::linorder \<Rightarrow> bool"
  assumes "frequently P at_top" "eventually Q at_top"
  shows "frequently (\<lambda>x. P x \<and> (\<forall>y\<ge>x. Q y) ) at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>\<^sub>F x in at_top. P x \<and> (\<forall>y\<ge>x. Q y)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
frequently P at_top
eventually Q at_top

goal (1 subgoal):
 1. \<exists>\<^sub>F x in at_top. P x \<and> (\<forall>y\<ge>x. Q y)
[PROOF STEP]
unfolding frequently_def eventually_at_top_linorder
[PROOF STATE]
proof (prove)
using this:
\<nexists>N. \<forall>n\<ge>N. \<not> P n
\<exists>N. \<forall>n\<ge>N. Q n

goal (1 subgoal):
 1. \<nexists>N. \<forall>n\<ge>N. \<not> (P n \<and> (\<forall>y\<ge>n. Q y))
[PROOF STEP]
by (metis (mono_tags, opaque_lifting) le_cases order_trans)


[STATEMENT]
lemma infsetsum_diff:
  assumes "f abs_summable_on A" and "g abs_summable_on A"
  shows   "infsetsum (\<lambda>x. f x - g x) A = infsetsum f A - infsetsum g A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>\<^sub>ax\<in>A. f x - g x) = infsetsum f A - infsetsum g A
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f abs_summable_on A
g abs_summable_on A

goal (1 subgoal):
 1. (\<Sum>\<^sub>ax\<in>A. f x - g x) = infsetsum f A - infsetsum g A
[PROOF STEP]
unfolding infsetsum_def abs_summable_on_def
[PROOF STATE]
proof (prove)
using this:
integrable (count_space A) f
integrable (count_space A) g

goal (1 subgoal):
 1. LINT x|count_space A. f x - g x = integral\<^sup>L (count_space A) f - integral\<^sup>L (count_space A) g
[PROOF STEP]
by (rule Bochner_Integration.integral_diff)


[STATEMENT]
lemma convex_differences:
  assumes "convex S" "convex T"
  shows "convex (\<Union>x\<in> S. \<Union>y \<in> T. {x - y})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. convex (\<Union>x\<in>S. \<Union>y\<in>T. {x - y})
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. convex (\<Union>x\<in>S. \<Union>y\<in>T. {x - y})
[PROOF STEP]
have "{x - y| x y. x \<in> S \<and> y \<in> T} = {x + y |x y. x \<in> S \<and> y \<in> uminus ` T}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x - y |x y. x \<in> S \<and> y \<in> T} = {x + y |x y. x \<in> S \<and> y \<in> uminus ` T}
[PROOF STEP]
by (auto simp: diff_conv_add_uminus simp del: add_uminus_conv_diff)
[PROOF STATE]
proof (state)
this:
{x - y |x y. x \<in> S \<and> y \<in> T} = {x + y |x y. x \<in> S \<and> y \<in> uminus ` T}

goal (1 subgoal):
 1. convex (\<Union>x\<in>S. \<Union>y\<in>T. {x - y})
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
{x - y |x y. x \<in> S \<and> y \<in> T} = {x + y |x y. x \<in> S \<and> y \<in> uminus ` T}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
{x - y |x y. x \<in> S \<and> y \<in> T} = {x + y |x y. x \<in> S \<and> y \<in> uminus ` T}

goal (1 subgoal):
 1. convex (\<Union>x\<in>S. \<Union>y\<in>T. {x - y})
[PROOF STEP]
using convex_sums[OF assms(1) convex_negations[OF assms(2)]]
[PROOF STATE]
proof (prove)
using this:
{x - y |x y. x \<in> S \<and> y \<in> T} = {x + y |x y. x \<in> S \<and> y \<in> uminus ` T}
convex (\<Union>x\<in>S. \<Union>y\<in>uminus ` T. {x + y})

goal (1 subgoal):
 1. convex (\<Union>x\<in>S. \<Union>y\<in>T. {x - y})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
convex (\<Union>x\<in>S. \<Union>y\<in>T. {x - y})

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma lagrange_basis_poly_0: assumes "x' \<in> set (map fst xs_ys)" and "x' \<noteq> x"
  shows "poly (lagrange_basis_poly (map fst xs_ys) x) x' = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly (lagrange_basis_poly (map fst xs_ys) x) x' = (0::'a)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. poly (lagrange_basis_poly (map fst xs_ys) x) x' = (0::'a)
[PROOF STEP]
let ?f = "\<lambda>xi. smult (inverse (x - xi)) [:- xi, 1:]"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. poly (lagrange_basis_poly (map fst xs_ys) x) x' = (0::'a)
[PROOF STEP]
let ?xs = "filter (\<lambda>c. c\<noteq>x) (map fst xs_ys)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. poly (lagrange_basis_poly (map fst xs_ys) x) x' = (0::'a)
[PROOF STEP]
have mem: "?f x' \<in> set (map ?f ?xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. smult (inverse (x - x')) [:- x', 1::'a:] \<in> set (map (\<lambda>xi. smult (inverse (x - xi)) [:- xi, 1::'a:]) (filter (\<lambda>c. c \<noteq> x) (map fst xs_ys)))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
x' \<in> set (map fst xs_ys)
x' \<noteq> x

goal (1 subgoal):
 1. smult (inverse (x - x')) [:- x', 1::'a:] \<in> set (map (\<lambda>xi. smult (inverse (x - xi)) [:- xi, 1::'a:]) (filter (\<lambda>c. c \<noteq> x) (map fst xs_ys)))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
smult (inverse (x - x')) [:- x', 1::'a:] \<in> set (map (\<lambda>xi. smult (inverse (x - xi)) [:- xi, 1::'a:]) (filter (\<lambda>c. c \<noteq> x) (map fst xs_ys)))

goal (1 subgoal):
 1. poly (lagrange_basis_poly (map fst xs_ys) x) x' = (0::'a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly (lagrange_basis_poly (map fst xs_ys) x) x' = (0::'a)
[PROOF STEP]
unfolding lagrange_basis_poly_def Let_def poly_prod_list prod_list_map_remove1[OF mem]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly (smult (inverse (x - x')) [:- x', 1::'a:]) x' * (\<Prod>p\<leftarrow>remove1 (smult (inverse (x - x')) [:- x', 1::'a:]) (map (\<lambda>xi. smult (inverse (x - xi)) [:- xi, 1::'a:]) (filter (\<lambda>xa. xa \<noteq> x) (map fst xs_ys))). poly p x') = (0::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
poly (lagrange_basis_poly (map fst xs_ys) x) x' = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sphere_params_on_sphere:
  fixes \<alpha> \<beta> :: real
  assumes "x = cos \<alpha> * cos \<beta>" and "y = cos \<alpha> * sin \<beta>" "z = sin \<alpha>"
  shows "x*x + y*y + z*z = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x * x + y * y + z * z = 1
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x * x + y * y + z * z = 1
[PROOF STEP]
have "x*x + y*y = (cos \<alpha> * cos \<alpha>) * (cos \<beta> * cos \<beta>) + (cos \<alpha> * cos \<alpha>) * (sin \<beta> * sin \<beta>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x * x + y * y = cos \<alpha> * cos \<alpha> * (cos \<beta> * cos \<beta>) + cos \<alpha> * cos \<alpha> * (sin \<beta> * sin \<beta>)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
x = cos \<alpha> * cos \<beta>
y = cos \<alpha> * sin \<beta>
z = sin \<alpha>

goal (1 subgoal):
 1. x * x + y * y = cos \<alpha> * cos \<alpha> * (cos \<beta> * cos \<beta>) + cos \<alpha> * cos \<alpha> * (sin \<beta> * sin \<beta>)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
x * x + y * y = cos \<alpha> * cos \<alpha> * (cos \<beta> * cos \<beta>) + cos \<alpha> * cos \<alpha> * (sin \<beta> * sin \<beta>)

goal (1 subgoal):
 1. x * x + y * y + z * z = 1
[PROOF STEP]
hence "x*x + y*y = cos \<alpha> * cos \<alpha>"
[PROOF STATE]
proof (prove)
using this:
x * x + y * y = cos \<alpha> * cos \<alpha> * (cos \<beta> * cos \<beta>) + cos \<alpha> * cos \<alpha> * (sin \<beta> * sin \<beta>)

goal (1 subgoal):
 1. x * x + y * y = cos \<alpha> * cos \<alpha>
[PROOF STEP]
using sin_cos_squared_add3[of \<beta>]
[PROOF STATE]
proof (prove)
using this:
x * x + y * y = cos \<alpha> * cos \<alpha> * (cos \<beta> * cos \<beta>) + cos \<alpha> * cos \<alpha> * (sin \<beta> * sin \<beta>)
cos \<beta> * cos \<beta> + sin \<beta> * sin \<beta> = 1

goal (1 subgoal):
 1. x * x + y * y = cos \<alpha> * cos \<alpha>
[PROOF STEP]
by (subst (asm) distrib_left[symmetric]) (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
x * x + y * y = cos \<alpha> * cos \<alpha>

goal (1 subgoal):
 1. x * x + y * y + z * z = 1
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
x * x + y * y = cos \<alpha> * cos \<alpha>

goal (1 subgoal):
 1. x * x + y * y + z * z = 1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
x * x + y * y = cos \<alpha> * cos \<alpha>
x = cos \<alpha> * cos \<beta>
y = cos \<alpha> * sin \<beta>
z = sin \<alpha>

goal (1 subgoal):
 1. x * x + y * y + z * z = 1
[PROOF STEP]
using sin_cos_squared_add3[of \<alpha>]
[PROOF STATE]
proof (prove)
using this:
x * x + y * y = cos \<alpha> * cos \<alpha>
x = cos \<alpha> * cos \<beta>
y = cos \<alpha> * sin \<beta>
z = sin \<alpha>
cos \<alpha> * cos \<alpha> + sin \<alpha> * sin \<alpha> = 1

goal (1 subgoal):
 1. x * x + y * y + z * z = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
x * x + y * y + z * z = 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sym_group_card_carrier: "card (carrier (sym_group n)) = fact n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (carrier (sym_group n)) = fact n
[PROOF STEP]
using card_permutations[of "{1..n}" n]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>card {1..n} = n; finite {1..n}\<rbrakk> \<Longrightarrow> card {p. p permutes {1..n}} = fact n

goal (1 subgoal):
 1. card (carrier (sym_group n)) = fact n
[PROOF STEP]
unfolding sym_group_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>card {1..n} = n; finite {1..n}\<rbrakk> \<Longrightarrow> card {p. p permutes {1..n}} = fact n

goal (1 subgoal):
 1. card (carrier \<lparr>carrier = {p. p permutes {1..n}}, monoid.mult = (\<circ>), one = id\<rparr>) = fact n
[PROOF STEP]
by simp


[STATEMENT]
lemma complex_abs_le_norm: "\<bar>Re z\<bar> + \<bar>Im z\<bar> \<le> sqrt 2 * norm z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>Re z\<bar> + \<bar>Im z\<bar> \<le> sqrt 2 * cmod z
[PROOF STEP]
unfolding norm_complex_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>Re z\<bar> + \<bar>Im z\<bar> \<le> sqrt 2 * sqrt ((Re z)\<^sup>2 + (Im z)\<^sup>2)
[PROOF STEP]
apply (rule abs_sqrt_wlog [where x="Re z"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. 0 \<le> x \<Longrightarrow> x + \<bar>Im z\<bar> \<le> sqrt 2 * sqrt (x\<^sup>2 + (Im z)\<^sup>2)
[PROOF STEP]
apply (rule abs_sqrt_wlog [where x="Im z"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x xa. \<lbrakk>0 \<le> x; 0 \<le> xa\<rbrakk> \<Longrightarrow> x + xa \<le> sqrt 2 * sqrt (x\<^sup>2 + xa\<^sup>2)
[PROOF STEP]
apply (rule power2_le_imp_le)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x xa. \<lbrakk>0 \<le> x; 0 \<le> xa\<rbrakk> \<Longrightarrow> (x + xa)\<^sup>2 \<le> (sqrt 2 * sqrt (x\<^sup>2 + xa\<^sup>2))\<^sup>2
 2. \<And>x xa. \<lbrakk>0 \<le> x; 0 \<le> xa\<rbrakk> \<Longrightarrow> 0 \<le> sqrt 2 * sqrt (x\<^sup>2 + xa\<^sup>2)
[PROOF STEP]
apply (simp_all add: power2_sum add.commute sum_squares_bound real_sqrt_mult [symmetric])
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma crb_lem_neg:
  fixes x:: "real"
  fixes p:: "real poly"
  assumes x: "poly p x = 0"
  assumes p: "p \<noteq> 0"
  shows "x > -crb p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_of_int (- crb p) < x
[PROOF STEP]
using cauchy_root_bound[of p x]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>poly p x = 0; p \<noteq> 0\<rbrakk> \<Longrightarrow> norm x \<le> 1 + max_list_non_empty (map (\<lambda>i. norm (coeff p i)) [0..<degree p]) / norm (lead_coeff p)

goal (1 subgoal):
 1. real_of_int (- crb p) < x
[PROOF STEP]
apply (auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lbrakk>poly p x = 0; p \<noteq> 0\<rbrakk> \<Longrightarrow> \<bar>x\<bar> \<le> 1 + max_list_non_empty (map (\<lambda>i. \<bar>coeff p i\<bar>) [0..<degree p]) / \<bar>lead_coeff p\<bar>) \<Longrightarrow> - real_of_int (crb p) < x
[PROOF STEP]
unfolding crb_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lbrakk>poly p x = 0; p \<noteq> 0\<rbrakk> \<Longrightarrow> \<bar>x\<bar> \<le> 1 + max_list_non_empty (map (\<lambda>i. \<bar>coeff p i\<bar>) [0..<degree p]) / \<bar>lead_coeff p\<bar>) \<Longrightarrow> - real_of_int \<lceil>2 + max_list_non_empty (map (\<lambda>i. norm (coeff p i)) [0..<degree p]) / norm (lead_coeff p)\<rceil> < x
[PROOF STEP]
apply (auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lbrakk>poly p x = 0; p \<noteq> 0\<rbrakk> \<Longrightarrow> \<bar>x\<bar> \<le> 1 + max_list_non_empty (map (\<lambda>i. \<bar>coeff p i\<bar>) [0..<degree p]) / \<bar>lead_coeff p\<bar>) \<Longrightarrow> - real_of_int \<lceil>2 + max_list_non_empty (map (\<lambda>i. \<bar>coeff p i\<bar>) [0..<degree p]) / \<bar>lead_coeff p\<bar>\<rceil> < x
[PROOF STEP]
using p x
[PROOF STATE]
proof (prove)
using this:
p \<noteq> 0
poly p x = 0

goal (1 subgoal):
 1. (\<lbrakk>poly p x = 0; p \<noteq> 0\<rbrakk> \<Longrightarrow> \<bar>x\<bar> \<le> 1 + max_list_non_empty (map (\<lambda>i. \<bar>coeff p i\<bar>) [0..<degree p]) / \<bar>lead_coeff p\<bar>) \<Longrightarrow> - real_of_int \<lceil>2 + max_list_non_empty (map (\<lambda>i. \<bar>coeff p i\<bar>) [0..<degree p]) / \<bar>lead_coeff p\<bar>\<rceil> < x
[PROOF STEP]
by linarith


[STATEMENT]
lemma real_inverse_ge_one_lemma:
      "\<lbrakk> 0 < (a::real); a < 1 \<rbrakk> \<Longrightarrow> inverse a \<ge> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < a; a < 1\<rbrakk> \<Longrightarrow> 1 \<le> inverse a
[PROOF STEP]
by (metis less_eq_real_def one_le_inverse_iff)


[STATEMENT]
lemma gcd_eq_0_iff [simp]: "gcd a b = 0 \<longleftrightarrow> a = 0 \<and> b = 0"
  (is "?P \<longleftrightarrow> ?Q")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (gcd a b = (0::'a)) = (a = (0::'a) \<and> b = (0::'a))
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. gcd a b = (0::'a) \<Longrightarrow> a = (0::'a) \<and> b = (0::'a)
 2. a = (0::'a) \<and> b = (0::'a) \<Longrightarrow> gcd a b = (0::'a)
[PROOF STEP]
assume ?P
[PROOF STATE]
proof (state)
this:
gcd a b = (0::'a)

goal (2 subgoals):
 1. gcd a b = (0::'a) \<Longrightarrow> a = (0::'a) \<and> b = (0::'a)
 2. a = (0::'a) \<and> b = (0::'a) \<Longrightarrow> gcd a b = (0::'a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
gcd a b = (0::'a)
[PROOF STEP]
have "0 dvd gcd a b"
[PROOF STATE]
proof (prove)
using this:
gcd a b = (0::'a)

goal (1 subgoal):
 1. (0::'a) dvd gcd a b
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(0::'a) dvd gcd a b

goal (2 subgoals):
 1. gcd a b = (0::'a) \<Longrightarrow> a = (0::'a) \<and> b = (0::'a)
 2. a = (0::'a) \<and> b = (0::'a) \<Longrightarrow> gcd a b = (0::'a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(0::'a) dvd gcd a b
[PROOF STEP]
have "0 dvd a" and "0 dvd b"
[PROOF STATE]
proof (prove)
using this:
(0::'a) dvd gcd a b

goal (1 subgoal):
 1. (0::'a) dvd a &&& (0::'a) dvd b
[PROOF STEP]
by (blast intro: dvd_trans)+
[PROOF STATE]
proof (state)
this:
(0::'a) dvd a
(0::'a) dvd b

goal (2 subgoals):
 1. gcd a b = (0::'a) \<Longrightarrow> a = (0::'a) \<and> b = (0::'a)
 2. a = (0::'a) \<and> b = (0::'a) \<Longrightarrow> gcd a b = (0::'a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(0::'a) dvd a
(0::'a) dvd b
[PROOF STEP]
show ?Q
[PROOF STATE]
proof (prove)
using this:
(0::'a) dvd a
(0::'a) dvd b

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

goal (1 subgoal):
 1. a = (0::'a) \<and> b = (0::'a) \<Longrightarrow> gcd a b = (0::'a)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a = (0::'a) \<and> b = (0::'a) \<Longrightarrow> gcd a b = (0::'a)
[PROOF STEP]
assume ?Q
[PROOF STATE]
proof (state)
this:
a = (0::'a) \<and> b = (0::'a)

goal (1 subgoal):
 1. a = (0::'a) \<and> b = (0::'a) \<Longrightarrow> gcd a b = (0::'a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
a = (0::'a) \<and> b = (0::'a)
[PROOF STEP]
show ?P
[PROOF STATE]
proof (prove)
using this:
a = (0::'a) \<and> b = (0::'a)

goal (1 subgoal):
 1. gcd a b = (0::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
gcd a b = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma dirichlet_prod_commutes:
  "dirichlet_prod (f :: nat \<Rightarrow> 'a :: comm_semiring_0) g = dirichlet_prod g f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dirichlet_prod f g = dirichlet_prod g f
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. dirichlet_prod f g x = dirichlet_prod g f x
[PROOF STEP]
fix n :: nat
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. dirichlet_prod f g x = dirichlet_prod g f x
[PROOF STEP]
show "dirichlet_prod f g n = dirichlet_prod g f n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dirichlet_prod f g n = dirichlet_prod g f n
[PROOF STEP]
proof (cases "n = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 0 \<Longrightarrow> dirichlet_prod f g n = dirichlet_prod g f n
 2. n \<noteq> 0 \<Longrightarrow> dirichlet_prod f g n = dirichlet_prod g f n
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
n \<noteq> 0

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> dirichlet_prod f g n = dirichlet_prod g f n
 2. n \<noteq> 0 \<Longrightarrow> dirichlet_prod f g n = dirichlet_prod g f n
[PROOF STEP]
have "(\<Sum>(r,d) | r * d = n. f r * g d) = (\<Sum>(d,r) | r * d = n. f r * g d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>(r, d)\<in>{(r, d). r * d = n}. f r * g d) = (\<Sum>(d, r)\<in>{(d, r). r * d = n}. f r * g d)
[PROOF STEP]
by (rule sum.reindex_bij_witness [of _ "\<lambda>(x,y). (y,x)" "\<lambda>(x,y). (y,x)"]) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>(r, d)\<in>{(r, d). r * d = n}. f r * g d) = (\<Sum>(d, r)\<in>{(d, r). r * d = n}. f r * g d)

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> dirichlet_prod f g n = dirichlet_prod g f n
 2. n \<noteq> 0 \<Longrightarrow> dirichlet_prod f g n = dirichlet_prod g f n
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>(r, d)\<in>{(r, d). r * d = n}. f r * g d) = (\<Sum>(d, r)\<in>{(d, r). r * d = n}. f r * g d)

goal (1 subgoal):
 1. dirichlet_prod f g n = dirichlet_prod g f n
[PROOF STEP]
by (simp add: dirichlet_prod_altdef2 mult.commute)
[PROOF STATE]
proof (state)
this:
dirichlet_prod f g n = dirichlet_prod g f n

goal (1 subgoal):
 1. n = 0 \<Longrightarrow> dirichlet_prod f g n = dirichlet_prod g f n
[PROOF STEP]
qed (simp add: dirichlet_prod_def)
[PROOF STATE]
proof (state)
this:
dirichlet_prod f g n = dirichlet_prod g f n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sincos_total_pi_half:
  assumes "0 \<le> x" "0 \<le> y" "x\<^sup>2 + y\<^sup>2 = 1"
  shows "\<exists>t. 0 \<le> t \<and> t \<le> pi/2 \<and> x = cos t \<and> y = sin t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>t\<ge>0. t \<le> pi / 2 \<and> x = cos t \<and> y = sin t
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>t\<ge>0. t \<le> pi / 2 \<and> x = cos t \<and> y = sin t
[PROOF STEP]
have x1: "x \<le> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<le> 1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 \<le> x
0 \<le> y
x\<^sup>2 + y\<^sup>2 = 1

goal (1 subgoal):
 1. x \<le> 1
[PROOF STEP]
by (metis le_add_same_cancel1 power2_le_imp_le power_one zero_le_power2)
[PROOF STATE]
proof (state)
this:
x \<le> 1

goal (1 subgoal):
 1. \<exists>t\<ge>0. t \<le> pi / 2 \<and> x = cos t \<and> y = sin t
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
0 \<le> x
0 \<le> y
x\<^sup>2 + y\<^sup>2 = 1
x \<le> 1
[PROOF STEP]
have *: "0 \<le> arccos x" "cos (arccos x) = x"
[PROOF STATE]
proof (prove)
using this:
0 \<le> x
0 \<le> y
x\<^sup>2 + y\<^sup>2 = 1
x \<le> 1

goal (1 subgoal):
 1. 0 \<le> arccos x &&& cos (arccos x) = x
[PROOF STEP]
by (auto simp: arccos)
[PROOF STATE]
proof (state)
this:
0 \<le> arccos x
cos (arccos x) = x

goal (1 subgoal):
 1. \<exists>t\<ge>0. t \<le> pi / 2 \<and> x = cos t \<and> y = sin t
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
0 \<le> x
0 \<le> y
x\<^sup>2 + y\<^sup>2 = 1
[PROOF STEP]
have "y = sqrt (1 - x\<^sup>2)"
[PROOF STATE]
proof (prove)
using this:
0 \<le> x
0 \<le> y
x\<^sup>2 + y\<^sup>2 = 1

goal (1 subgoal):
 1. y = sqrt (1 - x\<^sup>2)
[PROOF STEP]
by (metis abs_of_nonneg add.commute add_diff_cancel real_sqrt_abs)
[PROOF STATE]
proof (state)
this:
y = sqrt (1 - x\<^sup>2)

goal (1 subgoal):
 1. \<exists>t\<ge>0. t \<le> pi / 2 \<and> x = cos t \<and> y = sin t
[PROOF STEP]
with x1 * assms arccos_le_pi2 [of x]
[PROOF STATE]
proof (chain)
picking this:
x \<le> 1
0 \<le> arccos x
cos (arccos x) = x
0 \<le> x
0 \<le> y
x\<^sup>2 + y\<^sup>2 = 1
\<lbrakk>0 \<le> x; x \<le> 1\<rbrakk> \<Longrightarrow> arccos x \<le> pi / 2
y = sqrt (1 - x\<^sup>2)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
x \<le> 1
0 \<le> arccos x
cos (arccos x) = x
0 \<le> x
0 \<le> y
x\<^sup>2 + y\<^sup>2 = 1
\<lbrakk>0 \<le> x; x \<le> 1\<rbrakk> \<Longrightarrow> arccos x \<le> pi / 2
y = sqrt (1 - x\<^sup>2)

goal (1 subgoal):
 1. \<exists>t\<ge>0. t \<le> pi / 2 \<and> x = cos t \<and> y = sin t
[PROOF STEP]
by (rule_tac x="arccos x" in exI) (auto simp: sin_arccos)
[PROOF STATE]
proof (state)
this:
\<exists>t\<ge>0. t \<le> pi / 2 \<and> x = cos t \<and> y = sin t

goal:
No subgoals!
[PROOF STEP]
qed