[STATEMENT]
lemma nth_concat_two_lists:
  "i < length (concat (xs :: 'a list list)) \<Longrightarrow> length (ys :: 'b list list) = length xs
  \<Longrightarrow> (\<And> i. i < length xs \<Longrightarrow> length (ys ! i) = length (xs ! i))
  \<Longrightarrow> \<exists> j k. j < length xs \<and> k < length (xs ! j) \<and> (concat xs) ! i = xs ! j ! k \<and>
     (concat ys) ! i = ys ! j ! k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>i < length (concat xs); length ys = length xs; \<And>i. i < length xs \<Longrightarrow> length (ys ! i) = length (xs ! i)\<rbrakk> \<Longrightarrow> \<exists>j k. j < length xs \<and> k < length (xs ! j) \<and> concat xs ! i = xs ! j ! k \<and> concat ys ! i = ys ! j ! k
[PROOF STEP]
proof (induct xs arbitrary: i ys)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i ys. \<lbrakk>i < length (concat []); length ys = length []; \<And>i. i < length [] \<Longrightarrow> length (ys ! i) = length ([] ! i)\<rbrakk> \<Longrightarrow> \<exists>j k. j < length [] \<and> k < length ([] ! j) \<and> concat [] ! i = [] ! j ! k \<and> concat ys ! i = ys ! j ! k
 2. \<And>a xs i ys. \<lbrakk>\<And>i ys. \<lbrakk>i < length (concat xs); length ys = length xs; \<And>i. i < length xs \<Longrightarrow> length (ys ! i) = length (xs ! i)\<rbrakk> \<Longrightarrow> \<exists>j k. j < length xs \<and> k < length (xs ! j) \<and> concat xs ! i = xs ! j ! k \<and> concat ys ! i = ys ! j ! k; i < length (concat (a # xs)); length ys = length (a # xs); \<And>i. i < length (a # xs) \<Longrightarrow> length (ys ! i) = length ((a # xs) ! i)\<rbrakk> \<Longrightarrow> \<exists>j k. j < length (a # xs) \<and> k < length ((a # xs) ! j) \<and> concat (a # xs) ! i = (a # xs) ! j ! k \<and> concat ys ! i = ys ! j ! k
[PROOF STEP]
case (Cons x xs i yys)
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i < length (concat xs); length ?ys = length xs; \<And>i. i < length xs \<Longrightarrow> length (?ys ! i) = length (xs ! i)\<rbrakk> \<Longrightarrow> \<exists>j k. j < length xs \<and> k < length (xs ! j) \<and> concat xs ! ?i = xs ! j ! k \<and> concat ?ys ! ?i = ?ys ! j ! k
i < length (concat (x # xs))
length yys = length (x # xs)
?i < length (x # xs) \<Longrightarrow> length (yys ! ?i) = length ((x # xs) ! ?i)

goal (2 subgoals):
 1. \<And>i ys. \<lbrakk>i < length (concat []); length ys = length []; \<And>i. i < length [] \<Longrightarrow> length (ys ! i) = length ([] ! i)\<rbrakk> \<Longrightarrow> \<exists>j k. j < length [] \<and> k < length ([] ! j) \<and> concat [] ! i = [] ! j ! k \<and> concat ys ! i = ys ! j ! k
 2. \<And>a xs i ys. \<lbrakk>\<And>i ys. \<lbrakk>i < length (concat xs); length ys = length xs; \<And>i. i < length xs \<Longrightarrow> length (ys ! i) = length (xs ! i)\<rbrakk> \<Longrightarrow> \<exists>j k. j < length xs \<and> k < length (xs ! j) \<and> concat xs ! i = xs ! j ! k \<and> concat ys ! i = ys ! j ! k; i < length (concat (a # xs)); length ys = length (a # xs); \<And>i. i < length (a # xs) \<Longrightarrow> length (ys ! i) = length ((a # xs) ! i)\<rbrakk> \<Longrightarrow> \<exists>j k. j < length (a # xs) \<and> k < length ((a # xs) ! j) \<and> concat (a # xs) ! i = (a # xs) ! j ! k \<and> concat ys ! i = ys ! j ! k
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>?i < length (concat xs); length ?ys = length xs; \<And>i. i < length xs \<Longrightarrow> length (?ys ! i) = length (xs ! i)\<rbrakk> \<Longrightarrow> \<exists>j k. j < length xs \<and> k < length (xs ! j) \<and> concat xs ! ?i = xs ! j ! k \<and> concat ?ys ! ?i = ?ys ! j ! k
i < length (concat (x # xs))
length yys = length (x # xs)
?i < length (x # xs) \<Longrightarrow> length (yys ! ?i) = length ((x # xs) ! ?i)
[PROOF STEP]
obtain y ys where yys: "yys = y # ys"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?i < length (concat xs); length ?ys = length xs; \<And>i. i < length xs \<Longrightarrow> length (?ys ! i) = length (xs ! i)\<rbrakk> \<Longrightarrow> \<exists>j k. j < length xs \<and> k < length (xs ! j) \<and> concat xs ! ?i = xs ! j ! k \<and> concat ?ys ! ?i = ?ys ! j ! k
i < length (concat (x # xs))
length yys = length (x # xs)
?i < length (x # xs) \<Longrightarrow> length (yys ! ?i) = length ((x # xs) ! ?i)

goal (1 subgoal):
 1. (\<And>y ys. yys = y # ys \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (cases yys, auto)
[PROOF STATE]
proof (state)
this:
yys = y # ys

goal (2 subgoals):
 1. \<And>i ys. \<lbrakk>i < length (concat []); length ys = length []; \<And>i. i < length [] \<Longrightarrow> length (ys ! i) = length ([] ! i)\<rbrakk> \<Longrightarrow> \<exists>j k. j < length [] \<and> k < length ([] ! j) \<and> concat [] ! i = [] ! j ! k \<and> concat ys ! i = ys ! j ! k
 2. \<And>a xs i ys. \<lbrakk>\<And>i ys. \<lbrakk>i < length (concat xs); length ys = length xs; \<And>i. i < length xs \<Longrightarrow> length (ys ! i) = length (xs ! i)\<rbrakk> \<Longrightarrow> \<exists>j k. j < length xs \<and> k < length (xs ! j) \<and> concat xs ! i = xs ! j ! k \<and> concat ys ! i = ys ! j ! k; i < length (concat (a # xs)); length ys = length (a # xs); \<And>i. i < length (a # xs) \<Longrightarrow> length (ys ! i) = length ((a # xs) ! i)\<rbrakk> \<Longrightarrow> \<exists>j k. j < length (a # xs) \<and> k < length ((a # xs) ! j) \<and> concat (a # xs) ! i = (a # xs) ! j ! k \<and> concat ys ! i = ys ! j ! k
[PROOF STEP]
note Cons = Cons[unfolded yys]
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i < length (concat xs); length ?ys = length xs; \<And>i. i < length xs \<Longrightarrow> length (?ys ! i) = length (xs ! i)\<rbrakk> \<Longrightarrow> \<exists>j k. j < length xs \<and> k < length (xs ! j) \<and> concat xs ! ?i = xs ! j ! k \<and> concat ?ys ! ?i = ?ys ! j ! k
i < length (concat (x # xs))
length (y # ys) = length (x # xs)
?i < length (x # xs) \<Longrightarrow> length ((y # ys) ! ?i) = length ((x # xs) ! ?i)

goal (2 subgoals):
 1. \<And>i ys. \<lbrakk>i < length (concat []); length ys = length []; \<And>i. i < length [] \<Longrightarrow> length (ys ! i) = length ([] ! i)\<rbrakk> \<Longrightarrow> \<exists>j k. j < length [] \<and> k < length ([] ! j) \<and> concat [] ! i = [] ! j ! k \<and> concat ys ! i = ys ! j ! k
 2. \<And>a xs i ys. \<lbrakk>\<And>i ys. \<lbrakk>i < length (concat xs); length ys = length xs; \<And>i. i < length xs \<Longrightarrow> length (ys ! i) = length (xs ! i)\<rbrakk> \<Longrightarrow> \<exists>j k. j < length xs \<and> k < length (xs ! j) \<and> concat xs ! i = xs ! j ! k \<and> concat ys ! i = ys ! j ! k; i < length (concat (a # xs)); length ys = length (a # xs); \<And>i. i < length (a # xs) \<Longrightarrow> length (ys ! i) = length ((a # xs) ! i)\<rbrakk> \<Longrightarrow> \<exists>j k. j < length (a # xs) \<and> k < length ((a # xs) ! j) \<and> concat (a # xs) ! i = (a # xs) ! j ! k \<and> concat ys ! i = ys ! j ! k
[PROOF STEP]
from Cons(4)[of 0]
[PROOF STATE]
proof (chain)
picking this:
0 < length (x # xs) \<Longrightarrow> length ((y # ys) ! 0) = length ((x # xs) ! 0)
[PROOF STEP]
have [simp]: "length y = length x"
[PROOF STATE]
proof (prove)
using this:
0 < length (x # xs) \<Longrightarrow> length ((y # ys) ! 0) = length ((x # xs) ! 0)

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

goal (2 subgoals):
 1. \<And>i ys. \<lbrakk>i < length (concat []); length ys = length []; \<And>i. i < length [] \<Longrightarrow> length (ys ! i) = length ([] ! i)\<rbrakk> \<Longrightarrow> \<exists>j k. j < length [] \<and> k < length ([] ! j) \<and> concat [] ! i = [] ! j ! k \<and> concat ys ! i = ys ! j ! k
 2. \<And>a xs i ys. \<lbrakk>\<And>i ys. \<lbrakk>i < length (concat xs); length ys = length xs; \<And>i. i < length xs \<Longrightarrow> length (ys ! i) = length (xs ! i)\<rbrakk> \<Longrightarrow> \<exists>j k. j < length xs \<and> k < length (xs ! j) \<and> concat xs ! i = xs ! j ! k \<and> concat ys ! i = ys ! j ! k; i < length (concat (a # xs)); length ys = length (a # xs); \<And>i. i < length (a # xs) \<Longrightarrow> length (ys ! i) = length ((a # xs) ! i)\<rbrakk> \<Longrightarrow> \<exists>j k. j < length (a # xs) \<and> k < length ((a # xs) ! j) \<and> concat (a # xs) ! i = (a # xs) ! j ! k \<and> concat ys ! i = ys ! j ! k
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>j k. j < length (x # xs) \<and> k < length ((x # xs) ! j) \<and> concat (x # xs) ! i = (x # xs) ! j ! k \<and> concat yys ! i = yys ! j ! k
[PROOF STEP]
proof (cases "i < length x")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i < length x \<Longrightarrow> \<exists>j k. j < length (x # xs) \<and> k < length ((x # xs) ! j) \<and> concat (x # xs) ! i = (x # xs) ! j ! k \<and> concat yys ! i = yys ! j ! k
 2. \<not> i < length x \<Longrightarrow> \<exists>j k. j < length (x # xs) \<and> k < length ((x # xs) ! j) \<and> concat (x # xs) ! i = (x # xs) ! j ! k \<and> concat yys ! i = yys ! j ! k
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
i < length x

goal (2 subgoals):
 1. i < length x \<Longrightarrow> \<exists>j k. j < length (x # xs) \<and> k < length ((x # xs) ! j) \<and> concat (x # xs) ! i = (x # xs) ! j ! k \<and> concat yys ! i = yys ! j ! k
 2. \<not> i < length x \<Longrightarrow> \<exists>j k. j < length (x # xs) \<and> k < length ((x # xs) ! j) \<and> concat (x # xs) ! i = (x # xs) ! j ! k \<and> concat yys ! i = yys ! j ! k
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>j k. j < length (x # xs) \<and> k < length ((x # xs) ! j) \<and> concat (x # xs) ! i = (x # xs) ! j ! k \<and> concat yys ! i = yys ! j ! k
[PROOF STEP]
unfolding yys
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>j k. j < length (x # xs) \<and> k < length ((x # xs) ! j) \<and> concat (x # xs) ! i = (x # xs) ! j ! k \<and> concat (y # ys) ! i = (y # ys) ! j ! k
[PROOF STEP]
by (rule exI[of _ 0], rule exI[of _ i], insert True Cons(2-4), auto simp: nth_append)
[PROOF STATE]
proof (state)
this:
\<exists>j k. j < length (x # xs) \<and> k < length ((x # xs) ! j) \<and> concat (x # xs) ! i = (x # xs) ! j ! k \<and> concat yys ! i = yys ! j ! k

goal (1 subgoal):
 1. \<not> i < length x \<Longrightarrow> \<exists>j k. j < length (x # xs) \<and> k < length ((x # xs) ! j) \<and> concat (x # xs) ! i = (x # xs) ! j ! k \<and> concat yys ! i = yys ! j ! k
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> i < length x \<Longrightarrow> \<exists>j k. j < length (x # xs) \<and> k < length ((x # xs) ! j) \<and> concat (x # xs) ! i = (x # xs) ! j ! k \<and> concat yys ! i = yys ! j ! k
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> i < length x

goal (1 subgoal):
 1. \<not> i < length x \<Longrightarrow> \<exists>j k. j < length (x # xs) \<and> k < length ((x # xs) ! j) \<and> concat (x # xs) ! i = (x # xs) ! j ! k \<and> concat yys ! i = yys ! j ! k
[PROOF STEP]
let ?i = "i - length x"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> i < length x \<Longrightarrow> \<exists>j k. j < length (x # xs) \<and> k < length ((x # xs) ! j) \<and> concat (x # xs) ! i = (x # xs) ! j ! k \<and> concat yys ! i = yys ! j ! k
[PROOF STEP]
from False Cons(2-3)
[PROOF STATE]
proof (chain)
picking this:
\<not> i < length x
i < length (concat (x # xs))
length (y # ys) = length (x # xs)
[PROOF STEP]
have "?i < length (concat xs)" "length ys = length xs"
[PROOF STATE]
proof (prove)
using this:
\<not> i < length x
i < length (concat (x # xs))
length (y # ys) = length (x # xs)

goal (1 subgoal):
 1. i - length x < length (concat xs) &&& length ys = length xs
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i - length x < length (concat xs)
length ys = length xs

goal (1 subgoal):
 1. \<not> i < length x \<Longrightarrow> \<exists>j k. j < length (x # xs) \<and> k < length ((x # xs) ! j) \<and> concat (x # xs) ! i = (x # xs) ! j ! k \<and> concat yys ! i = yys ! j ! k
[PROOF STEP]
note IH = Cons(1)[OF this]
[PROOF STATE]
proof (state)
this:
(\<And>i. i < length xs \<Longrightarrow> length (ys ! i) = length (xs ! i)) \<Longrightarrow> \<exists>j k. j < length xs \<and> k < length (xs ! j) \<and> concat xs ! (i - length x) = xs ! j ! k \<and> concat ys ! (i - length x) = ys ! j ! k

goal (1 subgoal):
 1. \<not> i < length x \<Longrightarrow> \<exists>j k. j < length (x # xs) \<and> k < length ((x # xs) ! j) \<and> concat (x # xs) ! i = (x # xs) ! j ! k \<and> concat yys ! i = yys ! j ! k
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
(\<And>i. i < length xs \<Longrightarrow> length (ys ! i) = length (xs ! i)) \<Longrightarrow> \<exists>j k. j < length xs \<and> k < length (xs ! j) \<and> concat xs ! (i - length x) = xs ! j ! k \<and> concat ys ! (i - length x) = ys ! j ! k

goal (1 subgoal):
 1. \<not> i < length x \<Longrightarrow> \<exists>j k. j < length (x # xs) \<and> k < length ((x # xs) ! j) \<and> concat (x # xs) ! i = (x # xs) ! j ! k \<and> concat yys ! i = yys ! j ! k
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> ia__ < length x \<Longrightarrow> \<exists>j k. j < length (x # xs) \<and> k < length ((x # xs) ! j) \<and> concat (x # xs) ! ia__ = (x # xs) ! j ! k \<and> concat yys ! ia__ = yys ! j ! k
[PROOF STEP]
assume "i < length xs"
[PROOF STATE]
proof (state)
this:
i < length xs

goal (1 subgoal):
 1. \<not> ia__ < length x \<Longrightarrow> \<exists>j k. j < length (x # xs) \<and> k < length ((x # xs) ! j) \<and> concat (x # xs) ! ia__ = (x # xs) ! j ! k \<and> concat yys ! ia__ = yys ! j ! k
[PROOF STEP]
with Cons(4)[of "Suc i"]
[PROOF STATE]
proof (chain)
picking this:
Suc i < length (x # xs) \<Longrightarrow> length ((y # ys) ! Suc i) = length ((x # xs) ! Suc i)
i < length xs
[PROOF STEP]
have "length (ys ! i) = length (xs ! i)"
[PROOF STATE]
proof (prove)
using this:
Suc i < length (x # xs) \<Longrightarrow> length ((y # ys) ! Suc i) = length ((x # xs) ! Suc i)
i < length xs

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

goal (1 subgoal):
 1. \<not> ia__ < length x \<Longrightarrow> \<exists>j k. j < length (x # xs) \<and> k < length ((x # xs) ! j) \<and> concat (x # xs) ! ia__ = (x # xs) ! j ! k \<and> concat yys ! ia__ = yys ! j ! k
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?ib2 < length xs \<Longrightarrow> length (ys ! ?ib2) = length (xs ! ?ib2)

goal (1 subgoal):
 1. \<not> i < length x \<Longrightarrow> \<exists>j k. j < length (x # xs) \<and> k < length ((x # xs) ! j) \<and> concat (x # xs) ! i = (x # xs) ! j ! k \<and> concat yys ! i = yys ! j ! k
[PROOF STEP]
from IH[OF this]
[PROOF STATE]
proof (chain)
picking this:
(\<And>i. i < length xs \<Longrightarrow> i < length xs) \<Longrightarrow> \<exists>j k. j < length xs \<and> k < length (xs ! j) \<and> concat xs ! (i - length x) = xs ! j ! k \<and> concat ys ! (i - length x) = ys ! j ! k
[PROOF STEP]
obtain j k where IH1: "j < length xs" "k < length (xs ! j)"
      "concat xs ! ?i = xs ! j ! k"
      "concat ys ! ?i = ys ! j ! k"
[PROOF STATE]
proof (prove)
using this:
(\<And>i. i < length xs \<Longrightarrow> i < length xs) \<Longrightarrow> \<exists>j k. j < length xs \<and> k < length (xs ! j) \<and> concat xs ! (i - length x) = xs ! j ! k \<and> concat ys ! (i - length x) = ys ! j ! k

goal (1 subgoal):
 1. (\<And>j k. \<lbrakk>j < length xs; k < length (xs ! j); concat xs ! (i - length x) = xs ! j ! k; concat ys ! (i - length x) = ys ! j ! k\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
j < length xs
k < length (xs ! j)
concat xs ! (i - length x) = xs ! j ! k
concat ys ! (i - length x) = ys ! j ! k

goal (1 subgoal):
 1. \<not> i < length x \<Longrightarrow> \<exists>j k. j < length (x # xs) \<and> k < length ((x # xs) ! j) \<and> concat (x # xs) ! i = (x # xs) ! j ! k \<and> concat yys ! i = yys ! j ! k
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>j k. j < length (x # xs) \<and> k < length ((x # xs) ! j) \<and> concat (x # xs) ! i = (x # xs) ! j ! k \<and> concat yys ! i = yys ! j ! k
[PROOF STEP]
unfolding yys
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>j k. j < length (x # xs) \<and> k < length ((x # xs) ! j) \<and> concat (x # xs) ! i = (x # xs) ! j ! k \<and> concat (y # ys) ! i = (y # ys) ! j ! k
[PROOF STEP]
by (rule exI[of _ "Suc j"], rule exI[of _ k], insert IH1 False, auto simp: nth_append)
[PROOF STATE]
proof (state)
this:
\<exists>j k. j < length (x # xs) \<and> k < length ((x # xs) ! j) \<and> concat (x # xs) ! i = (x # xs) ! j ! k \<and> concat yys ! i = yys ! j ! k

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>j k. j < length (x # xs) \<and> k < length ((x # xs) ! j) \<and> concat (x # xs) ! i = (x # xs) ! j ! k \<and> concat yys ! i = yys ! j ! k

goal (1 subgoal):
 1. \<And>i ys. \<lbrakk>i < length (concat []); length ys = length []; \<And>i. i < length [] \<Longrightarrow> length (ys ! i) = length ([] ! i)\<rbrakk> \<Longrightarrow> \<exists>j k. j < length [] \<and> k < length ([] ! j) \<and> concat [] ! i = [] ! j ! k \<and> concat ys ! i = ys ! j ! k
[PROOF STEP]
qed simp


[STATEMENT]
lemma dotprod_le:
  assumes "x \<le>\<^sub>v u" and "y \<le>\<^sub>v v"
    and "length y = length x" and "length v = length u"
  shows "x \<bullet> y \<le> u \<bullet> v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<bullet> y \<le> u \<bullet> v
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
x \<le>\<^sub>v u
y \<le>\<^sub>v v
length y = length x
length v = length u

goal (1 subgoal):
 1. x \<bullet> y \<le> u \<bullet> v
[PROOF STEP]
by (metis dotprod_le_left dotprod_le_right le_length le_trans)


[STATEMENT]
lemma exhaust_3:
  fixes x :: 3
  shows "x = 1 \<or> x = 2 \<or> x = 3"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x = 1 \<or> x = 2 \<or> x = 3
[PROOF STEP]
proof (induct x)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>z. \<lbrakk>0 \<le> z; z < int CARD(3)\<rbrakk> \<Longrightarrow> of_int z = 1 \<or> of_int z = 2 \<or> of_int z = 3
[PROOF STEP]
case (of_int z)
[PROOF STATE]
proof (state)
this:
0 \<le> z
z < int CARD(3)

goal (1 subgoal):
 1. \<And>z. \<lbrakk>0 \<le> z; z < int CARD(3)\<rbrakk> \<Longrightarrow> of_int z = 1 \<or> of_int z = 2 \<or> of_int z = 3
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 \<le> z
z < int CARD(3)
[PROOF STEP]
have "0 \<le> z" and "z < 3"
[PROOF STATE]
proof (prove)
using this:
0 \<le> z
z < int CARD(3)

goal (1 subgoal):
 1. 0 \<le> z &&& z < 3
[PROOF STEP]
by simp_all
[PROOF STATE]
proof (state)
this:
0 \<le> z
z < 3

goal (1 subgoal):
 1. \<And>z. \<lbrakk>0 \<le> z; z < int CARD(3)\<rbrakk> \<Longrightarrow> of_int z = 1 \<or> of_int z = 2 \<or> of_int z = 3
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 \<le> z
z < 3
[PROOF STEP]
have "z = 0 \<or> z = 1 \<or> z = 2"
[PROOF STATE]
proof (prove)
using this:
0 \<le> z
z < 3

goal (1 subgoal):
 1. z = 0 \<or> z = 1 \<or> z = 2
[PROOF STEP]
by arith
[PROOF STATE]
proof (state)
this:
z = 0 \<or> z = 1 \<or> z = 2

goal (1 subgoal):
 1. \<And>z. \<lbrakk>0 \<le> z; z < int CARD(3)\<rbrakk> \<Longrightarrow> of_int z = 1 \<or> of_int z = 2 \<or> of_int z = 3
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
z = 0 \<or> z = 1 \<or> z = 2
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
z = 0 \<or> z = 1 \<or> z = 2

goal (1 subgoal):
 1. of_int z = 1 \<or> of_int z = 2 \<or> of_int z = 3
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
of_int z = 1 \<or> of_int z = 2 \<or> of_int z = 3

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sorted_insort1: "sorted (insort1 a xs) = sorted xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted (insort1 a xs) = sorted xs
[PROOF STEP]
apply(induction xs)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. sorted (insort1 a []) = sorted []
 2. \<And>aa xs. sorted (insort1 a xs) = sorted xs \<Longrightarrow> sorted (insort1 a (aa # xs)) = sorted (aa # xs)
[PROOF STEP]
apply(auto simp add: set_insort1)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma construct_add:
  assumes B[simp]: "vs1.independent B"
  shows "construct B (\<lambda>x. f x + g x) v = construct B f v + construct B g v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. construct B (\<lambda>x. f x + g x) v = construct B f v + construct B g v
[PROOF STEP]
proof (rule linear_eq_on)
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. linear (*a) (*b) (construct B (\<lambda>x. f x + g x))
 2. linear (*a) (*b) (\<lambda>a. construct B f a + construct B g a)
 3. v \<in> vs1.span ?B
 4. \<And>b. b \<in> ?B \<Longrightarrow> construct B (\<lambda>x. f x + g x) b = construct B f b + construct B g b
[PROOF STEP]
show "v \<in> vs1.span (vs1.extend_basis B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v \<in> vs1.span (vs1.extend_basis B)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
v \<in> vs1.span (vs1.extend_basis B)

goal (3 subgoals):
 1. linear (*a) (*b) (construct B (\<lambda>x. f x + g x))
 2. linear (*a) (*b) (\<lambda>a. construct B f a + construct B g a)
 3. \<And>b. b \<in> vs1.extend_basis B \<Longrightarrow> construct B (\<lambda>x. f x + g x) b = construct B f b + construct B g b
[PROOF STEP]
show "b \<in> vs1.extend_basis B \<Longrightarrow> construct B (\<lambda>x. f x + g x) b = construct B f b + construct B g b" for b
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b \<in> vs1.extend_basis B \<Longrightarrow> construct B (\<lambda>x. f x + g x) b = construct B f b + construct B g b
[PROOF STEP]
using construct_outside[OF B vs1.span_base, of b]
[PROOF STATE]
proof (prove)
using this:
b \<in> vs1.extend_basis B - B \<Longrightarrow> construct B ?f b = (0::'c)

goal (1 subgoal):
 1. b \<in> vs1.extend_basis B \<Longrightarrow> construct B (\<lambda>x. f x + g x) b = construct B f b + construct B g b
[PROOF STEP]
by (cases "b \<in> B") (auto simp: construct_basis)
[PROOF STATE]
proof (state)
this:
?b \<in> vs1.extend_basis B \<Longrightarrow> construct B (\<lambda>x. f x + g x) ?b = construct B f ?b + construct B g ?b

goal (2 subgoals):
 1. linear (*a) (*b) (construct B (\<lambda>x. f x + g x))
 2. linear (*a) (*b) (\<lambda>a. construct B f a + construct B g a)
[PROOF STEP]
qed (intro linear_compose_add linear_construct B)+


[STATEMENT]
theorem finite_char_closed: \<open>finite_char C \<Longrightarrow> subset_closed C\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite_char C \<Longrightarrow> subset_closed C
[PROOF STEP]
unfolding finite_char_def subset_closed_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>S. (S \<in> C) = (\<forall>S'. finite S' \<longrightarrow> S' \<subseteq> S \<longrightarrow> S' \<in> C) \<Longrightarrow> \<forall>S'\<in>C. \<forall>S\<subseteq>S'. S \<in> C
[PROOF STEP]
proof (intro ballI allI impI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>S' S. \<lbrakk>\<forall>S. (S \<in> C) = (\<forall>S'. finite S' \<longrightarrow> S' \<subseteq> S \<longrightarrow> S' \<in> C); S' \<in> C; S \<subseteq> S'\<rbrakk> \<Longrightarrow> S \<in> C
[PROOF STEP]
fix S S'
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>S' S. \<lbrakk>\<forall>S. (S \<in> C) = (\<forall>S'. finite S' \<longrightarrow> S' \<subseteq> S \<longrightarrow> S' \<in> C); S' \<in> C; S \<subseteq> S'\<rbrakk> \<Longrightarrow> S \<in> C
[PROOF STEP]
assume *: \<open>\<forall>S. (S \<in> C) = (\<forall>S'. finite S' \<longrightarrow> S' \<subseteq> S \<longrightarrow> S' \<in> C)\<close>
    and \<open>S' \<in> C\<close> and \<open>S \<subseteq> S'\<close>
[PROOF STATE]
proof (state)
this:
\<forall>S. (S \<in> C) = (\<forall>S'. finite S' \<longrightarrow> S' \<subseteq> S \<longrightarrow> S' \<in> C)
S' \<in> C
S \<subseteq> S'

goal (1 subgoal):
 1. \<And>S' S. \<lbrakk>\<forall>S. (S \<in> C) = (\<forall>S'. finite S' \<longrightarrow> S' \<subseteq> S \<longrightarrow> S' \<in> C); S' \<in> C; S \<subseteq> S'\<rbrakk> \<Longrightarrow> S \<in> C
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>S. (S \<in> C) = (\<forall>S'. finite S' \<longrightarrow> S' \<subseteq> S \<longrightarrow> S' \<in> C)
S' \<in> C
S \<subseteq> S'
[PROOF STEP]
have \<open>\<forall>S'. finite S' \<longrightarrow> S' \<subseteq> S \<longrightarrow> S' \<in> C\<close>
[PROOF STATE]
proof (prove)
using this:
\<forall>S. (S \<in> C) = (\<forall>S'. finite S' \<longrightarrow> S' \<subseteq> S \<longrightarrow> S' \<in> C)
S' \<in> C
S \<subseteq> S'

goal (1 subgoal):
 1. \<forall>S'. finite S' \<longrightarrow> S' \<subseteq> S \<longrightarrow> S' \<in> C
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<forall>S'. finite S' \<longrightarrow> S' \<subseteq> S \<longrightarrow> S' \<in> C

goal (1 subgoal):
 1. \<And>S' S. \<lbrakk>\<forall>S. (S \<in> C) = (\<forall>S'. finite S' \<longrightarrow> S' \<subseteq> S \<longrightarrow> S' \<in> C); S' \<in> C; S \<subseteq> S'\<rbrakk> \<Longrightarrow> S \<in> C
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>S'. finite S' \<longrightarrow> S' \<subseteq> S \<longrightarrow> S' \<in> C
[PROOF STEP]
show \<open>S \<in> C\<close>
[PROOF STATE]
proof (prove)
using this:
\<forall>S'. finite S' \<longrightarrow> S' \<subseteq> S \<longrightarrow> S' \<in> C

goal (1 subgoal):
 1. S \<in> C
[PROOF STEP]
using *
[PROOF STATE]
proof (prove)
using this:
\<forall>S'. finite S' \<longrightarrow> S' \<subseteq> S \<longrightarrow> S' \<in> C
\<forall>S. (S \<in> C) = (\<forall>S'. finite S' \<longrightarrow> S' \<subseteq> S \<longrightarrow> S' \<in> C)

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma has_derivativeI_sandwich:
  assumes e: "0 < e"
    and bounded: "bounded_linear f'"
    and sandwich: "(\<And>y. y \<in> s \<Longrightarrow> y \<noteq> x \<Longrightarrow> dist y x < e \<Longrightarrow>
      norm ((f y - f x) - f' (y - x)) / norm (y - x) \<le> H y)"
    and "(H \<longlongrightarrow> 0) (at x within s)"
  shows "(f has_derivative f') (at x within s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f has_derivative f') (at x within s)
[PROOF STEP]
unfolding has_derivative_iff_norm
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bounded_linear f' \<and> ((\<lambda>y. norm (f y - f x - f' (y - x)) / norm (y - x)) \<longlongrightarrow> 0) (at x within s)
[PROOF STEP]
proof safe
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. bounded_linear f'
 2. ((\<lambda>y. norm (f y - f x - f' (y - x)) / norm (y - x)) \<longlongrightarrow> 0) (at x within s)
[PROOF STEP]
show "((\<lambda>y. norm (f y - f x - f' (y - x)) / norm (y - x)) \<longlongrightarrow> 0) (at x within s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>y. norm (f y - f x - f' (y - x)) / norm (y - x)) \<longlongrightarrow> 0) (at x within s)
[PROOF STEP]
proof (rule tendsto_sandwich[where f="\<lambda>x. 0"])
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. \<forall>\<^sub>F n in at x within s. 0 \<le> norm (f n - f x - f' (n - x)) / norm (n - x)
 2. \<forall>\<^sub>F n in at x within s. norm (f n - f x - f' (n - x)) / norm (n - x) \<le> ?h n
 3. ((\<lambda>x. 0) \<longlongrightarrow> 0) (at x within s)
 4. (?h \<longlongrightarrow> 0) (at x within s)
[PROOF STEP]
show "(H \<longlongrightarrow> 0) (at x within s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (H \<longlongrightarrow> 0) (at x within s)
[PROOF STEP]
by fact
[PROOF STATE]
proof (state)
this:
(H \<longlongrightarrow> 0) (at x within s)

goal (3 subgoals):
 1. \<forall>\<^sub>F n in at x within s. 0 \<le> norm (f n - f x - f' (n - x)) / norm (n - x)
 2. \<forall>\<^sub>F n in at x within s. norm (f n - f x - f' (n - x)) / norm (n - x) \<le> H n
 3. ((\<lambda>x. 0) \<longlongrightarrow> 0) (at x within s)
[PROOF STEP]
show "eventually (\<lambda>n. norm (f n - f x - f' (n - x)) / norm (n - x) \<le> H n) (at x within s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F n in at x within s. norm (f n - f x - f' (n - x)) / norm (n - x) \<le> H n
[PROOF STEP]
unfolding eventually_at
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>d>0. \<forall>xa\<in>s. xa \<noteq> x \<and> dist xa x < d \<longrightarrow> norm (f xa - f x - f' (xa - x)) / norm (xa - x) \<le> H xa
[PROOF STEP]
using e sandwich
[PROOF STATE]
proof (prove)
using this:
0 < e
\<lbrakk>?y \<in> s; ?y \<noteq> x; dist ?y x < e\<rbrakk> \<Longrightarrow> norm (f ?y - f x - f' (?y - x)) / norm (?y - x) \<le> H ?y

goal (1 subgoal):
 1. \<exists>d>0. \<forall>xa\<in>s. xa \<noteq> x \<and> dist xa x < d \<longrightarrow> norm (f xa - f x - f' (xa - x)) / norm (xa - x) \<le> H xa
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F n in at x within s. norm (f n - f x - f' (n - x)) / norm (n - x) \<le> H n

goal (2 subgoals):
 1. \<forall>\<^sub>F n in at x within s. 0 \<le> norm (f n - f x - f' (n - x)) / norm (n - x)
 2. ((\<lambda>x. 0) \<longlongrightarrow> 0) (at x within s)
[PROOF STEP]
qed (auto simp: le_divide_eq)
[PROOF STATE]
proof (state)
this:
((\<lambda>y. norm (f y - f x - f' (y - x)) / norm (y - x)) \<longlongrightarrow> 0) (at x within s)

goal (1 subgoal):
 1. bounded_linear f'
[PROOF STEP]
qed fact


[STATEMENT]
lemma rep_comp:
    assumes "seq g f"
    shows "rep (g \<cdot> f) = \<^bold>\<parallel>rep g \<^bold>\<cdot> rep f\<^bold>\<parallel>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rep (g \<cdot> f) = \<^bold>\<parallel>rep g \<^bold>\<cdot> rep f\<^bold>\<parallel>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. rep (g \<cdot> f) = \<^bold>\<parallel>rep g \<^bold>\<cdot> rep f\<^bold>\<parallel>
[PROOF STEP]
have "rep (g \<cdot> f) = rep (mkarr (rep g \<^bold>\<cdot> rep f))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rep (g \<cdot> f) = rep (mkarr (rep g \<^bold>\<cdot> rep f))
[PROOF STEP]
using assms comp_char
[PROOF STATE]
proof (prove)
using this:
seq g f
?f \<cdot> ?g = (if seq ?f ?g then mkarr (rep ?f \<^bold>\<cdot> rep ?g) else null)

goal (1 subgoal):
 1. rep (g \<cdot> f) = rep (mkarr (rep g \<^bold>\<cdot> rep f))
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
rep (g \<cdot> f) = rep (mkarr (rep g \<^bold>\<cdot> rep f))

goal (1 subgoal):
 1. rep (g \<cdot> f) = \<^bold>\<parallel>rep g \<^bold>\<cdot> rep f\<^bold>\<parallel>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
rep (g \<cdot> f) = rep (mkarr (rep g \<^bold>\<cdot> rep f))

goal (1 subgoal):
 1. rep (g \<cdot> f) = \<^bold>\<parallel>rep g \<^bold>\<cdot> rep f\<^bold>\<parallel>
[PROOF STEP]
have "... = \<^bold>\<parallel>rep g \<^bold>\<cdot> rep f\<^bold>\<parallel>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rep (mkarr (rep g \<^bold>\<cdot> rep f)) = \<^bold>\<parallel>rep g \<^bold>\<cdot> rep f\<^bold>\<parallel>
[PROOF STEP]
using assms rep_preserves_seq rep_mkarr
[PROOF STATE]
proof (prove)
using this:
seq g f
seq ?g ?f \<Longrightarrow> Seq (rep ?g) (rep ?f)
Arr ?f \<Longrightarrow> rep (mkarr ?f) = \<^bold>\<parallel>?f\<^bold>\<parallel>

goal (1 subgoal):
 1. rep (mkarr (rep g \<^bold>\<cdot> rep f)) = \<^bold>\<parallel>rep g \<^bold>\<cdot> rep f\<^bold>\<parallel>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
rep (mkarr (rep g \<^bold>\<cdot> rep f)) = \<^bold>\<parallel>rep g \<^bold>\<cdot> rep f\<^bold>\<parallel>

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

goal (1 subgoal):
 1. rep (g \<cdot> f) = \<^bold>\<parallel>rep g \<^bold>\<cdot> rep f\<^bold>\<parallel>
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
rep (g \<cdot> f) = \<^bold>\<parallel>rep g \<^bold>\<cdot> rep f\<^bold>\<parallel>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma n_pow_n_le_fact_square: "n ^ n \<le> (fact n)^2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n ^ n \<le> (fact n)\<^sup>2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n ^ n \<le> (fact n)\<^sup>2
[PROOF STEP]
define ii where "ii (i :: nat) = (n + 1 - i)" for i
[PROOF STATE]
proof (state)
this:
ii ?i = n + 1 - ?i

goal (1 subgoal):
 1. n ^ n \<le> (fact n)\<^sup>2
[PROOF STEP]
have id: "ii ` {1..n} = {1..n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ii ` {1..n} = {1..n}
[PROOF STEP]
unfolding ii_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (-) (n + 1) ` {1..n} = {1..n}
[PROOF STEP]
proof (auto, goal_cases)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>Suc 0 \<le> x; x \<le> n\<rbrakk> \<Longrightarrow> x \<in> (-) (Suc n) ` {Suc 0..n}
[PROOF STEP]
case (1 i)
[PROOF STATE]
proof (state)
this:
Suc 0 \<le> i
i \<le> n

goal (1 subgoal):
 1. \<And>x. \<lbrakk>Suc 0 \<le> x; x \<le> n\<rbrakk> \<Longrightarrow> x \<in> (-) (Suc n) ` {Suc 0..n}
[PROOF STEP]
hence i: "i = (-) (Suc n) (ii i)"
[PROOF STATE]
proof (prove)
using this:
Suc 0 \<le> i
i \<le> n

goal (1 subgoal):
 1. i = Suc n - ii i
[PROOF STEP]
unfolding ii_def
[PROOF STATE]
proof (prove)
using this:
Suc 0 \<le> i
i \<le> n

goal (1 subgoal):
 1. i = Suc n - (n + 1 - i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i = Suc n - ii i

goal (1 subgoal):
 1. \<And>x. \<lbrakk>Suc 0 \<le> x; x \<le> n\<rbrakk> \<Longrightarrow> x \<in> (-) (Suc n) ` {Suc 0..n}
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i \<in> (-) (Suc n) ` {Suc 0..n}
[PROOF STEP]
by (subst i, rule imageI, insert 1, auto simp: ii_def)
[PROOF STATE]
proof (state)
this:
i \<in> (-) (Suc n) ` {Suc 0..n}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
ii ` {1..n} = {1..n}

goal (1 subgoal):
 1. n ^ n \<le> (fact n)\<^sup>2
[PROOF STEP]
have "(fact n) = (\<Prod>{1..n})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fact n = \<Prod>{1..n}
[PROOF STEP]
by (simp add: fact_prod)
[PROOF STATE]
proof (state)
this:
fact n = \<Prod>{1..n}

goal (1 subgoal):
 1. n ^ n \<le> (fact n)\<^sup>2
[PROOF STEP]
hence "(fact n)^2 = ((\<Prod>{1..n}) * (\<Prod>{1..n}))"
[PROOF STATE]
proof (prove)
using this:
fact n = \<Prod>{1..n}

goal (1 subgoal):
 1. (fact n)\<^sup>2 = \<Prod>{1..n} * \<Prod>{1..n}
[PROOF STEP]
by (auto simp: power2_eq_square)
[PROOF STATE]
proof (state)
this:
(fact n)\<^sup>2 = \<Prod>{1..n} * \<Prod>{1..n}

goal (1 subgoal):
 1. n ^ n \<le> (fact n)\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(fact n)\<^sup>2 = \<Prod>{1..n} * \<Prod>{1..n}

goal (1 subgoal):
 1. n ^ n \<le> (fact n)\<^sup>2
[PROOF STEP]
have "\<dots> = ((\<Prod>{1..n}) * prod (\<lambda> i. i) (ii ` {1..n}))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Prod>{1..n} * \<Prod>{1..n} = \<Prod>{1..n} * \<Prod>(ii ` {1..n})
[PROOF STEP]
by (rule arg_cong[of _ _ "\<lambda> x. (_ * x)"], rule prod.cong[OF id[symmetric]], auto)
[PROOF STATE]
proof (state)
this:
\<Prod>{1..n} * \<Prod>{1..n} = \<Prod>{1..n} * \<Prod>(ii ` {1..n})

goal (1 subgoal):
 1. n ^ n \<le> (fact n)\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<Prod>{1..n} * \<Prod>{1..n} = \<Prod>{1..n} * \<Prod>(ii ` {1..n})

goal (1 subgoal):
 1. n ^ n \<le> (fact n)\<^sup>2
[PROOF STEP]
have "\<dots> = ((\<Prod>{1..n}) * prod ii {1..n})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Prod>{1..n} * \<Prod>(ii ` {1..n}) = \<Prod>{1..n} * prod ii {1..n}
[PROOF STEP]
by (subst prod.reindex, auto simp: ii_def inj_on_def)
[PROOF STATE]
proof (state)
this:
\<Prod>{1..n} * \<Prod>(ii ` {1..n}) = \<Prod>{1..n} * prod ii {1..n}

goal (1 subgoal):
 1. n ^ n \<le> (fact n)\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<Prod>{1..n} * \<Prod>(ii ` {1..n}) = \<Prod>{1..n} * prod ii {1..n}

goal (1 subgoal):
 1. n ^ n \<le> (fact n)\<^sup>2
[PROOF STEP]
have "\<dots> = (prod (\<lambda> i. i * ii i) {1..n})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Prod>{1..n} * prod ii {1..n} = (\<Prod>i = 1..n. i * ii i)
[PROOF STEP]
by (subst prod.distrib, auto)
[PROOF STATE]
proof (state)
this:
\<Prod>{1..n} * prod ii {1..n} = (\<Prod>i = 1..n. i * ii i)

goal (1 subgoal):
 1. n ^ n \<le> (fact n)\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<Prod>{1..n} * prod ii {1..n} = (\<Prod>i = 1..n. i * ii i)

goal (1 subgoal):
 1. n ^ n \<le> (fact n)\<^sup>2
[PROOF STEP]
have "\<dots> \<ge> (prod (\<lambda> i. n) {1..n})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>i = 1..n. n) \<le> (\<Prod>i = 1..n. i * ii i)
[PROOF STEP]
proof (intro prod_mono conjI, simp)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i \<in> {1..n} \<Longrightarrow> n \<le> i * ii i
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i \<in> {1..n} \<Longrightarrow> n \<le> i * ii i
[PROOF STEP]
assume i: "i \<in> {1 .. n}"
[PROOF STATE]
proof (state)
this:
i \<in> {1..n}

goal (1 subgoal):
 1. \<And>i. i \<in> {1..n} \<Longrightarrow> n \<le> i * ii i
[PROOF STEP]
let ?j = "ii i"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i \<in> {1..n} \<Longrightarrow> n \<le> i * ii i
[PROOF STEP]
show "n \<le> i * ?j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n \<le> i * ii i
[PROOF STEP]
proof (cases "i = 1 \<or> i = n")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. i = 1 \<or> i = n \<Longrightarrow> n \<le> i * ii i
 2. \<not> (i = 1 \<or> i = n) \<Longrightarrow> n \<le> i * ii i
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
i = 1 \<or> i = n

goal (2 subgoals):
 1. i = 1 \<or> i = n \<Longrightarrow> n \<le> i * ii i
 2. \<not> (i = 1 \<or> i = n) \<Longrightarrow> n \<le> i * ii i
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
i = 1 \<or> i = n

goal (1 subgoal):
 1. n \<le> i * ii i
[PROOF STEP]
unfolding ii_def
[PROOF STATE]
proof (prove)
using this:
i = 1 \<or> i = n

goal (1 subgoal):
 1. n \<le> i * (n + 1 - i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
n \<le> i * ii i

goal (1 subgoal):
 1. \<not> (i = 1 \<or> i = n) \<Longrightarrow> n \<le> i * ii i
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> (i = 1 \<or> i = n) \<Longrightarrow> n \<le> i * ii i
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> (i = 1 \<or> i = n)

goal (1 subgoal):
 1. \<not> (i = 1 \<or> i = n) \<Longrightarrow> n \<le> i * ii i
[PROOF STEP]
hence min: "min i ?j \<ge> 2"
[PROOF STATE]
proof (prove)
using this:
\<not> (i = 1 \<or> i = n)

goal (1 subgoal):
 1. 2 \<le> min i (ii i)
[PROOF STEP]
using i
[PROOF STATE]
proof (prove)
using this:
\<not> (i = 1 \<or> i = n)
i \<in> {1..n}

goal (1 subgoal):
 1. 2 \<le> min i (ii i)
[PROOF STEP]
by (auto simp: ii_def)
[PROOF STATE]
proof (state)
this:
2 \<le> min i (ii i)

goal (1 subgoal):
 1. \<not> (i = 1 \<or> i = n) \<Longrightarrow> n \<le> i * ii i
[PROOF STEP]
have max: "n \<le> 2 * max i ?j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n \<le> 2 * max i (ii i)
[PROOF STEP]
using i
[PROOF STATE]
proof (prove)
using this:
i \<in> {1..n}

goal (1 subgoal):
 1. n \<le> 2 * max i (ii i)
[PROOF STEP]
by (auto simp: ii_def)
[PROOF STATE]
proof (state)
this:
n \<le> 2 * max i (ii i)

goal (1 subgoal):
 1. \<not> (i = 1 \<or> i = n) \<Longrightarrow> n \<le> i * ii i
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
n \<le> 2 * max i (ii i)

goal (1 subgoal):
 1. \<not> (i = 1 \<or> i = n) \<Longrightarrow> n \<le> i * ii i
[PROOF STEP]
have "\<dots> \<le> min i ?j * max i ?j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * max i (ii i) \<le> min i (ii i) * max i (ii i)
[PROOF STEP]
using min
[PROOF STATE]
proof (prove)
using this:
2 \<le> min i (ii i)

goal (1 subgoal):
 1. 2 * max i (ii i) \<le> min i (ii i) * max i (ii i)
[PROOF STEP]
by (intro mult_mono, auto)
[PROOF STATE]
proof (state)
this:
2 * max i (ii i) \<le> min i (ii i) * max i (ii i)

goal (1 subgoal):
 1. \<not> (i = 1 \<or> i = n) \<Longrightarrow> n \<le> i * ii i
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 * max i (ii i) \<le> min i (ii i) * max i (ii i)

goal (1 subgoal):
 1. \<not> (i = 1 \<or> i = n) \<Longrightarrow> n \<le> i * ii i
[PROOF STEP]
have "\<dots> = i * ?j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. min i (ii i) * max i (ii i) = i * ii i
[PROOF STEP]
by (cases "i < ?j", auto simp: ac_simps)
[PROOF STATE]
proof (state)
this:
min i (ii i) * max i (ii i) = i * ii i

goal (1 subgoal):
 1. \<not> (i = 1 \<or> i = n) \<Longrightarrow> n \<le> i * ii i
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
n \<le> i * ii i
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
n \<le> i * ii i

goal (1 subgoal):
 1. n \<le> i * ii i
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
n \<le> i * ii i

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
n \<le> i * ii i

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Prod>i = 1..n. n) \<le> (\<Prod>i = 1..n. i * ii i)

goal (1 subgoal):
 1. n ^ n \<le> (fact n)\<^sup>2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Prod>i = 1..n. n) \<le> (fact n)\<^sup>2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Prod>i = 1..n. n) \<le> (fact n)\<^sup>2

goal (1 subgoal):
 1. n ^ n \<le> (fact n)\<^sup>2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
n ^ n \<le> (fact n)\<^sup>2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma suminf_cmult_ereal:
  fixes f g :: "nat \<Rightarrow> ereal"
  assumes "\<And>i. 0 \<le> f i"
    and "0 \<le> a"
  shows "(\<Sum>i. a * f i) = a * suminf f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i. a * f i) = a * suminf f
[PROOF STEP]
by (auto simp: sum_ereal_right_distrib[symmetric] assms
       ereal_zero_le_0_iff sum_nonneg suminf_ereal_eq_SUP
       intro!: SUP_ereal_mult_left)


[STATEMENT]
lemma gcd_exp [simp]:
  "gcd (a ^ n) (b ^ n) = gcd a b ^ n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcd (a ^ n) (b ^ n) = gcd a b ^ n
[PROOF STEP]
using gcd_exp_weak[of a n b]
[PROOF STATE]
proof (prove)
using this:
gcd (a ^ n) (b ^ n) = normalize (gcd a b ^ n)

goal (1 subgoal):
 1. gcd (a ^ n) (b ^ n) = gcd a b ^ n
[PROOF STEP]
by (simp add: normalize_power)


[STATEMENT]
lemma from_nat_inj: assumes i: "i < CARD('a :: finite)"
  and j: "j < CARD('a :: finite)"
  and id: "(from_nat i :: 'a) = from_nat j"
  shows "i = j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i = j
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. i = j
[PROOF STEP]
from arg_cong[OF id, of to_nat]
[PROOF STATE]
proof (chain)
picking this:
to_nat (from_nat i) = to_nat (from_nat j)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
to_nat (from_nat i) = to_nat (from_nat j)

goal (1 subgoal):
 1. i = j
[PROOF STEP]
using i j
[PROOF STATE]
proof (prove)
using this:
to_nat (from_nat i) = to_nat (from_nat j)
i < CARD('a)
j < CARD('a)

goal (1 subgoal):
 1. i = j
[PROOF STEP]
by (simp add: to_nat_from_nat_id)
[PROOF STATE]
proof (state)
this:
i = j

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma minSetOfComponentsTestL2p1:
"minSetOfComponents level2 {data10, data13} = {sS1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. minSetOfComponents level2 {data10, data13} = {sS1}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. minSetOfComponents level2 {data10, data13} = {sS1}
[PROOF STEP]
have outL2:"outSetOfComponents level2 {data10, data13} = {sS1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. outSetOfComponents level2 {data10, data13} = {sS1}
[PROOF STEP]
by (simp add: outSetOfComponents_def  AbstrLevel2, auto)
[PROOF STATE]
proof (state)
this:
outSetOfComponents level2 {data10, data13} = {sS1}

goal (1 subgoal):
 1. minSetOfComponents level2 {data10, data13} = {sS1}
[PROOF STEP]
have "Sources level2 sS1 = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Sources level2 sS1 = {}
[PROOF STEP]
by (simp add: SourcesS1_L2)
[PROOF STATE]
proof (state)
this:
Sources level2 sS1 = {}

goal (1 subgoal):
 1. minSetOfComponents level2 {data10, data13} = {sS1}
[PROOF STEP]
with outL2
[PROOF STATE]
proof (chain)
picking this:
outSetOfComponents level2 {data10, data13} = {sS1}
Sources level2 sS1 = {}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
outSetOfComponents level2 {data10, data13} = {sS1}
Sources level2 sS1 = {}

goal (1 subgoal):
 1. minSetOfComponents level2 {data10, data13} = {sS1}
[PROOF STEP]
by (simp add:  minSetOfComponents_def)
[PROOF STATE]
proof (state)
this:
minSetOfComponents level2 {data10, data13} = {sS1}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma summable_norm_comparison_test:
  "\<exists>N. \<forall>n\<ge>N. norm (f n) \<le> g n \<Longrightarrow> summable g \<Longrightarrow> summable (\<lambda>n. norm (f n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<exists>N. \<forall>n\<ge>N. norm (f n) \<le> g n; summable g\<rbrakk> \<Longrightarrow> summable (\<lambda>n. norm (f n))
[PROOF STEP]
by (rule summable_comparison_test) auto


[STATEMENT]
lemma hom_mult_eq_zero: assumes "x * y = 0" shows "hom x * hom y = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. hom x * hom y = (0::'b)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. hom x * hom y = (0::'b)
[PROOF STEP]
have "0 = x * y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0::'a) = x * y
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
x * y = (0::'a)

goal (1 subgoal):
 1. (0::'a) = x * y
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
(0::'a) = x * y

goal (1 subgoal):
 1. hom x * hom y = (0::'b)
[PROOF STEP]
hence "hom 0 = hom (x * y)"
[PROOF STATE]
proof (prove)
using this:
(0::'a) = x * y

goal (1 subgoal):
 1. hom (0::'a) = hom (x * y)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
hom (0::'a) = hom (x * y)

goal (1 subgoal):
 1. hom x * hom y = (0::'b)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
hom (0::'a) = hom (x * y)

goal (1 subgoal):
 1. hom x * hom y = (0::'b)
[PROOF STEP]
by (auto simp:hom_distribs)
[PROOF STATE]
proof (state)
this:
hom x * hom y = (0::'b)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma arg_Im_sgn:
  assumes "\<not> is_real z"
  shows "sgn (Arg z) = sgn (Im z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sgn (Arg z) = sgn (Im z)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. sgn (Arg z) = sgn (Im z)
[PROOF STEP]
have "z \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z \<noteq> 0
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
Im z \<noteq> 0

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

goal (1 subgoal):
 1. sgn (Arg z) = sgn (Im z)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
z \<noteq> 0
[PROOF STEP]
obtain r \<phi> where polar: "z = cor r * cis \<phi>" "\<phi> = Arg z" "r > 0"
[PROOF STATE]
proof (prove)
using this:
z \<noteq> 0

goal (1 subgoal):
 1. (\<And>r \<phi>. \<lbrakk>z = cor r * cis \<phi>; \<phi> = Arg z; 0 < r\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (smt cmod_cis mult_eq_0_iff norm_ge_zero of_real_0)
[PROOF STATE]
proof (state)
this:
z = cor r * cis \<phi>
\<phi> = Arg z
0 < r

goal (1 subgoal):
 1. sgn (Arg z) = sgn (Im z)
[PROOF STEP]
hence "Im z = r * sin \<phi>"
[PROOF STATE]
proof (prove)
using this:
z = cor r * cis \<phi>
\<phi> = Arg z
0 < r

goal (1 subgoal):
 1. Im z = r * sin \<phi>
[PROOF STEP]
by (metis Im_mult_real Re_complex_of_real cis.simps(2) Im_complex_of_real)
[PROOF STATE]
proof (state)
this:
Im z = r * sin \<phi>

goal (1 subgoal):
 1. sgn (Arg z) = sgn (Im z)
[PROOF STEP]
hence  "Im z > 0 \<longleftrightarrow> sin \<phi> > 0" "Im z < 0 \<longleftrightarrow> sin \<phi> < 0"
[PROOF STATE]
proof (prove)
using this:
Im z = r * sin \<phi>

goal (1 subgoal):
 1. (0 < Im z) = (0 < sin \<phi>) &&& (Im z < 0) = (sin \<phi> < 0)
[PROOF STEP]
using \<open>r > 0\<close>
[PROOF STATE]
proof (prove)
using this:
Im z = r * sin \<phi>
0 < r

goal (1 subgoal):
 1. (0 < Im z) = (0 < sin \<phi>) &&& (Im z < 0) = (sin \<phi> < 0)
[PROOF STEP]
using mult_pos_pos mult_nonneg_nonneg zero_less_mult_pos mult_less_cancel_left
[PROOF STATE]
proof (prove)
using this:
Im z = r * sin \<phi>
0 < r
\<lbrakk>(0::?'a) < ?a; (0::?'a) < ?b\<rbrakk> \<Longrightarrow> (0::?'a) < ?a * ?b
\<lbrakk>(0::?'a) \<le> ?a; (0::?'a) \<le> ?b\<rbrakk> \<Longrightarrow> (0::?'a) \<le> ?a * ?b
\<lbrakk>(0::?'a) < ?a * ?b; (0::?'a) < ?a\<rbrakk> \<Longrightarrow> (0::?'a) < ?b
(?c * ?a < ?c * ?b) = (((0::?'a) \<le> ?c \<longrightarrow> ?a < ?b) \<and> (?c \<le> (0::?'a) \<longrightarrow> ?b < ?a))

goal (1 subgoal):
 1. (0 < Im z) = (0 < sin \<phi>) &&& (Im z < 0) = (sin \<phi> < 0)
[PROOF STEP]
by smt+
[PROOF STATE]
proof (state)
this:
(0 < Im z) = (0 < sin \<phi>)
(Im z < 0) = (sin \<phi> < 0)

goal (1 subgoal):
 1. sgn (Arg z) = sgn (Im z)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(0 < Im z) = (0 < sin \<phi>)
(Im z < 0) = (sin \<phi> < 0)

goal (1 subgoal):
 1. sgn (Arg z) = sgn (Im z)
[PROOF STEP]
have "\<phi> \<noteq> pi" "\<phi> \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<phi> \<noteq> pi &&& \<phi> \<noteq> 0
[PROOF STEP]
using \<open>\<not> is_real z\<close> polar cis_pi
[PROOF STATE]
proof (prove)
using this:
Im z \<noteq> 0
z = cor r * cis \<phi>
\<phi> = Arg z
0 < r
cis pi = - 1

goal (1 subgoal):
 1. \<phi> \<noteq> pi &&& \<phi> \<noteq> 0
[PROOF STEP]
by force+
[PROOF STATE]
proof (state)
this:
\<phi> \<noteq> pi
\<phi> \<noteq> 0

goal (1 subgoal):
 1. sgn (Arg z) = sgn (Im z)
[PROOF STEP]
hence "sin \<phi> > 0 \<longleftrightarrow> \<phi> > 0" "\<phi> < 0 \<longleftrightarrow> sin \<phi> < 0"
[PROOF STATE]
proof (prove)
using this:
\<phi> \<noteq> pi
\<phi> \<noteq> 0

goal (1 subgoal):
 1. (0 < sin \<phi>) = (0 < \<phi>) &&& (\<phi> < 0) = (sin \<phi> < 0)
[PROOF STEP]
using \<open>\<phi> = Arg z\<close> \<open>\<phi> \<noteq> 0\<close> \<open>\<phi> \<noteq> pi\<close>
[PROOF STATE]
proof (prove)
using this:
\<phi> \<noteq> pi
\<phi> \<noteq> 0
\<phi> = Arg z
\<phi> \<noteq> 0
\<phi> \<noteq> pi

goal (1 subgoal):
 1. (0 < sin \<phi>) = (0 < \<phi>) &&& (\<phi> < 0) = (sin \<phi> < 0)
[PROOF STEP]
using Arg_bounded[of z]
[PROOF STATE]
proof (prove)
using this:
\<phi> \<noteq> pi
\<phi> \<noteq> 0
\<phi> = Arg z
\<phi> \<noteq> 0
\<phi> \<noteq> pi
- pi < Arg z \<and> Arg z \<le> pi

goal (1 subgoal):
 1. (0 < sin \<phi>) = (0 < \<phi>) &&& (\<phi> < 0) = (sin \<phi> < 0)
[PROOF STEP]
by (smt sin_gt_zero sin_le_zero sin_pi_minus sin_0_iff_canon sin_ge_zero)+
[PROOF STATE]
proof (state)
this:
(0 < sin \<phi>) = (0 < \<phi>)
(\<phi> < 0) = (sin \<phi> < 0)

goal (1 subgoal):
 1. sgn (Arg z) = sgn (Im z)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(0 < Im z) = (0 < sin \<phi>)
(Im z < 0) = (sin \<phi> < 0)
(0 < sin \<phi>) = (0 < \<phi>)
(\<phi> < 0) = (sin \<phi> < 0)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(0 < Im z) = (0 < sin \<phi>)
(Im z < 0) = (sin \<phi> < 0)
(0 < sin \<phi>) = (0 < \<phi>)
(\<phi> < 0) = (sin \<phi> < 0)

goal (1 subgoal):
 1. sgn (Arg z) = sgn (Im z)
[PROOF STEP]
using \<open>\<phi> = Arg z\<close>
[PROOF STATE]
proof (prove)
using this:
(0 < Im z) = (0 < sin \<phi>)
(Im z < 0) = (sin \<phi> < 0)
(0 < sin \<phi>) = (0 < \<phi>)
(\<phi> < 0) = (sin \<phi> < 0)
\<phi> = Arg z

goal (1 subgoal):
 1. sgn (Arg z) = sgn (Im z)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
sgn (Arg z) = sgn (Im z)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma nonzero_of_rat_inverse: "a \<noteq> 0 \<Longrightarrow> of_rat (inverse a) = inverse (of_rat a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<noteq> 0 \<Longrightarrow> of_rat (inverse a) = inverse (of_rat a)
[PROOF STEP]
by (rule inverse_unique [symmetric]) (simp add: of_rat_mult [symmetric])


[STATEMENT]
lemma inorder_insert:
  "sorted (inorder t) \<Longrightarrow> inorder (insert x t) = ins_list x (inorder t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Sorted_Less.sorted (Tree2.inorder t) \<Longrightarrow> Tree2.inorder (Interval_Tree.insert x t) = ins_list x (Tree2.inorder t)
[PROOF STEP]
by (induct t rule: tree2_induct) (auto simp: ins_list_simps)


[STATEMENT]
lemma cf_rcomp_ObjMap_app[cat_cs_simps]:
  assumes "category \<alpha> \<BB>"
    and "\<GG> : \<AA> \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<CC>"
    and "b \<in>\<^sub>\<circ> \<BB>\<lparr>Obj\<rparr>"
    and "a \<in>\<^sub>\<circ> \<AA>\<lparr>Obj\<rparr>"
  shows "cf_rcomp \<BB> \<SS> \<GG>\<lparr>ObjMap\<rparr>\<lparr>b, a\<rparr>\<^sub>\<bullet> = \<SS>\<lparr>ObjMap\<rparr>\<lparr>b, \<GG>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr>\<rparr>\<^sub>\<bullet>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b \<otimes>\<^sub>H\<^sub>M\<^sub>.\<^sub>O\<^bsub>cf_rcomp \<BB> \<SS> \<GG>\<^esub> a = b \<otimes>\<^sub>H\<^sub>M\<^sub>.\<^sub>O\<^bsub>\<SS>\<^esub> \<GG>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr>
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
category \<alpha> \<BB>
\<GG> : \<AA> \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<CC>
b \<in>\<^sub>\<circ> \<BB>\<lparr>Obj\<rparr>
a \<in>\<^sub>\<circ> \<AA>\<lparr>Obj\<rparr>

goal (1 subgoal):
 1. b \<otimes>\<^sub>H\<^sub>M\<^sub>.\<^sub>O\<^bsub>cf_rcomp \<BB> \<SS> \<GG>\<^esub> a = b \<otimes>\<^sub>H\<^sub>M\<^sub>.\<^sub>O\<^bsub>\<SS>\<^esub> \<GG>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr>
[PROOF STEP]
unfolding cf_rcomp_def
[PROOF STATE]
proof (prove)
using this:
category \<alpha> \<BB>
\<GG> : \<AA> \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<CC>
b \<in>\<^sub>\<circ> \<BB>\<lparr>Obj\<rparr>
a \<in>\<^sub>\<circ> \<AA>\<lparr>Obj\<rparr>

goal (1 subgoal):
 1. b \<otimes>\<^sub>H\<^sub>M\<^sub>.\<^sub>O\<^bsub>cf_bcomp \<SS> (dghm_id \<BB>) \<GG>\<^esub> a = b \<otimes>\<^sub>H\<^sub>M\<^sub>.\<^sub>O\<^bsub>\<SS>\<^esub> \<GG>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr>
[PROOF STEP]
by (cs_concl cs_simp: cat_cs_simps cs_intro: cat_cs_intros cat_prod_cs_intros)


[STATEMENT]
lemma mset_ran_subst_inside: "finite r \<Longrightarrow> i\<in>r \<Longrightarrow> mset_ran (a(i:=x)) r = mset_ran a r + {#x#} - {#a i#}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite r; i \<in> r\<rbrakk> \<Longrightarrow> mset_ran (a(i := x)) r = mset_ran a r + {#x#} - {#a i#}
[PROOF STEP]
unfolding mset_ran_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite r; i \<in> r\<rbrakk> \<Longrightarrow> image_mset (a(i := x)) (mset_set r) = image_mset a (mset_set r) + {#x#} - {#a i#}
[PROOF STEP]
by (auto simp: image_mset_set_subst_inside)


[STATEMENT]
lemma vec_to_iarray_column[code_unfold]: "vec_to_iarray (column i A) = column_iarray (to_nat i) (matrix_to_iarray A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_to_iarray (column i A) = column_iarray (mod_type_class.to_nat i) (matrix_to_iarray A)
[PROOF STEP]
unfolding column_def vec_to_iarray_def column_iarray_def length_eq_card_rows
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. IArray.of_fun (\<lambda>ia. (\<chi>ia. A $ ia $ i) $ mod_type_class.from_nat ia) CARD('b) = IArray.of_fun (\<lambda>m. matrix_to_iarray A !! m !! mod_type_class.to_nat i) CARD('b)
[PROOF STEP]
by (auto, metis IArray.sub_def from_nat_not_eq vec_matrix vec_to_iarray_nth')


[STATEMENT]
lemma (in Group) cmp_rfn1:"\<lbrakk>0 < r; 0 < s; compseries G r f; compseries G s g\<rbrakk>
  \<Longrightarrow> f (Suc 0) \<diamondop>\<^bsub>G\<^esub> ((f 0 ) \<inter> (g 0)) = carrier G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; compseries G r f; compseries G s g\<rbrakk> \<Longrightarrow> f (Suc 0) \<diamondop> f 0 \<inter> g 0 = carrier G
[PROOF STEP]
apply (frule compseriesTr2 [of "r" "f"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; compseries G r f; compseries G s g; f 0 = carrier G\<rbrakk> \<Longrightarrow> f (Suc 0) \<diamondop> f 0 \<inter> g 0 = carrier G
[PROOF STEP]
apply (frule compseriesTr2 [of "s" "g"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; compseries G r f; compseries G s g; f 0 = carrier G; g 0 = carrier G\<rbrakk> \<Longrightarrow> f (Suc 0) \<diamondop> f 0 \<inter> g 0 = carrier G
[PROOF STEP]
apply (frule compseriesTr0 [of _ "f" "Suc 0"])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>0 < r; 0 < s; compseries G r f; compseries G s g; f 0 = carrier G; g 0 = carrier G\<rbrakk> \<Longrightarrow> Suc 0 \<le> r
 2. \<lbrakk>0 < r; 0 < s; compseries G r f; compseries G s g; f 0 = carrier G; g 0 = carrier G; G \<guillemotright> f (Suc 0) \<rbrakk> \<Longrightarrow> f (Suc 0) \<diamondop> f 0 \<inter> g 0 = carrier G
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; compseries G r f; compseries G s g; f 0 = carrier G; g 0 = carrier G; G \<guillemotright> f (Suc 0) \<rbrakk> \<Longrightarrow> f (Suc 0) \<diamondop> f 0 \<inter> g 0 = carrier G
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; compseries G r f; compseries G s g; f 0 = carrier G; g 0 = carrier G; G \<guillemotright> f (Suc 0) \<rbrakk> \<Longrightarrow> f (Suc 0) \<diamondop> carrier G = carrier G
[PROOF STEP]
apply (rule K_absorb_HK[of "f (Suc 0)" "carrier G"], assumption+,
       simp add:special_sg_G)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; compseries G r f; compseries G s g; f 0 = carrier G; g 0 = carrier G; G \<guillemotright> f (Suc 0) \<rbrakk> \<Longrightarrow> f (Suc 0) \<subseteq> carrier G
[PROOF STEP]
apply (rule sg_subset, assumption)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma set_of_sum_subset: "set_of (sum f X) \<subseteq> set_of (sum g X)"
  if "\<And>x. x \<in> X \<Longrightarrow> set_of (f x) \<subseteq> set_of (g x)"
  for f :: "_\<Rightarrow>'a::linordered_ab_group_add interval"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set_of (sum f X) \<subseteq> set_of (sum g X)
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
?x \<in> X \<Longrightarrow> set_of (f ?x) \<subseteq> set_of (g ?x)

goal (1 subgoal):
 1. set_of (sum f X) \<subseteq> set_of (sum g X)
[PROOF STEP]
by (induction X rule: infinite_finite_induct) (simp_all add: set_of_add_inc)


[STATEMENT]
lemma nontrivial_integer_group [simp]: "\<not> trivial_group integer_group"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> trivial_group integer_group
[PROOF STEP]
using integer_mod_group_def trivial_integer_mod_group
[PROOF STATE]
proof (prove)
using this:
integer_mod_group ?n \<equiv> if ?n = 0 then integer_group else \<lparr>carrier = {0..<int ?n}, mult = \<lambda>x y. (x + y) mod int ?n, one = 0\<rparr>
trivial_group (integer_mod_group ?n) = (?n = 1)

goal (1 subgoal):
 1. \<not> trivial_group integer_group
[PROOF STEP]
by presburger


[STATEMENT]
lemma eventually_at_ball': "d > 0 \<Longrightarrow> eventually (\<lambda>t. t \<in> ball z d \<and> t \<noteq> z \<and> t \<in> A) (at z within A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < d \<Longrightarrow> \<forall>\<^sub>F t in at z within A. t \<in> ball z d \<and> t \<noteq> z \<and> t \<in> A
[PROOF STEP]
unfolding eventually_at
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < d \<Longrightarrow> \<exists>da>0. \<forall>x\<in>A. x \<noteq> z \<and> dist x z < da \<longrightarrow> x \<in> ball z d \<and> x \<noteq> z \<and> x \<in> A
[PROOF STEP]
by (intro exI[of _ d]) (simp_all add: dist_commute)


[STATEMENT]
lemma higher_deriv_mult:
  fixes z::complex
  assumes "f holomorphic_on S" "g holomorphic_on S" "open S" and z: "z \<in> S"
    shows "(deriv ^^ n) (\<lambda>w. f w * g w) z =
           (\<Sum>i = 0..n. of_nat (n choose i) * (deriv ^^ i) f z * (deriv ^^ (n - i)) g z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (deriv ^^ n) (\<lambda>w. f w * g w) z = (\<Sum>i = 0..n. of_nat (n choose i) * (deriv ^^ i) f z * (deriv ^^ (n - i)) g z)
[PROOF STEP]
using z
[PROOF STATE]
proof (prove)
using this:
z \<in> S

goal (1 subgoal):
 1. (deriv ^^ n) (\<lambda>w. f w * g w) z = (\<Sum>i = 0..n. of_nat (n choose i) * (deriv ^^ i) f z * (deriv ^^ (n - i)) g z)
[PROOF STEP]
proof (induction n arbitrary: z)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>z. z \<in> S \<Longrightarrow> (deriv ^^ 0) (\<lambda>w. f w * g w) z = (\<Sum>i = 0..0. of_nat (0 choose i) * (deriv ^^ i) f z * (deriv ^^ (0 - i)) g z)
 2. \<And>n z. \<lbrakk>\<And>z. z \<in> S \<Longrightarrow> (deriv ^^ n) (\<lambda>w. f w * g w) z = (\<Sum>i = 0..n. of_nat (n choose i) * (deriv ^^ i) f z * (deriv ^^ (n - i)) g z); z \<in> S\<rbrakk> \<Longrightarrow> (deriv ^^ Suc n) (\<lambda>w. f w * g w) z = (\<Sum>i = 0..Suc n. of_nat (Suc n choose i) * (deriv ^^ i) f z * (deriv ^^ (Suc n - i)) g z)
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
z \<in> S

goal (2 subgoals):
 1. \<And>z. z \<in> S \<Longrightarrow> (deriv ^^ 0) (\<lambda>w. f w * g w) z = (\<Sum>i = 0..0. of_nat (0 choose i) * (deriv ^^ i) f z * (deriv ^^ (0 - i)) g z)
 2. \<And>n z. \<lbrakk>\<And>z. z \<in> S \<Longrightarrow> (deriv ^^ n) (\<lambda>w. f w * g w) z = (\<Sum>i = 0..n. of_nat (n choose i) * (deriv ^^ i) f z * (deriv ^^ (n - i)) g z); z \<in> S\<rbrakk> \<Longrightarrow> (deriv ^^ Suc n) (\<lambda>w. f w * g w) z = (\<Sum>i = 0..Suc n. of_nat (Suc n choose i) * (deriv ^^ i) f z * (deriv ^^ (Suc n - i)) g z)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
z \<in> S
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
z \<in> S

goal (1 subgoal):
 1. (deriv ^^ 0) (\<lambda>w. f w * g w) z = (\<Sum>i = 0..0. of_nat (0 choose i) * (deriv ^^ i) f z * (deriv ^^ (0 - i)) g z)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(deriv ^^ 0) (\<lambda>w. f w * g w) z = (\<Sum>i = 0..0. of_nat (0 choose i) * (deriv ^^ i) f z * (deriv ^^ (0 - i)) g z)

goal (1 subgoal):
 1. \<And>n z. \<lbrakk>\<And>z. z \<in> S \<Longrightarrow> (deriv ^^ n) (\<lambda>w. f w * g w) z = (\<Sum>i = 0..n. of_nat (n choose i) * (deriv ^^ i) f z * (deriv ^^ (n - i)) g z); z \<in> S\<rbrakk> \<Longrightarrow> (deriv ^^ Suc n) (\<lambda>w. f w * g w) z = (\<Sum>i = 0..Suc n. of_nat (Suc n choose i) * (deriv ^^ i) f z * (deriv ^^ (Suc n - i)) g z)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n z. \<lbrakk>\<And>z. z \<in> S \<Longrightarrow> (deriv ^^ n) (\<lambda>w. f w * g w) z = (\<Sum>i = 0..n. of_nat (n choose i) * (deriv ^^ i) f z * (deriv ^^ (n - i)) g z); z \<in> S\<rbrakk> \<Longrightarrow> (deriv ^^ Suc n) (\<lambda>w. f w * g w) z = (\<Sum>i = 0..Suc n. of_nat (Suc n choose i) * (deriv ^^ i) f z * (deriv ^^ (Suc n - i)) g z)
[PROOF STEP]
case (Suc n z)
[PROOF STATE]
proof (state)
this:
?z \<in> S \<Longrightarrow> (deriv ^^ n) (\<lambda>w. f w * g w) ?z = (\<Sum>i = 0..n. of_nat (n choose i) * (deriv ^^ i) f ?z * (deriv ^^ (n - i)) g ?z)
z \<in> S

goal (1 subgoal):
 1. \<And>n z. \<lbrakk>\<And>z. z \<in> S \<Longrightarrow> (deriv ^^ n) (\<lambda>w. f w * g w) z = (\<Sum>i = 0..n. of_nat (n choose i) * (deriv ^^ i) f z * (deriv ^^ (n - i)) g z); z \<in> S\<rbrakk> \<Longrightarrow> (deriv ^^ Suc n) (\<lambda>w. f w * g w) z = (\<Sum>i = 0..Suc n. of_nat (Suc n choose i) * (deriv ^^ i) f z * (deriv ^^ (Suc n - i)) g z)
[PROOF STEP]
have *: "\<And>n. ((deriv ^^ n) f has_field_derivative deriv ((deriv ^^ n) f) z) (at z)"
          "\<And>n. ((deriv ^^ n) g has_field_derivative deriv ((deriv ^^ n) g) z) (at z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>n. ((deriv ^^ n) f has_field_derivative deriv ((deriv ^^ n) f) z) (at z)) &&& (\<And>n. ((deriv ^^ n) g has_field_derivative deriv ((deriv ^^ n) g) z) (at z))
[PROOF STEP]
using Suc.prems assms has_field_derivative_higher_deriv
[PROOF STATE]
proof (prove)
using this:
z \<in> S
f holomorphic_on S
g holomorphic_on S
open S
z \<in> S
\<lbrakk>?f holomorphic_on ?S; open ?S; ?x \<in> ?S\<rbrakk> \<Longrightarrow> ((deriv ^^ ?n) ?f has_field_derivative (deriv ^^ Suc ?n) ?f ?x) (at ?x)

goal (1 subgoal):
 1. (\<And>n. ((deriv ^^ n) f has_field_derivative deriv ((deriv ^^ n) f) z) (at z)) &&& (\<And>n. ((deriv ^^ n) g has_field_derivative deriv ((deriv ^^ n) g) z) (at z))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
((deriv ^^ ?n) f has_field_derivative deriv ((deriv ^^ ?n) f) z) (at z)
((deriv ^^ ?n) g has_field_derivative deriv ((deriv ^^ ?n) g) z) (at z)

goal (1 subgoal):
 1. \<And>n z. \<lbrakk>\<And>z. z \<in> S \<Longrightarrow> (deriv ^^ n) (\<lambda>w. f w * g w) z = (\<Sum>i = 0..n. of_nat (n choose i) * (deriv ^^ i) f z * (deriv ^^ (n - i)) g z); z \<in> S\<rbrakk> \<Longrightarrow> (deriv ^^ Suc n) (\<lambda>w. f w * g w) z = (\<Sum>i = 0..Suc n. of_nat (Suc n choose i) * (deriv ^^ i) f z * (deriv ^^ (Suc n - i)) g z)
[PROOF STEP]
have sumeq: "(\<Sum>i = 0..n.
               of_nat (n choose i) * (deriv ((deriv ^^ i) f) z * (deriv ^^ (n - i)) g z + deriv ((deriv ^^ (n - i)) g) z * (deriv ^^ i) f z)) =
            g z * deriv ((deriv ^^ n) f) z + (\<Sum>i = 0..n. (deriv ^^ i) f z * (of_nat (Suc n choose i) * (deriv ^^ (Suc n - i)) g z))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..n. of_nat (n choose i) * (deriv ((deriv ^^ i) f) z * (deriv ^^ (n - i)) g z + deriv ((deriv ^^ (n - i)) g) z * (deriv ^^ i) f z)) = g z * deriv ((deriv ^^ n) f) z + (\<Sum>i = 0..n. (deriv ^^ i) f z * (of_nat (Suc n choose i) * (deriv ^^ (Suc n - i)) g z))
[PROOF STEP]
apply (simp add: bb algebra_simps sum.distrib)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..n. of_nat (n choose i) * ((deriv ^^ i) f z * deriv ((deriv ^^ (n - i)) g) z)) + (\<Sum>i = 0..n. of_nat (n choose i) * (deriv ((deriv ^^ i) f) z * (deriv ^^ (n - i)) g z)) = g z * deriv ((deriv ^^ n) f) z + ((\<Sum>i = 0..n. of_nat (n choose i) * ((deriv ^^ i) f z * (deriv ^^ (Suc n - i)) g z)) + (\<Sum>i = 0..n. (deriv ^^ i) f z * ((deriv ^^ (Suc n - i)) g z * of_nat (if i = 0 then 0 else n choose (i - 1)))))
[PROOF STEP]
apply (subst (4) sum_Suc_reindex)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..n. of_nat (n choose i) * ((deriv ^^ i) f z * deriv ((deriv ^^ (n - i)) g) z)) + (\<Sum>i = 0..n. of_nat (n choose i) * (deriv ((deriv ^^ i) f) z * (deriv ^^ (n - i)) g z)) = g z * deriv ((deriv ^^ n) f) z + ((\<Sum>i = 0..n. of_nat (n choose i) * ((deriv ^^ i) f z * (deriv ^^ (Suc n - i)) g z)) + ((deriv ^^ 0) f z * ((deriv ^^ (Suc n - 0)) g z * of_nat (if 0 = 0 then 0 else n choose (0 - 1))) - (deriv ^^ Suc n) f z * ((deriv ^^ (Suc n - Suc n)) g z * of_nat (if Suc n = 0 then 0 else n choose (Suc n - 1))) + (\<Sum>i = 0..n. (deriv ^^ Suc i) f z * ((deriv ^^ (Suc n - Suc i)) g z * of_nat (if Suc i = 0 then 0 else n choose (Suc i - 1))))))
[PROOF STEP]
apply (auto simp: algebra_simps Suc_diff_le intro: sum.cong)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
(\<Sum>i = 0..n. of_nat (n choose i) * (deriv ((deriv ^^ i) f) z * (deriv ^^ (n - i)) g z + deriv ((deriv ^^ (n - i)) g) z * (deriv ^^ i) f z)) = g z * deriv ((deriv ^^ n) f) z + (\<Sum>i = 0..n. (deriv ^^ i) f z * (of_nat (Suc n choose i) * (deriv ^^ (Suc n - i)) g z))

goal (1 subgoal):
 1. \<And>n z. \<lbrakk>\<And>z. z \<in> S \<Longrightarrow> (deriv ^^ n) (\<lambda>w. f w * g w) z = (\<Sum>i = 0..n. of_nat (n choose i) * (deriv ^^ i) f z * (deriv ^^ (n - i)) g z); z \<in> S\<rbrakk> \<Longrightarrow> (deriv ^^ Suc n) (\<lambda>w. f w * g w) z = (\<Sum>i = 0..Suc n. of_nat (Suc n choose i) * (deriv ^^ i) f z * (deriv ^^ (Suc n - i)) g z)
[PROOF STEP]
have "((deriv ^^ n) (\<lambda>w. f w * g w) has_field_derivative
         (\<Sum>i = 0..Suc n. (Suc n choose i) * (deriv ^^ i) f z * (deriv ^^ (Suc n - i)) g z))
        (at z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((deriv ^^ n) (\<lambda>w. f w * g w) has_field_derivative (\<Sum>i = 0..Suc n. of_nat (Suc n choose i) * (deriv ^^ i) f z * (deriv ^^ (Suc n - i)) g z)) (at z)
[PROOF STEP]
apply (rule has_field_derivative_transform_within_open
        [of "\<lambda>w. (\<Sum>i = 0..n. of_nat (n choose i) * (deriv ^^ i) f w * (deriv ^^ (n - i)) g w)" _ _ S])
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. ((\<lambda>w. \<Sum>i = 0..n. of_nat (n choose i) * (deriv ^^ i) f w * (deriv ^^ (n - i)) g w) has_field_derivative (\<Sum>i = 0..Suc n. of_nat (Suc n choose i) * (deriv ^^ i) f z * (deriv ^^ (Suc n - i)) g z)) (at z)
 2. open S
 3. z \<in> S
 4. \<And>x. x \<in> S \<Longrightarrow> (\<Sum>i = 0..n. of_nat (n choose i) * (deriv ^^ i) f x * (deriv ^^ (n - i)) g x) = (deriv ^^ n) (\<lambda>w. f w * g w) x
[PROOF STEP]
apply (simp add: algebra_simps)
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. ((\<lambda>w. \<Sum>i = 0..n. of_nat (n choose i) * ((deriv ^^ i) f w * (deriv ^^ (n - i)) g w)) has_field_derivative g z * deriv ((deriv ^^ n) f) z + (\<Sum>i = 0..n. (deriv ^^ i) f z * (of_nat (Suc n choose i) * (deriv ^^ (Suc n - i)) g z))) (at z)
 2. open S
 3. z \<in> S
 4. \<And>x. x \<in> S \<Longrightarrow> (\<Sum>i = 0..n. of_nat (n choose i) * (deriv ^^ i) f x * (deriv ^^ (n - i)) g x) = (deriv ^^ n) (\<lambda>w. f w * g w) x
[PROOF STEP]
apply (rule derivative_eq_intros | simp)+
[PROOF STATE]
proof (prove)
goal (8 subgoals):
 1. \<And>n. n \<le> n \<Longrightarrow> ((deriv ^^ n) f has_field_derivative ?Da22 n) (at z)
 2. \<And>n. n \<in> {0..n} \<Longrightarrow> ((deriv ^^ (n - n)) g has_field_derivative ?Db22 n) (at z)
 3. \<And>n. n \<in> {0..n} \<Longrightarrow> ?Da22 n * (deriv ^^ (n - n)) g z + ?Db22 n * (deriv ^^ n) f z = ?Db12 n
 4. \<And>n. n \<in> {0..n} \<Longrightarrow> 0 * ((deriv ^^ n) f z * (deriv ^^ (n - n)) g z) + ?Db12 n * of_nat (n choose n) = ?f'8 ?w8 n
 5. sum (?f'8 ?w8) {0..n} = g z * deriv ((deriv ^^ n) f) z + (\<Sum>i = 0..n. (deriv ^^ i) f z * (of_nat (Suc n choose i) * (deriv ^^ (Suc n - i)) g z))
 6. open S
 7. z \<in> S
 8. \<And>x. x \<in> S \<Longrightarrow> (\<Sum>i = 0..n. of_nat (n choose i) * (deriv ^^ i) f x * (deriv ^^ (n - i)) g x) = (deriv ^^ n) (\<lambda>w. f w * g w) x
[PROOF STEP]
apply (auto intro: DERIV_mult * \<open>open S\<close> Suc.prems Suc.IH [symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x = 0..n. (deriv ((deriv ^^ x) f) z * (deriv ^^ (n - x)) g z + deriv ((deriv ^^ (n - x)) g) z * (deriv ^^ x) f z) * of_nat (n choose x)) = g z * deriv ((deriv ^^ n) f) z + (\<Sum>i = 0..n. (deriv ^^ i) f z * (of_nat (Suc n choose i) * (deriv ^^ (Suc n - i)) g z))
[PROOF STEP]
by (metis (no_types, lifting) mult.commute sum.cong sumeq)
[PROOF STATE]
proof (state)
this:
((deriv ^^ n) (\<lambda>w. f w * g w) has_field_derivative (\<Sum>i = 0..Suc n. of_nat (Suc n choose i) * (deriv ^^ i) f z * (deriv ^^ (Suc n - i)) g z)) (at z)

goal (1 subgoal):
 1. \<And>n z. \<lbrakk>\<And>z. z \<in> S \<Longrightarrow> (deriv ^^ n) (\<lambda>w. f w * g w) z = (\<Sum>i = 0..n. of_nat (n choose i) * (deriv ^^ i) f z * (deriv ^^ (n - i)) g z); z \<in> S\<rbrakk> \<Longrightarrow> (deriv ^^ Suc n) (\<lambda>w. f w * g w) z = (\<Sum>i = 0..Suc n. of_nat (Suc n choose i) * (deriv ^^ i) f z * (deriv ^^ (Suc n - i)) g z)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
((deriv ^^ n) (\<lambda>w. f w * g w) has_field_derivative (\<Sum>i = 0..Suc n. of_nat (Suc n choose i) * (deriv ^^ i) f z * (deriv ^^ (Suc n - i)) g z)) (at z)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
((deriv ^^ n) (\<lambda>w. f w * g w) has_field_derivative (\<Sum>i = 0..Suc n. of_nat (Suc n choose i) * (deriv ^^ i) f z * (deriv ^^ (Suc n - i)) g z)) (at z)

goal (1 subgoal):
 1. (deriv ^^ Suc n) (\<lambda>w. f w * g w) z = (\<Sum>i = 0..Suc n. of_nat (Suc n choose i) * (deriv ^^ i) f z * (deriv ^^ (Suc n - i)) g z)
[PROOF STEP]
unfolding funpow.simps o_apply
[PROOF STATE]
proof (prove)
using this:
((deriv ^^ n) (\<lambda>w. f w * g w) has_field_derivative (\<Sum>i = 0..Suc n. of_nat (Suc n choose i) * (deriv ^^ i) f z * (deriv ^^ (Suc n - i)) g z)) (at z)

goal (1 subgoal):
 1. deriv ((deriv ^^ n) (\<lambda>w. f w * g w)) z = (\<Sum>i = 0..Suc n. of_nat (Suc n choose i) * (deriv ^^ i) f z * (deriv ^^ (Suc n - i)) g z)
[PROOF STEP]
by (simp add: DERIV_imp_deriv)
[PROOF STATE]
proof (state)
this:
(deriv ^^ Suc n) (\<lambda>w. f w * g w) z = (\<Sum>i = 0..Suc n. of_nat (Suc n choose i) * (deriv ^^ i) f z * (deriv ^^ (Suc n - i)) g z)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Infinitesimal_add_approx: "y \<in> Infinitesimal \<Longrightarrow> x + y = z \<Longrightarrow> x \<approx> z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>y \<in> Infinitesimal; x + y = z\<rbrakk> \<Longrightarrow> x \<approx> z
[PROOF STEP]
using approx_sym bex_Infinitesimal_iff2
[PROOF STATE]
proof (prove)
using this:
?x \<approx> ?y \<Longrightarrow> ?y \<approx> ?x
(\<exists>y\<in>Infinitesimal. ?x = ?z + y) = (?x \<approx> ?z)

goal (1 subgoal):
 1. \<lbrakk>y \<in> Infinitesimal; x + y = z\<rbrakk> \<Longrightarrow> x \<approx> z
[PROOF STEP]
by blast


[STATEMENT]
lemma embedding_imp_closed_map:
   "\<lbrakk>embedding_map X Y f; closedin Y (f ` topspace X)\<rbrakk> \<Longrightarrow> closed_map X Y f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>embedding_map X Y f; closedin Y (f ` topspace X)\<rbrakk> \<Longrightarrow> closed_map X Y f
[PROOF STEP]
unfolding closed_map_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>embedding_map X Y f; closedin Y (f ` topspace X)\<rbrakk> \<Longrightarrow> \<forall>U. closedin X U \<longrightarrow> closedin Y (f ` U)
[PROOF STEP]
by (auto simp: closedin_closed_subtopology embedding_map_def homeomorphic_map_closedness_eq)


[STATEMENT]
lemma stepfun_imp_chainp:
  assumes "\<forall>i\<ge>n::nat. f i > i \<and> P (S i) (S (f i))"
  shows "chainp P (\<lambda>i. S ((f ^^ i) n))" (is "chainp P ?T")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i. P (S ((f ^^ i) n)) (S ((f ^^ Suc i) n))
[PROOF STEP]
using stepfun_imp_chainp'[of n f P S] and assms
[PROOF STATE]
proof (prove)
using this:
\<forall>i\<ge>n. i \<le> f i \<and> P (S i) (S (f i)) \<Longrightarrow> \<forall>i. P (S ((f ^^ i) n)) (S ((f ^^ Suc i) n))
\<forall>i\<ge>n. i < f i \<and> P (S i) (S (f i))

goal (1 subgoal):
 1. \<forall>i. P (S ((f ^^ i) n)) (S ((f ^^ Suc i) n))
[PROOF STEP]
by force


[STATEMENT]
lemma bounded_clinearI:
  assumes \<open>\<And>b1 b2. f (b1 + b2) = f b1 + f b2\<close>
  assumes \<open>\<And>r b. f (r *\<^sub>C b) = r *\<^sub>C f b\<close>
  assumes \<open>\<And>x. norm (f x) \<le> norm x * K\<close>
  shows "bounded_clinear f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bounded_clinear f
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f (?b1.0 + ?b2.0) = f ?b1.0 + f ?b2.0
f (?r *\<^sub>C ?b) = ?r *\<^sub>C f ?b
norm (f ?x) \<le> norm ?x * K

goal (1 subgoal):
 1. bounded_clinear f
[PROOF STEP]
by (auto intro!: exI bounded_clinear.intro clinearI simp: bounded_clinear_axioms_def)


[STATEMENT]
lemma f2_hash_pow_exp:
  assumes "k < p"
  shows
    "expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^m) =
     ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
have "odd p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. odd p
[PROOF STEP]
using p_prime p_ge_3 prime_odd_nat assms
[PROOF STATE]
proof (prove)
using this:
normalization_semidom_class.prime p
3 \<le> p
\<lbrakk>normalization_semidom_class.prime ?p; 2 < ?p\<rbrakk> \<Longrightarrow> odd ?p
k < p

goal (1 subgoal):
 1. odd p
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
odd p

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
odd p
[PROOF STEP]
obtain t where t_def: "p=2*t+1"
[PROOF STATE]
proof (prove)
using this:
odd p

goal (1 subgoal):
 1. (\<And>t. p = 2 * t + 1 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using oddE
[PROOF STATE]
proof (prove)
using this:
odd p
\<lbrakk>odd ?a; \<And>b. ?a = (2::?'a) * b + (1::?'a) \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. (\<And>t. p = 2 * t + 1 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
p = 2 * t + 1

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
have "Collect even \<inter> {..<2 * t + 1} \<subseteq> (*) 2 ` {..<t + 1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Collect even \<inter> {..<2 * t + 1} \<subseteq> (*) 2 ` {..<t + 1}
[PROOF STEP]
by (rule in_image_by_witness[where g="\<lambda>x. x div 2"], simp, linarith)
[PROOF STATE]
proof (state)
this:
Collect even \<inter> {..<2 * t + 1} \<subseteq> (*) 2 ` {..<t + 1}

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
Collect even \<inter> {..<2 * t + 1} \<subseteq> (*) 2 ` {..<t + 1}

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
have " (*) 2 ` {..<t + 1} \<subseteq> Collect even \<inter> {..<2 * t + 1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (*) 2 ` {..<t + 1} \<subseteq> Collect even \<inter> {..<2 * t + 1}
[PROOF STEP]
by (rule image_subsetI, simp)
[PROOF STATE]
proof (state)
this:
(*) 2 ` {..<t + 1} \<subseteq> Collect even \<inter> {..<2 * t + 1}

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
Collect even \<inter> {..<2 * t + 1} \<subseteq> (*) 2 ` {..<t + 1}
(*) 2 ` {..<t + 1} \<subseteq> Collect even \<inter> {..<2 * t + 1}
[PROOF STEP]
have "card ({k. even k} \<inter> {..<p}) = card ((\<lambda>x. 2*x) ` {..<t+1})"
[PROOF STATE]
proof (prove)
using this:
Collect even \<inter> {..<2 * t + 1} \<subseteq> (*) 2 ` {..<t + 1}
(*) 2 ` {..<t + 1} \<subseteq> Collect even \<inter> {..<2 * t + 1}

goal (1 subgoal):
 1. card (Collect even \<inter> {..<p}) = card ((*) 2 ` {..<t + 1})
[PROOF STEP]
unfolding t_def
[PROOF STATE]
proof (prove)
using this:
Collect even \<inter> {..<2 * t + 1} \<subseteq> (*) 2 ` {..<t + 1}
(*) 2 ` {..<t + 1} \<subseteq> Collect even \<inter> {..<2 * t + 1}

goal (1 subgoal):
 1. card (Collect even \<inter> {..<2 * t + 1}) = card ((*) 2 ` {..<t + 1})
[PROOF STEP]
using order_antisym
[PROOF STATE]
proof (prove)
using this:
Collect even \<inter> {..<2 * t + 1} \<subseteq> (*) 2 ` {..<t + 1}
(*) 2 ` {..<t + 1} \<subseteq> Collect even \<inter> {..<2 * t + 1}
\<lbrakk>?x \<le> ?y; ?y \<le> ?x\<rbrakk> \<Longrightarrow> ?x = ?y

goal (1 subgoal):
 1. card (Collect even \<inter> {..<2 * t + 1}) = card ((*) 2 ` {..<t + 1})
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
card (Collect even \<inter> {..<p}) = card ((*) 2 ` {..<t + 1})

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card (Collect even \<inter> {..<p}) = card ((*) 2 ` {..<t + 1})

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
have "... = card {..<t+1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card ((*) 2 ` {..<t + 1}) = card {..<t + 1}
[PROOF STEP]
by (rule card_image, simp add: inj_on_mult)
[PROOF STATE]
proof (state)
this:
card ((*) 2 ` {..<t + 1}) = card {..<t + 1}

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card ((*) 2 ` {..<t + 1}) = card {..<t + 1}

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
have "... =  t+1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {..<t + 1} = t + 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card {..<t + 1} = t + 1

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
card (Collect even \<inter> {..<p}) = t + 1
[PROOF STEP]
have card_even: "card ({k. even k} \<inter> {..<p}) = t+1"
[PROOF STATE]
proof (prove)
using this:
card (Collect even \<inter> {..<p}) = t + 1

goal (1 subgoal):
 1. card (Collect even \<inter> {..<p}) = t + 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card (Collect even \<inter> {..<p}) = t + 1

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
hence "card ({k. even k} \<inter> {..<p}) * 2 = (p+1)"
[PROOF STATE]
proof (prove)
using this:
card (Collect even \<inter> {..<p}) = t + 1

goal (1 subgoal):
 1. card (Collect even \<inter> {..<p}) * 2 = p + 1
[PROOF STEP]
by (simp add:t_def)
[PROOF STATE]
proof (state)
this:
card (Collect even \<inter> {..<p}) * 2 = p + 1

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
hence prob_even: "prob {\<omega>. hash k \<omega> \<in> Collect even} = (real p + 1)/(2*real p)"
[PROOF STATE]
proof (prove)
using this:
card (Collect even \<inter> {..<p}) * 2 = p + 1

goal (1 subgoal):
 1. prob {\<omega>. hash k \<omega> \<in> Collect even} = (real p + 1) / (2 * real p)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
card (Collect even \<inter> {..<p}) * 2 = p + 1
k < p

goal (1 subgoal):
 1. prob {\<omega>. hash k \<omega> \<in> Collect even} = (real p + 1) / (2 * real p)
[PROOF STEP]
by (subst prob_range, auto simp:frac_eq_eq p_gt_0 mod_ring_def)
[PROOF STATE]
proof (state)
this:
prob {\<omega>. hash k \<omega> \<in> Collect even} = (real p + 1) / (2 * real p)

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
have "p = card {..<p}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p = card {..<p}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
p = card {..<p}

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
p = card {..<p}

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
have "... = card (({k. odd k} \<inter> {..<p}) \<union> ({k. even k} \<inter> {..<p}))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {..<p} = card ({k. odd k} \<inter> {..<p} \<union> Collect even \<inter> {..<p})
[PROOF STEP]
by (rule arg_cong[where f="card"], auto)
[PROOF STATE]
proof (state)
this:
card {..<p} = card ({k. odd k} \<inter> {..<p} \<union> Collect even \<inter> {..<p})

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card {..<p} = card ({k. odd k} \<inter> {..<p} \<union> Collect even \<inter> {..<p})

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
have "... = card ({k. odd k} \<inter> {..<p}) +  card ({k. even k} \<inter> {..<p})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card ({k. odd k} \<inter> {..<p} \<union> Collect even \<inter> {..<p}) = card ({k. odd k} \<inter> {..<p}) + card (Collect even \<inter> {..<p})
[PROOF STEP]
by (rule card_Un_disjoint, simp, simp, blast)
[PROOF STATE]
proof (state)
this:
card ({k. odd k} \<inter> {..<p} \<union> Collect even \<inter> {..<p}) = card ({k. odd k} \<inter> {..<p}) + card (Collect even \<inter> {..<p})

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card ({k. odd k} \<inter> {..<p} \<union> Collect even \<inter> {..<p}) = card ({k. odd k} \<inter> {..<p}) + card (Collect even \<inter> {..<p})

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
have "... = card ({k. odd k} \<inter> {..<p}) + t+1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card ({k. odd k} \<inter> {..<p}) + card (Collect even \<inter> {..<p}) = card ({k. odd k} \<inter> {..<p}) + t + 1
[PROOF STEP]
by (simp add:card_even)
[PROOF STATE]
proof (state)
this:
card ({k. odd k} \<inter> {..<p}) + card (Collect even \<inter> {..<p}) = card ({k. odd k} \<inter> {..<p}) + t + 1

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
p = card ({k. odd k} \<inter> {..<p}) + t + 1
[PROOF STEP]
have "p = card ({k. odd k} \<inter> {..<p}) + t+1"
[PROOF STATE]
proof (prove)
using this:
p = card ({k. odd k} \<inter> {..<p}) + t + 1

goal (1 subgoal):
 1. p = card ({k. odd k} \<inter> {..<p}) + t + 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
p = card ({k. odd k} \<inter> {..<p}) + t + 1

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
hence "card ({k. odd k} \<inter> {..<p}) * 2 = (p-1)"
[PROOF STATE]
proof (prove)
using this:
p = card ({k. odd k} \<inter> {..<p}) + t + 1

goal (1 subgoal):
 1. card ({k. odd k} \<inter> {..<p}) * 2 = p - 1
[PROOF STEP]
by (simp add:t_def)
[PROOF STATE]
proof (state)
this:
card ({k. odd k} \<inter> {..<p}) * 2 = p - 1

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
hence prob_odd: "prob {\<omega>. hash k \<omega> \<in> Collect odd} = (real p - 1)/(2*real p)"
[PROOF STATE]
proof (prove)
using this:
card ({k. odd k} \<inter> {..<p}) * 2 = p - 1

goal (1 subgoal):
 1. prob {\<omega>. hash k \<omega> \<in> {a. odd a}} = (real p - 1) / (2 * real p)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
card ({k. odd k} \<inter> {..<p}) * 2 = p - 1
k < p

goal (1 subgoal):
 1. prob {\<omega>. hash k \<omega> \<in> {a. odd a}} = (real p - 1) / (2 * real p)
[PROOF STEP]
by (subst prob_range, auto simp add: frac_eq_eq mod_ring_def)
[PROOF STATE]
proof (state)
this:
prob {\<omega>. hash k \<omega> \<in> {a. odd a}} = (real p - 1) / (2 * real p)

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
have "expectation (\<lambda>x. real_of_int (f2_hash p x k) ^ m) =
    expectation (\<lambda>\<omega>. indicator {\<omega>. even (hash k \<omega>)} \<omega> * (real p - 1)^m +
      indicator {\<omega>. odd (hash k \<omega>)} \<omega> * (-real p - 1)^m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. expectation (\<lambda>x. real_of_int (f2_hash p x k) ^ m) = expectation (\<lambda>\<omega>. indicat_real {\<omega>. even (hash k \<omega>)} \<omega> * (real p - 1) ^ m + indicat_real {\<omega>. odd (hash k \<omega>)} \<omega> * (- real p - 1) ^ m)
[PROOF STEP]
by (rule Bochner_Integration.integral_cong, simp, simp)
[PROOF STATE]
proof (state)
this:
expectation (\<lambda>x. real_of_int (f2_hash p x k) ^ m) = expectation (\<lambda>\<omega>. indicat_real {\<omega>. even (hash k \<omega>)} \<omega> * (real p - 1) ^ m + indicat_real {\<omega>. odd (hash k \<omega>)} \<omega> * (- real p - 1) ^ m)

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
expectation (\<lambda>x. real_of_int (f2_hash p x k) ^ m) = expectation (\<lambda>\<omega>. indicat_real {\<omega>. even (hash k \<omega>)} \<omega> * (real p - 1) ^ m + indicat_real {\<omega>. odd (hash k \<omega>)} \<omega> * (- real p - 1) ^ m)

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
have "... =
     prob {\<omega>. hash  k \<omega> \<in> Collect even}  * (real p - 1) ^ m  +
     prob {\<omega>. hash  k \<omega> \<in> Collect odd}  * (-real p - 1) ^ m "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. indicat_real {\<omega>. even (hash k \<omega>)} \<omega> * (real p - 1) ^ m + indicat_real {\<omega>. odd (hash k \<omega>)} \<omega> * (- real p - 1) ^ m) = prob {\<omega>. hash k \<omega> \<in> Collect even} * (real p - 1) ^ m + prob {\<omega>. hash k \<omega> \<in> {a. odd a}} * (- real p - 1) ^ m
[PROOF STEP]
by (simp, simp add:M_def)
[PROOF STATE]
proof (state)
this:
expectation (\<lambda>\<omega>. indicat_real {\<omega>. even (hash k \<omega>)} \<omega> * (real p - 1) ^ m + indicat_real {\<omega>. odd (hash k \<omega>)} \<omega> * (- real p - 1) ^ m) = prob {\<omega>. hash k \<omega> \<in> Collect even} * (real p - 1) ^ m + prob {\<omega>. hash k \<omega> \<in> {a. odd a}} * (- real p - 1) ^ m

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
expectation (\<lambda>\<omega>. indicat_real {\<omega>. even (hash k \<omega>)} \<omega> * (real p - 1) ^ m + indicat_real {\<omega>. odd (hash k \<omega>)} \<omega> * (- real p - 1) ^ m) = prob {\<omega>. hash k \<omega> \<in> Collect even} * (real p - 1) ^ m + prob {\<omega>. hash k \<omega> \<in> {a. odd a}} * (- real p - 1) ^ m

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
have "... = (real p + 1) * (real p - 1) ^ m / (2 * real p) + (real p - 1) * (- real p - 1) ^ m / (2 * real p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prob {\<omega>. hash k \<omega> \<in> Collect even} * (real p - 1) ^ m + prob {\<omega>. hash k \<omega> \<in> {a. odd a}} * (- real p - 1) ^ m = (real p + 1) * (real p - 1) ^ m / (2 * real p) + (real p - 1) * (- real p - 1) ^ m / (2 * real p)
[PROOF STEP]
by (subst prob_even, subst prob_odd, simp)
[PROOF STATE]
proof (state)
this:
prob {\<omega>. hash k \<omega> \<in> Collect even} * (real p - 1) ^ m + prob {\<omega>. hash k \<omega> \<in> {a. odd a}} * (- real p - 1) ^ m = (real p + 1) * (real p - 1) ^ m / (2 * real p) + (real p - 1) * (- real p - 1) ^ m / (2 * real p)

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
prob {\<omega>. hash k \<omega> \<in> Collect even} * (real p - 1) ^ m + prob {\<omega>. hash k \<omega> \<in> {a. odd a}} * (- real p - 1) ^ m = (real p + 1) * (real p - 1) ^ m / (2 * real p) + (real p - 1) * (- real p - 1) ^ m / (2 * real p)

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
have "... =
    ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (real p + 1) * (real p - 1) ^ m / (2 * real p) + (real p - 1) * (- real p - 1) ^ m / (2 * real p) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
by (simp add:add_divide_distrib ac_simps)
[PROOF STATE]
proof (state)
this:
(real p + 1) * (real p - 1) ^ m / (2 * real p) + (real p - 1) * (- real p - 1) ^ m / (2 * real p) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)

goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. real_of_int (f2_hash p \<omega> k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
expectation (\<lambda>x. real_of_int (f2_hash p x k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
show "expectation (\<lambda>x. real_of_int (f2_hash p x k) ^ m) =
    ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)"
[PROOF STATE]
proof (prove)
using this:
expectation (\<lambda>x. real_of_int (f2_hash p x k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)

goal (1 subgoal):
 1. expectation (\<lambda>x. real_of_int (f2_hash p x k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
expectation (\<lambda>x. real_of_int (f2_hash p x k) ^ m) = ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mpoly_map_vars_monom_single [simp]:
  assumes "bij f"
  shows   "mpoly_map_vars f (monom (Poly_Mapping.single i n) c) =
             monom (Poly_Mapping.single (f i) n) c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mpoly_map_vars f (MPoly_Type.monom (Poly_Mapping.single i n) c) = MPoly_Type.monom (Poly_Mapping.single (f i) n) c
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
bij f

goal (1 subgoal):
 1. mpoly_map_vars f (MPoly_Type.monom (Poly_Mapping.single i n) c) = MPoly_Type.monom (Poly_Mapping.single (f i) n) c
[PROOF STEP]
by (simp add: mpoly_map_vars_monom permutep_single bij_imp_bij_inv inv_inv_eq)