[STATEMENT]
lemma
  shows var_sketch_rv:"variance sketch_rv \<le> 2*(real_of_rat (F 2 as)^2) * ((real p)\<^sup>2-1)\<^sup>2" (is "?A")
  and exp_sketch_rv:"expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2-1)" (is "?B")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2 &&& expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
define h where "h = (\<lambda>\<omega> x. real_of_int (f2_hash p \<omega> x))"
[PROOF STATE]
proof (state)
this:
h = (\<lambda>\<omega> x. real_of_int (f2_hash p \<omega> x))

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
define c where "c = (\<lambda>x. real (count_list as x))"
[PROOF STATE]
proof (state)
this:
c = (\<lambda>x. real (count_list as x))

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
define r where "r = (\<lambda>(m::nat). ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p))"
[PROOF STATE]
proof (state)
this:
r = (\<lambda>m. ((real p - 1) ^ m * (real p + 1) + (- real p - 1) ^ m * (real p - 1)) / (2 * real p))

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
define h_prod where "h_prod = (\<lambda>as \<omega>. prod_list (map (h \<omega>) as))"
[PROOF STATE]
proof (state)
this:
h_prod = (\<lambda>as \<omega>. prod_list (map (h \<omega>) as))

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
define exp_h_prod :: "nat list \<Rightarrow> real" where "exp_h_prod = (\<lambda>as. (\<Prod>i \<in> set as. r (count_list as i)))"
[PROOF STATE]
proof (state)
this:
exp_h_prod = (\<lambda>as. \<Prod>i\<in>set as. r (count_list as i))

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
have f_eq: "sketch_rv = (\<lambda>\<omega>. (\<Sum>x \<in> set as. c x * h \<omega> x)^2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sketch_rv = (\<lambda>\<omega>. (\<Sum>x\<in>set as. c x * h \<omega> x)\<^sup>2)
[PROOF STEP]
by (rule ext, simp add:sketch_rv_def c_def h_def sum_list_eval del:f2_hash.simps)
[PROOF STATE]
proof (state)
this:
sketch_rv = (\<lambda>\<omega>. (\<Sum>x\<in>set as. c x * h \<omega> x)\<^sup>2)

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
have r_one: "r (Suc 0) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r (Suc 0) = 0
[PROOF STEP]
by (simp add:r_def algebra_simps)
[PROOF STATE]
proof (state)
this:
r (Suc 0) = 0

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
have r_two: "r 2 = (real p^2-1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r 2 = (real p)\<^sup>2 - 1
[PROOF STEP]
using p_gt_0
[PROOF STATE]
proof (prove)
using this:
0 < p

goal (1 subgoal):
 1. r 2 = (real p)\<^sup>2 - 1
[PROOF STEP]
unfolding r_def power2_eq_square
[PROOF STATE]
proof (prove)
using this:
0 < p

goal (1 subgoal):
 1. ((real p - 1) * (real p - 1) * (real p + 1) + (- real p - 1) * (- real p - 1) * (real p - 1)) / (2 * real p) = real p * real p - 1
[PROOF STEP]
by (simp add:nonzero_divide_eq_eq, simp add:algebra_simps)
[PROOF STATE]
proof (state)
this:
r 2 = (real p)\<^sup>2 - 1

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
have"(real p)^2 \<ge> 2^2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2\<^sup>2 \<le> (real p)\<^sup>2
[PROOF STEP]
by (rule power_mono, use p_gt_1 in linarith, simp)
[PROOF STATE]
proof (state)
this:
2\<^sup>2 \<le> (real p)\<^sup>2

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
hence p_square_ge_4: "(real p)\<^sup>2 \<ge> 4"
[PROOF STATE]
proof (prove)
using this:
2\<^sup>2 \<le> (real p)\<^sup>2

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

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
have "r 4 = (real p)^4+2*(real p)\<^sup>2 - 3"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r 4 = real p ^ 4 + 2 * (real p)\<^sup>2 - 3
[PROOF STEP]
using p_gt_0
[PROOF STATE]
proof (prove)
using this:
0 < p

goal (1 subgoal):
 1. r 4 = real p ^ 4 + 2 * (real p)\<^sup>2 - 3
[PROOF STEP]
unfolding r_def
[PROOF STATE]
proof (prove)
using this:
0 < p

goal (1 subgoal):
 1. ((real p - 1) ^ 4 * (real p + 1) + (- real p - 1) ^ 4 * (real p - 1)) / (2 * real p) = real p ^ 4 + 2 * (real p)\<^sup>2 - 3
[PROOF STEP]
by (subst nonzero_divide_eq_eq, auto simp:power4_eq_xxxx power2_eq_square algebra_simps)
[PROOF STATE]
proof (state)
this:
r 4 = real p ^ 4 + 2 * (real p)\<^sup>2 - 3

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
r 4 = real p ^ 4 + 2 * (real p)\<^sup>2 - 3

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
have "... \<le> (real p)^4+2*(real p)\<^sup>2 + 3"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real p ^ 4 + 2 * (real p)\<^sup>2 - 3 \<le> real p ^ 4 + 2 * (real p)\<^sup>2 + 3
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
real p ^ 4 + 2 * (real p)\<^sup>2 - 3 \<le> real p ^ 4 + 2 * (real p)\<^sup>2 + 3

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real p ^ 4 + 2 * (real p)\<^sup>2 - 3 \<le> real p ^ 4 + 2 * (real p)\<^sup>2 + 3

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
have "... \<le> 3 * r 2 * r 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real p ^ 4 + 2 * (real p)\<^sup>2 + 3 \<le> 3 * r 2 * r 2
[PROOF STEP]
using p_square_ge_4
[PROOF STATE]
proof (prove)
using this:
4 \<le> (real p)\<^sup>2

goal (1 subgoal):
 1. real p ^ 4 + 2 * (real p)\<^sup>2 + 3 \<le> 3 * r 2 * r 2
[PROOF STEP]
by (simp add:r_two power4_eq_xxxx power2_eq_square algebra_simps mult_left_mono)
[PROOF STATE]
proof (state)
this:
real p ^ 4 + 2 * (real p)\<^sup>2 + 3 \<le> 3 * r 2 * r 2

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
r 4 \<le> 3 * r 2 * r 2
[PROOF STEP]
have r_four_est: "r 4 \<le> 3 * r 2 * r 2"
[PROOF STATE]
proof (prove)
using this:
r 4 \<le> 3 * r 2 * r 2

goal (1 subgoal):
 1. r 4 \<le> 3 * r 2 * r 2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
r 4 \<le> 3 * r 2 * r 2

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
have exp_h_prod_elim: "exp_h_prod = (\<lambda>as. prod_list (map (r \<circ> count_list as) (remdups as)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. exp_h_prod = (\<lambda>as. prod_list (map (r \<circ> count_list as) (remdups as)))
[PROOF STEP]
by (simp add:exp_h_prod_def prod.set_conv_list[symmetric])
[PROOF STATE]
proof (state)
this:
exp_h_prod = (\<lambda>as. prod_list (map (r \<circ> count_list as) (remdups as)))

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
have exp_h_prod: "\<And>x. set x \<subseteq> set as \<Longrightarrow> length x \<le> 4 \<Longrightarrow> expectation (h_prod x) = exp_h_prod x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>set x \<subseteq> set as; length x \<le> 4\<rbrakk> \<Longrightarrow> expectation (h_prod x) = exp_h_prod x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>set x \<subseteq> set as; length x \<le> 4\<rbrakk> \<Longrightarrow> expectation (h_prod x) = exp_h_prod x
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>set x \<subseteq> set as; length x \<le> 4\<rbrakk> \<Longrightarrow> expectation (h_prod x) = exp_h_prod x
[PROOF STEP]
assume "set x \<subseteq> set as"
[PROOF STATE]
proof (state)
this:
set x \<subseteq> set as

goal (1 subgoal):
 1. \<And>x. \<lbrakk>set x \<subseteq> set as; length x \<le> 4\<rbrakk> \<Longrightarrow> expectation (h_prod x) = exp_h_prod x
[PROOF STEP]
hence x_sub_p: "set x \<subseteq> {..<p}"
[PROOF STATE]
proof (prove)
using this:
set x \<subseteq> set as

goal (1 subgoal):
 1. set x \<subseteq> {..<p}
[PROOF STEP]
using as_range p_ge_n
[PROOF STATE]
proof (prove)
using this:
set x \<subseteq> set as
set as \<subseteq> {..<n}
n \<le> p

goal (1 subgoal):
 1. set x \<subseteq> {..<p}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
set x \<subseteq> {..<p}

goal (1 subgoal):
 1. \<And>x. \<lbrakk>set x \<subseteq> set as; length x \<le> 4\<rbrakk> \<Longrightarrow> expectation (h_prod x) = exp_h_prod x
[PROOF STEP]
hence x_le_p: "\<And>k. k \<in> set x \<Longrightarrow> k < p"
[PROOF STATE]
proof (prove)
using this:
set x \<subseteq> {..<p}

goal (1 subgoal):
 1. \<And>k. k \<in> set x \<Longrightarrow> k < p
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?k4 \<in> set x \<Longrightarrow> ?k4 < p

goal (1 subgoal):
 1. \<And>x. \<lbrakk>set x \<subseteq> set as; length x \<le> 4\<rbrakk> \<Longrightarrow> expectation (h_prod x) = exp_h_prod x
[PROOF STEP]
assume "length x \<le> 4"
[PROOF STATE]
proof (state)
this:
length x \<le> 4

goal (1 subgoal):
 1. \<And>x. \<lbrakk>set x \<subseteq> set as; length x \<le> 4\<rbrakk> \<Longrightarrow> expectation (h_prod x) = exp_h_prod x
[PROOF STEP]
hence card_x: "card (set x) \<le> 4"
[PROOF STATE]
proof (prove)
using this:
length x \<le> 4

goal (1 subgoal):
 1. card (set x) \<le> 4
[PROOF STEP]
using card_length dual_order.trans
[PROOF STATE]
proof (prove)
using this:
length x \<le> 4
card (set ?xs) \<le> length ?xs
\<lbrakk>?b \<le> ?a; ?c \<le> ?b\<rbrakk> \<Longrightarrow> ?c \<le> ?a

goal (1 subgoal):
 1. card (set x) \<le> 4
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
card (set x) \<le> 4

goal (1 subgoal):
 1. \<And>x. \<lbrakk>set x \<subseteq> set as; length x \<le> 4\<rbrakk> \<Longrightarrow> expectation (h_prod x) = exp_h_prod x
[PROOF STEP]
have "set x \<subseteq> carrier (mod_ring p) "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set x \<subseteq> carrier (Field.mod_ring p)
[PROOF STEP]
using x_sub_p
[PROOF STATE]
proof (prove)
using this:
set x \<subseteq> {..<p}

goal (1 subgoal):
 1. set x \<subseteq> carrier (Field.mod_ring p)
[PROOF STEP]
by (simp add:mod_ring_def)
[PROOF STATE]
proof (state)
this:
set x \<subseteq> carrier (Field.mod_ring p)

goal (1 subgoal):
 1. \<And>x. \<lbrakk>set x \<subseteq> set as; length x \<le> 4\<rbrakk> \<Longrightarrow> expectation (h_prod x) = exp_h_prod x
[PROOF STEP]
hence h_indep: "indep_vars (\<lambda>_. borel) (\<lambda>i \<omega>. h \<omega> i ^ count_list x i) (set x)"
[PROOF STATE]
proof (prove)
using this:
set x \<subseteq> carrier (Field.mod_ring p)

goal (1 subgoal):
 1. indep_vars (\<lambda>_. borel) (\<lambda>i \<omega>. h \<omega> i ^ count_list x i) (set x)
[PROOF STEP]
using k_wise_indep_vars_subset[OF k_wise_indep] card_x as_range h_def
[PROOF STATE]
proof (prove)
using this:
set x \<subseteq> carrier (Field.mod_ring p)
\<lbrakk>?J \<subseteq> carrier (Field.mod_ring p); finite ?J; card ?J \<le> 4\<rbrakk> \<Longrightarrow> indep_vars (\<lambda>_. discrete) hash ?J
card (set x) \<le> 4
set as \<subseteq> {..<n}
h = (\<lambda>\<omega> x. real_of_int (f2_hash p \<omega> x))

goal (1 subgoal):
 1. indep_vars (\<lambda>_. borel) (\<lambda>i \<omega>. h \<omega> i ^ count_list x i) (set x)
[PROOF STEP]
by (auto intro:indep_vars_compose2[where X="hash" and M'=" (\<lambda>_. discrete)"])
[PROOF STATE]
proof (state)
this:
indep_vars (\<lambda>_. borel) (\<lambda>i \<omega>. h \<omega> i ^ count_list x i) (set x)

goal (1 subgoal):
 1. \<And>x. \<lbrakk>set x \<subseteq> set as; length x \<le> 4\<rbrakk> \<Longrightarrow> expectation (h_prod x) = exp_h_prod x
[PROOF STEP]
have "expectation (h_prod x) = expectation (\<lambda>\<omega>. \<Prod> i \<in> set x. h \<omega> i^(count_list x i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. expectation (h_prod x) = expectation (\<lambda>\<omega>. \<Prod>i\<in>set x. h \<omega> i ^ count_list x i)
[PROOF STEP]
by (simp add:h_prod_def prod_list_eval)
[PROOF STATE]
proof (state)
this:
expectation (h_prod x) = expectation (\<lambda>\<omega>. \<Prod>i\<in>set x. h \<omega> i ^ count_list x i)

goal (1 subgoal):
 1. \<And>x. \<lbrakk>set x \<subseteq> set as; length x \<le> 4\<rbrakk> \<Longrightarrow> expectation (h_prod x) = exp_h_prod x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
expectation (h_prod x) = expectation (\<lambda>\<omega>. \<Prod>i\<in>set x. h \<omega> i ^ count_list x i)

goal (1 subgoal):
 1. \<And>x. \<lbrakk>set x \<subseteq> set as; length x \<le> 4\<rbrakk> \<Longrightarrow> expectation (h_prod x) = exp_h_prod x
[PROOF STEP]
have "... = (\<Prod>i \<in> set x. expectation (\<lambda>\<omega>. h \<omega> i^(count_list x i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. expectation (\<lambda>\<omega>. \<Prod>i\<in>set x. h \<omega> i ^ count_list x i) = (\<Prod>i\<in>set x. expectation (\<lambda>\<omega>. h \<omega> i ^ count_list x i))
[PROOF STEP]
by (simp add: indep_vars_lebesgue_integral[OF _ h_indep])
[PROOF STATE]
proof (state)
this:
expectation (\<lambda>\<omega>. \<Prod>i\<in>set x. h \<omega> i ^ count_list x i) = (\<Prod>i\<in>set x. expectation (\<lambda>\<omega>. h \<omega> i ^ count_list x i))

goal (1 subgoal):
 1. \<And>x. \<lbrakk>set x \<subseteq> set as; length x \<le> 4\<rbrakk> \<Longrightarrow> expectation (h_prod x) = exp_h_prod x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
expectation (\<lambda>\<omega>. \<Prod>i\<in>set x. h \<omega> i ^ count_list x i) = (\<Prod>i\<in>set x. expectation (\<lambda>\<omega>. h \<omega> i ^ count_list x i))

goal (1 subgoal):
 1. \<And>x. \<lbrakk>set x \<subseteq> set as; length x \<le> 4\<rbrakk> \<Longrightarrow> expectation (h_prod x) = exp_h_prod x
[PROOF STEP]
have "... = (\<Prod>i \<in> set x. r (count_list x i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>i\<in>set x. expectation (\<lambda>\<omega>. h \<omega> i ^ count_list x i)) = (\<Prod>i\<in>set x. r (count_list x i))
[PROOF STEP]
using f2_hash_pow_exp x_le_p
[PROOF STATE]
proof (prove)
using this:
?k < p \<Longrightarrow> 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)
?k4 \<in> set x \<Longrightarrow> ?k4 < p

goal (1 subgoal):
 1. (\<Prod>i\<in>set x. expectation (\<lambda>\<omega>. h \<omega> i ^ count_list x i)) = (\<Prod>i\<in>set x. r (count_list x i))
[PROOF STEP]
by (simp add:h_def r_def M_def[symmetric] del:f2_hash.simps)
[PROOF STATE]
proof (state)
this:
(\<Prod>i\<in>set x. expectation (\<lambda>\<omega>. h \<omega> i ^ count_list x i)) = (\<Prod>i\<in>set x. r (count_list x i))

goal (1 subgoal):
 1. \<And>x. \<lbrakk>set x \<subseteq> set as; length x \<le> 4\<rbrakk> \<Longrightarrow> expectation (h_prod x) = exp_h_prod x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Prod>i\<in>set x. expectation (\<lambda>\<omega>. h \<omega> i ^ count_list x i)) = (\<Prod>i\<in>set x. r (count_list x i))

goal (1 subgoal):
 1. \<And>x. \<lbrakk>set x \<subseteq> set as; length x \<le> 4\<rbrakk> \<Longrightarrow> expectation (h_prod x) = exp_h_prod x
[PROOF STEP]
have "... = exp_h_prod x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>i\<in>set x. r (count_list x i)) = exp_h_prod x
[PROOF STEP]
by (simp add:exp_h_prod_def)
[PROOF STATE]
proof (state)
this:
(\<Prod>i\<in>set x. r (count_list x i)) = exp_h_prod x

goal (1 subgoal):
 1. \<And>x. \<lbrakk>set x \<subseteq> set as; length x \<le> 4\<rbrakk> \<Longrightarrow> expectation (h_prod x) = exp_h_prod x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
expectation (h_prod x) = exp_h_prod x
[PROOF STEP]
show "expectation (h_prod x) = exp_h_prod x"
[PROOF STATE]
proof (prove)
using this:
expectation (h_prod x) = exp_h_prod x

goal (1 subgoal):
 1. expectation (h_prod x) = exp_h_prod x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
expectation (h_prod x) = exp_h_prod x

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<lbrakk>set ?x4 \<subseteq> set as; length ?x4 \<le> 4\<rbrakk> \<Longrightarrow> expectation (h_prod ?x4) = exp_h_prod ?x4

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
have "\<And>x y. kernel_of x = kernel_of y \<Longrightarrow> exp_h_prod x = exp_h_prod y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x y. kernel_of x = kernel_of y \<Longrightarrow> exp_h_prod x = exp_h_prod y
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. kernel_of x = kernel_of y \<Longrightarrow> exp_h_prod x = exp_h_prod y
[PROOF STEP]
fix x y :: "nat list"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. kernel_of x = kernel_of y \<Longrightarrow> exp_h_prod x = exp_h_prod y
[PROOF STEP]
assume a:"kernel_of x = kernel_of y"
[PROOF STATE]
proof (state)
this:
kernel_of x = kernel_of y

goal (1 subgoal):
 1. \<And>x y. kernel_of x = kernel_of y \<Longrightarrow> exp_h_prod x = exp_h_prod y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
kernel_of x = kernel_of y
[PROOF STEP]
obtain f where b:"bij_betw f (set x) (set y)" and c:"\<And>z. z \<in> set x \<Longrightarrow> count_list x z = count_list y (f z)"
[PROOF STATE]
proof (prove)
using this:
kernel_of x = kernel_of y

goal (1 subgoal):
 1. (\<And>f. \<lbrakk>bij_betw f (set x) (set y); \<And>z. z \<in> set x \<Longrightarrow> count_list x z = count_list y (f z)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using kernel_of_eq_imp_bij
[PROOF STATE]
proof (prove)
using this:
kernel_of x = kernel_of y
kernel_of ?x = kernel_of ?y \<Longrightarrow> \<exists>f. bij_betw f (set ?x) (set ?y) \<and> (\<forall>z\<in>set ?x. count_list ?x z = count_list ?y (f z))

goal (1 subgoal):
 1. (\<And>f. \<lbrakk>bij_betw f (set x) (set y); \<And>z. z \<in> set x \<Longrightarrow> count_list x z = count_list y (f z)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
bij_betw f (set x) (set y)
?z4 \<in> set x \<Longrightarrow> count_list x ?z4 = count_list y (f ?z4)

goal (1 subgoal):
 1. \<And>x y. kernel_of x = kernel_of y \<Longrightarrow> exp_h_prod x = exp_h_prod y
[PROOF STEP]
have "exp_h_prod x = prod ( (\<lambda>i. r(count_list y i)) \<circ> f) (set x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. exp_h_prod x = prod ((\<lambda>i. r (count_list y i)) \<circ> f) (set x)
[PROOF STEP]
by (simp add:exp_h_prod_def c)
[PROOF STATE]
proof (state)
this:
exp_h_prod x = prod ((\<lambda>i. r (count_list y i)) \<circ> f) (set x)

goal (1 subgoal):
 1. \<And>x y. kernel_of x = kernel_of y \<Longrightarrow> exp_h_prod x = exp_h_prod y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
exp_h_prod x = prod ((\<lambda>i. r (count_list y i)) \<circ> f) (set x)

goal (1 subgoal):
 1. \<And>x y. kernel_of x = kernel_of y \<Longrightarrow> exp_h_prod x = exp_h_prod y
[PROOF STEP]
have "... = (\<Prod>i \<in> f ` (set x). r(count_list y i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prod ((\<lambda>i. r (count_list y i)) \<circ> f) (set x) = (\<Prod>i\<in>f ` set x. r (count_list y i))
[PROOF STEP]
by (metis b bij_betw_def prod.reindex)
[PROOF STATE]
proof (state)
this:
prod ((\<lambda>i. r (count_list y i)) \<circ> f) (set x) = (\<Prod>i\<in>f ` set x. r (count_list y i))

goal (1 subgoal):
 1. \<And>x y. kernel_of x = kernel_of y \<Longrightarrow> exp_h_prod x = exp_h_prod y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
prod ((\<lambda>i. r (count_list y i)) \<circ> f) (set x) = (\<Prod>i\<in>f ` set x. r (count_list y i))

goal (1 subgoal):
 1. \<And>x y. kernel_of x = kernel_of y \<Longrightarrow> exp_h_prod x = exp_h_prod y
[PROOF STEP]
have "... = exp_h_prod y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>i\<in>f ` set x. r (count_list y i)) = exp_h_prod y
[PROOF STEP]
unfolding exp_h_prod_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>i\<in>f ` set x. r (count_list y i)) = (\<Prod>i\<in>set y. r (count_list y i))
[PROOF STEP]
by (rule prod.cong, metis b bij_betw_def) simp
[PROOF STATE]
proof (state)
this:
(\<Prod>i\<in>f ` set x. r (count_list y i)) = exp_h_prod y

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

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
kernel_of ?x4 = kernel_of ?y4 \<Longrightarrow> exp_h_prod ?x4 = exp_h_prod ?y4

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
hence exp_h_prod_cong: "\<And>p x. of_bool (kernel_of x = kernel_of p) * exp_h_prod p =
    of_bool (kernel_of x = kernel_of p) * exp_h_prod x"
[PROOF STATE]
proof (prove)
using this:
kernel_of ?x4 = kernel_of ?y4 \<Longrightarrow> exp_h_prod ?x4 = exp_h_prod ?y4

goal (1 subgoal):
 1. \<And>p x. of_bool (kernel_of x = kernel_of p) * exp_h_prod p = of_bool (kernel_of x = kernel_of p) * exp_h_prod x
[PROOF STEP]
by (metis (full_types) of_bool_eq_0_iff vector_space_over_itself.scale_zero_left)
[PROOF STATE]
proof (state)
this:
of_bool (kernel_of ?x4 = kernel_of ?p4) * exp_h_prod ?p4 = of_bool (kernel_of ?x4 = kernel_of ?p4) * exp_h_prod ?x4

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
have c:"(\<Sum>p\<leftarrow>enum_rgfs n. of_bool (kernel_of xs = kernel_of p) * r) = r"
    if a:"length xs = n" for xs :: "nat list" and n and r :: real
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>p\<leftarrow>enum_rgfs n. of_bool (kernel_of xs = kernel_of p) * r) = r
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>p\<leftarrow>enum_rgfs n. of_bool (kernel_of xs = kernel_of p) * r) = r
[PROOF STEP]
have "(\<Sum>p\<leftarrow>enum_rgfs n. of_bool (kernel_of xs = kernel_of p) * 1) = (1::real)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>p\<leftarrow>enum_rgfs n. of_bool (kernel_of xs = kernel_of p) * 1) = 1
[PROOF STEP]
using equiv_rels_2[OF a[symmetric]]
[PROOF STATE]
proof (prove)
using this:
(\<Sum>x\<leftarrow>equiv_rels n. of_bool (kernel_of xs = x)) = (1::?'a)

goal (1 subgoal):
 1. (\<Sum>p\<leftarrow>enum_rgfs n. of_bool (kernel_of xs = kernel_of p) * 1) = 1
[PROOF STEP]
by (simp add:equiv_rels_def comp_def)
[PROOF STATE]
proof (state)
this:
(\<Sum>p\<leftarrow>enum_rgfs n. of_bool (kernel_of xs = kernel_of p) * 1) = 1

goal (1 subgoal):
 1. (\<Sum>p\<leftarrow>enum_rgfs n. of_bool (kernel_of xs = kernel_of p) * r) = r
[PROOF STEP]
thus "(\<Sum>p\<leftarrow>enum_rgfs n. of_bool (kernel_of xs = kernel_of p) * r) = (r::real)"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>p\<leftarrow>enum_rgfs n. of_bool (kernel_of xs = kernel_of p) * 1) = 1

goal (1 subgoal):
 1. (\<Sum>p\<leftarrow>enum_rgfs n. of_bool (kernel_of xs = kernel_of p) * r) = r
[PROOF STEP]
by (simp add:sum_list_mult_const)
[PROOF STATE]
proof (state)
this:
(\<Sum>p\<leftarrow>enum_rgfs n. of_bool (kernel_of xs = kernel_of p) * r) = r

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
length ?xs4 = ?n4 \<Longrightarrow> (\<Sum>p\<leftarrow>enum_rgfs ?n4. of_bool (kernel_of ?xs4 = kernel_of p) * ?r4) = ?r4

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
have "expectation sketch_rv = (\<Sum>i\<in>set as. (\<Sum>j\<in>set as. c i * c j * expectation (h_prod [i,j])))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. expectation sketch_rv = (\<Sum>i\<in>set as. \<Sum>j\<in>set as. c i * c j * expectation (h_prod [i, j]))
[PROOF STEP]
by (simp add:f_eq h_prod_def power2_eq_square sum_distrib_left sum_distrib_right Bochner_Integration.integral_sum algebra_simps)
[PROOF STATE]
proof (state)
this:
expectation sketch_rv = (\<Sum>i\<in>set as. \<Sum>j\<in>set as. c i * c j * expectation (h_prod [i, j]))

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
expectation sketch_rv = (\<Sum>i\<in>set as. \<Sum>j\<in>set as. c i * c j * expectation (h_prod [i, j]))

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
have "... = (\<Sum>i\<in>set as. (\<Sum>j\<in>set as. c i * c j * exp_h_prod [i,j]))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>set as. \<Sum>j\<in>set as. c i * c j * expectation (h_prod [i, j])) = (\<Sum>i\<in>set as. \<Sum>j\<in>set as. c i * c j * exp_h_prod [i, j])
[PROOF STEP]
by (simp add:exp_h_prod)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>set as. \<Sum>j\<in>set as. c i * c j * expectation (h_prod [i, j])) = (\<Sum>i\<in>set as. \<Sum>j\<in>set as. c i * c j * exp_h_prod [i, j])

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>set as. \<Sum>j\<in>set as. c i * c j * expectation (h_prod [i, j])) = (\<Sum>i\<in>set as. \<Sum>j\<in>set as. c i * c j * exp_h_prod [i, j])

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
have "... = (\<Sum>i \<in> set as. (\<Sum>j \<in> set as.
    c i * c j * (sum_list (map (\<lambda>p. of_bool (kernel_of [i,j] = kernel_of p) * exp_h_prod p) (enum_rgfs 2)))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>set as. \<Sum>j\<in>set as. c i * c j * exp_h_prod [i, j]) = (\<Sum>i\<in>set as. \<Sum>j\<in>set as. c i * c j * (\<Sum>p\<leftarrow>enum_rgfs 2. of_bool (kernel_of [i, j] = kernel_of p) * exp_h_prod p))
[PROOF STEP]
by (subst exp_h_prod_cong, simp add:c)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>set as. \<Sum>j\<in>set as. c i * c j * exp_h_prod [i, j]) = (\<Sum>i\<in>set as. \<Sum>j\<in>set as. c i * c j * (\<Sum>p\<leftarrow>enum_rgfs 2. of_bool (kernel_of [i, j] = kernel_of p) * exp_h_prod p))

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>set as. \<Sum>j\<in>set as. c i * c j * exp_h_prod [i, j]) = (\<Sum>i\<in>set as. \<Sum>j\<in>set as. c i * c j * (\<Sum>p\<leftarrow>enum_rgfs 2. of_bool (kernel_of [i, j] = kernel_of p) * exp_h_prod p))

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
have "... = (\<Sum>i\<in>set as. c i * c i * r 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>set as. \<Sum>j\<in>set as. c i * c j * (\<Sum>p\<leftarrow>enum_rgfs 2. of_bool (kernel_of [i, j] = kernel_of p) * exp_h_prod p)) = (\<Sum>i\<in>set as. c i * c i * r 2)
[PROOF STEP]
by (simp add: numeral_eq_Suc kernel_of_eq All_less_Suc exp_h_prod_elim r_one distrib_left sum.distrib sum_collapse)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>set as. \<Sum>j\<in>set as. c i * c j * (\<Sum>p\<leftarrow>enum_rgfs 2. of_bool (kernel_of [i, j] = kernel_of p) * exp_h_prod p)) = (\<Sum>i\<in>set as. c i * c i * r 2)

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>set as. \<Sum>j\<in>set as. c i * c j * (\<Sum>p\<leftarrow>enum_rgfs 2. of_bool (kernel_of [i, j] = kernel_of p) * exp_h_prod p)) = (\<Sum>i\<in>set as. c i * c i * r 2)

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
have "... = real_of_rat (F 2 as) * ((real p)^2-1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>set as. c i * c i * r 2) = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
by (simp add: sum_distrib_right[symmetric] c_def F_def power2_eq_square of_rat_sum of_rat_mult r_two)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>set as. c i * c i * r 2) = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)

goal (2 subgoals):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
 2. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
show b:?B
[PROOF STATE]
proof (prove)
using this:
expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)

goal (1 subgoal):
 1. expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
expectation sketch_rv = real_of_rat (F 2 as) * ((real p)\<^sup>2 - 1)

goal (1 subgoal):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
[PROOF STEP]
have "expectation (\<lambda>x. (sketch_rv x)\<^sup>2) = (\<Sum>i1 \<in> set as. (\<Sum>i2 \<in> set as. (\<Sum>i3 \<in> set as. (\<Sum>i4 \<in> set as.
    c i1 * c i2 * c i3 * c i4 * expectation (h_prod [i1, i2, i3, i4])))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. expectation (\<lambda>x. (sketch_rv x)\<^sup>2) = (\<Sum>i1\<in>set as. \<Sum>i2\<in>set as. \<Sum>i3\<in>set as. \<Sum>i4\<in>set as. c i1 * c i2 * c i3 * c i4 * expectation (h_prod [i1, i2, i3, i4]))
[PROOF STEP]
by (simp add:f_eq h_prod_def power4_eq_xxxx sum_distrib_left sum_distrib_right Bochner_Integration.integral_sum algebra_simps)
[PROOF STATE]
proof (state)
this:
expectation (\<lambda>x. (sketch_rv x)\<^sup>2) = (\<Sum>i1\<in>set as. \<Sum>i2\<in>set as. \<Sum>i3\<in>set as. \<Sum>i4\<in>set as. c i1 * c i2 * c i3 * c i4 * expectation (h_prod [i1, i2, i3, i4]))

goal (1 subgoal):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
expectation (\<lambda>x. (sketch_rv x)\<^sup>2) = (\<Sum>i1\<in>set as. \<Sum>i2\<in>set as. \<Sum>i3\<in>set as. \<Sum>i4\<in>set as. c i1 * c i2 * c i3 * c i4 * expectation (h_prod [i1, i2, i3, i4]))

goal (1 subgoal):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
[PROOF STEP]
have "... = (\<Sum>i1 \<in> set as. (\<Sum>i2 \<in> set as. (\<Sum>i3 \<in> set as. (\<Sum>i4 \<in> set as.
    c i1 * c i2 * c i3 * c i4 * exp_h_prod [i1,i2,i3,i4]))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i1\<in>set as. \<Sum>i2\<in>set as. \<Sum>i3\<in>set as. \<Sum>i4\<in>set as. c i1 * c i2 * c i3 * c i4 * expectation (h_prod [i1, i2, i3, i4])) = (\<Sum>i1\<in>set as. \<Sum>i2\<in>set as. \<Sum>i3\<in>set as. \<Sum>i4\<in>set as. c i1 * c i2 * c i3 * c i4 * exp_h_prod [i1, i2, i3, i4])
[PROOF STEP]
by (simp add:exp_h_prod)
[PROOF STATE]
proof (state)
this:
(\<Sum>i1\<in>set as. \<Sum>i2\<in>set as. \<Sum>i3\<in>set as. \<Sum>i4\<in>set as. c i1 * c i2 * c i3 * c i4 * expectation (h_prod [i1, i2, i3, i4])) = (\<Sum>i1\<in>set as. \<Sum>i2\<in>set as. \<Sum>i3\<in>set as. \<Sum>i4\<in>set as. c i1 * c i2 * c i3 * c i4 * exp_h_prod [i1, i2, i3, i4])

goal (1 subgoal):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i1\<in>set as. \<Sum>i2\<in>set as. \<Sum>i3\<in>set as. \<Sum>i4\<in>set as. c i1 * c i2 * c i3 * c i4 * expectation (h_prod [i1, i2, i3, i4])) = (\<Sum>i1\<in>set as. \<Sum>i2\<in>set as. \<Sum>i3\<in>set as. \<Sum>i4\<in>set as. c i1 * c i2 * c i3 * c i4 * exp_h_prod [i1, i2, i3, i4])

goal (1 subgoal):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
[PROOF STEP]
have "... = (\<Sum>i1 \<in> set as. (\<Sum>i2 \<in> set as. (\<Sum>i3 \<in> set as. (\<Sum>i4 \<in> set as.
    c i1 * c i2 * c i3 * c i4 *
    (sum_list (map (\<lambda>p. of_bool (kernel_of [i1,i2,i3,i4] = kernel_of p) * exp_h_prod p) (enum_rgfs 4)))))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i1\<in>set as. \<Sum>i2\<in>set as. \<Sum>i3\<in>set as. \<Sum>i4\<in>set as. c i1 * c i2 * c i3 * c i4 * exp_h_prod [i1, i2, i3, i4]) = (\<Sum>i1\<in>set as. \<Sum>i2\<in>set as. \<Sum>i3\<in>set as. \<Sum>i4\<in>set as. c i1 * c i2 * c i3 * c i4 * (\<Sum>p\<leftarrow>enum_rgfs 4. of_bool (kernel_of [i1, i2, i3, i4] = kernel_of p) * exp_h_prod p))
[PROOF STEP]
by (subst exp_h_prod_cong, simp add:c)
[PROOF STATE]
proof (state)
this:
(\<Sum>i1\<in>set as. \<Sum>i2\<in>set as. \<Sum>i3\<in>set as. \<Sum>i4\<in>set as. c i1 * c i2 * c i3 * c i4 * exp_h_prod [i1, i2, i3, i4]) = (\<Sum>i1\<in>set as. \<Sum>i2\<in>set as. \<Sum>i3\<in>set as. \<Sum>i4\<in>set as. c i1 * c i2 * c i3 * c i4 * (\<Sum>p\<leftarrow>enum_rgfs 4. of_bool (kernel_of [i1, i2, i3, i4] = kernel_of p) * exp_h_prod p))

goal (1 subgoal):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i1\<in>set as. \<Sum>i2\<in>set as. \<Sum>i3\<in>set as. \<Sum>i4\<in>set as. c i1 * c i2 * c i3 * c i4 * exp_h_prod [i1, i2, i3, i4]) = (\<Sum>i1\<in>set as. \<Sum>i2\<in>set as. \<Sum>i3\<in>set as. \<Sum>i4\<in>set as. c i1 * c i2 * c i3 * c i4 * (\<Sum>p\<leftarrow>enum_rgfs 4. of_bool (kernel_of [i1, i2, i3, i4] = kernel_of p) * exp_h_prod p))

goal (1 subgoal):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
[PROOF STEP]
have "... =
    3 * (\<Sum>i \<in> set as. (\<Sum>j \<in> set as. c i^2 * c j^2 * r 2 * r 2)) + ((\<Sum> i \<in> set as. c i^4 * r 4) - 3 *  (\<Sum> i \<in> set as. c i ^ 4 * r 2 * r 2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i1\<in>set as. \<Sum>i2\<in>set as. \<Sum>i3\<in>set as. \<Sum>i4\<in>set as. c i1 * c i2 * c i3 * c i4 * (\<Sum>p\<leftarrow>enum_rgfs 4. of_bool (kernel_of [i1, i2, i3, i4] = kernel_of p) * exp_h_prod p)) = 3 * (\<Sum>i\<in>set as. \<Sum>j\<in>set as. (c i)\<^sup>2 * (c j)\<^sup>2 * r 2 * r 2) + ((\<Sum>i\<in>set as. c i ^ 4 * r 4) - 3 * (\<Sum>i\<in>set as. c i ^ 4 * r 2 * r 2))
[PROOF STEP]
apply (simp add: numeral_eq_Suc exp_h_prod_elim r_one)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i1\<in>set as. \<Sum>i2\<in>set as. \<Sum>i3\<in>set as. \<Sum>i4\<in>set as. c i1 * c i2 * c i3 * c i4 * (of_bool (kernel_of [i1, i2, i3, i4] = kernel_of [0, 0, 0, 0]) * r (Suc (Suc (Suc (Suc 0)))) + (of_bool (kernel_of [i1, i2, i3, i4] = kernel_of [0, 0, Suc 0, Suc 0]) * (r (Suc (Suc 0)) * r (Suc (Suc 0))) + (of_bool (kernel_of [i1, i2, i3, i4] = kernel_of [0, Suc 0, 0, Suc 0]) * (r (Suc (Suc 0)) * r (Suc (Suc 0))) + of_bool (kernel_of [i1, i2, i3, i4] = kernel_of [0, Suc 0, Suc 0, 0]) * (r (Suc (Suc 0)) * r (Suc (Suc 0))))))) = 3 * (\<Sum>i\<in>set as. \<Sum>j\<in>set as. c i * c i * (c j * c j) * r (Suc (Suc 0)) * r (Suc (Suc 0))) + ((\<Sum>i\<in>set as. c i * (c i * (c i * c i)) * r (Suc (Suc (Suc (Suc 0))))) - 3 * (\<Sum>i\<in>set as. c i * (c i * (c i * c i)) * r (Suc (Suc 0)) * r (Suc (Suc 0))))
[PROOF STEP]
(* large intermediate terms *)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i1\<in>set as. \<Sum>i2\<in>set as. \<Sum>i3\<in>set as. \<Sum>i4\<in>set as. c i1 * c i2 * c i3 * c i4 * (of_bool (kernel_of [i1, i2, i3, i4] = kernel_of [0, 0, 0, 0]) * r (Suc (Suc (Suc (Suc 0)))) + (of_bool (kernel_of [i1, i2, i3, i4] = kernel_of [0, 0, Suc 0, Suc 0]) * (r (Suc (Suc 0)) * r (Suc (Suc 0))) + (of_bool (kernel_of [i1, i2, i3, i4] = kernel_of [0, Suc 0, 0, Suc 0]) * (r (Suc (Suc 0)) * r (Suc (Suc 0))) + of_bool (kernel_of [i1, i2, i3, i4] = kernel_of [0, Suc 0, Suc 0, 0]) * (r (Suc (Suc 0)) * r (Suc (Suc 0))))))) = 3 * (\<Sum>i\<in>set as. \<Sum>j\<in>set as. c i * c i * (c j * c j) * r (Suc (Suc 0)) * r (Suc (Suc 0))) + ((\<Sum>i\<in>set as. c i * (c i * (c i * c i)) * r (Suc (Suc (Suc (Suc 0))))) - 3 * (\<Sum>i\<in>set as. c i * (c i * (c i * c i)) * r (Suc (Suc 0)) * r (Suc (Suc 0))))
[PROOF STEP]
apply (simp add: kernel_of_eq All_less_Suc numeral_eq_Suc distrib_left sum.distrib sum_collapse neq_commute of_bool_not_iff)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i1\<in>set as. c i1 * c i1 * c i1 * c i1 * r (Suc (Suc (Suc (Suc 0))))) + ((\<Sum>i1\<in>set as. \<Sum>i3\<in>set as. c i1 * c i1 * c i3 * c i3 * ((1 - of_bool (i1 = i3)) * (r (Suc (Suc 0)) * r (Suc (Suc 0))))) + (\<Sum>i1\<in>set as. \<Sum>i2\<in>set as. 2 * (c i1 * (c i1 * (c i2 * (c i2 * (r (Suc (Suc 0)) * (r (Suc (Suc 0)) * (1 - of_bool (i1 = i2)))))))))) = 3 * (\<Sum>i\<in>set as. \<Sum>j\<in>set as. c i * c i * (c j * c j) * r (Suc (Suc 0)) * r (Suc (Suc 0))) + ((\<Sum>i\<in>set as. c i * (c i * (c i * c i)) * r (Suc (Suc (Suc (Suc 0))))) - 3 * (\<Sum>i\<in>set as. c i * (c i * (c i * c i)) * r (Suc (Suc 0)) * r (Suc (Suc 0))))
[PROOF STEP]
apply (simp add: algebra_simps sum_subtractf sum_collapse)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * (\<Sum>i1\<in>set as. c i1 * (c i1 * (c i1 * (c i1 * (r (Suc (Suc 0)) * r (Suc (Suc 0))))))) + (\<Sum>i1\<in>set as. \<Sum>i2\<in>set as. c i1 * (c i1 * (c i2 * (c i2 * (2 * (r (Suc (Suc 0)) * r (Suc (Suc 0)))))))) = (\<Sum>i1\<in>set as. c i1 * (c i1 * (c i1 * (c i1 * (2 * (r (Suc (Suc 0)) * r (Suc (Suc 0)))))))) + 2 * (\<Sum>i1\<in>set as. \<Sum>i3\<in>set as. c i1 * (c i1 * (c i3 * (c i3 * (r (Suc (Suc 0)) * r (Suc (Suc 0)))))))
[PROOF STEP]
apply (simp add: sum_distrib_left algebra_simps)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
(\<Sum>i1\<in>set as. \<Sum>i2\<in>set as. \<Sum>i3\<in>set as. \<Sum>i4\<in>set as. c i1 * c i2 * c i3 * c i4 * (\<Sum>p\<leftarrow>enum_rgfs 4. of_bool (kernel_of [i1, i2, i3, i4] = kernel_of p) * exp_h_prod p)) = 3 * (\<Sum>i\<in>set as. \<Sum>j\<in>set as. (c i)\<^sup>2 * (c j)\<^sup>2 * r 2 * r 2) + ((\<Sum>i\<in>set as. c i ^ 4 * r 4) - 3 * (\<Sum>i\<in>set as. c i ^ 4 * r 2 * r 2))

goal (1 subgoal):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i1\<in>set as. \<Sum>i2\<in>set as. \<Sum>i3\<in>set as. \<Sum>i4\<in>set as. c i1 * c i2 * c i3 * c i4 * (\<Sum>p\<leftarrow>enum_rgfs 4. of_bool (kernel_of [i1, i2, i3, i4] = kernel_of p) * exp_h_prod p)) = 3 * (\<Sum>i\<in>set as. \<Sum>j\<in>set as. (c i)\<^sup>2 * (c j)\<^sup>2 * r 2 * r 2) + ((\<Sum>i\<in>set as. c i ^ 4 * r 4) - 3 * (\<Sum>i\<in>set as. c i ^ 4 * r 2 * r 2))

goal (1 subgoal):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
[PROOF STEP]
have "... = 3 * (\<Sum>i \<in> set as. c i^2 * r 2)^2 + (\<Sum> i \<in> set as. c i ^ 4 * (r 4 - 3 * r 2 * r 2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 3 * (\<Sum>i\<in>set as. \<Sum>j\<in>set as. (c i)\<^sup>2 * (c j)\<^sup>2 * r 2 * r 2) + ((\<Sum>i\<in>set as. c i ^ 4 * r 4) - 3 * (\<Sum>i\<in>set as. c i ^ 4 * r 2 * r 2)) = 3 * (\<Sum>i\<in>set as. (c i)\<^sup>2 * r 2)\<^sup>2 + (\<Sum>i\<in>set as. c i ^ 4 * (r 4 - 3 * r 2 * r 2))
[PROOF STEP]
by (simp add:power2_eq_square sum_distrib_left algebra_simps sum_subtractf)
[PROOF STATE]
proof (state)
this:
3 * (\<Sum>i\<in>set as. \<Sum>j\<in>set as. (c i)\<^sup>2 * (c j)\<^sup>2 * r 2 * r 2) + ((\<Sum>i\<in>set as. c i ^ 4 * r 4) - 3 * (\<Sum>i\<in>set as. c i ^ 4 * r 2 * r 2)) = 3 * (\<Sum>i\<in>set as. (c i)\<^sup>2 * r 2)\<^sup>2 + (\<Sum>i\<in>set as. c i ^ 4 * (r 4 - 3 * r 2 * r 2))

goal (1 subgoal):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
3 * (\<Sum>i\<in>set as. \<Sum>j\<in>set as. (c i)\<^sup>2 * (c j)\<^sup>2 * r 2 * r 2) + ((\<Sum>i\<in>set as. c i ^ 4 * r 4) - 3 * (\<Sum>i\<in>set as. c i ^ 4 * r 2 * r 2)) = 3 * (\<Sum>i\<in>set as. (c i)\<^sup>2 * r 2)\<^sup>2 + (\<Sum>i\<in>set as. c i ^ 4 * (r 4 - 3 * r 2 * r 2))

goal (1 subgoal):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
[PROOF STEP]
have "... = 3 * (\<Sum>i \<in> set as. c i^2)^2 * (r 2)^2 + (\<Sum>i \<in> set as. c i ^ 4 * (r 4 - 3 * r 2 * r 2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 3 * (\<Sum>i\<in>set as. (c i)\<^sup>2 * r 2)\<^sup>2 + (\<Sum>i\<in>set as. c i ^ 4 * (r 4 - 3 * r 2 * r 2)) = 3 * (\<Sum>i\<in>set as. (c i)\<^sup>2)\<^sup>2 * (r 2)\<^sup>2 + (\<Sum>i\<in>set as. c i ^ 4 * (r 4 - 3 * r 2 * r 2))
[PROOF STEP]
by (simp add:power_mult_distrib sum_distrib_right[symmetric])
[PROOF STATE]
proof (state)
this:
3 * (\<Sum>i\<in>set as. (c i)\<^sup>2 * r 2)\<^sup>2 + (\<Sum>i\<in>set as. c i ^ 4 * (r 4 - 3 * r 2 * r 2)) = 3 * (\<Sum>i\<in>set as. (c i)\<^sup>2)\<^sup>2 * (r 2)\<^sup>2 + (\<Sum>i\<in>set as. c i ^ 4 * (r 4 - 3 * r 2 * r 2))

goal (1 subgoal):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
3 * (\<Sum>i\<in>set as. (c i)\<^sup>2 * r 2)\<^sup>2 + (\<Sum>i\<in>set as. c i ^ 4 * (r 4 - 3 * r 2 * r 2)) = 3 * (\<Sum>i\<in>set as. (c i)\<^sup>2)\<^sup>2 * (r 2)\<^sup>2 + (\<Sum>i\<in>set as. c i ^ 4 * (r 4 - 3 * r 2 * r 2))

goal (1 subgoal):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
[PROOF STEP]
have "... \<le> 3 * (\<Sum>i \<in> set as. c i^2)^2 * (r 2)^2 + (\<Sum>i \<in> set as. c i ^ 4 * 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 3 * (\<Sum>i\<in>set as. (c i)\<^sup>2)\<^sup>2 * (r 2)\<^sup>2 + (\<Sum>i\<in>set as. c i ^ 4 * (r 4 - 3 * r 2 * r 2)) \<le> 3 * (\<Sum>i\<in>set as. (c i)\<^sup>2)\<^sup>2 * (r 2)\<^sup>2 + (\<Sum>i\<in>set as. c i ^ 4 * 0)
[PROOF STEP]
using r_four_est
[PROOF STATE]
proof (prove)
using this:
r 4 \<le> 3 * r 2 * r 2

goal (1 subgoal):
 1. 3 * (\<Sum>i\<in>set as. (c i)\<^sup>2)\<^sup>2 * (r 2)\<^sup>2 + (\<Sum>i\<in>set as. c i ^ 4 * (r 4 - 3 * r 2 * r 2)) \<le> 3 * (\<Sum>i\<in>set as. (c i)\<^sup>2)\<^sup>2 * (r 2)\<^sup>2 + (\<Sum>i\<in>set as. c i ^ 4 * 0)
[PROOF STEP]
by (auto intro!: sum_nonpos simp add:mult_nonneg_nonpos)
[PROOF STATE]
proof (state)
this:
3 * (\<Sum>i\<in>set as. (c i)\<^sup>2)\<^sup>2 * (r 2)\<^sup>2 + (\<Sum>i\<in>set as. c i ^ 4 * (r 4 - 3 * r 2 * r 2)) \<le> 3 * (\<Sum>i\<in>set as. (c i)\<^sup>2)\<^sup>2 * (r 2)\<^sup>2 + (\<Sum>i\<in>set as. c i ^ 4 * 0)

goal (1 subgoal):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
3 * (\<Sum>i\<in>set as. (c i)\<^sup>2)\<^sup>2 * (r 2)\<^sup>2 + (\<Sum>i\<in>set as. c i ^ 4 * (r 4 - 3 * r 2 * r 2)) \<le> 3 * (\<Sum>i\<in>set as. (c i)\<^sup>2)\<^sup>2 * (r 2)\<^sup>2 + (\<Sum>i\<in>set as. c i ^ 4 * 0)

goal (1 subgoal):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
[PROOF STEP]
have "... = 3 * (real_of_rat (F 2 as)^2) * ((real p)\<^sup>2-1)\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 3 * (\<Sum>i\<in>set as. (c i)\<^sup>2)\<^sup>2 * (r 2)\<^sup>2 + (\<Sum>i\<in>set as. c i ^ 4 * 0) = 3 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
[PROOF STEP]
by (simp add:c_def r_two F_def of_rat_sum of_rat_power)
[PROOF STATE]
proof (state)
this:
3 * (\<Sum>i\<in>set as. (c i)\<^sup>2)\<^sup>2 * (r 2)\<^sup>2 + (\<Sum>i\<in>set as. c i ^ 4 * 0) = 3 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2

goal (1 subgoal):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
expectation (\<lambda>x. (sketch_rv x)\<^sup>2) \<le> 3 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
[PROOF STEP]
have "expectation (\<lambda>x. (sketch_rv x)\<^sup>2) \<le> 3 * (real_of_rat (F 2 as)^2) * ((real p)\<^sup>2-1)\<^sup>2"
[PROOF STATE]
proof (prove)
using this:
expectation (\<lambda>x. (sketch_rv x)\<^sup>2) \<le> 3 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2

goal (1 subgoal):
 1. expectation (\<lambda>x. (sketch_rv x)\<^sup>2) \<le> 3 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
expectation (\<lambda>x. (sketch_rv x)\<^sup>2) \<le> 3 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2

goal (1 subgoal):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
[PROOF STEP]
thus "variance sketch_rv \<le> 2*(real_of_rat (F 2 as)^2) * ((real p)\<^sup>2-1)\<^sup>2"
[PROOF STATE]
proof (prove)
using this:
expectation (\<lambda>x. (sketch_rv x)\<^sup>2) \<le> 3 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2

goal (1 subgoal):
 1. expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2
[PROOF STEP]
by (simp add: variance_eq, simp add:power_mult_distrib b)
[PROOF STATE]
proof (state)
this:
expectation (\<lambda>x. (sketch_rv x - expectation sketch_rv)\<^sup>2) \<le> 2 * (real_of_rat (F 2 as))\<^sup>2 * ((real p)\<^sup>2 - 1)\<^sup>2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma uminus_SUP: "- (SUP x\<in>A. B x) = (INF x\<in>A. - B x)" for B :: \<open>'a \<Rightarrow> 'b::complete_orthocomplemented_lattice\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. - \<Squnion> (B ` A) = (\<Sqinter>x\<in>A. - B x)
[PROOF STEP]
by (simp add: uminus_Sup image_image)


[STATEMENT]
lemma to_int_mod_ring_plus: "to_int_mod_ring ((x :: 'a mod_ring) + y) = M (to_int_mod_ring x + to_int_mod_ring y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. to_int_mod_ring (x + y) = M (to_int_mod_ring x + to_int_mod_ring y)
[PROOF STEP]
unfolding M_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. to_int_mod_ring (x + y) = (to_int_mod_ring x + to_int_mod_ring y) mod m
[PROOF STEP]
using m
[PROOF STATE]
proof (prove)
using this:
m = int CARD('a)

goal (1 subgoal):
 1. to_int_mod_ring (x + y) = (to_int_mod_ring x + to_int_mod_ring y) mod m
[PROOF STEP]
by (transfer, auto)


[STATEMENT]
lemma gfp_fusion_var:
  fixes F :: "('a::order \<Rightarrow> 'b::complete_lattice) \<Rightarrow> 'a \<Rightarrow> 'b"
  and g :: "'b \<Rightarrow> 'b"
  assumes "mono F"
  and "mono g"
  and "\<forall>h. F h x = g (h x)"
  shows "gfp F x = gfp g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gfp F x = gfp g
[PROOF STEP]
by (metis (no_types, opaque_lifting) assms eq_iff gfp_fixpoint gfp_upperbound k_adju_var monoE order_refl)


[STATEMENT]
lemma cart_product_add_1_filter2: "{#m \<in># (M \<times># (add_mset b N)) . P m #} =
    {#m \<in># (M \<times># N) . P m #} + {#m \<in># (M \<times>#  {#b#}) . P m #}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. filter_mset P (M \<times># add_mset b N) = filter_mset P (M \<times># N) + filter_mset P (M \<times># {#b#})
[PROOF STEP]
unfolding add_mset_add_single [of b N] Sigma_mset_plus_distrib1
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. filter_mset P (M \<times># (N + {#b#})) = filter_mset P (M \<times># N) + filter_mset P (M \<times># {#b#})
[PROOF STEP]
by (metis Times_insert_left Times_mset_single_right add_mset_add_single filter_union_mset)


[STATEMENT]
lemma hv_him_eq: "Hv(HIm q) = q \<longleftrightarrow> Re q = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Hv (HIm q) = q) = (quat.Re q = 0)
[PROOF STEP]
by (simp add: hv_him quat_eq_iff)


[STATEMENT]
lemma rbt_map_rel_sv[relator_props]:
  "\<lbrakk>single_valued Rk; single_valued Rv\<rbrakk>
  \<Longrightarrow> single_valued (\<langle>Rk,Rv\<rangle>rbt_map_rel lt)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>single_valued Rk; single_valued Rv\<rbrakk> \<Longrightarrow> single_valued (\<langle>Rk, Rv\<rangle>rbt_map_rel lt)
[PROOF STEP]
apply (auto simp: rbt_map_rel_def rbt_map_rel'_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>single_valued Rk; single_valued Rv\<rbrakk> \<Longrightarrow> single_valued (\<langle>Rk, Rv\<rangle>rbt_rel O br (ord.rbt_lookup lt) (ord.is_rbt lt))
[PROOF STEP]
apply (rule single_valued_relcomp)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>single_valued Rk; single_valued Rv\<rbrakk> \<Longrightarrow> single_valued (\<langle>Rk, Rv\<rangle>rbt_rel)
 2. \<lbrakk>single_valued Rk; single_valued Rv\<rbrakk> \<Longrightarrow> single_valued (br (ord.rbt_lookup lt) (ord.is_rbt lt))
[PROOF STEP]
apply (rule rbt_rel_sv, assumption+)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>single_valued Rk; single_valued Rv\<rbrakk> \<Longrightarrow> single_valued (br (ord.rbt_lookup lt) (ord.is_rbt lt))
[PROOF STEP]
apply (rule br_sv)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
theorem corec2:
  "dtor2 (corec2 s1 s2 a) =
    F2map id (case_sum id (corec1 s1 s2)) (case_sum id (corec2 s1 s2)) (s2 a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dtor2 (corec2 s1 s2 a) = F2map id (case_sum id (corec1 s1 s2)) (case_sum id (corec2 s1 s2)) (s2 a)
[PROOF STEP]
unfolding corec1_def corec2_def o_apply unfold2 sum.case
    case_sum_expand_Inr[OF corec1_Inl_sum] case_sum_expand_Inr[OF corec2_Inl_sum]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. F2map id (unfold1 (case_sum (\<lambda>x. F1map id Inl Inl (dtor1 x)) s1) (case_sum (\<lambda>x. F2map id Inl Inl (dtor2 x)) s2)) (unfold2 (case_sum (\<lambda>x. F1map id Inl Inl (dtor1 x)) s1) (case_sum (\<lambda>x. F2map id Inl Inl (dtor2 x)) s2)) (s2 a) = F2map id (unfold1 (case_sum (\<lambda>x. F1map id Inl Inl (dtor1 x)) s1) (case_sum (\<lambda>x. F2map id Inl Inl (dtor2 x)) s2)) (unfold2 (case_sum (\<lambda>x. F1map id Inl Inl (dtor1 x)) s1) (case_sum (\<lambda>x. F2map id Inl Inl (dtor2 x)) s2)) (s2 a)
[PROOF STEP]
..


[STATEMENT]
lemma abs_infty_q_triangle_ineq:
  "abs_infty_q (x+y) \<le> abs_infty_q x + abs_infty_q y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. abs_infty_q (x + y) \<le> abs_infty_q x + abs_infty_q y
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. abs_infty_q (x + y) \<le> abs_infty_q x + abs_infty_q y
[PROOF STEP]
have "to_int_mod_ring (x + y) mod+- q =
        (to_int_mod_ring x + to_int_mod_ring y) mod q mod+-q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. to_int_mod_ring (x + y) mod+- q = (to_int_mod_ring x + to_int_mod_ring y) mod q mod+- q
[PROOF STEP]
by (simp add: to_int_mod_ring_def CARD_a plus_mod_ring.rep_eq)
[PROOF STATE]
proof (state)
this:
to_int_mod_ring (x + y) mod+- q = (to_int_mod_ring x + to_int_mod_ring y) mod q mod+- q

goal (1 subgoal):
 1. abs_infty_q (x + y) \<le> abs_infty_q x + abs_infty_q y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
to_int_mod_ring (x + y) mod+- q = (to_int_mod_ring x + to_int_mod_ring y) mod q mod+- q

goal (1 subgoal):
 1. abs_infty_q (x + y) \<le> abs_infty_q x + abs_infty_q y
[PROOF STEP]
have "\<dots> = (to_int_mod_ring x + to_int_mod_ring y) mod+-q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (to_int_mod_ring x + to_int_mod_ring y) mod q mod+- q = (to_int_mod_ring x + to_int_mod_ring y) mod+- q
[PROOF STEP]
unfolding mod_plus_minus_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((to_int_mod_ring x + to_int_mod_ring y) mod q + \<lfloor>real_of_int q / 2\<rfloor>) mod q - \<lfloor>real_of_int q / 2\<rfloor> = (to_int_mod_ring x + to_int_mod_ring y + \<lfloor>real_of_int q / 2\<rfloor>) mod q - \<lfloor>real_of_int q / 2\<rfloor>
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
(to_int_mod_ring x + to_int_mod_ring y) mod q mod+- q = (to_int_mod_ring x + to_int_mod_ring y) mod+- q

goal (1 subgoal):
 1. abs_infty_q (x + y) \<le> abs_infty_q x + abs_infty_q y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(to_int_mod_ring x + to_int_mod_ring y) mod q mod+- q = (to_int_mod_ring x + to_int_mod_ring y) mod+- q

goal (1 subgoal):
 1. abs_infty_q (x + y) \<le> abs_infty_q x + abs_infty_q y
[PROOF STEP]
have "\<dots> = (to_int_mod_ring x mod+- q +
    to_int_mod_ring y mod+- q) mod+- q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (to_int_mod_ring x + to_int_mod_ring y) mod+- q = (to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q
[PROOF STEP]
unfolding mod_plus_minus_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (to_int_mod_ring x + to_int_mod_ring y + \<lfloor>real_of_int q / 2\<rfloor>) mod q - \<lfloor>real_of_int q / 2\<rfloor> = ((to_int_mod_ring x + \<lfloor>real_of_int q / 2\<rfloor>) mod q - \<lfloor>real_of_int q / 2\<rfloor> + ((to_int_mod_ring y + \<lfloor>real_of_int q / 2\<rfloor>) mod q - \<lfloor>real_of_int q / 2\<rfloor>) + \<lfloor>real_of_int q / 2\<rfloor>) mod q - \<lfloor>real_of_int q / 2\<rfloor>
[PROOF STEP]
by (smt (verit, ccfv_threshold) mod_add_eq mod_diff_left_eq)
[PROOF STATE]
proof (state)
this:
(to_int_mod_ring x + to_int_mod_ring y) mod+- q = (to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q

goal (1 subgoal):
 1. abs_infty_q (x + y) \<le> abs_infty_q x + abs_infty_q y
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
to_int_mod_ring (x + y) mod+- q = (to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q
[PROOF STEP]
have rewrite:"to_int_mod_ring (x + y) mod+- q =
    (to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q"
[PROOF STATE]
proof (prove)
using this:
to_int_mod_ring (x + y) mod+- q = (to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q

goal (1 subgoal):
 1. to_int_mod_ring (x + y) mod+- q = (to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
to_int_mod_ring (x + y) mod+- q = (to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q

goal (1 subgoal):
 1. abs_infty_q (x + y) \<le> abs_infty_q x + abs_infty_q y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
to_int_mod_ring (x + y) mod+- q = (to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q
[PROOF STEP]
have "\<bar>to_int_mod_ring (x + y) mod+- q\<bar>
    \<le> \<bar>to_int_mod_ring x mod+- q\<bar> + \<bar>to_int_mod_ring y mod+- q\<bar>"
[PROOF STATE]
proof (prove)
using this:
to_int_mod_ring (x + y) mod+- q = (to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q

goal (1 subgoal):
 1. \<bar>to_int_mod_ring (x + y) mod+- q\<bar> \<le> \<bar>to_int_mod_ring x mod+- q\<bar> + \<bar>to_int_mod_ring y mod+- q\<bar>
[PROOF STEP]
proof (cases
    "(to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) \<in>
       {-\<lfloor>real_of_int q/2\<rfloor>..<\<lfloor>real_of_int q/2\<rfloor>}")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>to_int_mod_ring (x + y) mod+- q = (to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q; to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q \<in> {- \<lfloor>real_of_int q / 2\<rfloor>..<\<lfloor>real_of_int q / 2\<rfloor>}\<rbrakk> \<Longrightarrow> \<bar>to_int_mod_ring (x + y) mod+- q\<bar> \<le> \<bar>to_int_mod_ring x mod+- q\<bar> + \<bar>to_int_mod_ring y mod+- q\<bar>
 2. \<lbrakk>to_int_mod_ring (x + y) mod+- q = (to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q; to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q \<notin> {- \<lfloor>real_of_int q / 2\<rfloor>..<\<lfloor>real_of_int q / 2\<rfloor>}\<rbrakk> \<Longrightarrow> \<bar>to_int_mod_ring (x + y) mod+- q\<bar> \<le> \<bar>to_int_mod_ring x mod+- q\<bar> + \<bar>to_int_mod_ring y mod+- q\<bar>
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q \<in> {- \<lfloor>real_of_int q / 2\<rfloor>..<\<lfloor>real_of_int q / 2\<rfloor>}

goal (2 subgoals):
 1. \<lbrakk>to_int_mod_ring (x + y) mod+- q = (to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q; to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q \<in> {- \<lfloor>real_of_int q / 2\<rfloor>..<\<lfloor>real_of_int q / 2\<rfloor>}\<rbrakk> \<Longrightarrow> \<bar>to_int_mod_ring (x + y) mod+- q\<bar> \<le> \<bar>to_int_mod_ring x mod+- q\<bar> + \<bar>to_int_mod_ring y mod+- q\<bar>
 2. \<lbrakk>to_int_mod_ring (x + y) mod+- q = (to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q; to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q \<notin> {- \<lfloor>real_of_int q / 2\<rfloor>..<\<lfloor>real_of_int q / 2\<rfloor>}\<rbrakk> \<Longrightarrow> \<bar>to_int_mod_ring (x + y) mod+- q\<bar> \<le> \<bar>to_int_mod_ring x mod+- q\<bar> + \<bar>to_int_mod_ring y mod+- q\<bar>
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q \<in> {- \<lfloor>real_of_int q / 2\<rfloor>..<\<lfloor>real_of_int q / 2\<rfloor>}
[PROOF STEP]
have "(to_int_mod_ring x mod+- q +
        to_int_mod_ring y mod+- q) mod+- q
       = to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q"
[PROOF STATE]
proof (prove)
using this:
to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q \<in> {- \<lfloor>real_of_int q / 2\<rfloor>..<\<lfloor>real_of_int q / 2\<rfloor>}

goal (1 subgoal):
 1. (to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q = to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q
[PROOF STEP]
using mod_plus_minus_rangeE[OF True q_odd]
[PROOF STATE]
proof (prove)
using this:
to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q \<in> {- \<lfloor>real_of_int q / 2\<rfloor>..<\<lfloor>real_of_int q / 2\<rfloor>}
to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q = (to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q

goal (1 subgoal):
 1. (to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q = to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q = to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q

goal (2 subgoals):
 1. \<lbrakk>to_int_mod_ring (x + y) mod+- q = (to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q; to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q \<in> {- \<lfloor>real_of_int q / 2\<rfloor>..<\<lfloor>real_of_int q / 2\<rfloor>}\<rbrakk> \<Longrightarrow> \<bar>to_int_mod_ring (x + y) mod+- q\<bar> \<le> \<bar>to_int_mod_ring x mod+- q\<bar> + \<bar>to_int_mod_ring y mod+- q\<bar>
 2. \<lbrakk>to_int_mod_ring (x + y) mod+- q = (to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q; to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q \<notin> {- \<lfloor>real_of_int q / 2\<rfloor>..<\<lfloor>real_of_int q / 2\<rfloor>}\<rbrakk> \<Longrightarrow> \<bar>to_int_mod_ring (x + y) mod+- q\<bar> \<le> \<bar>to_int_mod_ring x mod+- q\<bar> + \<bar>to_int_mod_ring y mod+- q\<bar>
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q = to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q = to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q

goal (1 subgoal):
 1. \<bar>to_int_mod_ring (x + y) mod+- q\<bar> \<le> \<bar>to_int_mod_ring x mod+- q\<bar> + \<bar>to_int_mod_ring y mod+- q\<bar>
[PROOF STEP]
by (simp add: rewrite)
[PROOF STATE]
proof (state)
this:
\<bar>to_int_mod_ring (x + y) mod+- q\<bar> \<le> \<bar>to_int_mod_ring x mod+- q\<bar> + \<bar>to_int_mod_ring y mod+- q\<bar>

goal (1 subgoal):
 1. \<lbrakk>to_int_mod_ring (x + y) mod+- q = (to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q; to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q \<notin> {- \<lfloor>real_of_int q / 2\<rfloor>..<\<lfloor>real_of_int q / 2\<rfloor>}\<rbrakk> \<Longrightarrow> \<bar>to_int_mod_ring (x + y) mod+- q\<bar> \<le> \<bar>to_int_mod_ring x mod+- q\<bar> + \<bar>to_int_mod_ring y mod+- q\<bar>
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>to_int_mod_ring (x + y) mod+- q = (to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q; to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q \<notin> {- \<lfloor>real_of_int q / 2\<rfloor>..<\<lfloor>real_of_int q / 2\<rfloor>}\<rbrakk> \<Longrightarrow> \<bar>to_int_mod_ring (x + y) mod+- q\<bar> \<le> \<bar>to_int_mod_ring x mod+- q\<bar> + \<bar>to_int_mod_ring y mod+- q\<bar>
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q \<notin> {- \<lfloor>real_of_int q / 2\<rfloor>..<\<lfloor>real_of_int q / 2\<rfloor>}

goal (1 subgoal):
 1. \<lbrakk>to_int_mod_ring (x + y) mod+- q = (to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q; to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q \<notin> {- \<lfloor>real_of_int q / 2\<rfloor>..<\<lfloor>real_of_int q / 2\<rfloor>}\<rbrakk> \<Longrightarrow> \<bar>to_int_mod_ring (x + y) mod+- q\<bar> \<le> \<bar>to_int_mod_ring x mod+- q\<bar> + \<bar>to_int_mod_ring y mod+- q\<bar>
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q \<notin> {- \<lfloor>real_of_int q / 2\<rfloor>..<\<lfloor>real_of_int q / 2\<rfloor>}
[PROOF STEP]
have "\<bar>(to_int_mod_ring x mod+- q +
        to_int_mod_ring y mod+- q)\<bar> \<ge> \<lfloor>real_of_int q /2\<rfloor>"
[PROOF STATE]
proof (prove)
using this:
to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q \<notin> {- \<lfloor>real_of_int q / 2\<rfloor>..<\<lfloor>real_of_int q / 2\<rfloor>}

goal (1 subgoal):
 1. \<lfloor>real_of_int q / 2\<rfloor> \<le> \<bar>to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q\<bar>
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<lfloor>real_of_int q / 2\<rfloor> \<le> \<bar>to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q\<bar>

goal (1 subgoal):
 1. \<lbrakk>to_int_mod_ring (x + y) mod+- q = (to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q; to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q \<notin> {- \<lfloor>real_of_int q / 2\<rfloor>..<\<lfloor>real_of_int q / 2\<rfloor>}\<rbrakk> \<Longrightarrow> \<bar>to_int_mod_ring (x + y) mod+- q\<bar> \<le> \<bar>to_int_mod_ring x mod+- q\<bar> + \<bar>to_int_mod_ring y mod+- q\<bar>
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lfloor>real_of_int q / 2\<rfloor> \<le> \<bar>to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q\<bar>
[PROOF STEP]
have "\<bar>(to_int_mod_ring x mod+- q +
        to_int_mod_ring y mod+- q)\<bar> \<ge> \<bar>(to_int_mod_ring x mod+- q +
        to_int_mod_ring y mod+- q) mod+- q\<bar>"
[PROOF STATE]
proof (prove)
using this:
\<lfloor>real_of_int q / 2\<rfloor> \<le> \<bar>to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q\<bar>

goal (1 subgoal):
 1. \<bar>(to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q\<bar> \<le> \<bar>to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q\<bar>
[PROOF STEP]
using mod_plus_minus_range[OF q_gt_zero,
        of "(to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q)"]
[PROOF STATE]
proof (prove)
using this:
\<lfloor>real_of_int q / 2\<rfloor> \<le> \<bar>to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q\<bar>
(to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q \<in> {- \<lfloor>real_of_int q / 2\<rfloor>..\<lfloor>real_of_int q / 2\<rfloor>}

goal (1 subgoal):
 1. \<bar>(to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q\<bar> \<le> \<bar>to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q\<bar>
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<bar>(to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q\<bar> \<le> \<bar>to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q\<bar>

goal (1 subgoal):
 1. \<lbrakk>to_int_mod_ring (x + y) mod+- q = (to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q; to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q \<notin> {- \<lfloor>real_of_int q / 2\<rfloor>..<\<lfloor>real_of_int q / 2\<rfloor>}\<rbrakk> \<Longrightarrow> \<bar>to_int_mod_ring (x + y) mod+- q\<bar> \<le> \<bar>to_int_mod_ring x mod+- q\<bar> + \<bar>to_int_mod_ring y mod+- q\<bar>
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<bar>(to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q\<bar> \<le> \<bar>to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q\<bar>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<bar>(to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q) mod+- q\<bar> \<le> \<bar>to_int_mod_ring x mod+- q + to_int_mod_ring y mod+- q\<bar>

goal (1 subgoal):
 1. \<bar>to_int_mod_ring (x + y) mod+- q\<bar> \<le> \<bar>to_int_mod_ring x mod+- q\<bar> + \<bar>to_int_mod_ring y mod+- q\<bar>
[PROOF STEP]
by (simp add: rewrite)
[PROOF STATE]
proof (state)
this:
\<bar>to_int_mod_ring (x + y) mod+- q\<bar> \<le> \<bar>to_int_mod_ring x mod+- q\<bar> + \<bar>to_int_mod_ring y mod+- q\<bar>

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<bar>to_int_mod_ring (x + y) mod+- q\<bar> \<le> \<bar>to_int_mod_ring x mod+- q\<bar> + \<bar>to_int_mod_ring y mod+- q\<bar>

goal (1 subgoal):
 1. abs_infty_q (x + y) \<le> abs_infty_q x + abs_infty_q y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<bar>to_int_mod_ring (x + y) mod+- q\<bar> \<le> \<bar>to_int_mod_ring x mod+- q\<bar> + \<bar>to_int_mod_ring y mod+- q\<bar>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<bar>to_int_mod_ring (x + y) mod+- q\<bar> \<le> \<bar>to_int_mod_ring x mod+- q\<bar> + \<bar>to_int_mod_ring y mod+- q\<bar>

goal (1 subgoal):
 1. abs_infty_q (x + y) \<le> abs_infty_q x + abs_infty_q y
[PROOF STEP]
by (auto simp add: abs_infty_q_def mod_plus_minus_def)
[PROOF STATE]
proof (state)
this:
abs_infty_q (x + y) \<le> abs_infty_q x + abs_infty_q y

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma tan_periodic [simp]: "tan (x + 2 * pi) = tan x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tan (x + 2 * pi) = tan x
[PROOF STEP]
by (simp add: tan_def)


[STATEMENT]
lemma step_push_size_big [simp]: "\<lbrakk>
  invar (States dir big small);
  step (States dir (Big.push x big) small) = States dir' big' small'
\<rbrakk> \<Longrightarrow> size big' = Suc (size big)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>invar (States dir big small); step (States dir (Big.push x big) small) = States dir' big' small'\<rbrakk> \<Longrightarrow> size big' = Suc (size big)
[PROOF STEP]
using
    invar_push_big[of dir big small x]
    Big_Proof.size_push[of big]
    step_size_big[of dir "Big.push x big" small dir' big' small']
[PROOF STATE]
proof (prove)
using this:
invar (States dir big small) \<Longrightarrow> invar (States dir (Big.push x big) small)
invar big \<Longrightarrow> size (Big.push ?x big) = Suc (size big)
\<lbrakk>invar (States dir (Big.push x big) small); step (States dir (Big.push x big) small) = States dir' big' small'\<rbrakk> \<Longrightarrow> size big' = size (Big.push x big)

goal (1 subgoal):
 1. \<lbrakk>invar (States dir big small); step (States dir (Big.push x big) small) = States dir' big' small'\<rbrakk> \<Longrightarrow> size big' = Suc (size big)
[PROOF STEP]
by simp


[STATEMENT]
lemma has_LabelS_proj_iff_not_has_LabelN:
  "list_all has_LabelS (proj l A) \<longleftrightarrow> \<not>list_ex (has_LabelN l) A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. list_all has_LabelS (proj l A) = (\<not> list_ex (has_LabelN l) A)
[PROOF STEP]
by (induct A) (auto simp add: proj_def)


[STATEMENT]
lemma merge_pure_or[simp]:
  "\<up>a \<or>\<^sub>A \<up>b = \<up>(a\<or>b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<up> a \<or>\<^sub>A \<up> b = \<up> (a \<or> b)
[PROOF STEP]
unfolding sup_assn_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Abs_assn (\<lambda>h. h \<Turnstile> \<up> a \<or> h \<Turnstile> \<up> b) = \<up> (a \<or> b)
[PROOF STEP]
apply rule
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>h. (h \<Turnstile> \<up> a \<or> h \<Turnstile> \<up> b) = (h \<Turnstile> \<up> (a \<or> b))
[PROOF STEP]
unfolding pure_assn_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>h. (h \<Turnstile> Abs_assn (pure_assn_raw a) \<or> h \<Turnstile> Abs_assn (pure_assn_raw b)) = (h \<Turnstile> Abs_assn (pure_assn_raw (a \<or> b)))
[PROOF STEP]
apply (simp add: Abs_assn_inverse)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>h. (pure_assn_raw a h \<or> pure_assn_raw b h) = pure_assn_raw (a \<or> b) h
[PROOF STEP]
apply fastforce
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma matrix_vector_mul_diag_axis[simp]: "diag_mat f *v (axis i k) = axis i (f i * k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diag_mat f *v axis i k = axis i (f i * k)
[PROOF STEP]
by (simp add: matrix_vector_mul_diag_mat axis_def fun_eq_iff)


[STATEMENT]
lemma LstSeq_append:
  "\<lbrakk>LstSeq s1 k1 y1; LstSeq s2 k2 y2\<rbrakk> \<Longrightarrow> LstSeq (seq_append (succ k1) s1 s2) (succ (k1 @+ k2)) y2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>LstSeq s1 k1 y1; LstSeq s2 k2 y2\<rbrakk> \<Longrightarrow> LstSeq (seq_append (succ k1) s1 s2) (succ (k1 @+ k2)) y2
[PROOF STEP]
apply (auto simp: LstSeq_def Seq_append Ord_hadd Seq_append_pair)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<lbrakk>Seq s1 (succ k1); Seq s2 (succ k2); Ord k1; Ord k2; \<langle>k1, y1\<rangle> \<^bold>\<in> s1; OrdDom s1; \<langle>k2, y2\<rangle> \<^bold>\<in> s2; OrdDom s2\<rbrakk> \<Longrightarrow> Seq (seq_append (succ k1) s1 s2) (succ (succ (k1 @+ k2)))
 2. \<lbrakk>Seq s1 (succ k1); Seq s2 (succ k2); Ord k1; Ord k2; \<langle>k1, y1\<rangle> \<^bold>\<in> s1; OrdDom s1; \<langle>k2, y2\<rangle> \<^bold>\<in> s2; OrdDom s2\<rbrakk> \<Longrightarrow> \<langle>succ (k1 @+ k2), y2\<rangle> \<^bold>\<in> seq_append (succ k1) s1 s2
 3. \<lbrakk>Seq s1 (succ k1); Seq s2 (succ k2); Ord k1; Ord k2; \<langle>k1, y1\<rangle> \<^bold>\<in> s1; OrdDom s1; \<langle>k2, y2\<rangle> \<^bold>\<in> s2; OrdDom s2\<rbrakk> \<Longrightarrow> OrdDom (seq_append (succ k1) s1 s2)
[PROOF STEP]
apply (metis Seq_append hadd_succ_left hadd_succ_right)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>Seq s1 (succ k1); Seq s2 (succ k2); Ord k1; Ord k2; \<langle>k1, y1\<rangle> \<^bold>\<in> s1; OrdDom s1; \<langle>k2, y2\<rangle> \<^bold>\<in> s2; OrdDom s2\<rbrakk> \<Longrightarrow> \<langle>succ (k1 @+ k2), y2\<rangle> \<^bold>\<in> seq_append (succ k1) s1 s2
 2. \<lbrakk>Seq s1 (succ k1); Seq s2 (succ k2); Ord k1; Ord k2; \<langle>k1, y1\<rangle> \<^bold>\<in> s1; OrdDom s1; \<langle>k2, y2\<rangle> \<^bold>\<in> s2; OrdDom s2\<rbrakk> \<Longrightarrow> OrdDom (seq_append (succ k1) s1 s2)
[PROOF STEP]
apply (metis Seq_append_pair hadd_succ_left)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Seq s1 (succ k1); Seq s2 (succ k2); Ord k1; Ord k2; \<langle>k1, y1\<rangle> \<^bold>\<in> s1; OrdDom s1; \<langle>k2, y2\<rangle> \<^bold>\<in> s2; OrdDom s2\<rbrakk> \<Longrightarrow> OrdDom (seq_append (succ k1) s1 s2)
[PROOF STEP]
apply (metis Ord_succ Seq_append_OrdDom)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma  basic_cqe_conv_2b: "(\<exists>x. poly p x \<noteq> (0::complex)) \<longleftrightarrow> p \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<exists>x. poly p x \<noteq> 0) = (p \<noteq> 0)
[PROOF STEP]
by (metis poly_all_0_iff_0)


[STATEMENT]
lemma of_nat_eq_enat: "of_nat n = enat n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_nat n = enat n
[PROOF STEP]
apply (induct n)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. of_nat 0 = enat 0
 2. \<And>n. of_nat n = enat n \<Longrightarrow> of_nat (Suc n) = enat (Suc n)
[PROOF STEP]
apply (simp add: enat_0)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. of_nat n = enat n \<Longrightarrow> of_nat (Suc n) = enat (Suc n)
[PROOF STEP]
apply (simp add: plus_1_eSuc eSuc_enat)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma weak_conv_m_subseq:
  assumes "weak_conv_m M_seq M" "strict_mono r"
  shows "weak_conv_m (\<lambda>n. M_seq (r n)) M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. weak_conv_m (\<lambda>n. M_seq (r n)) M
[PROOF STEP]
using assms LIMSEQ_subseq_LIMSEQ
[PROOF STATE]
proof (prove)
using this:
weak_conv_m M_seq M
strict_mono r
\<lbrakk>?X \<longlonglongrightarrow> ?L; strict_mono ?f\<rbrakk> \<Longrightarrow> (?X \<circ> ?f) \<longlonglongrightarrow> ?L

goal (1 subgoal):
 1. weak_conv_m (\<lambda>n. M_seq (r n)) M
[PROOF STEP]
unfolding weak_conv_m_def weak_conv_def comp_def
[PROOF STATE]
proof (prove)
using this:
\<forall>x. isCont (cdf M) x \<longrightarrow> (\<lambda>n. cdf (M_seq n) x) \<longlonglongrightarrow> cdf M x
strict_mono r
\<lbrakk>?X \<longlonglongrightarrow> ?L; strict_mono ?f\<rbrakk> \<Longrightarrow> (\<lambda>x. ?X (?f x)) \<longlonglongrightarrow> ?L

goal (1 subgoal):
 1. \<forall>x. isCont (cdf M) x \<longrightarrow> (\<lambda>n. cdf (M_seq (r n)) x) \<longlonglongrightarrow> cdf M x
[PROOF STEP]
by auto


[STATEMENT]
lemma isom_gch_units_transpTr5_1:"\<lbrakk>Ugp E; Gchain n g; Gchain n h; i \<le> (n::nat);
      j \<le> n; i < j; isom_Gchains n (transpos i j) g h\<rbrakk> \<Longrightarrow> g i \<cong> h j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Ugp E; Gchain n g; Gchain n h; i \<le> n; j \<le> n; i < j; isom_Gchains n (transpos i j) g h\<rbrakk> \<Longrightarrow> g i \<cong> h j
[PROOF STEP]
apply (simp add:isom_Gchains_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Ugp E; Gchain n g; Gchain n h; j \<le> n; i < j; \<forall>ia\<le>n. g ia \<cong> h (transpos i j ia)\<rbrakk> \<Longrightarrow> g i \<cong> h j
[PROOF STEP]
apply (frule_tac a = i in forall_spec,
       frule_tac x = i and y = j and z = n in less_le_trans,
       assumption+, simp,
       thin_tac "\<forall>ia \<le> n. g ia \<cong> h (transpos i j ia)")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Ugp E; Gchain n g; Gchain n h; j \<le> n; i < j; g i \<cong> h (transpos i j i)\<rbrakk> \<Longrightarrow> g i \<cong> h j
[PROOF STEP]
apply (simp add:transpos_ij_1 [of "i" "n" "j"])
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma straight_path_diffrentiable_y:
  fixes b :: "real" and
    y1 y2 ::"real"
  assumes gamma_def: "\<gamma> = (\<lambda>x. (y2 + y1 * x , b))"
  shows "\<forall>x. \<gamma> differentiable at x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x. \<gamma> differentiable at x
[PROOF STEP]
unfolding gamma_def differentiable_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x. \<exists>D. ((\<lambda>x. (y2 + y1 * x, b)) has_derivative D) (at x)
[PROOF STEP]
by (fast intro!: derivative_intros)


[STATEMENT]
lemma less_floor_iff: "z < \<lfloor>x\<rfloor> \<longleftrightarrow> of_int z + 1 \<le> x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (z < \<lfloor>x\<rfloor>) = (of_int z + (1::'a) \<le> x)
[PROOF STEP]
using le_floor_iff [of "z + 1" x]
[PROOF STATE]
proof (prove)
using this:
(z + 1 \<le> \<lfloor>x\<rfloor>) = (of_int (z + 1) \<le> x)

goal (1 subgoal):
 1. (z < \<lfloor>x\<rfloor>) = (of_int z + (1::'a) \<le> x)
[PROOF STEP]
by auto