diff --git a/thys/Distributed_Distinct_Elements/Distributed_Distinct_Elements_Accuracy_Without_Cutoff.thy b/thys/Distributed_Distinct_Elements/Distributed_Distinct_Elements_Accuracy_Without_Cutoff.thy --- a/thys/Distributed_Distinct_Elements/Distributed_Distinct_Elements_Accuracy_Without_Cutoff.thy +++ b/thys/Distributed_Distinct_Elements/Distributed_Distinct_Elements_Accuracy_Without_Cutoff.thy @@ -1,1004 +1,1005 @@ section \Accuracy without cutoff\label{sec:accuracy_wo_cutoff}\ text \This section verifies that each of the $l$ estimate have the required accuracy with high probability assuming that there was no cut-off, i.e., that $s=0$. Section~\ref{sec:accuracy} will then show that this remains true as long as the cut-off is below @{term "t f"} the subsampling threshold.\ theory Distributed_Distinct_Elements_Accuracy_Without_Cutoff imports Concentration_Inequalities.Bienaymes_Identity Distributed_Distinct_Elements_Inner_Algorithm Distributed_Distinct_Elements_Balls_and_Bins begin +hide_fact (open) Discrete.log_mono no_notation Polynomials.var ("X\") locale inner_algorithm_fix_A = inner_algorithm + fixes A assumes A_range: "A \ {.. A" begin definition X :: nat where "X = card A" definition q_max where "q_max = nat (\log 2 X\ - b_exp)" definition t :: "(nat \ nat) \ int" where "t f = int (Max (f ` A)) - b_exp + 9" definition s :: "(nat \ nat) \ nat" where "s f = nat (t f)" definition R :: "(nat \ nat) \ nat set" where "R f = {a. a \ A \ f a \ s f}" definition r :: "nat \ (nat \ nat) \ nat" where "r x f = card {a. a \ A \ f a \ x}" definition p where "p = (\(f,g,h). card {j\ {..\<^sub>1 (f,g,h) A 0 j \ s f})" definition Y where "Y = (\(f,g,h). 2 ^ s f * \_inv (p (f,g,h)))" lemma fin_A: "finite A" using A_range finite_nat_iff_bounded by auto lemma X_le_n: "X \ n" proof - have "card A \ card {.. 1" unfolding X_def using fin_A A_nonempty by (simp add: leI) lemma of_bool_square: "(of_bool x)\<^sup>2 = ((of_bool x)::real)" by (cases x, auto) lemma r_eq: "r x f = (\ a \ A.( of_bool( x \ f a) :: real))" unfolding r_def of_bool_def sum.If_cases[OF fin_A] by (simp add: Collect_conj_eq) lemma shows r_exp: "(\\. real (r x \) \ \\<^sub>1) = real X * (of_bool (x \ max (nat \log 2 n\) 1) / 2^x)" and r_var: "measure_pmf.variance \\<^sub>1 (\\. real (r x \)) \ (\\. real (r x \) \ \\<^sub>1)" proof - define V :: "nat \ (nat \ nat) \ real" where "V = (\a f. of_bool (x \ f a))" have V_exp: "(\\. V a \ \\\<^sub>1) = of_bool (x \ max (nat \log 2 n\) 1)/2^x" (is "?L = ?R") if "a \ A" for a proof - have a_le_n: "a < n" using that A_range by auto have "?L = (\\. indicator {f. x \ f a} \ \ \\<^sub>1)" unfolding V_def by (intro integral_cong_AE) auto also have "... = measure (map_pmf (\\. \ a) (sample_pro \\<^sub>1)) {f. x \ f}" by simp also have "... = measure (\ n_exp) {f. x \ f}" by (subst hash_pro_component[OF \\<^sub>1 a_le_n]) auto also have "... = of_bool (x \ max (nat \log 2 n\) 1)/2^x" unfolding geom_pro_prob n_exp_def by simp finally show ?thesis by simp qed have b:"(\\. real (r x \) \ \\<^sub>1) = (\ a \ A. (\\. V a \ \\\<^sub>1))" unfolding r_eq V_def by (intro Bochner_Integration.integral_sum) auto also have "... = (\ a \ A. of_bool (x \ max (nat \log 2 n\) 1)/2^x)" using V_exp by (intro sum.cong) auto also have "... = X * (of_bool (x \ max (nat \log 2 n\) 1) / 2^x)" using X_def by simp finally show "(\\. real (r x \) \ \\<^sub>1) = real X * (of_bool (x \ max (nat \log 2 n\) 1)/ 2^x)" by simp have "(\\. (V a \)^2 \ \\<^sub>1) = (\\. V a \ \ \\<^sub>1)" for a unfolding V_def of_bool_square by simp hence a:"measure_pmf.variance \\<^sub>1 (V a) \ measure_pmf.expectation \\<^sub>1 (V a)" for a by (subst measure_pmf.variance_eq) auto have "J \ A \ card J = 2 \ prob_space.indep_vars \\<^sub>1 (\_. borel) V J" for J unfolding V_def using A_range finite_subset[OF _ fin_A] by (intro prob_space.indep_vars_compose2[where Y="\i y. of_bool(x \ y)" and M'="\_. discrete"] hash_pro_indep[OF \\<^sub>1]) (auto simp:prob_space_measure_pmf) hence "measure_pmf.variance \\<^sub>1 (\\. real (r x \)) = (\ a \ A. measure_pmf.variance \\<^sub>1 (V a))" unfolding r_eq V_def by (intro measure_pmf.bienaymes_identity_pairwise_indep_2 fin_A) simp_all also have "... \ (\ a \ A. (\\. V a \ \ \\<^sub>1))" by (intro sum_mono a) also have "... = (\\. real (r x \) \ \\<^sub>1)" unfolding b by simp finally show "measure_pmf.variance \\<^sub>1 (\\. real (r x \)) \ (\\. real (r x \) \ \\<^sub>1)" by simp qed definition E\<^sub>1 where "E\<^sub>1 = (\(f,g,h). 2 powr (-t f) * X \ {b/2^16..b/2})" lemma t_low: "measure \\<^sub>1 {f. of_int (t f) < log 2 (real X) + 1 - b_exp} \ 1/2^7" (is "?L \ ?R") proof (cases "log 2 (real X) \ 8") case True define Z :: "(nat \ nat) \ real" where "Z = r (nat \log 2 (real X) - 8\)" have "log 2 (real X) \ log 2 (real n)" using X_le_n X_ge_1 by (intro log_mono) auto hence "nat \log 2 (real X) - 8\ \ nat \log 2 (real n)\" by (intro nat_mono ceiling_mono) simp hence a:"(nat \log 2 (real X) - 8\ \ max (nat \log 2 (real n)\) 1)" by simp have b:"real (nat (\log 2 (real X)\ - 8)) \ log 2 (real X) - 7" using True by linarith have "2 ^ 7 = real X / (2 powr (log 2 X) * 2 powr (-7))" using X_ge_1 by simp also have "... = real X / (2 powr (log 2 X - 7))" by (subst powr_add[symmetric]) simp also have "... \ real X / (2 powr (real (nat \log 2 (real X) - 8\)))" using b by (intro divide_left_mono powr_mono) auto also have "... = real X / 2 ^ nat \log 2 (real X) - 8\" by (subst powr_realpow) auto finally have "2 ^ 7 \ real X / 2 ^ nat \log 2 (real X) - 8\" by simp hence exp_Z_gt_2_7: "(\\. Z \ \\\<^sub>1) \ 2^7" using a unfolding Z_def r_exp by simp have var_Z_le_exp_Z: "measure_pmf.variance \\<^sub>1 Z \ (\\. Z \ \\\<^sub>1)" unfolding Z_def by (intro r_var) have "?L \ measure \\<^sub>1 {f. of_nat (Max (f ` A)) < log 2 (real X) - 8}" unfolding t_def by (intro pmf_mono) (auto simp add:int_of_nat_def) also have "... \ measure \\<^sub>1 {f \ space \\<^sub>1. (\\. Z \ \\\<^sub>1) \ \Z f - (\\. Z \ \\\<^sub>1) \}" proof (rule pmf_mono) fix f assume "f \ set_pmf (sample_pro \\<^sub>1)" have fin_f_A: "finite (f ` A)" using fin_A finite_imageI by blast assume " f \ {f. real (Max (f ` A)) < log 2 (real X) - 8}" hence "real (Max (f ` A)) < log 2 (real X) - 8" by auto hence "real (f a) < log 2 (real X) - 8" if "a \ A" for a using Max_ge[OF fin_f_A] imageI[OF that] order_less_le_trans by fastforce hence "of_nat (f a) < \log 2 (real X) - 8\" if "a \ A" for a using that by (subst less_ceiling_iff) auto hence "f a < nat \log 2 (real X) - 8\" if "a \ A" for a using that True by fastforce hence "r (nat \log 2 (real X) - 8\) f = 0" unfolding r_def card_eq_0_iff using not_less by auto hence "Z f = 0" unfolding Z_def by simp thus "f \ {f \ space \\<^sub>1. (\\. Z \ \\\<^sub>1) \ \Z f - (\\. Z \ \\\<^sub>1)\}" by auto qed also have "... \ measure_pmf.variance \\<^sub>1 Z / (\\. Z \ \\\<^sub>1)^2" using exp_Z_gt_2_7 by (intro measure_pmf.second_moment_method) simp_all also have "... \ (\\. Z \ \\\<^sub>1) / (\\. Z \ \\\<^sub>1)^2" by (intro divide_right_mono var_Z_le_exp_Z) simp also have "... = 1 / (\\. Z \ \\\<^sub>1)" using exp_Z_gt_2_7 by (simp add:power2_eq_square) also have "... \ ?R" using exp_Z_gt_2_7 by (intro divide_left_mono) auto finally show ?thesis by simp next case "False" have "?L \ measure \\<^sub>1 {f. of_nat (Max (f ` A)) < log 2 (real X) - 8}" unfolding t_def by (intro pmf_mono) (auto simp add:int_of_nat_def) also have "... \ measure \\<^sub>1 {}" using False by (intro pmf_mono) simp also have "... = 0" by simp also have "... \ ?R" by simp finally show ?thesis by simp qed lemma t_high: "measure \\<^sub>1 {f. of_int (t f) > log 2 (real X) + 16 - b_exp} \ 1/2^7" (is "?L \ ?R") proof - define Z :: "(nat \ nat) \ real" where "Z = r (nat \log 2 (real X) + 8\)" have Z_nonneg: "Z f \ 0" for f unfolding Z_def r_def by simp have "(\\. Z \ \\\<^sub>1) \ real X / (2 ^ nat \log 2 (real X) + 8\)" unfolding Z_def r_exp by simp also have "... \ real X / (2 powr (real (nat \log 2 (real X) + 8\)))" by (subst powr_realpow) auto also have "... \ real X / (2 powr \log 2 (real X) + 8\)" by (intro divide_left_mono powr_mono) auto also have "... \ real X / (2 powr (log 2 (real X) + 7))" by (intro divide_left_mono powr_mono, linarith) auto also have "... = real X / 2 powr (log 2 (real X)) / 2 powr 7" by (subst powr_add) simp also have "... \ 1/2 powr 7" using X_ge_1 by (subst powr_log_cancel) auto finally have Z_exp: "(\\. Z \ \\\<^sub>1) \ 1/2^7" by simp have "?L \ measure \\<^sub>1 {f. of_nat (Max (f ` A)) > log 2 (real X) + 7}" unfolding t_def by (intro pmf_mono) (auto simp add:int_of_nat_def) also have "... \ measure \\<^sub>1 {f. Z f \ 1}" proof (rule pmf_mono) fix f assume "f \ set_pmf (sample_pro \\<^sub>1)" assume " f \ {f. real (Max (f ` A)) > log 2 (real X) + 7}" hence "real (Max (f ` A)) > log 2 (real X) + 7" by simp hence "int (Max (f ` A)) \ \log 2 (real X) + 8\" by linarith hence "Max (f ` A) \ nat \log 2 (real X) + 8\" by simp moreover have "f ` A \ {}" "finite (f ` A)" using fin_A finite_imageI A_nonempty by auto ultimately obtain fa where "fa \ f ` A" " fa \ nat \log 2 (real X) + 8\" using Max_in by auto then obtain ae where ae_def: "ae \ A" "nat \log 2 (real X) + 8\ \ f ae" by auto hence "r (nat \log 2 (real X) + 8\) f > 0" unfolding r_def card_gt_0_iff using fin_A by auto hence "Z f \ 1" unfolding Z_def by simp thus "f \ {f. 1 \ Z f}" by simp qed also have "... \ (\\. Z \ \\\<^sub>1) / 1" using Z_nonneg by (intro pmf_markov) auto also have "... \ ?R" using Z_exp by simp finally show ?thesis by simp qed lemma e_1: "measure \ {\. \E\<^sub>1 \} \ 1/2^6" proof - have "measure \\<^sub>1 {f. 2 powr (of_int (-t f)) * real X \ {real b/2^16..real b/2}} \ measure \\<^sub>1 {f. 2 powr (of_int (-t f)) * real X < real b/2^16} + measure \\<^sub>1 {f. 2 powr (of_int (-t f)) * real X > real b/2}" by (intro pmf_add) auto also have "... \ measure \\<^sub>1 {f. of_int (t f) > log 2 X + 16 - b_exp} + measure \\<^sub>1 {f. of_int (t f) < log 2 X + 1 - b_exp}" proof (rule add_mono) show "measure \\<^sub>1 {f. 2 powr (of_int (-t f)) * real X < real b/2^16} \ measure \\<^sub>1 {f. of_int (t f) > log 2 X + 16 - b_exp}" proof (rule pmf_mono) fix f assume "f \ {f. 2 powr real_of_int (-t f) * real X < real b / 2 ^ 16}" hence "2 powr real_of_int (-t f) * real X < real b / 2 ^ 16" by simp hence "log 2 (2 powr of_int (-t f) * real X) < log 2 (real b / 2^16)" using b_min X_ge_1 by (intro iffD2[OF log_less_cancel_iff]) auto hence "of_int (-t f) + log 2 (real X) < log 2 (real b / 2^16)" using X_ge_1 by (subst (asm) log_mult) auto also have "... = real b_exp - log 2 (2 powr 16)" unfolding b_def by (subst log_divide) auto also have "... = real b_exp - 16" by (subst log_powr_cancel) auto finally have "of_int (-t f) + log 2 (real X) < real b_exp - 16" by simp thus "f \ {f. of_int (t f) > log 2 (real X) + 16 - b_exp}" by simp qed next show "measure \\<^sub>1 {f. 2 powr of_int (-t f) * real X > real b/2} \ measure \\<^sub>1 {f. of_int (t f) < log 2 X + 1 - b_exp}" proof (rule pmf_mono) fix f assume "f \ {f. 2 powr real_of_int (-t f) * real X > real b / 2}" hence "2 powr real_of_int (-t f) * real X > real b / 2" by simp hence "log 2 (2 powr of_int (-t f) * real X) > log 2 (real b / 2)" using b_min X_ge_1 by (intro iffD2[OF log_less_cancel_iff]) auto hence "of_int (-t f) + log 2 (real X) > log 2 (real b / 2)" using X_ge_1 by (subst (asm) log_mult) auto hence "of_int (-t f) + log 2 (real X) > real b_exp - 1" unfolding b_def by (subst (asm) log_divide) auto hence "of_int (t f) < log 2 (real X) + 1 - b_exp" by simp thus "f \ {f. of_int (t f) < log 2 (real X) + 1 - b_exp}" by simp qed qed also have "... \ 1/2^7 + 1/2^7" by (intro add_mono t_low t_high) also have "... = 1/2^6" by simp finally have "measure \\<^sub>1 {f. 2 powr of_int (-t f) * real X \ {real b/2^16..real b/2}} \ 1/2^6" by simp thus ?thesis unfolding sample_pro_\ E\<^sub>1_def case_prod_beta by (subst pair_pmf_prob_left) qed definition E\<^sub>2 where "E\<^sub>2 = (\(f,g,h). \card (R f) - X / 2^(s f)\ \ \/3 * X / 2^(s f))" lemma e_2: "measure \ {\. E\<^sub>1 \ \ \E\<^sub>2 \} \ 1/2^6" (is "?L \ ?R") proof - define t\<^sub>m :: int where "t\<^sub>m = \log 2 (real X)\ + 16 - b_exp" have t_m_bound: "t\<^sub>m \ \log 2 (real X)\ - 10" unfolding t\<^sub>m_def using b_exp_ge_26 by simp have "real b / 2^16 = (real X * (1/ X)) * (real b / 2^16)" using X_ge_1 by simp also have "... = (real X * 2 powr (-log 2 X)) * (real b / 2^16)" using X_ge_1 by (subst powr_minus_divide) simp also have "... \ (real X * 2 powr (- \log 2 (real X)\)) * (2 powr b_exp / 2^16)" unfolding b_def using powr_realpow by (intro mult_mono powr_mono) auto also have "... = real X * (2 powr (- \log 2 (real X)\) * 2 powr(real b_exp-16))" by (subst powr_diff) simp also have "... = real X * 2 powr (- \log 2 (real X)\ + (int b_exp - 16))" by (subst powr_add[symmetric]) simp also have "... = real X * 2 powr (-t\<^sub>m)" unfolding t\<^sub>m_def by (simp add:algebra_simps) finally have c:"real b / 2^16 \ real X * 2 powr (-t\<^sub>m)" by simp define T :: "nat set" where "T = {x. (real X / 2^x \ real b / 2^16)}" have "x \ T \ int x \ t\<^sub>m" for x proof - have "x \ T \ 2^ x \ real X * 2^16 / b" using b_min by (simp add: field_simps T_def) also have "... \ log 2 (2^x) \ log 2 (real X * 2^16 / b)" using X_ge_1 b_min by (intro log_le_cancel_iff[symmetric] divide_pos_pos) auto also have "... \ x \ log 2 (real X * 2^16) - log 2 b" using X_ge_1 b_min by (subst log_divide) auto also have "... \ x \ log 2 (real X) + log 2 (2 powr 16) - b_exp" unfolding b_def using X_ge_1 by (subst log_mult) auto also have "... \ x \ \log 2 (real X) + log 2 (2 powr 16) - b_exp\" by linarith also have "... \ x \ \log 2 (real X) + 16 - real_of_int (int b_exp)\" by (subst log_powr_cancel) auto also have "... \ x \ t\<^sub>m" unfolding t\<^sub>m_def by linarith finally show ?thesis by simp qed hence T_eq: "T = {x. int x \ t\<^sub>m}" by auto have "T = {x. int x < t\<^sub>m+1}" unfolding T_eq by simp also have "... = {x. x < nat (t\<^sub>m + 1)}" unfolding zless_nat_eq_int_zless by simp finally have T_eq_2: "T = {x. x < nat (t\<^sub>m + 1)}" by simp have inj_1: "inj_on ((-) (nat t\<^sub>m)) T" unfolding T_eq by (intro inj_onI) simp have fin_T: "finite T" unfolding T_eq_2 by simp have r_exp: "(\\. real (r t \) \\\<^sub>1) = real X / 2^t" if "t \ T" for t proof - have "t \ t\<^sub>m" using that unfolding T_eq by simp also have "... \ \log 2 (real X)\ - 10" using t_m_bound by simp also have "... \ \log 2 (real X)\" by simp also have "... \ \log 2 (real n)\" using X_le_n X_ge_1 by (intro floor_mono log_mono) auto also have "... \ \log 2 (real n)\" by simp finally have "t \ \log 2 (real n)\" by simp hence "t \ max (nat \log 2 (real n)\) 1"by simp thus ?thesis unfolding r_exp by simp qed have r_var: "measure_pmf.variance \\<^sub>1 (\\. real (r t \)) \ real X / 2^t" if "t \ T" for t using r_exp[OF that] r_var by metis have "9 = C\<^sub>4 / \\<^sup>2 * \^2/2^23" using \_gt_0 by (simp add:C\<^sub>4_def) also have "... = 2 powr (log 2 (C\<^sub>4 / \\<^sup>2)) * \^2/2^23" using \_gt_0 C\<^sub>4_def by (subst powr_log_cancel) auto also have "... \ 2 powr b_exp * \^2/2^23" unfolding b_exp_def by (intro divide_right_mono mult_right_mono powr_mono, linarith) auto also have "... = b * \^2/2^23" using powr_realpow unfolding b_def by simp also have "... = (b/2^16) * (\^2/2^7)" by simp also have "... \ (X * 2 powr (-t\<^sub>m)) * (\^2/2^7)" by (intro mult_mono c) auto also have "... = X * (2 powr (-t\<^sub>m) * 2 powr (-7)) * \^2" using powr_realpow by simp also have "... = 2 powr (-t\<^sub>m-7) * (\^2 * X)" by (subst powr_add[symmetric]) (simp ) finally have "9 \ 2 powr (-t\<^sub>m-7) * (\^2 * X)" by simp hence b: "9/ (\^2 * X) \ 2 powr (-t\<^sub>m -7)" using \_gt_0 X_ge_1 by (subst pos_divide_le_eq) auto have a: "measure \\<^sub>1 {f.\real (r t f)-real X/2^t\> \/3 *real X/2^t} \ 2 powr (real t-t\<^sub>m-7)" (is"?L1 \ ?R1") if "t \ T" for t proof - have "?L1 \ \

(f in \\<^sub>1. \real (r t f) - real X / 2^t\ \ \/3 * real X / 2^t)" by (intro pmf_mono) auto also have "... = \

(f in \\<^sub>1. \real (r t f)-(\\. real (r t \) \ \\<^sub>1)\ \ \/3 * real X/2^t)" by (simp add: r_exp[OF that]) also have "... \ measure_pmf.variance \\<^sub>1 (\\. real (r t \)) / (\/3 * real X / 2^t)^2" using X_ge_1 \_gt_0 by (intro measure_pmf.Chebyshev_inequality divide_pos_pos mult_pos_pos) auto also have "... \ (X / 2^t) / (\/3 * X / 2^t)^2" by (intro divide_right_mono r_var[OF that]) simp also have "... = 2^t*(9/ ( \^2 * X))" by (simp add:power2_eq_square algebra_simps) also have "... \ 2^t*(2 powr (-t\<^sub>m-7))" by (intro mult_left_mono b) simp also have "... = 2 powr t * 2 powr (-t\<^sub>m-7)" by (subst powr_realpow[symmetric]) auto also have "... = ?R1" by (subst powr_add[symmetric]) (simp add:algebra_simps) finally show "?L1 \ ?R1" by simp qed have "\ym + 1). x = nat t\<^sub>m - y" if "x < nat (t\<^sub>m+1)" for x using that by (intro exI[where x="nat t\<^sub>m - x"]) simp hence T_reindex: "(-) (nat t\<^sub>m) ` {x. x < nat (t\<^sub>m + 1)} = {..m + 1)}" by (auto simp add: set_eq_iff image_iff) have "?L \ measure \ {\. (\t \ T. \real (r t (fst \))-real X/2^t\ > \/3 * real X / 2^t)}" proof (rule pmf_mono) fix \ assume "\ \ set_pmf (sample_pro \)" obtain f g h where \_def: "\ = (f,g,h)" by (metis prod_cases3) assume "\ \ {\. E\<^sub>1 \ \ \ E\<^sub>2 \}" hence a:"2 powr ( -real_of_int (t f)) * real X \ {real b/2^16..real b/2}" and b:"\card (R f) - real X / 2^(s f)\ > \/3 * X / 2^(s f)" unfolding E\<^sub>1_def E\<^sub>2_def by (auto simp add:\_def) have "\card (R f) - X / 2^(s f)\ = 0" if "s f= 0" using that by (simp add:R_def X_def) moreover have "( \/3) * (X / 2^s f) \ 0" using \_gt_0 X_ge_1 by (intro mult_nonneg_nonneg) auto ultimately have "False" if "s f = 0" using b that by simp hence "s f > 0" by auto hence "t f = s f" unfolding s_def by simp hence "2 powr (-real (s f)) * X \ b / 2^16" using a by simp hence "X / 2 powr (real (s f)) \ b / 2^16" by (simp add: divide_powr_uminus mult.commute) hence "real X / 2 ^ (s f) \ b / 2^16" by (subst (asm) powr_realpow, auto) hence "s f \ T" unfolding T_def by simp moreover have "\r (s f) f - X / 2^s f\ > \/3 * X / 2^s f" using R_def r_def b by simp ultimately have "\t \ T. \r t (fst \) - X / 2^t\ > \/3 * X / 2^t" using \_def by (intro bexI[where x="s f"]) simp thus "\ \ {\. (\t \ T. \r t (fst \) - X / 2^t\ > \/3 * X / 2^t)}" by simp qed also have "... = measure \\<^sub>1 {f. (\t \ T. \real (r t f)-real X / 2^t\ > \/3 * real X/2^t)}" unfolding sample_pro_\ by (intro pair_pmf_prob_left) also have "... = measure \\<^sub>1 (\t \ T. {f. \real (r t f)-real X / 2^t\ > \/3 * real X/2^t})" by (intro measure_pmf_cong) auto also have "... \ (\t \ T. measure \\<^sub>1 {f.\real (r t f)-real X / 2^t\ > \/3 * real X/2^t})" by (intro measure_UNION_le fin_T) (simp) also have "... \ (\t \ T. 2 powr (real t - of_int t\<^sub>m - 7))" by (intro sum_mono a) also have "... = (\t \ T. 2 powr (-int (nat t\<^sub>m-t) - 7))" unfolding T_eq by (intro sum.cong refl arg_cong2[where f="(powr)"]) simp also have "... = (\x \ (\x. nat t\<^sub>m - x) ` T. 2 powr (-real x - 7))" by (subst sum.reindex[OF inj_1]) simp also have "... = (\x \ (\x. nat t\<^sub>m - x) ` T. 2 powr (-7) * 2 powr (-real x))" by (subst powr_add[symmetric]) (simp add:algebra_simps) also have "... = 1/2^7 * (\x \ (\x. nat t\<^sub>m - x) ` T. 2 powr (-real x))" by (subst sum_distrib_left) simp also have "... = 1/2^7 * (\x m+1). 2 powr (-real x))" unfolding T_eq_2 T_reindex by (intro arg_cong2[where f="(*)"] sum.cong) auto also have "... = 1/2^7 * (\x m+1). (2 powr (-1)) powr (real x))" by (subst powr_powr) simp also have "... = 1/2^7 * (\x m+1). (1/2)^x)" using powr_realpow by simp also have "... \ 1/2^7 * 2" by(subst geometric_sum) auto also have "... = 1/2^6" by simp finally show ?thesis by simp qed definition E\<^sub>3 where "E\<^sub>3 = (\(f,g,h). inj_on g (R f))" lemma R_bound: fixes f g h assumes "E\<^sub>1 (f,g,h)" assumes "E\<^sub>2 (f,g,h)" shows "card (R f) \ 2/3 * b" proof - have "real (card (R f)) \ ( \ / 3) * (real X / 2 ^ s f) + real X / 2 ^ s f" using assms(2) unfolding E\<^sub>2_def by simp also have "... \ (1/3) * (real X / 2 ^ s f) + real X / 2 ^ s f" using \_lt_1 by (intro add_mono mult_right_mono) auto also have "... = (4/3) * (real X / 2 powr s f)" using powr_realpow by simp also have "... \ (4/3) * (real X / 2 powr t f)" unfolding s_def by (intro mult_left_mono divide_left_mono powr_mono) auto also have "... = (4/3) * (2 powr (-(of_int (t f))) * real X)" by (subst powr_minus_divide) simp also have "... = (4/3) * (2 powr (- t f) * real X)" by simp also have "... \ (4/3) * (b/2)" using assms(1) unfolding E\<^sub>1_def by (intro mult_left_mono) auto also have "... \ (2/3) * b" by simp finally show ?thesis by simp qed lemma e_3: "measure \ {\. E\<^sub>1 \ \ E\<^sub>2 \ \ \E\<^sub>3 \} \ 1/2^6" (is "?L \ ?R") proof - let ?\ = "(\(z,x,y) f. z < C\<^sub>7*b^2 \ x \ R f \ y \ R f \ x < y)" let ?\ = "(\(z,x,y) g. g x = z \ g y = z)" have \_prob: "measure \\<^sub>2 {g. ?\ \ g} \ (1/real (C\<^sub>7*b^2)^2)" if "?\ \ f" for \ f proof - obtain x y z where \_def: "\ = (z,x,y)" by (metis prod_cases3) have a:"prob_space.indep_vars \\<^sub>2 (\i. discrete) (\x \. \ x = z) I" if "I \ {.. 2" for I by (intro prob_space.indep_vars_compose2[OF _ hash_pro_indep[OF \\<^sub>2]] that) (simp_all add:prob_space_measure_pmf) have "u \ R f \ u < n" for u unfolding R_def using A_range by auto hence b: "x < n" "y < n" "card {x, y} = 2" using that \_def by auto have c: "z < C\<^sub>7*b\<^sup>2" using \_def that by simp have "measure \\<^sub>2 {g. ?\ \ g} = measure \\<^sub>2 {g. (\\ \ {x,y}. g \ = z)}" by (simp add:\_def) also have "... = (\\ \ {x,y}. measure \\<^sub>2 {g. g \ = z})" using b by (intro measure_pmf.split_indep_events[OF refl, where I="{x,y}"] a) (simp_all add:prob_space_measure_pmf) also have "... = (\\ \ {x,y}. measure (map_pmf (\\. \ \) (sample_pro \\<^sub>2)) {g. g = z}) " by (simp add:vimage_def) also have "... = (\\ \ {x,y}. measure (\ (C\<^sub>7 * b\<^sup>2)) {g. g=z})" using b hash_pro_component[OF \\<^sub>2] by (intro prod.cong) fastforce+ also have "... = (\\ \ {x,y}. measure (pmf_of_set {..7 * b\<^sup>2}) {z})" by (subst nat_pro) (simp_all add:C\<^sub>7_def b_def) also have "... = (measure (pmf_of_set {..7 * b\<^sup>2}) {z})^2" using b by simp also have "... \ (1 /(C\<^sub>7*b\<^sup>2))^2" using c by (subst measure_pmf_of_set) auto also have "... = (1 /(C\<^sub>7*b\<^sup>2)^2)" by (simp add:algebra_simps power2_eq_square) finally show ?thesis by simp qed have \_card: "card {\. ?\ \ f} \ (C\<^sub>7*b^2) * (card (R f) * (card (R f)-1)/2)" (is "?TL \ ?TR") and fin_\: "finite {\. ?\ \ f}" (is "?T2") for f proof - have t1: "{\. ?\ \ f} \ {..7*b^2} \ {(x,y) \ R f \ R f. x < y}" by (intro subsetI) auto moreover have "card ({..7*b^2} \ {(x,y) \ R f \ R f. x < y}) = ?TR" using card_ordered_pairs'[where M="R f"] by (simp add: card_cartesian_product) moreover have "finite (R f)" unfolding R_def using fin_A finite_subset by simp hence "finite {(x, y). (x, y) \ R f \ R f \ x < y}" by (intro finite_subset[where B="R f \ R f", OF _ finite_cartesian_product]) auto hence t2: "finite ({..7*b^2} \ {(x,y) \ R f \ R f. x < y})" by (intro finite_cartesian_product) auto ultimately show "?TL \ ?TR" using card_mono of_nat_le_iff by (metis (no_types, lifting)) show ?T2 using finite_subset[OF t1 t2] by simp qed have "?L \ measure \ {(f,g,h). card (R f) \ b \ (\ x y z. ?\ (x,y,z) f \ ?\ (x,y,z) g)}" proof (rule pmf_mono) fix \ assume b:"\ \ set_pmf (sample_pro \)" obtain f g h where \_def:"\ = (f,g,h)" by (metis prod_cases3) have "(f,g,h) \ pro_set \" using b \_def by simp hence c:"g x < C\<^sub>7*b^2" for x using g_range by simp assume a:"\ \ {\. E\<^sub>1 \ \ E\<^sub>2 \ \ \ E\<^sub>3 \}" hence "card (R f) \ 2/3 * b" using R_bound \_def by force moreover have "\a b. a \ R f \ b \ R f \ a \ b \ g a = g b" using a unfolding \_def E\<^sub>3_def inj_on_def by auto hence "\x y. x \ R f \ y \ R f \ x < y \ g x = g y" by (metis not_less_iff_gr_or_eq) hence "\x y z. ?\ (x,y,z) f \ ?\ (x,y,z) g" using c by blast ultimately show "\ \ {(f, g, h). card (R f) \ b \ (\ x y z. ?\ (x,y,z) f \ ?\ (x,y,z) g)}" unfolding \_def by auto qed also have "... = (\f. measure (pair_pmf \\<^sub>2 \\<^sub>3) {g. card (R f) \ b \ (\x y z. ?\ (x,y,z) f \ ?\ (x,y,z) (fst g))} \\\<^sub>1)" unfolding sample_pro_\ split_pair_pmf by (simp add: case_prod_beta) also have "... = (\f. measure \\<^sub>2 {g. card (R f) \ b \ (\x y z. ?\ (x,y,z) f \ ?\ (x,y,z) g)} \\\<^sub>1)" by (subst pair_pmf_prob_left) simp also have "... \ (\f. 1/real (2*C\<^sub>7) \\\<^sub>1)" proof (rule pmf_exp_mono[OF integrable_sample_pro integrable_sample_pro]) fix f assume "f \ set_pmf (sample_pro \\<^sub>1)" show "measure \\<^sub>2 {g. card (R f) \ b \ (\x y z. ?\ (x,y,z) f \ ?\ (x,y,z) g)} \ 1 / real (2 * C\<^sub>7)" (is "?L1 \ ?R1") proof (cases "card (R f) \ b") case True have "?L1 \ measure \\<^sub>2 (\ \ \ {\. ?\ \ f}. {g. ?\ \ g})" by (intro pmf_mono) auto also have "... \ (\\ \ {\. ?\ \ f}. measure \\<^sub>2 {g. ?\ \ g})" by (intro measure_UNION_le fin_\) auto also have "... \ (\\ \ {\. ?\ \ f}. (1/real (C\<^sub>7*b^2)^2))" by (intro sum_mono \_prob) auto also have "... = card {\. ?\ \ f} /(C\<^sub>7*b^2)^2" by simp also have "... \ (C\<^sub>7*b^2) * (card (R f) * (card (R f)-1)/2) / (C\<^sub>7*b^2)^2" by (intro \_card divide_right_mono) simp also have "... \ (C\<^sub>7*b^2) * (b * b / 2) / (C\<^sub>7*b^2)^2" unfolding C\<^sub>7_def using True by (intro divide_right_mono Nat.of_nat_mono mult_mono) auto also have "... = 1/(2*C\<^sub>7)" using b_min by (simp add:algebra_simps power2_eq_square) finally show ?thesis by simp next case False then show ?thesis by simp qed qed also have "... \ 1/2^6" unfolding C\<^sub>7_def by simp finally show ?thesis by simp qed definition E\<^sub>4 where "E\<^sub>4 = (\(f,g,h). \p (f,g,h) - \ (card (R f))\ \ \/12 * card (R f))" lemma e_4_h: "9 / sqrt b \ \ / 12" proof - have "108 \ sqrt (C\<^sub>4)" unfolding C\<^sub>4_def by (approximation 5) also have "... \ sqrt( \^2 * real b)" using b_lower_bound \_gt_0 by (intro real_sqrt_le_mono) (simp add: pos_divide_le_eq algebra_simps) also have "... = \ * sqrt b" using \_gt_0 by (simp add:real_sqrt_mult) finally have "108 \ \ * sqrt b" by simp thus ?thesis using b_min by (simp add:pos_divide_le_eq) qed lemma e_4: "measure \ {\. E\<^sub>1 \ \ E\<^sub>2 \ \ E\<^sub>3 \ \ \E\<^sub>4 \} \ 1/2^6" (is "?L \ ?R") proof - have a: "measure \\<^sub>3 {h. E\<^sub>1 (f,g,h) \ E\<^sub>2 (f,g,h) \ E\<^sub>3 (f,g,h) \ \E\<^sub>4 (f,g,h)} \ 1/2^6" (is "?L1 \ ?R1") if "f \ set_pmf (sample_pro \\<^sub>1)" "g \ set_pmf(sample_pro \\<^sub>2)" for f g proof (cases "card (R f) \ b \ inj_on g (R f)") case True have g_inj: "inj_on g (R f)" using True by simp have fin_R: "finite (g ` R f)" unfolding R_def using fin_A by (intro finite_imageI) simp interpret B:balls_and_bins_abs "g ` R f" "{.. {..7 * b\<^sup>2}" using g_range_1 that(2) by auto hence g_ran: "g ` R f \ {..7 * b\<^sup>2}" by auto have "sample_pro (\ b) = pmf_of_set {..\. \ x) (sample_pro (\ k (C\<^sub>7 * b\<^sup>2) (\ b))) = pmf_of_set {.. g ` R f" for x using g_ran hash_pro_component[OF \\<^sub>3 _ k_gt_0] that by auto moreover have "prob_space.k_wise_indep_vars \\<^sub>3 k (\_. discrete) (\x \. \ x) (g ` R f)" by (intro prob_space.k_wise_indep_subset[OF _ _ hash_pro_k_indep[OF \\<^sub>3]] g_ran prob_space_measure_pmf) ultimately have lim_balls_and_bins: "B.lim_balls_and_bins k (sample_pro (\ k (C\<^sub>7 * b\<^sup>2) (\ b)))" unfolding B.lim_balls_and_bins_def by auto have card_g_R: "card (g ` R f) = card (R f)" using True card_image by auto hence b_mu: "\ (card (R f)) = B.\" unfolding B.\_def \_def using b_min by (simp add:powr_realpow) have card_g_le_b: "card (g ` R f) \ card {.. measure \\<^sub>3 {h. \B.Y h - B.\\ > 9 * real (card (g ` R f)) / sqrt (card {.. {h. E\<^sub>1 (f,g,h) \ E\<^sub>2 (f,g,h) \ E\<^sub>3 (f,g,h) \ \E\<^sub>4 (f,g,h)}" hence b: "\p (f,g,h) -\ (card (R f))\ > \/12 * card (R f)" unfolding E\<^sub>4_def by simp assume "h \ set_pmf (sample_pro \\<^sub>3)" hence h_range: "h x < b" for x using h_range_1 by simp have "{j \ {.. \\<^sub>1 (f, g, h) A 0 j} = {j \ {.. max (Max ({int (f a) |a. a \ A \ h (g a) = j} \ {-1})) (- 1)}" unfolding \\<^sub>1_def by simp also have "... = {j \ {.. Max ({int (f a) |a. a \ A \ h (g a) = j} \ {-1})}" using fin_A by (subst max_absorb1) (auto intro: Max_ge) also have "... = {j \ {..a \ R f. h (g a) = j)}" unfolding R_def using fin_A by (subst Max_ge_iff) auto also have "... = {j. \a \ R f. h (g a) = j}" using h_range by auto also have "... = (h \ g) ` (R f)" by (auto simp add:set_eq_iff image_iff) also have "... = h ` (g ` (R f))" by (simp add:image_image) finally have c:"{j \ {.. \\<^sub>1 (f, g, h) A 0 j} = h ` (g ` R f)" by simp have "9 * real (card (g ` R f)) / sqrt (card {.. \/12 * card (R f)" by (intro mult_right_mono e_4_h) simp also have "... < \B.Y h - B.\\" using b c unfolding B.Y_def p_def b_mu by simp finally show "h \ {h. \B.Y h - B.\\ > 9 * real (card (g ` R f)) / sqrt (card {.. 1/2^6" using k_min by (intro B.devitation_bound[OF card_g_le_b lim_balls_and_bins]) auto finally show ?thesis by simp next case False have "?L1 \ measure \\<^sub>3 {}" proof (rule pmf_mono) fix h assume b:"h \ {h. E\<^sub>1 (f, g, h) \ E\<^sub>2 (f, g, h) \ E\<^sub>3 (f, g, h) \ \ E\<^sub>4 (f, g, h)}" hence "card (R f) \ (2/3)*b" by (auto intro!: R_bound[simplified]) hence "card (R f) \ b" by simp moreover have "inj_on g (R f)" using b by (simp add:E\<^sub>3_def) ultimately have "False" using False by simp thus "h \ {}" by simp qed also have "... = 0" by simp finally show ?thesis by simp qed have "?L = (\f. (\g. measure \\<^sub>3 {h. E\<^sub>1 (f,g,h) \ E\<^sub>2 (f,g,h) \ E\<^sub>3 (f,g,h) \ \E\<^sub>4 (f,g,h)} \\\<^sub>2) \\\<^sub>1)" unfolding sample_pro_\ split_pair_pmf by simp also have "... \ (\f. (\g. 1/2^6 \\\<^sub>2) \\\<^sub>1)" using a by (intro integral_mono_AE AE_pmfI) simp_all also have "... = 1/2^6" by simp finally show ?thesis by simp qed lemma \_inverse: "\_inv (\ x) = x" proof - have a:"1-1/b \ 0" using b_min by simp have "\ x = b * (1-(1-1/b) powr x)" unfolding \_def by simp hence "\ x / real b = 1-(1-1/b) powr x" by simp hence "ln (1 - \ x / real b) = ln ((1-1/b) powr x)" by simp also have "... = x * ln (1 - 1/ b)" using a by (intro ln_powr) finally have "ln (1 - \ x / real b) = x * ln (1- 1/ b)" by simp moreover have "ln (1-1/b) < 0" using b_min by (subst ln_less_zero_iff) auto ultimately show ?thesis using \_inv_def by simp qed lemma rho_mono: assumes "x \ y" shows "\ x \ \ y" proof- have "(1 - 1 / real b) powr y \ (1 - 1 / real b) powr x" using b_min by (intro powr_mono_rev assms) auto thus ?thesis unfolding \_def by (intro mult_left_mono) auto qed lemma rho_two_thirds: "\ (2/3 * b) \ 3/5 *b" proof - have "1/3 \ exp ( - 13 / 12::real )" by (approximation 8) also have "... \ exp ( - 1 - 2 / real b )" using b_min by (intro iffD2[OF exp_le_cancel_iff]) (simp add:algebra_simps) also have "... \ exp ( b * (-(1/real b)-2*(1/real b)^2))" using b_min by (simp add:algebra_simps power2_eq_square) also have "... \ exp ( b * ln (1-1/real b))" using b_min by (intro iffD2[OF exp_le_cancel_iff] mult_left_mono ln_one_minus_pos_lower_bound) auto also have "... = exp ( ln ( (1-1/real b) powr b))" using b_min by (subst ln_powr) auto also have "... = (1-1/real b) powr b" using b_min by (subst exp_ln) auto finally have a:"1/3 \ (1-1/real b) powr b" by simp have "2/5 \ (1/3) powr (2/3::real)" by (approximation 5) also have "... \ ((1-1/real b) powr b) powr (2/3)" by (intro powr_mono2 a) auto also have "... = (1-1/real b) powr (2/3 * real b)" by (subst powr_powr) (simp add:algebra_simps) finally have "2/5 \ (1 - 1 / real b) powr (2 / 3 * real b)" by simp hence "1 - (1 - 1 / real b) powr (2 / 3 * real b) \ 3/5" by simp hence "\ (2/3 * b) \ b * (3/5)" unfolding \_def by (intro mult_left_mono) auto thus ?thesis by simp qed definition \_inv' :: "real \ real" where "\_inv' x = -1 / (real b * (1-x / real b) * ln (1 - 1 / real b))" lemma \_inv'_bound: assumes "x \ 0" assumes "x \ 59/90*b" shows "\\_inv' x\ \ 4" proof - have c:"ln (1 - 1 / real b) < 0" using b_min by (subst ln_less_zero_iff) auto hence d:"real b * (1 - x / real b) * ln (1 - 1 / real b) < 0" using b_min assms by (intro Rings.mult_pos_neg) auto have "(1::real) \ 31/30" by simp also have "... \ (31/30) * (b * -(- 1 / real b))" using b_min by simp also have "... \ (31/30) * (b * -ln (1 + (- 1 / real b)))" using b_min by (intro mult_left_mono le_imp_neg_le ln_add_one_self_le_self2) auto also have "... \ 3 * (31/90) * (- b * ln (1 - 1 / real b))" by simp also have "... \ 3 * (1 - x / real b) * (- b * ln (1 - 1 / real b))" using assms b_min pos_divide_le_eq[where c="b"] c by (intro mult_right_mono mult_left_mono mult_nonpos_nonpos) auto also have "... \ 3 * (real b * (1 - x / real b) * (-ln (1 - 1 / real b)))" by (simp add:algebra_simps) finally have "3 * (real b * (1 - x / real b) * (-ln (1 - 1 / real b))) \ 1" by simp hence "3 * (real b * (1 - x / real b) * ln (1 - 1 / real b)) \ -1" by simp hence "\_inv' x \ 3" unfolding \_inv'_def using d by (subst neg_divide_le_eq) auto moreover have "\_inv' x > 0" unfolding \_inv'_def using d by (intro divide_neg_neg) auto ultimately show ?thesis by simp qed lemma \_inv': fixes x :: real assumes "x < b" shows "DERIV \_inv x :> \_inv' x" proof - have "DERIV (ln \ (\x. (1 - x / real b))) x :> 1 / (1-x / real b) * (0 -1/b)" using assms b_min by (intro DERIV_chain DERIV_ln_divide DERIV_cdivide derivative_intros) auto hence "DERIV \_inv x :> (1 / (1-x / real b) * (-1/b)) / ln (1-1/real b)" unfolding comp_def \_inv_def by (intro DERIV_cdivide) auto thus ?thesis by (simp add:\_inv'_def algebra_simps) qed lemma accuracy_without_cutoff: "measure \ {(f,g,h). \Y (f,g,h) - real X\ > \ * X \ s f < q_max} \ 1/2^4" (is "?L \ ?R") proof - have "?L \ measure \ {\. \E\<^sub>1 \ \ \E\<^sub>2 \ \ \E\<^sub>3 \ \ \E\<^sub>4 \}" proof (rule pmf_rev_mono) fix \ assume "\ \ set_pmf (sample_pro \)" obtain f g h where \_def: "\ = (f,g,h)" by (metis prod_cases3) assume "\ \ {\. \ E\<^sub>1 \ \ \ E\<^sub>2 \ \ \ E\<^sub>3 \ \ \ E\<^sub>4 \}" hence assms: "E\<^sub>1 (f,g,h)" "E\<^sub>2 (f,g,h)" "E\<^sub>3 (f,g,h)" "E\<^sub>4 (f,g,h)" unfolding \_def by auto define I :: "real set" where "I = {0..59/90*b}" have "p (f,g,h) \ \ (card (R f)) + \/12 * card (R f)" using assms(4) E\<^sub>4_def unfolding abs_le_iff by simp also have "... \ \(2/3*b) + 1/12* (2/3*b)" using \_lt_1 R_bound[OF assms(1,2)] by (intro add_mono rho_mono mult_mono) auto also have "... \ 3/5 * b + 1/18*b" by (intro add_mono rho_two_thirds) auto also have "... \ 59/90 * b" by simp finally have "p (f,g,h) \ 59/90 * b" by simp hence p_in_I: "p (f,g,h) \ I" unfolding I_def by simp have "\ (card (R f)) \ \(2/3 * b)" using R_bound[OF assms(1,2)] by (intro rho_mono) auto also have "... \ 3/5 * b" using rho_two_thirds by simp also have "... \ b * 59/90" by simp finally have "\ (card (R f)) \ b * 59/90" by simp moreover have "(1 - 1 / real b) powr (real (card (R f))) \ 1 powr (real (card (R f)))" using b_min by (intro powr_mono2) auto hence "\ (card (R f)) \ 0" unfolding \_def by (intro mult_nonneg_nonneg) auto ultimately have "\ (card (R f)) \ I" unfolding I_def by simp moreover have "interval I" unfolding I_def interval_def by simp moreover have "59 / 90 * b < b" using b_min by simp hence "DERIV \_inv x :> \_inv' x" if "x \ I" for x using that I_def by (intro \_inv') simp ultimately obtain \ :: real where \_def: "\ \ I" "\_inv (p(f,g,h)) - \_inv (\ (card (R f))) = (p (f,g,h) - \(card (R f))) * \_inv' \" using p_in_I MVT_interval by blast have "\\_inv(p (f,g,h)) - card (R f)\ = \\_inv(p (f,g,h)) - \_inv(\(card (R f)))\" by (subst \_inverse) simp also have "... = \(p (f,g,h) - \ (card (R f)))\ * \\_inv' \ \" using \_def(2) abs_mult by simp also have "... \ \p (f,g,h) - \ (card (R f))\ * 4" using \_def(1) I_def by (intro mult_left_mono \_inv'_bound) auto also have "... \ ( \/12 * card (R f)) * 4" using assms(4) E\<^sub>4_def by (intro mult_right_mono) auto also have "... = \/3 * card (R f)" by simp finally have b: "\\_inv(p (f,g,h)) - card (R f)\ \ \/3 * card (R f)" by simp have "\\_inv(p (f,g,h)) - X / 2 ^ (s f)\ \ \\_inv(p (f,g,h)) - card (R f)\ + \card (R f) - X / 2 ^ (s f)\" by simp also have "... \ \/3 * card (R f) + \card (R f) - X / 2 ^ (s f)\" by (intro add_mono b) auto also have "... = \/3 * \X / 2 ^ (s f) + (card (R f) - X / 2 ^ (s f))\ + \card (R f) - X / 2 ^ (s f)\" by simp also have "... \ \/3 * (\X / 2 ^ (s f)\ + \card (R f) - X / 2 ^ (s f)\) + \card (R f) - X / 2 ^ (s f)\" using \_gt_0 by (intro mult_left_mono add_mono abs_triangle_ineq) auto also have "... \ \/3 * \X / 2 ^ (s f)\ + (1+ \/3) * \card (R f) - X / 2 ^ (s f)\" using \_gt_0 \_lt_1 by (simp add:algebra_simps) also have "... \ \/3 * \X / 2 ^ s f\ + (4/3) * ( \ / 3 * real X / 2 ^ s f)" using assms(2) \_gt_0 \_lt_1 unfolding E\<^sub>2_def by (intro add_mono mult_mono) auto also have "... = (7/9) * \ * real X / 2^s f" using X_ge_1 by (subst abs_of_nonneg) auto also have "... \ 1 * \ * real X / 2^s f" using \_gt_0 by (intro mult_mono divide_right_mono) auto also have "... = \ * real X / 2^s f" by simp finally have a:"\\_inv(p (f,g,h)) - X / 2 ^ (s f)\ \ \ * X / 2 ^ (s f)" by simp have "\Y (f, g, h) - real X\ = \2 ^ (s f)\ * \\_inv(p (f,g,h)) - real X / 2 ^ (s f)\" unfolding Y_def by (subst abs_mult[symmetric]) (simp add:algebra_simps powr_add[symmetric]) also have "... \ 2 ^ (s f) * (\ * X / 2 ^ (s f))" by (intro mult_mono a) auto also have "... = \ * X" by (simp add:algebra_simps powr_add[symmetric]) finally have "\Y (f, g, h) - real X\ \ \ * X" by simp moreover have "2 powr (\log 2 (real X)\ - t f) \ 2 powr b_exp" (is "?L1 \ ?R1") proof - have "?L1 \ 2 powr (1 + log 2 (real X)- t f)" by (intro powr_mono, linarith) auto also have "... = 2 powr 1 * 2 powr (log 2 (real X)) * 2 powr (- t f)" unfolding powr_add[symmetric] by simp also have "... = 2 * (2 powr (-t f) * X)" using X_ge_1 by simp also have "... \ 2 * (b/2)" using assms(1) unfolding E\<^sub>1_def by (intro mult_left_mono) auto also have "... = b" by simp also have "... = ?R1" unfolding b_def by (simp add: powr_realpow) finally show ?thesis by simp qed hence "\log 2 (real X)\ - t f \ real b_exp" unfolding not_less[symmetric] using powr_less_mono[where x="2"] by simp hence "s f \ q_max" unfolding s_def q_max_def by (intro nat_mono) auto ultimately show "\ \ {(f, g, h). \ * X < \Y (f, g, h) - real X\ \ s f < q_max}" unfolding \_def by auto qed also have "... \ measure \ {\. \E\<^sub>1 \ \ \E\<^sub>2 \ \ \E\<^sub>3 \} + measure \ {\. E\<^sub>1 \ \ E\<^sub>2 \ \ E\<^sub>3 \ \ \E\<^sub>4 \}" by (intro pmf_add) auto also have "... \ (measure \ {\. \E\<^sub>1 \ \ \E\<^sub>2 \} + measure \ {\. E\<^sub>1 \ \ E\<^sub>2 \ \ \E\<^sub>3 \}) + 1/2^6" by (intro add_mono e_4 pmf_add) auto also have "... \ ((measure \ {\. \E\<^sub>1 \} + measure \ {\. E\<^sub>1 \ \ \E\<^sub>2 \}) + 1/2^6) + 1/2^6" by (intro add_mono e_3 pmf_add) auto also have "... \ ((1/2^6 + 1/2^6) + 1/2^6) + 1/2^6" by (intro add_mono e_2 e_1) auto also have "... = ?R" by simp finally show ?thesis by simp qed end end diff --git a/thys/Distributed_Distinct_Elements/Distributed_Distinct_Elements_Cutoff_Level.thy b/thys/Distributed_Distinct_Elements/Distributed_Distinct_Elements_Cutoff_Level.thy --- a/thys/Distributed_Distinct_Elements/Distributed_Distinct_Elements_Cutoff_Level.thy +++ b/thys/Distributed_Distinct_Elements/Distributed_Distinct_Elements_Cutoff_Level.thy @@ -1,461 +1,461 @@ section \Cutoff Level\ text \This section verifies that the cutoff will be below @{term "q_max"} with high probability. The result will be needed in Section~\ref{sec:accuracy}, where it is shown that the estimates will be accurate for any cutoff below @{term "q_max"}.\ theory Distributed_Distinct_Elements_Cutoff_Level imports Distributed_Distinct_Elements_Accuracy_Without_Cutoff Distributed_Distinct_Elements_Tail_Bounds begin -hide_const Quantum.Z +hide_const (open) Quantum.Z unbundle intro_cong_syntax lemma mono_real_of_int: "mono real_of_int" unfolding mono_def by auto lemma Max_le_Sum: fixes f :: "'a \ int" assumes "finite A" assumes "\a. a \ A \ f a \ 0" shows "Max (insert 0 (f ` A)) \ (\a \A .f a)" (is "?L \ ?R") proof (cases "A\{}") case True have 0: "f a \ (\a \A .f a)" if "a \ A" for a using that assms by (intro member_le_sum) auto have "?L = max 0 (Max (f ` A))" using True assms(1) by (subst Max_insert) auto also have "... = Max (max 0 ` f ` A)" using assms True by (intro mono_Max_commute monoI) auto also have "... = Max (f ` A)" unfolding image_image using assms by (intro arg_cong[where f="Max"] image_cong) auto also have "... \ ?R" using 0 True assms(1) by (intro iffD2[OF Max_le_iff]) auto finally show ?thesis by simp next case False hence "A = {}" by simp then show ?thesis by simp qed context inner_algorithm_fix_A begin text \The following inequality is true for base e on the entire domain ($x > 0$). It is shown in @{thm [source] ln_add_one_self_le_self}. In the following it is established for base $2$, where it holds for $x \geq 1$.\ lemma log_2_estimate: assumes "x \ (1::real)" shows "log 2 (1+x) \ x" proof - define f where "f x = x - log 2 (1+ x)" for x :: real define f' where "f' x = 1 - 1/((x+1)*ln 2)" for x :: real have 0:"(f has_real_derivative (f' x)) (at x)" if "x > 0" for x unfolding f_def f'_def using that by (auto intro!: derivative_eq_intros) have "f' x \ 0" if "1 \ x" for x :: real proof - have "(1::real) \ 2*ln 2" by (approximation 5) also have "... \ (x+1)*ln 2" using that by (intro mult_right_mono) auto finally have "1 \ (x+1)*ln 2" by simp hence "1/((x+1)*ln 2) \ 1" by simp thus ?thesis unfolding f'_def by simp qed hence "\y. (f has_real_derivative y) (at x) \ 0 \ y" if "x \ 1" for x :: real using that order_less_le_trans[OF exp_gt_zero] by (intro exI[where x="f' x"] conjI 0) auto hence "f 1 \ f x" by (intro DERIV_nonneg_imp_nondecreasing[OF assms]) auto thus "?thesis" unfolding f_def by simp qed lemma cutoff_eq_7: "real X * 2 powr (-real q_max) / b \ 1" proof - have "real X = 2 powr (log 2 X)" using X_ge_1 by (intro powr_log_cancel[symmetric]) auto also have "... \ 2 powr (nat \log 2 X\)" by (intro powr_mono) linarith+ also have "... = 2 ^ (nat \log 2 X\)" by (subst powr_realpow) auto also have "... = real (2 ^ (nat \log 2 (real X)\))" by simp also have "... \ real (2 ^ (b_exp + nat (\log 2 (real X)\ - int b_exp)))" by (intro Nat.of_nat_mono power_increasing) linarith+ also have "... = b * 2^q_max" unfolding q_max_def b_def by (simp add: power_add) finally have "real X \ b * 2 ^ q_max" by simp thus ?thesis using b_min unfolding powr_minus inverse_eq_divide by (simp add:field_simps powr_realpow) qed lemma cutoff_eq_6: fixes k assumes "a \ A" shows " (\f. real_of_int (max 0 (int (f a) - int k)) \\\<^sub>1) \ 2 powr (-real k)" (is "?L \ ?R") proof (cases "k \ n_exp - 1") case True have a_le_n: "a < n" using assms A_range by auto have "?L = (\x. real_of_int (max 0 (int x - k)) \map_pmf (\x. x a) \\<^sub>1)" by simp also have "... = (\x. real_of_int (max 0 (int x - k)) \(\ n_exp))" by (subst hash_pro_component[OF \\<^sub>1 a_le_n]) auto also have "... = (\x. max 0 (real x - real k) \(\ n_exp))" unfolding max_of_mono[OF mono_real_of_int,symmetric] by simp also have "... = (\x\n_exp. max 0 (real x - real k) * pmf (\ n_exp) x)" using geom_pro_range by (intro integral_measure_pmf_real) auto also have "... = (\x=k+1..n_exp. (real x - real k) * pmf (\ n_exp) x)" by (intro sum.mono_neutral_cong_right) auto also have "... = (\x=k+1..n_exp. (real x - real k) * measure (\ n_exp) {x})" unfolding measure_pmf_single by simp also have "... = (\x=k+1..n_exp. (real x-real k)*(measure (\ n_exp) ({\. \\x}-{\. \\(x+1)})))" by (intro sum.cong arg_cong2[where f="(*)"] measure_pmf_cong) auto also have "... = (\x=k+1..n_exp. (real x-real k)* (measure (\ n_exp) {\. \\x} - measure (\ n_exp) {\. \\(x+1)}))" by (intro sum.cong arg_cong2[where f="(*)"] measure_Diff) auto also have "... = (\x=k+1..n_exp. (real x - real k) * (1/2^x - of_bool(x+1\n_exp)/2^(x+1)))" unfolding geom_pro_prob by (intro_cong "[\\<^sub>2 (*), \\<^sub>2 (-), \\<^sub>2 (/)]" more:sum.cong) auto also have "... = (\x=k+1..n_exp. (real x-k)/2^x) - (\x=k+1..n_exp. (real x-k)* of_bool(x+1\n_exp)/2^(x+1))" by (simp add:algebra_simps sum_subtractf) also have "...=(\x=k+1..n_exp. (real x-k)/2^x)-(\x=k+1..n_exp-1. (real x-k)/2^(x+1))" by (intro arg_cong2[where f="(-)"] refl sum.mono_neutral_cong_right) auto also have "...=(\x=k+1..(n_exp-1)+1. (real x-k)/2^x)-(\x=k+1..n_exp-1. (real x-k)/2^(x+1))" using n_exp_gt_0 by (intro arg_cong2[where f="(-)"] refl sum.cong) auto also have "...= (\x\insert k {k+1..n_exp-1}. (real (x+1)-k)/2^(x+1))- (\x=k+1..n_exp-1. (real x-k)/2^(x+1))" unfolding sum.shift_bounds_cl_nat_ivl using True by (intro arg_cong2[where f="(-)"] sum.cong) auto also have "... = 1/2^(k+1)+(\x=k+1..n_exp-1. (real (x+1)-k)/2^(x+1)- (real x-k)/2^(x+1))" by (subst sum.insert) (auto simp add:sum_subtractf) also have "... = 1/2^(k+1)+(\x=k+1..n_exp-1. (1/2^(x+1)))" by (intro arg_cong2[where f="(+)"] sum.cong refl) (simp add:field_simps) also have "... = (\x\insert k {k+1..n_exp-1}. (1/2^(x+1)))" by (subst sum.insert) auto also have "... = (\x=0+k..(n_exp-1-k)+k. 1/2^(x+1))" using True by (intro sum.cong) auto also have "... = (\xx (1/2)^(k+1) * 2 * (1-0)" by (intro mult_left_mono diff_mono) auto also have "... = (1/2)^k" unfolding power_add by simp also have "... = ?R" unfolding powr_minus by (simp add:powr_realpow inverse_eq_divide power_divide) finally show ?thesis by simp next case False hence k_ge_n_exp: "k \ n_exp" by simp have a_lt_n: "a < n" using assms A_range by auto have "?L = (\x. real_of_int (max 0 (int x - k)) \map_pmf (\x. x a) \\<^sub>1)" by simp also have "... = (\x. real_of_int (max 0 (int x - k)) \(\ n_exp))" by (subst hash_pro_component[OF \\<^sub>1 a_lt_n]) auto also have "... = (\x. real_of_int 0 \(\ n_exp))" using geom_pro_range k_ge_n_exp by (intro integral_cong_AE AE_pmfI iffD2[OF of_int_eq_iff] max_absorb1) force+ also have "... = 0" by simp finally show ?thesis by simp qed lemma cutoff_eq_5: assumes "x \ (-1 :: real)" shows "real_of_int \log 2 (x+2)\ \ (real c+2) + max (x - 2^c) 0" (is "?L \ ?R") proof - have 0: "1 \ 2 ^ 1 * ln (2::real)" by (approximation 5) consider (a) "c = 0 \ x \ 2^c+1" | (b) "c > 0 \ x \ 2^c+1" | (c) "x \ 2^c+1" by linarith hence "log 2 (x+2) \ ?R" proof (cases) case a have "log 2 (x+2) = log 2 (1+(x+1))" by (simp add:algebra_simps) also have "... \ x+1" using a by (intro log_2_estimate) auto also have "... = ?R" using a by auto finally show ?thesis by simp next case b have "0 < 0 + (1::real)" by simp also have "... \ 2^c+(1::real)" by (intro add_mono) auto also have "... \ x" using b by simp finally have x_gt_0: "x > 0" by simp have "log 2 (x+2) = log 2 ((x+2)/2^c) + c" using x_gt_0 by (subst log_divide) auto also have "... = log 2 (1+(x+2-2^c)/2^c) + c" by (simp add:divide_simps) also have "... \ (x+2-2^c)/2^c / ln 2 + c" using b unfolding log_def by (intro add_mono divide_right_mono ln_add_one_self_le_self divide_nonneg_pos) auto also have "... = (x+2-2^c)/(2^c*ln 2) + c" by simp also have "... \ (x+2-2^c)/(2^1*ln 2)+c" using b by (intro add_mono divide_left_mono mult_right_mono power_increasing) simp_all also have "... \ (x+2-2^c)/1 + c" using b by (intro add_mono divide_left_mono 0) auto also have "... \ (c+2) + max (x - 2^c) 0" using b by simp finally show ?thesis by simp next case c hence "log 2 (x+2) \ log 2 ((2^c+1)+2)" using assms by (intro log_mono add_mono) auto also have "... = log 2 (2^c*(1+3/2^c))" by (simp add:algebra_simps) also have "... = c + log 2 (1+3/2^c)" by (subst log_mult) (auto intro:add_pos_nonneg) also have "... \ c + log 2 (1+3/2^0)" by (intro add_mono log_mono divide_left_mono power_increasing add_pos_nonneg) auto also have "... = c + log 2 (2*2)" by simp also have "... = real c + 2" by (subst log_mult) auto also have "... \ (c+2) + max (x - 2^c) 0" by simp finally show ?thesis by simp qed moreover have "\log 2 (x+2)\ \ log 2 (x+2)" by simp ultimately show ?thesis using order_trans by blast qed lemma cutoff_level: "measure \ {\. q \ A > q_max} \ \/2" (is "?L \ ?R") proof - have C\<^sub>1_est: "C\<^sub>1 * l \ 30 * real l" unfolding C\<^sub>1_def by (intro mult_right_mono of_nat_0_le_iff) (approximation 10) define Z where "Z \ = (\jlog 2 (of_int (max (\\<^sub>1 \ A q_max j) (-1)) + 2)\)" for \ define V where "V \ = Z \ / real b - 3" for \ have 2:"Z \ \ real b*(real c+2) + of_int (\a\A. max 0 (int (fst \ a) - q_max -2^c))" (is "?L1 \ ?R1") if "\ \ sample_pro \" for c \ proof - obtain f g h where \_def: "\ = (f,g,h)" using prod_cases3 by blast have \_range: "(f,g,h) \ sample_pro \" using that unfolding \_def by simp have "- 1 - 2^c \ -1-(1::real)" by (intro diff_mono) auto also have "... \ 0" by simp finally have "- 1 - 2 ^ c \ (0::real)" by simp hence aux3: "max (-1-2^c) 0 = (0::real)" by (intro max_absorb2) have "- 1 - int q_max - 2 ^ c \ -1 - 0 - 1" by (intro diff_mono) auto also have "... \ 0" by simp finally have "- 1 - int q_max - 2 ^ c \ 0" by simp hence aux3_2: "max 0 (- 1 - int q_max - 2 ^ c) = 0" by (intro max_absorb1) have "?L1 \ (\j\<^sub>1 \ A q_max j) (- 1)) - 2^c) 0)" unfolding Z_def by (intro sum_mono cutoff_eq_5) auto also have "... = (\j\<^sub>0 \ A j - q_max - 2^c) 0)" unfolding \\<^sub>1_def max_of_mono[OF mono_real_of_int,symmetric] by (intro_cong "[\\<^sub>2 (+)]" more:sum.cong) (simp add:max_diff_distrib_left max.assoc aux3) also have "... = real b * (real c + 2) + of_int (\j A \ h (g a) = j})-q_max - 2^c)))" unfolding \_def by (simp add:max.commute) also have "... = real b * (real c + 2) + of_int (\jx. x-q_max-2^c)`(insert(-1){int (f a) |a. a \ A\h(g a)=j}))))" using fin_A by (intro_cong "[\\<^sub>2 (+), \\<^sub>1 of_int, \\<^sub>2 max]" more:sum.cong mono_Max_commute) (auto simp:monoI) also have "... = real b * (real c + 2) + of_int(\j A \ h (g a) = j})))" by (intro_cong "[\\<^sub>2 (+), \\<^sub>1 of_int, \\<^sub>2 max, \\<^sub>1 Max]" more:sum.cong) auto also have "... = real b * (real c + 2) + of_int (\j A \ h (g a) = j})))" using fin_A by (intro_cong "[\\<^sub>2 (+), \\<^sub>1 of_int]" more:sum.cong mono_Max_commute) (auto simp add:monoI setcompr_eq_image) also have "... = real b * (real c + 2) + of_int (\j A \ h (g a) = j}))" using aux3_2 by (intro_cong "[\\<^sub>2 (+), \\<^sub>1 of_int, \\<^sub>1 Max]" more:sum.cong) (simp add:setcompr_eq_image image_image) also have "... \ b*(real c+2)+ of_int(\ja|a\A\h(g(a))=j. max 0(int(f a)-q_max-2^c)))" using fin_A Max_le_Sum unfolding setcompr_eq_image by (intro add_mono iffD2[OF of_int_le_iff] sum_mono Max_le_Sum) (simp_all) also have "... = real b*(real c+2)+ of_int(\a\(\j\{..A\ h(g(a)) = j}). max 0(int(f a)-q_max-2^c))" using fin_A by (intro_cong "[\\<^sub>2 (+), \\<^sub>1 of_int]" more:sum.UNION_disjoint[symmetric]) auto also have "... = real b*(real c+2) + of_int(\a\A. max 0(int(f a)-q_max-2^c))" using h_range[OF \_range] by (intro_cong "[\\<^sub>2 (+), \\<^sub>1 of_int]" more:sum.cong) auto also have "... = ?R1" unfolding \_def by simp finally show ?thesis by simp qed have 1: "measure \ {\. real c \ V \} \ 2 powr (- (2^c))" (is "?L1 \ ?R1") for c proof - have "?L1 = measure \ {\. real b * (real c + 3) \ Z \}" unfolding V_def using b_min by (intro measure_pmf_cong) (simp add:field_simps) also have "... \ measure \ {\. real b*(real c+3)\ real b*(real c+2)+ of_int (\a\A. max 0 (int (fst \ a)-q_max -2^c))}" using 2 order_trans by (intro pmf_mono) blast also have "... = measure \ {\. real b \ (\a\A. of_int (max 0 (int (fst \ a) -q_max -2^c)))}" by (intro measure_pmf_cong) (simp add:algebra_simps) also have "... \ (\\. (\a\A. of_int (max 0 (int (fst \ a) -q_max -2^c))) \\)/real b" using b_min by (intro pmf_markov sum_nonneg) simp_all also have "... = (\a\A. (\\. of_int (max 0 (int (fst \ a) -q_max -2^c)) \\))/real b" by (intro_cong "[\\<^sub>2(/)]" more:Bochner_Integration.integral_sum) simp also have "... = (\a\A. (\f. of_int (max 0 (int (f a)-q_max -2^c)) \(map_pmf fst \)))/real b" by simp also have "... = (\a\A. (\f. of_int (max 0 (int (f a) - (q_max +2^c))) \\\<^sub>1))/real b" unfolding sample_pro_\ map_fst_pair_pmf by (simp add:algebra_simps) also have "... \ (\a\A. 2 powr -real (q_max + 2^c))/real b" using b_min by (intro sum_mono divide_right_mono cutoff_eq_6) auto also have "... = real X * 2 powr (- real q_max + (- (2 ^ c))) / real b" unfolding X_def by simp also have "... = (real X * 2 powr (-real q_max) / b) * 2 powr (-(2^c))" unfolding powr_add by (simp add:algebra_simps) also have "... \ 1 * 2 powr (-(2^c))" using cutoff_eq_7 by (intro mult_right_mono) auto finally show ?thesis by simp qed have 0: "measure \ {\. x \ V \} \ exp (- x * ln x ^ 3)" (is "?L1 \ ?R1") if "x \ 20" for x proof - define c where "c = nat \x\" have "x * ln x^3 \ exp (x * ln 2) * ln 2/2" if "x \ 150" for x::real proof - have aux_aux_0: "x^4 \ 0" by simp have "x * ln x^3 \ x * x^3" using that by (intro mult_left_mono power_mono ln_bound) auto also have "... = x^4 * 1" by (simp add:numeral_eq_Suc) also have "... \ x^4 * ((ln 2 / 10)^4 * (150 * (ln 2 / 10))^6 * (ln 2/2))" by (intro mult_left_mono aux_aux_0) (approximation 8) also have "... = (x * (ln 2 / 10))^4 * (150 * (ln 2 / 10))^6 * (ln 2/2)" unfolding power_mult_distrib by (simp add:algebra_simps) also have "... \ (x * (ln 2 / 10))^4 * (x * (ln 2 / 10))^6 * (ln 2/2)" by (intro mult_right_mono mult_left_mono power_mono that) auto also have "... = (0+x * (ln 2 / 10))^10 * (ln 2/2)" unfolding power_add[symmetric] by simp also have "... \ (1+x * ln 2 / 10)^10 * (ln 2/2)" using that by (intro mult_right_mono power_mono add_mono) auto also have "... \ exp (x * ln 2 / 10)^10 * (ln 2/2)" using that by (intro mult_right_mono power_mono exp_ge_add_one_self) auto also have "... = exp (x * ln 2) * (ln 2/2)" unfolding exp_of_nat_mult[symmetric] by simp finally show ?thesis by simp qed moreover have "x * ln x^3 \ exp (x * ln 2) * ln 2/2" if "x \ {20..150}" using that by (approximation 10 splitting: x=1) ultimately have "x * ln x^3 \ exp (x * ln 2) * ln 2/2" using that by fastforce also have "... = 2 powr (x-1) * ln 2" unfolding powr_diff unfolding powr_def by simp also have "... \ 2 powr c * ln 2" unfolding c_def using that by (intro mult_right_mono powr_mono) auto also have "... = 2^c * ln 2" using powr_realpow by simp finally have aux0: "x * ln x^3 \ 2^c * ln 2" by simp have "real c \ x" using that unfolding c_def by linarith hence "?L1 \ measure \ {\. real c \ V \}" by (intro pmf_mono) auto also have "... \ 2 powr (-(2^c))" by (intro 1) also have "... = exp (- (2 ^ c * ln 2))" by (simp add:powr_def) also have "... \ exp (- (x *ln x^3))" using aux0 by (intro iffD2[OF exp_le_cancel_iff]) auto also have "... = ?R1" by simp finally show ?thesis by simp qed have "?L \ measure \ {\. is_too_large (\\<^sub>2 \ A q_max)}" using lt_s_too_large by (intro pmf_mono) (simp del:is_too_large.simps) also have "... = measure \ {\. (\(i,j)\{..{..log 2 (of_int (max (\\<^sub>2 \ A q_max i j) (-1)) + 2)\) > C\<^sub>5 * b *l}" by simp also have "... = measure \ {\. real_of_int (\(i,j)\{..{..log 2 (of_int (max (\\<^sub>2 \ A q_max i j) (-1)) + 2)\) > of_int (C\<^sub>5 * b * l)}" unfolding of_int_less_iff by simp also have "... = measure \ {\. real_of_int C\<^sub>5 * real b * real l < of_int (\x\{.. {..log 2 (real_of_int (\\<^sub>1 (\ (fst x)) A q_max (snd x)) + 2)\)}" by (intro_cong "[\\<^sub>2 measure, \\<^sub>1 Collect, \\<^sub>1 of_int, \\<^sub>2 (<)]" more:ext sum.cong) (auto simp add:case_prod_beta \\<^sub>2_def \\<^sub>1_def) also have "... = measure \ {\. (\i i)) > of_int C\<^sub>5 * real b * real l}" unfolding Z_def sum.cartesian_product \\<^sub>1_def by (simp add:case_prod_beta) also have "... = measure \ {\. (\i i) + 3) > of_int C\<^sub>5 * real l}" unfolding V_def using b_min by (intro measure_pmf_cong) (simp add:sum_divide_distrib[symmetric] field_simps sum.distrib) also have "... = measure \ {\. (\i i)) > of_int (C\<^sub>5-3) * real l}" by (simp add:sum.distrib algebra_simps) also have "... \ measure \ {\. (\i i)) \ C\<^sub>1 * real l}" unfolding C\<^sub>5_def using C\<^sub>1_est by (intro pmf_mono) auto also have "... \ exp (- real l)" by (intro deviation_bound l_gt_0 0) (simp_all add: \_def) also have "... \ exp (- (C\<^sub>6 * ln (2 / \)))" using l_lbound by (intro iffD2[OF exp_le_cancel_iff]) auto also have "... \ exp (- (1 * ln (2 / \)))" unfolding C\<^sub>6_def using \_gt_0 \_lt_1 by (intro iffD2[OF exp_le_cancel_iff] le_imp_neg_le mult_right_mono ln_ge_zero) auto also have "... = exp ( ln ( \ / 2))" using \_gt_0 by (simp add: ln_div) also have "... = \/2" using \_gt_0 by simp finally show ?thesis by simp qed end unbundle no_intro_cong_syntax end \ No newline at end of file