[STATEMENT]
lemma (in product_prob_space) measure_PiM_emb:
  assumes "J \<subseteq> I" "finite J" "\<And>i. i \<in> J \<Longrightarrow> X i \<in> sets (M i)"
  shows "measure (PiM I M) (emb I J (Pi\<^sub>E J X)) = (\<Prod> i\<in>J. measure (M i) (X i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P.prob (emb I J (Pi\<^sub>E J X)) = (\<Prod>i\<in>J. M.prob i (X i))
[PROOF STEP]
using emeasure_PiM_emb[OF assms]
[PROOF STATE]
proof (prove)
using this:
(\<And>i. i \<in> J \<Longrightarrow> i \<in> J) \<Longrightarrow> emeasure (Pi\<^sub>M I M) (emb I J (Pi\<^sub>E J X)) = (\<Prod>i\<in>J. emeasure (M i) (X i))

goal (1 subgoal):
 1. P.prob (emb I J (Pi\<^sub>E J X)) = (\<Prod>i\<in>J. M.prob i (X i))
[PROOF STEP]
unfolding emeasure_eq_measure M.emeasure_eq_measure
[PROOF STATE]
proof (prove)
using this:
(\<And>i. i \<in> J \<Longrightarrow> i \<in> J) \<Longrightarrow> ennreal (P.prob (emb I J (Pi\<^sub>E J X))) = (\<Prod>i\<in>J. ennreal (M.prob i (X i)))

goal (1 subgoal):
 1. P.prob (emb I J (Pi\<^sub>E J X)) = (\<Prod>i\<in>J. M.prob i (X i))
[PROOF STEP]
by (simp add: prod_ennreal measure_nonneg prod_nonneg)


[STATEMENT]
lemma min_Liminf_at:
  fixes f :: "'a::metric_space \<Rightarrow> 'b::complete_linorder"
  shows "min (f x) (Liminf (at x) f) = (SUP e\<in>{0<..}. INF y\<in>ball x e. f y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. min (f x) (Liminf (at x) f) = (SUP e\<in>{0<..}. Inf (f ` ball x e))
[PROOF STEP]
apply (simp add: inf_min [symmetric] Liminf_at)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inf (f x) (SUP e\<in>{0<..}. Inf (f ` (ball x e - {x}))) = (SUP e\<in>{0<..}. Inf (f ` ball x e))
[PROOF STEP]
apply (subst inf_commute)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inf (SUP e\<in>{0<..}. Inf (f ` (ball x e - {x}))) (f x) = (SUP e\<in>{0<..}. Inf (f ` ball x e))
[PROOF STEP]
apply (subst SUP_inf)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (SUP b\<in>{0<..}. inf (Inf (f ` (ball x b - {x}))) (f x)) = (SUP e\<in>{0<..}. Inf (f ` ball x e))
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (SUP xa\<in>{0<..}. inf (Inf (f ` (ball x xa - {x}))) (f x)) = (SUP xa\<in>{0<..}. Inf (f ` ball x xa))
[PROOF STEP]
apply (metis (no_types, lifting) INF_insert centre_in_ball greaterThan_iff image_cong inf_commute insert_Diff)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma omap_alt: "omap f l = Some l' \<longleftrightarrow> (l' = map (the o f) l \<and> (\<forall>x\<in>set l. f x \<noteq> None))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (omap f l = Some l') = (l' = map (the \<circ> f) l \<and> (\<forall>x\<in>set l. f x \<noteq> None))
[PROOF STEP]
apply (induction l arbitrary: l')
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>l'. (omap f [] = Some l') = (l' = map (the \<circ> f) [] \<and> (\<forall>x\<in>set []. f x \<noteq> None))
 2. \<And>a l l'. (\<And>l'. (omap f l = Some l') = (l' = map (the \<circ> f) l \<and> (\<forall>x\<in>set l. f x \<noteq> None))) \<Longrightarrow> (omap f (a # l) = Some l') = (l' = map (the \<circ> f) (a # l) \<and> (\<forall>x\<in>set (a # l). f x \<noteq> None))
[PROOF STEP]
apply (auto split: Option.bind_splits)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma bij_betw_map_lists:
assumes "bij_betw f A B"
shows "bij_betw (map f) (lists A) (lists B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij_betw (map f) (lists A) (lists B)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
bij_betw f A B

goal (1 subgoal):
 1. bij_betw (map f) (lists A) (lists B)
[PROOF STEP]
unfolding bij_betw_def
[PROOF STATE]
proof (prove)
using this:
inj_on f A \<and> f ` A = B

goal (1 subgoal):
 1. inj_on (map f) (lists A) \<and> map f ` lists A = lists B
[PROOF STEP]
by(auto simp add: inj_on_map_lists map_lists_surjective)


[STATEMENT]
lemma "\<forall>(x::'a::linordered_field) y z. \<exists>w \<ge> x + y + z. w \<le> \<bar>x\<bar> + \<bar>y\<bar> + \<bar>z\<bar>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x y z. \<exists>w\<ge>x + y + z. w \<le> \<bar>x\<bar> + \<bar>y\<bar> + \<bar>z\<bar>
[PROOF STEP]
by ferrack


[STATEMENT]
lemma insert_dominated[simp]: "length gs \<le> ffp \<Longrightarrow>
    length gs + (max xs (Max (insert ffp (x1 ` x2 ` set gs))) - length gs) =
    max xs (Max (insert ffp (x1 ` x2 ` set gs)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length gs \<le> ffp \<Longrightarrow> length gs + (max xs (Max (insert ffp (x1 ` x2 ` set gs))) - length gs) = max xs (Max (insert ffp (x1 ` x2 ` set gs)))
[PROOF STEP]
apply(rule_tac le_add_diff_inverse)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length gs \<le> ffp \<Longrightarrow> length gs \<le> max xs (Max (insert ffp (x1 ` x2 ` set gs)))
[PROOF STEP]
apply(rule_tac max.coboundedI2)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length gs \<le> ffp \<Longrightarrow> length gs \<le> Max (insert ffp (x1 ` x2 ` set gs))
[PROOF STEP]
apply(simp add: Max_ge_iff)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma uminus_image_real_of_ereal_image_greaterThanLessThan:
  "uminus ` real_of_ereal ` {l <..< u} = real_of_ereal ` {-u <..< -l}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. uminus ` real_of_ereal ` {l<..<u} = real_of_ereal ` {- u<..<- l}
[PROOF STEP]
by (force simp: algebra_simps ereal_less_uminus_reorder
    ereal_uminus_less_reorder intro: image_eqI[where x="-x" for x])


[STATEMENT]
lemma mat_leqb_eqc_satisfies2:
  assumes "x \<Turnstile>\<^sub>c\<^sub>s set (mat_leqb_eqc A b c)"
  assumes "dim_vec b \<le> i" and "i < dim_vec (b@\<^sub>vc)"
    and "dim_row A = dim_vec b" and "dim_vec c \<le> dim_col A"
  shows "(matrix_to_lpolies (two_block_non_interfering A A\<^sup>T) ! i) \<lbrace>x\<rbrace> = (b @\<^sub>v c) $ i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix_to_lpolies (two_block_non_interfering A A\<^sup>T) ! i \<lbrace> x \<rbrace> = (b @\<^sub>v c) $ i
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. matrix_to_lpolies (two_block_non_interfering A A\<^sup>T) ! i \<lbrace> x \<rbrace> = (b @\<^sub>v c) $ i
[PROOF STEP]
have e_e: "EQ (vec_to_lpoly (0\<^sub>v (dim_col A) @\<^sub>v row A\<^sup>T (i - dim_vec b))) (c $ (i - dim_vec b))
              \<in> set (mat_leqb_eqc A b c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. EQ (vec_to_lpoly (0\<^sub>v (dim_col A) @\<^sub>v row A\<^sup>T (i - dim_vec b))) (c $ (i - dim_vec b)) \<in> set (mat_leqb_eqc A b c)
[PROOF STEP]
using assms(2) mat_leqb_eqc.simps[of A b c]
      nth_mem[of i "(mat_leqb_eqc A b c)"]
[PROOF STATE]
proof (prove)
using this:
dim_vec b \<le> i
mat_leqb_eqc A b c = (let lst = matrix_to_lpolies (two_block_non_interfering A A\<^sup>T) in map (\<lambda>i. LEQ (lst ! i) (b $ i)) [0..<dim_vec b] @ map (\<lambda>i. EQ (lst ! i) ((b @\<^sub>v c) $ i)) [dim_vec b..<dim_vec (b @\<^sub>v c)])
i < length (mat_leqb_eqc A b c) \<Longrightarrow> mat_leqb_eqc A b c ! i \<in> set (mat_leqb_eqc A b c)

goal (1 subgoal):
 1. EQ (vec_to_lpoly (0\<^sub>v (dim_col A) @\<^sub>v row A\<^sup>T (i - dim_vec b))) (c $ (i - dim_vec b)) \<in> set (mat_leqb_eqc A b c)
[PROOF STEP]
using  mat_leqb_eqc_for_EQ[of b i c A, OF assms(2) assms(3) assms(4) assms(5)]
[PROOF STATE]
proof (prove)
using this:
dim_vec b \<le> i
mat_leqb_eqc A b c = (let lst = matrix_to_lpolies (two_block_non_interfering A A\<^sup>T) in map (\<lambda>i. LEQ (lst ! i) (b $ i)) [0..<dim_vec b] @ map (\<lambda>i. EQ (lst ! i) ((b @\<^sub>v c) $ i)) [dim_vec b..<dim_vec (b @\<^sub>v c)])
i < length (mat_leqb_eqc A b c) \<Longrightarrow> mat_leqb_eqc A b c ! i \<in> set (mat_leqb_eqc A b c)
mat_leqb_eqc A b c ! i = EQ (vec_to_lpoly (0\<^sub>v (dim_col A) @\<^sub>v row A\<^sup>T (i - dim_vec b))) (c $ (i - dim_vec b))

goal (1 subgoal):
 1. EQ (vec_to_lpoly (0\<^sub>v (dim_col A) @\<^sub>v row A\<^sup>T (i - dim_vec b))) (c $ (i - dim_vec b)) \<in> set (mat_leqb_eqc A b c)
[PROOF STEP]
by (metis (mono_tags, lifting) add_diff_cancel_left' assms(3) diff_zero index_append_vec(2)
        length_append length_map length_upt)
[PROOF STATE]
proof (state)
this:
EQ (vec_to_lpoly (0\<^sub>v (dim_col A) @\<^sub>v row A\<^sup>T (i - dim_vec b))) (c $ (i - dim_vec b)) \<in> set (mat_leqb_eqc A b c)

goal (1 subgoal):
 1. matrix_to_lpolies (two_block_non_interfering A A\<^sup>T) ! i \<lbrace> x \<rbrace> = (b @\<^sub>v c) $ i
[PROOF STEP]
hence sateq: "x \<Turnstile>\<^sub>c EQ (vec_to_lpoly (0\<^sub>v (dim_col A) @\<^sub>v
                row A\<^sup>T (i - dim_vec b))) (c $ (i - dim_vec b))"
[PROOF STATE]
proof (prove)
using this:
EQ (vec_to_lpoly (0\<^sub>v (dim_col A) @\<^sub>v row A\<^sup>T (i - dim_vec b))) (c $ (i - dim_vec b)) \<in> set (mat_leqb_eqc A b c)

goal (1 subgoal):
 1. x \<Turnstile>\<^sub>c EQ (vec_to_lpoly (0\<^sub>v (dim_col A) @\<^sub>v row A\<^sup>T (i - dim_vec b))) (c $ (i - dim_vec b))
[PROOF STEP]
using assms(1)
[PROOF STATE]
proof (prove)
using this:
EQ (vec_to_lpoly (0\<^sub>v (dim_col A) @\<^sub>v row A\<^sup>T (i - dim_vec b))) (c $ (i - dim_vec b)) \<in> set (mat_leqb_eqc A b c)
x \<Turnstile>\<^sub>c\<^sub>s set (mat_leqb_eqc A b c)

goal (1 subgoal):
 1. x \<Turnstile>\<^sub>c EQ (vec_to_lpoly (0\<^sub>v (dim_col A) @\<^sub>v row A\<^sup>T (i - dim_vec b))) (c $ (i - dim_vec b))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
x \<Turnstile>\<^sub>c EQ (vec_to_lpoly (0\<^sub>v (dim_col A) @\<^sub>v row A\<^sup>T (i - dim_vec b))) (c $ (i - dim_vec b))

goal (1 subgoal):
 1. matrix_to_lpolies (two_block_non_interfering A A\<^sup>T) ! i \<lbrace> x \<rbrace> = (b @\<^sub>v c) $ i
[PROOF STEP]
have *: "i < dim_row (two_block_non_interfering A A\<^sup>T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i < dim_row (two_block_non_interfering A A\<^sup>T)
[PROOF STEP]
by (metis assms(3) assms(4) assms(5) dual_order.order_iff_strict dual_order.strict_trans
        index_append_vec(2) index_transpose_mat(2) nat_add_left_cancel_less
        two_block_non_interfering_dims(1))
[PROOF STATE]
proof (state)
this:
i < dim_row (two_block_non_interfering A A\<^sup>T)

goal (1 subgoal):
 1. matrix_to_lpolies (two_block_non_interfering A A\<^sup>T) ! i \<lbrace> x \<rbrace> = (b @\<^sub>v c) $ i
[PROOF STEP]
have **: "dim_row A \<le> i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row A \<le> i
[PROOF STEP]
by (simp add: assms(2) assms(4))
[PROOF STATE]
proof (state)
this:
dim_row A \<le> i

goal (1 subgoal):
 1. matrix_to_lpolies (two_block_non_interfering A A\<^sup>T) ! i \<lbrace> x \<rbrace> = (b @\<^sub>v c) $ i
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
dim_row A \<le> i
[PROOF STEP]
have "x \<Turnstile>\<^sub>c EQ ((matrix_to_lpolies (two_block_non_interfering A A\<^sup>T))!i) ((b@\<^sub>vc)$i)"
[PROOF STATE]
proof (prove)
using this:
dim_row A \<le> i

goal (1 subgoal):
 1. x \<Turnstile>\<^sub>c EQ (matrix_to_lpolies (two_block_non_interfering A A\<^sup>T) ! i) ((b @\<^sub>v c) $ i)
[PROOF STEP]
using two_block_non_interfering_row_comp2[of i A "A\<^sup>T", OF * **]
[PROOF STATE]
proof (prove)
using this:
dim_row A \<le> i
row (two_block_non_interfering A A\<^sup>T) i = 0\<^sub>v (dim_col A) @\<^sub>v row A\<^sup>T (i - dim_row A)

goal (1 subgoal):
 1. x \<Turnstile>\<^sub>c EQ (matrix_to_lpolies (two_block_non_interfering A A\<^sup>T) ! i) ((b @\<^sub>v c) $ i)
[PROOF STEP]
by (metis "*" sateq assms(3) assms(4) index_append_vec(1) index_append_vec(2) leD
        matrix_to_lp_vec_to_lpoly_row)
[PROOF STATE]
proof (state)
this:
x \<Turnstile>\<^sub>c EQ (matrix_to_lpolies (two_block_non_interfering A A\<^sup>T) ! i) ((b @\<^sub>v c) $ i)

goal (1 subgoal):
 1. matrix_to_lpolies (two_block_non_interfering A A\<^sup>T) ! i \<lbrace> x \<rbrace> = (b @\<^sub>v c) $ i
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<Turnstile>\<^sub>c EQ (matrix_to_lpolies (two_block_non_interfering A A\<^sup>T) ! i) ((b @\<^sub>v c) $ i)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
x \<Turnstile>\<^sub>c EQ (matrix_to_lpolies (two_block_non_interfering A A\<^sup>T) ! i) ((b @\<^sub>v c) $ i)

goal (1 subgoal):
 1. matrix_to_lpolies (two_block_non_interfering A A\<^sup>T) ! i \<lbrace> x \<rbrace> = (b @\<^sub>v c) $ i
[PROOF STEP]
using satisfies_constraint.simps(5)
[PROOF STATE]
proof (prove)
using this:
x \<Turnstile>\<^sub>c EQ (matrix_to_lpolies (two_block_non_interfering A A\<^sup>T) ! i) ((b @\<^sub>v c) $ i)
?v \<Turnstile>\<^sub>c EQ ?l ?r = (?l \<lbrace> ?v \<rbrace> = ?r *R (1::?'a))

goal (1 subgoal):
 1. matrix_to_lpolies (two_block_non_interfering A A\<^sup>T) ! i \<lbrace> x \<rbrace> = (b @\<^sub>v c) $ i
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
matrix_to_lpolies (two_block_non_interfering A A\<^sup>T) ! i \<lbrace> x \<rbrace> = (b @\<^sub>v c) $ i

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma multisets_supp_finite:
  fixes M::"('a::fs multiset)"
  shows "finite (supp M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (supp M)
[PROOF STEP]
by (simp only: supp_of_multisets Union_finite_multiset)


[STATEMENT]
lemma sets_to_inds_finite:
  assumes "finite I"
  shows "finite S \<Longrightarrow> finite (Pi\<^sub>E S (\<lambda>_. I))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite S \<Longrightarrow> finite (S \<rightarrow>\<^sub>E I)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite I

goal (1 subgoal):
 1. finite S \<Longrightarrow> finite (S \<rightarrow>\<^sub>E I)
[PROOF STEP]
by (simp add: finite_PiE)


[STATEMENT]
theorem comp_tot_rec: "\<lbrakk> total_recursive f; total_recursive g \<rbrakk> \<Longrightarrow> total_recursive (f o g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>total_recursive f; total_recursive g\<rbrakk> \<Longrightarrow> total_recursive (f \<circ> g)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>total_recursive f; total_recursive g\<rbrakk> \<Longrightarrow> total_recursive (f \<circ> g)
[PROOF STEP]
assume "total_recursive f"
[PROOF STATE]
proof (state)
this:
total_recursive f

goal (1 subgoal):
 1. \<lbrakk>total_recursive f; total_recursive g\<rbrakk> \<Longrightarrow> total_recursive (f \<circ> g)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
total_recursive f
[PROOF STEP]
have f_ce: "graph f \<in> ce_rels"
[PROOF STATE]
proof (prove)
using this:
total_recursive f

goal (1 subgoal):
 1. graph f \<in> ce_rels
[PROOF STEP]
by (unfold total_recursive_def)
[PROOF STATE]
proof (state)
this:
graph f \<in> ce_rels

goal (1 subgoal):
 1. \<lbrakk>total_recursive f; total_recursive g\<rbrakk> \<Longrightarrow> total_recursive (f \<circ> g)
[PROOF STEP]
assume "total_recursive g"
[PROOF STATE]
proof (state)
this:
total_recursive g

goal (1 subgoal):
 1. \<lbrakk>total_recursive f; total_recursive g\<rbrakk> \<Longrightarrow> total_recursive (f \<circ> g)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
total_recursive g
[PROOF STEP]
have g_ce: "graph g \<in> ce_rels"
[PROOF STATE]
proof (prove)
using this:
total_recursive g

goal (1 subgoal):
 1. graph g \<in> ce_rels
[PROOF STEP]
by (unfold total_recursive_def)
[PROOF STATE]
proof (state)
this:
graph g \<in> ce_rels

goal (1 subgoal):
 1. \<lbrakk>total_recursive f; total_recursive g\<rbrakk> \<Longrightarrow> total_recursive (f \<circ> g)
[PROOF STEP]
from f_ce g_ce
[PROOF STATE]
proof (chain)
picking this:
graph f \<in> ce_rels
graph g \<in> ce_rels
[PROOF STEP]
have "graph g O graph f \<in> ce_rels"
[PROOF STATE]
proof (prove)
using this:
graph f \<in> ce_rels
graph g \<in> ce_rels

goal (1 subgoal):
 1. graph g O graph f \<in> ce_rels
[PROOF STEP]
by (rule ce_rel_lm_24)
[PROOF STATE]
proof (state)
this:
graph g O graph f \<in> ce_rels

goal (1 subgoal):
 1. \<lbrakk>total_recursive f; total_recursive g\<rbrakk> \<Longrightarrow> total_recursive (f \<circ> g)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
graph g O graph f \<in> ce_rels
[PROOF STEP]
have "graph (f o g) \<in> ce_rels"
[PROOF STATE]
proof (prove)
using this:
graph g O graph f \<in> ce_rels

goal (1 subgoal):
 1. graph (f \<circ> g) \<in> ce_rels
[PROOF STEP]
by (simp add: graph_lm_4)
[PROOF STATE]
proof (state)
this:
graph (f \<circ> g) \<in> ce_rels

goal (1 subgoal):
 1. \<lbrakk>total_recursive f; total_recursive g\<rbrakk> \<Longrightarrow> total_recursive (f \<circ> g)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
graph (f \<circ> g) \<in> ce_rels
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
graph (f \<circ> g) \<in> ce_rels

goal (1 subgoal):
 1. total_recursive (f \<circ> g)
[PROOF STEP]
by (unfold total_recursive_def)
[PROOF STATE]
proof (state)
this:
total_recursive (f \<circ> g)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma condensation_condense1: "(\<Sum>k=1..<2^n. f (2 ^ Discrete.log k)) = (\<Sum>k<n. 2^k * f (2 ^ k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k = 1..<2 ^ n. f (2 ^ Discrete.log k)) = (\<Sum>k<n. 2 ^ k * f (2 ^ k))
[PROOF STEP]
proof (induction n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (\<Sum>k = 1..<2 ^ 0. f (2 ^ Discrete.log k)) = (\<Sum>k<0. 2 ^ k * f (2 ^ k))
 2. \<And>n. (\<Sum>k = 1..<2 ^ n. f (2 ^ Discrete.log k)) = (\<Sum>k<n. 2 ^ k * f (2 ^ k)) \<Longrightarrow> (\<Sum>k = 1..<2 ^ Suc n. f (2 ^ Discrete.log k)) = (\<Sum>k<Suc n. 2 ^ k * f (2 ^ k))
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 1..<2 ^ n. f (2 ^ Discrete.log k)) = (\<Sum>k<n. 2 ^ k * f (2 ^ k))

goal (2 subgoals):
 1. (\<Sum>k = 1..<2 ^ 0. f (2 ^ Discrete.log k)) = (\<Sum>k<0. 2 ^ k * f (2 ^ k))
 2. \<And>n. (\<Sum>k = 1..<2 ^ n. f (2 ^ Discrete.log k)) = (\<Sum>k<n. 2 ^ k * f (2 ^ k)) \<Longrightarrow> (\<Sum>k = 1..<2 ^ Suc n. f (2 ^ Discrete.log k)) = (\<Sum>k<Suc n. 2 ^ k * f (2 ^ k))
[PROOF STEP]
have "{1..<2^Suc n} = {1..<2^n} \<union> {2^n..<(2^Suc n :: nat)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {1..<2 ^ Suc n} = {1..<2 ^ n} \<union> {2 ^ n..<2 ^ Suc n}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{1..<2 ^ Suc n} = {1..<2 ^ n} \<union> {2 ^ n..<2 ^ Suc n}

goal (2 subgoals):
 1. (\<Sum>k = 1..<2 ^ 0. f (2 ^ Discrete.log k)) = (\<Sum>k<0. 2 ^ k * f (2 ^ k))
 2. \<And>n. (\<Sum>k = 1..<2 ^ n. f (2 ^ Discrete.log k)) = (\<Sum>k<n. 2 ^ k * f (2 ^ k)) \<Longrightarrow> (\<Sum>k = 1..<2 ^ Suc n. f (2 ^ Discrete.log k)) = (\<Sum>k<Suc n. 2 ^ k * f (2 ^ k))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
{1..<2 ^ Suc n} = {1..<2 ^ n} \<union> {2 ^ n..<2 ^ Suc n}

goal (2 subgoals):
 1. (\<Sum>k = 1..<2 ^ 0. f (2 ^ Discrete.log k)) = (\<Sum>k<0. 2 ^ k * f (2 ^ k))
 2. \<And>n. (\<Sum>k = 1..<2 ^ n. f (2 ^ Discrete.log k)) = (\<Sum>k<n. 2 ^ k * f (2 ^ k)) \<Longrightarrow> (\<Sum>k = 1..<2 ^ Suc n. f (2 ^ Discrete.log k)) = (\<Sum>k<Suc n. 2 ^ k * f (2 ^ k))
[PROOF STEP]
have "(\<Sum>k\<in>\<dots>. f (2 ^ Discrete.log k)) =
                 (\<Sum>k<n. 2^k * f (2^k)) + (\<Sum>k = 2^n..<2^Suc n. f (2^Discrete.log k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k\<in>{1..<2 ^ n} \<union> {2 ^ n..<2 ^ Suc n}. f (2 ^ Discrete.log k)) = (\<Sum>k<n. 2 ^ k * f (2 ^ k)) + (\<Sum>k = 2 ^ n..<2 ^ Suc n. f (2 ^ Discrete.log k))
[PROOF STEP]
by (subst sum.union_disjoint) (insert Suc, auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<in>{1..<2 ^ n} \<union> {2 ^ n..<2 ^ Suc n}. f (2 ^ Discrete.log k)) = (\<Sum>k<n. 2 ^ k * f (2 ^ k)) + (\<Sum>k = 2 ^ n..<2 ^ Suc n. f (2 ^ Discrete.log k))

goal (2 subgoals):
 1. (\<Sum>k = 1..<2 ^ 0. f (2 ^ Discrete.log k)) = (\<Sum>k<0. 2 ^ k * f (2 ^ k))
 2. \<And>n. (\<Sum>k = 1..<2 ^ n. f (2 ^ Discrete.log k)) = (\<Sum>k<n. 2 ^ k * f (2 ^ k)) \<Longrightarrow> (\<Sum>k = 1..<2 ^ Suc n. f (2 ^ Discrete.log k)) = (\<Sum>k<Suc n. 2 ^ k * f (2 ^ k))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<in>{1..<2 ^ n} \<union> {2 ^ n..<2 ^ Suc n}. f (2 ^ Discrete.log k)) = (\<Sum>k<n. 2 ^ k * f (2 ^ k)) + (\<Sum>k = 2 ^ n..<2 ^ Suc n. f (2 ^ Discrete.log k))

goal (2 subgoals):
 1. (\<Sum>k = 1..<2 ^ 0. f (2 ^ Discrete.log k)) = (\<Sum>k<0. 2 ^ k * f (2 ^ k))
 2. \<And>n. (\<Sum>k = 1..<2 ^ n. f (2 ^ Discrete.log k)) = (\<Sum>k<n. 2 ^ k * f (2 ^ k)) \<Longrightarrow> (\<Sum>k = 1..<2 ^ Suc n. f (2 ^ Discrete.log k)) = (\<Sum>k<Suc n. 2 ^ k * f (2 ^ k))
[PROOF STEP]
have "Discrete.log k = n" if "k \<in> {2^n..<2^Suc n}" for k
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Discrete.log k = n
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
k \<in> {2 ^ n..<2 ^ Suc n}

goal (1 subgoal):
 1. Discrete.log k = n
[PROOF STEP]
by (intro Discrete.log_eqI) simp_all
[PROOF STATE]
proof (state)
this:
?k \<in> {2 ^ n..<2 ^ Suc n} \<Longrightarrow> Discrete.log ?k = n

goal (2 subgoals):
 1. (\<Sum>k = 1..<2 ^ 0. f (2 ^ Discrete.log k)) = (\<Sum>k<0. 2 ^ k * f (2 ^ k))
 2. \<And>n. (\<Sum>k = 1..<2 ^ n. f (2 ^ Discrete.log k)) = (\<Sum>k<n. 2 ^ k * f (2 ^ k)) \<Longrightarrow> (\<Sum>k = 1..<2 ^ Suc n. f (2 ^ Discrete.log k)) = (\<Sum>k<Suc n. 2 ^ k * f (2 ^ k))
[PROOF STEP]
hence "(\<Sum>k = 2^n..<2^Suc n. f (2^Discrete.log k)) = (\<Sum>(_::nat) = 2^n..<2^Suc n. f (2^n))"
[PROOF STATE]
proof (prove)
using this:
?k \<in> {2 ^ n..<2 ^ Suc n} \<Longrightarrow> Discrete.log ?k = n

goal (1 subgoal):
 1. (\<Sum>k = 2 ^ n..<2 ^ Suc n. f (2 ^ Discrete.log k)) = (\<Sum>_ = 2 ^ n..<2 ^ Suc n. f (2 ^ n))
[PROOF STEP]
by (intro sum.cong) simp_all
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 2 ^ n..<2 ^ Suc n. f (2 ^ Discrete.log k)) = (\<Sum>_ = 2 ^ n..<2 ^ Suc n. f (2 ^ n))

goal (2 subgoals):
 1. (\<Sum>k = 1..<2 ^ 0. f (2 ^ Discrete.log k)) = (\<Sum>k<0. 2 ^ k * f (2 ^ k))
 2. \<And>n. (\<Sum>k = 1..<2 ^ n. f (2 ^ Discrete.log k)) = (\<Sum>k<n. 2 ^ k * f (2 ^ k)) \<Longrightarrow> (\<Sum>k = 1..<2 ^ Suc n. f (2 ^ Discrete.log k)) = (\<Sum>k<Suc n. 2 ^ k * f (2 ^ k))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 2 ^ n..<2 ^ Suc n. f (2 ^ Discrete.log k)) = (\<Sum>_ = 2 ^ n..<2 ^ Suc n. f (2 ^ n))

goal (2 subgoals):
 1. (\<Sum>k = 1..<2 ^ 0. f (2 ^ Discrete.log k)) = (\<Sum>k<0. 2 ^ k * f (2 ^ k))
 2. \<And>n. (\<Sum>k = 1..<2 ^ n. f (2 ^ Discrete.log k)) = (\<Sum>k<n. 2 ^ k * f (2 ^ k)) \<Longrightarrow> (\<Sum>k = 1..<2 ^ Suc n. f (2 ^ Discrete.log k)) = (\<Sum>k<Suc n. 2 ^ k * f (2 ^ k))
[PROOF STEP]
have "\<dots> = 2^n * f (2^n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>_ = 2 ^ n..<2 ^ Suc n. f (2 ^ n)) = 2 ^ n * f (2 ^ n)
[PROOF STEP]
by (simp)
[PROOF STATE]
proof (state)
this:
(\<Sum>_ = 2 ^ n..<2 ^ Suc n. f (2 ^ n)) = 2 ^ n * f (2 ^ n)

goal (2 subgoals):
 1. (\<Sum>k = 1..<2 ^ 0. f (2 ^ Discrete.log k)) = (\<Sum>k<0. 2 ^ k * f (2 ^ k))
 2. \<And>n. (\<Sum>k = 1..<2 ^ n. f (2 ^ Discrete.log k)) = (\<Sum>k<n. 2 ^ k * f (2 ^ k)) \<Longrightarrow> (\<Sum>k = 1..<2 ^ Suc n. f (2 ^ Discrete.log k)) = (\<Sum>k<Suc n. 2 ^ k * f (2 ^ k))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>k = 1..<2 ^ Suc n. f (2 ^ Discrete.log k)) = (\<Sum>k<n. 2 ^ k * f (2 ^ k)) + 2 ^ n * f (2 ^ n)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
(\<Sum>k = 1..<2 ^ Suc n. f (2 ^ Discrete.log k)) = (\<Sum>k<n. 2 ^ k * f (2 ^ k)) + 2 ^ n * f (2 ^ n)

goal (1 subgoal):
 1. (\<Sum>k = 1..<2 ^ Suc n. f (2 ^ Discrete.log k)) = (\<Sum>k<Suc n. 2 ^ k * f (2 ^ k))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>k = 1..<2 ^ Suc n. f (2 ^ Discrete.log k)) = (\<Sum>k<Suc n. 2 ^ k * f (2 ^ k))

goal (1 subgoal):
 1. (\<Sum>k = 1..<2 ^ 0. f (2 ^ Discrete.log k)) = (\<Sum>k<0. 2 ^ k * f (2 ^ k))
[PROOF STEP]
qed simp


[STATEMENT]
lemma f1_l0: assumes "l0 \<le> l/c" shows "f1*(l/c) \<le> f1*l - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f1 * (l / c) \<le> f1 * l - 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. f1 * (l / c) \<le> f1 * l - 1
[PROOF STEP]
have "1 = f1*((c-1)/c)*(c*(1/(f1*(c-1))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 = f1 * ((c - 1) / c) * (c * (1 / (f1 * (c - 1))))
[PROOF STEP]
using f1'_le_f2' f2'_less_f2
[PROOF STATE]
proof (prove)
using this:
f1' \<le> f2'
f2' < f2

goal (1 subgoal):
 1. 1 = f1 * ((c - 1) / c) * (c * (1 / (f1 * (c - 1))))
[PROOF STEP]
by(simp add: field_simps)
[PROOF STATE]
proof (state)
this:
1 = f1 * ((c - 1) / c) * (c * (1 / (f1 * (c - 1))))

goal (1 subgoal):
 1. f1 * (l / c) \<le> f1 * l - 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 = f1 * ((c - 1) / c) * (c * (1 / (f1 * (c - 1))))

goal (1 subgoal):
 1. f1 * (l / c) \<le> f1 * l - 1
[PROOF STEP]
note l0f1c
[PROOF STATE]
proof (state)
this:
1 / (f1 * (c - 1)) \<le> real l0

goal (1 subgoal):
 1. f1 * (l / c) \<le> f1 * l - 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 / (f1 * (c - 1)) \<le> real l0

goal (1 subgoal):
 1. f1 * (l / c) \<le> f1 * l - 1
[PROOF STEP]
have l': "c*l0 \<le> l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c * real l0 \<le> l
[PROOF STEP]
using assms(1)
[PROOF STATE]
proof (prove)
using this:
real l0 \<le> l / c

goal (1 subgoal):
 1. c * real l0 \<le> l
[PROOF STEP]
by(simp add: field_simps)
[PROOF STATE]
proof (state)
this:
c * real l0 \<le> l

goal (1 subgoal):
 1. f1 * (l / c) \<le> f1 * l - 1
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>\<And>x y. x \<le> y \<Longrightarrow> f1 * ((c - 1) / c) * (c * x) \<le> f1 * ((c - 1) / c) * (c * y); \<And>x y. x \<le> y \<Longrightarrow> f1 * ((c - 1) / c) * x \<le> f1 * ((c - 1) / c) * y\<rbrakk> \<Longrightarrow> 1 \<le> f1 * ((c - 1) / c) * l
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>x y. x \<le> y \<Longrightarrow> f1 * ((c - 1) / c) * (c * x) \<le> f1 * ((c - 1) / c) * (c * y); \<And>x y. x \<le> y \<Longrightarrow> f1 * ((c - 1) / c) * x \<le> f1 * ((c - 1) / c) * y\<rbrakk> \<Longrightarrow> 1 \<le> f1 * ((c - 1) / c) * l

goal (1 subgoal):
 1. f1 * (l / c) \<le> f1 * l - 1
[PROOF STEP]
by(simp add: divide_le_cancel) (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
f1 * (l / c) \<le> f1 * l - 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma variation_mult_pos:
  assumes "c>0"
  shows "variation (c*x) y =variation x y" and "variation x (c*y) =variation x y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. variation (c * x) y = variation x y &&& variation x (c * y) = variation x y
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. variation (c * x) y = variation x y
 2. variation x (c * y) = variation x y
[PROOF STEP]
have "sgn (c*x) = sgn x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sgn (c * x) = sgn x
[PROOF STEP]
using \<open>c>0\<close>
[PROOF STATE]
proof (prove)
using this:
0 < c

goal (1 subgoal):
 1. sgn (c * x) = sgn x
[PROOF STEP]
by (simp add: Real_Vector_Spaces.sgn_mult)
[PROOF STATE]
proof (state)
this:
sgn (c * x) = sgn x

goal (2 subgoals):
 1. variation (c * x) y = variation x y
 2. variation x (c * y) = variation x y
[PROOF STEP]
thus "variation (c*x) y =variation x y"
[PROOF STATE]
proof (prove)
using this:
sgn (c * x) = sgn x

goal (1 subgoal):
 1. variation (c * x) y = variation x y
[PROOF STEP]
using variation_congr
[PROOF STATE]
proof (prove)
using this:
sgn (c * x) = sgn x
\<lbrakk>sgn ?x = sgn ?x'; sgn ?y = sgn ?y'\<rbrakk> \<Longrightarrow> variation ?x ?y = variation ?x' ?y'

goal (1 subgoal):
 1. variation (c * x) y = variation x y
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
variation (c * x) y = variation x y

goal (1 subgoal):
 1. variation x (c * y) = variation x y
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. variation x (c * y) = variation x y
[PROOF STEP]
have "sgn (c*y) = sgn y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sgn (c * y) = sgn y
[PROOF STEP]
using \<open>c>0\<close>
[PROOF STATE]
proof (prove)
using this:
0 < c

goal (1 subgoal):
 1. sgn (c * y) = sgn y
[PROOF STEP]
by (simp add: Real_Vector_Spaces.sgn_mult)
[PROOF STATE]
proof (state)
this:
sgn (c * y) = sgn y

goal (1 subgoal):
 1. variation x (c * y) = variation x y
[PROOF STEP]
thus "variation x (c*y) =variation x y"
[PROOF STATE]
proof (prove)
using this:
sgn (c * y) = sgn y

goal (1 subgoal):
 1. variation x (c * y) = variation x y
[PROOF STEP]
using variation_congr
[PROOF STATE]
proof (prove)
using this:
sgn (c * y) = sgn y
\<lbrakk>sgn ?x = sgn ?x'; sgn ?y = sgn ?y'\<rbrakk> \<Longrightarrow> variation ?x ?y = variation ?x' ?y'

goal (1 subgoal):
 1. variation x (c * y) = variation x y
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
variation x (c * y) = variation x y

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma pmf_neg_binomial:
  assumes p: "p \<in> {0<..1}"
  shows   "pmf (neg_binomial_pmf n p) k = real ((k + n - 1) choose k) * p ^ n * (1 - p) ^ k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf (neg_binomial_pmf n p) k = real (k + n - 1 choose k) * p ^ n * (1 - p) ^ k
[PROOF STEP]
proof (induction n arbitrary: k)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>k. pmf (neg_binomial_pmf 0 p) k = real (k + 0 - 1 choose k) * p ^ 0 * (1 - p) ^ k
 2. \<And>n k. (\<And>k. pmf (neg_binomial_pmf n p) k = real (k + n - 1 choose k) * p ^ n * (1 - p) ^ k) \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. \<And>k. pmf (neg_binomial_pmf 0 p) k = real (k + 0 - 1 choose k) * p ^ 0 * (1 - p) ^ k
 2. \<And>n k. (\<And>k. pmf (neg_binomial_pmf n p) k = real (k + n - 1 choose k) * p ^ n * (1 - p) ^ k) \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf (neg_binomial_pmf 0 p) k = real (k + 0 - 1 choose k) * p ^ 0 * (1 - p) ^ k
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
p \<in> {0<..1}

goal (1 subgoal):
 1. pmf (neg_binomial_pmf 0 p) k = real (k + 0 - 1 choose k) * p ^ 0 * (1 - p) ^ k
[PROOF STEP]
by (auto simp: indicator_def)
[PROOF STATE]
proof (state)
this:
pmf (neg_binomial_pmf 0 p) k = real (k + 0 - 1 choose k) * p ^ 0 * (1 - p) ^ k

goal (1 subgoal):
 1. \<And>n k. (\<And>k. pmf (neg_binomial_pmf n p) k = real (k + n - 1 choose k) * p ^ n * (1 - p) ^ k) \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n k. (\<And>k. pmf (neg_binomial_pmf n p) k = real (k + n - 1 choose k) * p ^ n * (1 - p) ^ k) \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
pmf (neg_binomial_pmf n p) ?k = real (?k + n - 1 choose ?k) * p ^ n * (1 - p) ^ ?k

goal (1 subgoal):
 1. \<And>n k. (\<And>k. pmf (neg_binomial_pmf n p) k = real (k + n - 1 choose k) * p ^ n * (1 - p) ^ k) \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
proof (cases "n = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 0 \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
 2. n \<noteq> 0 \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
n = 0

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
 2. n \<noteq> 0 \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
n = 0

goal (1 subgoal):
 1. pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
n = 0
p \<in> {0<..1}

goal (1 subgoal):
 1. pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
n \<noteq> 0

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
let ?f = "pmf (neg_binomial_pmf n p)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
have "pmf (neg_binomial_pmf (Suc n) p) k =
            pmf (geometric_pmf p \<bind> (\<lambda>x. map_pmf ((+) x) (neg_binomial_pmf n p))) k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf (neg_binomial_pmf (Suc n) p) k = pmf (geometric_pmf p \<bind> (\<lambda>x. map_pmf ((+) x) (neg_binomial_pmf n p))) k
[PROOF STEP]
by (auto simp: pair_pmf_def bind_return_pmf map_pmf_def bind_assoc_pmf neg_binomial_pmf_Suc)
[PROOF STATE]
proof (state)
this:
pmf (neg_binomial_pmf (Suc n) p) k = pmf (geometric_pmf p \<bind> (\<lambda>x. map_pmf ((+) x) (neg_binomial_pmf n p))) k

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
pmf (neg_binomial_pmf (Suc n) p) k = pmf (geometric_pmf p \<bind> (\<lambda>x. map_pmf ((+) x) (neg_binomial_pmf n p))) k

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
have "\<dots> = measure_pmf.expectation (geometric_pmf p)
                      (\<lambda>x. measure_pmf.prob (neg_binomial_pmf n p) ((+) x -` {k}))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf (geometric_pmf p \<bind> (\<lambda>x. map_pmf ((+) x) (neg_binomial_pmf n p))) k = measure_pmf.expectation (geometric_pmf p) (\<lambda>x. measure_pmf.prob (neg_binomial_pmf n p) ((+) x -` {k}))
[PROOF STEP]
by (simp add: pmf_bind pmf_map)
[PROOF STATE]
proof (state)
this:
pmf (geometric_pmf p \<bind> (\<lambda>x. map_pmf ((+) x) (neg_binomial_pmf n p))) k = measure_pmf.expectation (geometric_pmf p) (\<lambda>x. measure_pmf.prob (neg_binomial_pmf n p) ((+) x -` {k}))

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
pmf (geometric_pmf p \<bind> (\<lambda>x. map_pmf ((+) x) (neg_binomial_pmf n p))) k = measure_pmf.expectation (geometric_pmf p) (\<lambda>x. measure_pmf.prob (neg_binomial_pmf n p) ((+) x -` {k}))

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
have "(\<lambda>x. (+) x -` {k}) = (\<lambda>x. if x \<le> k then {k - x} else {})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. (+) x -` {k}) = (\<lambda>x. if x \<le> k then {k - x} else {})
[PROOF STEP]
by (auto simp: fun_eq_iff)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. (+) x -` {k}) = (\<lambda>x. if x \<le> k then {k - x} else {})

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<lambda>x. (+) x -` {k}) = (\<lambda>x. if x \<le> k then {k - x} else {})

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
have "(\<lambda>x. measure_pmf.prob (neg_binomial_pmf n p) (\<dots> x)) =
               (\<lambda>x. if x \<le> k then ?f(k - x) else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. measure_pmf.prob (neg_binomial_pmf n p) (if x \<le> k then {k - x} else {})) = (\<lambda>x. if x \<le> k then pmf (neg_binomial_pmf n p) (k - x) else 0)
[PROOF STEP]
by (auto simp: fun_eq_iff measure_pmf_single)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. measure_pmf.prob (neg_binomial_pmf n p) (if x \<le> k then {k - x} else {})) = (\<lambda>x. if x \<le> k then pmf (neg_binomial_pmf n p) (k - x) else 0)

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<lambda>x. measure_pmf.prob (neg_binomial_pmf n p) (if x \<le> k then {k - x} else {})) = (\<lambda>x. if x \<le> k then pmf (neg_binomial_pmf n p) (k - x) else 0)

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
have "measure_pmf.expectation (geometric_pmf p) \<dots> =
                 (\<Sum>i\<le>k. pmf (neg_binomial_pmf n p) (k - i) * pmf (geometric_pmf p) i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. measure_pmf.expectation (geometric_pmf p) (\<lambda>x. if x \<le> k then pmf (neg_binomial_pmf n p) (k - x) else 0) = (\<Sum>i\<le>k. pmf (neg_binomial_pmf n p) (k - i) * pmf (geometric_pmf p) i)
[PROOF STEP]
by (subst integral_measure_pmf_real[where A = "{..k}"]) (auto split: if_splits)
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (geometric_pmf p) (\<lambda>x. if x \<le> k then pmf (neg_binomial_pmf n p) (k - x) else 0) = (\<Sum>i\<le>k. pmf (neg_binomial_pmf n p) (k - i) * pmf (geometric_pmf p) i)

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
measure_pmf.expectation (geometric_pmf p) (\<lambda>x. if x \<le> k then pmf (neg_binomial_pmf n p) (k - x) else 0) = (\<Sum>i\<le>k. pmf (neg_binomial_pmf n p) (k - i) * pmf (geometric_pmf p) i)

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
have "\<dots> = p^(n+1) * (1-p)^k * real (\<Sum>i\<le>k. (k - i + n - 1) choose (k - i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<le>k. pmf (neg_binomial_pmf n p) (k - i) * pmf (geometric_pmf p) i) = p ^ (n + 1) * (1 - p) ^ k * real (\<Sum>i\<le>k. k - i + n - 1 choose (k - i))
[PROOF STEP]
unfolding sum_distrib_left of_nat_sum
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<le>k. pmf (neg_binomial_pmf n p) (k - i) * pmf (geometric_pmf p) i) = (\<Sum>n\<le>k. p ^ (n + 1) * (1 - p) ^ k * real (k - n + n - 1 choose (k - n)))
[PROOF STEP]
proof (intro sum.cong refl, goal_cases)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {..k} \<Longrightarrow> pmf (neg_binomial_pmf n p) (k - x) * pmf (geometric_pmf p) x = p ^ (n + 1) * (1 - p) ^ k * real (k - x + n - 1 choose (k - x))
[PROOF STEP]
case (1 i)
[PROOF STATE]
proof (state)
this:
i \<in> {..k}

goal (1 subgoal):
 1. \<And>x. x \<in> {..k} \<Longrightarrow> pmf (neg_binomial_pmf n p) (k - x) * pmf (geometric_pmf p) x = p ^ (n + 1) * (1 - p) ^ k * real (k - x + n - 1 choose (k - x))
[PROOF STEP]
have "pmf (neg_binomial_pmf n p) (k - i) * pmf (geometric_pmf p) i =
              real ((k - i + n - 1) choose (k - i)) * p^(n+1) * ((1-p)^(k-i) * (1-p)^i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf (neg_binomial_pmf n p) (k - i) * pmf (geometric_pmf p) i = real (k - i + n - 1 choose (k - i)) * p ^ (n + 1) * ((1 - p) ^ (k - i) * (1 - p) ^ i)
[PROOF STEP]
using assms Suc.IH
[PROOF STATE]
proof (prove)
using this:
p \<in> {0<..1}
pmf (neg_binomial_pmf n p) ?k = real (?k + n - 1 choose ?k) * p ^ n * (1 - p) ^ ?k

goal (1 subgoal):
 1. pmf (neg_binomial_pmf n p) (k - i) * pmf (geometric_pmf p) i = real (k - i + n - 1 choose (k - i)) * p ^ (n + 1) * ((1 - p) ^ (k - i) * (1 - p) ^ i)
[PROOF STEP]
by (simp add: mult_ac)
[PROOF STATE]
proof (state)
this:
pmf (neg_binomial_pmf n p) (k - i) * pmf (geometric_pmf p) i = real (k - i + n - 1 choose (k - i)) * p ^ (n + 1) * ((1 - p) ^ (k - i) * (1 - p) ^ i)

goal (1 subgoal):
 1. \<And>x. x \<in> {..k} \<Longrightarrow> pmf (neg_binomial_pmf n p) (k - x) * pmf (geometric_pmf p) x = p ^ (n + 1) * (1 - p) ^ k * real (k - x + n - 1 choose (k - x))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
pmf (neg_binomial_pmf n p) (k - i) * pmf (geometric_pmf p) i = real (k - i + n - 1 choose (k - i)) * p ^ (n + 1) * ((1 - p) ^ (k - i) * (1 - p) ^ i)

goal (1 subgoal):
 1. \<And>x. x \<in> {..k} \<Longrightarrow> pmf (neg_binomial_pmf n p) (k - x) * pmf (geometric_pmf p) x = p ^ (n + 1) * (1 - p) ^ k * real (k - x + n - 1 choose (k - x))
[PROOF STEP]
have "(1-p)^(k-i) * (1-p)^i = (1-p)^k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (1 - p) ^ (k - i) * (1 - p) ^ i = (1 - p) ^ k
[PROOF STEP]
using 1
[PROOF STATE]
proof (prove)
using this:
i \<in> {..k}

goal (1 subgoal):
 1. (1 - p) ^ (k - i) * (1 - p) ^ i = (1 - p) ^ k
[PROOF STEP]
by (subst power_add [symmetric]) auto
[PROOF STATE]
proof (state)
this:
(1 - p) ^ (k - i) * (1 - p) ^ i = (1 - p) ^ k

goal (1 subgoal):
 1. \<And>x. x \<in> {..k} \<Longrightarrow> pmf (neg_binomial_pmf n p) (k - x) * pmf (geometric_pmf p) x = p ^ (n + 1) * (1 - p) ^ k * real (k - x + n - 1 choose (k - x))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
pmf (neg_binomial_pmf n p) (k - i) * pmf (geometric_pmf p) i = real (k - i + n - 1 choose (k - i)) * p ^ (n + 1) * (1 - p) ^ k
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
pmf (neg_binomial_pmf n p) (k - i) * pmf (geometric_pmf p) i = real (k - i + n - 1 choose (k - i)) * p ^ (n + 1) * (1 - p) ^ k

goal (1 subgoal):
 1. pmf (neg_binomial_pmf n p) (k - i) * pmf (geometric_pmf p) i = p ^ (n + 1) * (1 - p) ^ k * real (k - i + n - 1 choose (k - i))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
pmf (neg_binomial_pmf n p) (k - i) * pmf (geometric_pmf p) i = p ^ (n + 1) * (1 - p) ^ k * real (k - i + n - 1 choose (k - i))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>k. pmf (neg_binomial_pmf n p) (k - i) * pmf (geometric_pmf p) i) = p ^ (n + 1) * (1 - p) ^ k * real (\<Sum>i\<le>k. k - i + n - 1 choose (k - i))

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>k. pmf (neg_binomial_pmf n p) (k - i) * pmf (geometric_pmf p) i) = p ^ (n + 1) * (1 - p) ^ k * real (\<Sum>i\<le>k. k - i + n - 1 choose (k - i))

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
have "(\<Sum>i\<le>k. (k - i + n - 1) choose (k - i)) = (\<Sum>i\<le>k. (n - 1 + i) choose i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<le>k. k - i + n - 1 choose (k - i)) = (\<Sum>i\<le>k. n - 1 + i choose i)
[PROOF STEP]
by (intro sum.reindex_bij_witness[of _ "\<lambda>i. k - i" "\<lambda>i. k - i"])
         (use \<open>n \<noteq> 0\<close> in \<open>auto simp: algebra_simps\<close>)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>k. k - i + n - 1 choose (k - i)) = (\<Sum>i\<le>k. n - 1 + i choose i)

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>k. k - i + n - 1 choose (k - i)) = (\<Sum>i\<le>k. n - 1 + i choose i)

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
have "\<dots> = (n + k) choose k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<le>k. n - 1 + i choose i) = n + k choose k
[PROOF STEP]
by (subst sum_choose_lower) (use \<open>n \<noteq> 0\<close> in auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>k. n - 1 + i choose i) = n + k choose k

goal (1 subgoal):
 1. n \<noteq> 0 \<Longrightarrow> pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
pmf (neg_binomial_pmf (Suc n) p) k = p ^ (n + 1) * (1 - p) ^ k * real (n + k choose k)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
pmf (neg_binomial_pmf (Suc n) p) k = p ^ (n + 1) * (1 - p) ^ k * real (n + k choose k)

goal (1 subgoal):
 1. pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k
[PROOF STEP]
by (simp add: add_ac)
[PROOF STATE]
proof (state)
this:
pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
pmf (neg_binomial_pmf (Suc n) p) k = real (k + Suc n - 1 choose k) * p ^ Suc n * (1 - p) ^ k

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma max_mid_sums_cons: "Max (mid_sums (x#xs)) = max (Max (front_sums (x#xs))) (Max (mid_sums xs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Max (mid_sums (x # xs)) = max (Max (front_sums (x # xs))) (Max (mid_sums xs))
[PROOF STEP]
by (auto simp: mid_sums_cons Max_Un finite_front_sums finite_mid_sums front_sums_not_empty mid_sums_not_empty)


[STATEMENT]
lemma list_mean_eq_iff:
  fixes one::"real list" and two::"real list"
  assumes
    se: "( \<Sum>:one = \<Sum>:two )" and
    le: "(length one = length two)"
  shows "(mean one = mean two)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mean one = mean two
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. mean one = mean two
[PROOF STEP]
from se le
[PROOF STATE]
proof (chain)
picking this:
sum_list one = sum_list two
length one = length two
[PROOF STEP]
have
    "(\<Sum>:one / real (length one)) = (\<Sum>:two / real (length two))"
[PROOF STATE]
proof (prove)
using this:
sum_list one = sum_list two
length one = length two

goal (1 subgoal):
 1. sum_list one / real (length one) = sum_list two / real (length two)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
sum_list one / real (length one) = sum_list two / real (length two)

goal (1 subgoal):
 1. mean one = mean two
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
sum_list one / real (length one) = sum_list two / real (length two)

goal (1 subgoal):
 1. mean one = mean two
[PROOF STEP]
unfolding mean_def
[PROOF STATE]
proof (prove)
using this:
sum_list one / real (length one) = sum_list two / real (length two)

goal (1 subgoal):
 1. sum_list one / real (length one) = sum_list two / real (length two)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
mean one = mean two

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ap_map_prod_eq_Some_conv:
  "ap_map_prod f g p = Some p' \<longleftrightarrow> (\<exists>x y. p = (x, y) \<and> (\<exists>x' y'. p' = (x', y') \<and> f x = Some x' \<and> g y = Some y'))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (ap_map_prod f g p = Some p') = (\<exists>x y. p = (x, y) \<and> (\<exists>x' y'. p' = (x', y') \<and> f x = Some x' \<and> g y = Some y'))
[PROOF STEP]
proof (cases p)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a b. p = (a, b) \<Longrightarrow> (ap_map_prod f g p = Some p') = (\<exists>x y. p = (x, y) \<and> (\<exists>x' y'. p' = (x', y') \<and> f x = Some x' \<and> g y = Some y'))
[PROOF STEP]
case (Pair x y)
[PROOF STATE]
proof (state)
this:
p = (x, y)

goal (1 subgoal):
 1. \<And>a b. p = (a, b) \<Longrightarrow> (ap_map_prod f g p = Some p') = (\<exists>x y. p = (x, y) \<and> (\<exists>x' y'. p' = (x', y') \<and> f x = Some x' \<and> g y = Some y'))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
p = (x, y)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
p = (x, y)

goal (1 subgoal):
 1. (ap_map_prod f g p = Some p') = (\<exists>x y. p = (x, y) \<and> (\<exists>x' y'. p' = (x', y') \<and> f x = Some x' \<and> g y = Some y'))
[PROOF STEP]
unfolding ap_map_prod_def
[PROOF STATE]
proof (prove)
using this:
p = (x, y)

goal (1 subgoal):
 1. (Some Pair \<diamondop> f (fst p) \<diamondop> g (snd p) = Some p') = (\<exists>x y. p = (x, y) \<and> (\<exists>x' y'. p' = (x', y') \<and> f x = Some x' \<and> g y = Some y'))
[PROOF STEP]
by (auto simp add: ap_map_prod_def ap_option_eq_Some_conv)
[PROOF STATE]
proof (state)
this:
(ap_map_prod f g p = Some p') = (\<exists>x y. p = (x, y) \<and> (\<exists>x' y'. p' = (x', y') \<and> f x = Some x' \<and> g y = Some y'))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma expectation_finite_uniform_indicator:
  assumes "M = uniform_count_measure S" and "finite S"
  shows "expectation (\<lambda> x. indicator (T x) y) = prob {x \<in> S . indicator (T x) y = 1}" (is "expectation ?X = _")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. expectation (\<lambda>x. rind (T x) y) = prob {x \<in> S. indicator (T x) y = (1::'c)}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. expectation (\<lambda>x. rind (T x) y) = prob {x \<in> S. indicator (T x) y = (1::'c)}
[PROOF STEP]
have ss: "?X ` S \<subseteq> {0, 1}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. rind (T x) y) ` S \<subseteq> {0, 1}
[PROOF STEP]
by (intro subsetI, auto simp add: indicator_eq_1_iff)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. rind (T x) y) ` S \<subseteq> {0, 1}

goal (1 subgoal):
 1. expectation (\<lambda>x. rind (T x) y) = prob {x \<in> S. indicator (T x) y = (1::'c)}
[PROOF STEP]
have diff: "\<And> y'. y' \<in> ({0, 1} - ?X ` S) \<Longrightarrow> prob {x \<in> S . ?X x = y'} = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>y'. y' \<in> {0, 1} - (\<lambda>x. rind (T x) y) ` S \<Longrightarrow> prob {x \<in> S. rind (T x) y = y'} = 0
[PROOF STEP]
by (metis (mono_tags, lifting) DiffD2 empty_Collect_eq image_eqI measure_empty)
[PROOF STATE]
proof (state)
this:
?y'12 \<in> {0, 1} - (\<lambda>x. rind (T x) y) ` S \<Longrightarrow> prob {x \<in> S. rind (T x) y = ?y'12} = 0

goal (1 subgoal):
 1. expectation (\<lambda>x. rind (T x) y) = prob {x \<in> S. indicator (T x) y = (1::'c)}
[PROOF STEP]
have "expectation ?X = (\<Sum> y \<in> ?X ` S . prob {x \<in> S . ?X x = y} * y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. expectation (\<lambda>x. rind (T x) y) = (\<Sum>ya\<in>(\<lambda>x. rind (T x) y) ` S. prob {x \<in> S. rind (T x) y = ya} * ya)
[PROOF STEP]
using expectation_finite_uniform_space assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>M = uniform_count_measure ?S; finite ?S\<rbrakk> \<Longrightarrow> expectation ?X = (\<Sum>y\<in>?X ` ?S. prob {x \<in> ?S. ?X x = y} * y)
M = uniform_count_measure S
finite S

goal (1 subgoal):
 1. expectation (\<lambda>x. rind (T x) y) = (\<Sum>ya\<in>(\<lambda>x. rind (T x) y) ` S. prob {x \<in> S. rind (T x) y = ya} * ya)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
expectation (\<lambda>x. rind (T x) y) = (\<Sum>ya\<in>(\<lambda>x. rind (T x) y) ` S. prob {x \<in> S. rind (T x) y = ya} * ya)

goal (1 subgoal):
 1. expectation (\<lambda>x. rind (T x) y) = prob {x \<in> S. indicator (T x) y = (1::'c)}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
expectation (\<lambda>x. rind (T x) y) = (\<Sum>ya\<in>(\<lambda>x. rind (T x) y) ` S. prob {x \<in> S. rind (T x) y = ya} * ya)

goal (1 subgoal):
 1. expectation (\<lambda>x. rind (T x) y) = prob {x \<in> S. indicator (T x) y = (1::'c)}
[PROOF STEP]
have "... = (\<Sum> y \<in> ?X ` S . prob {x \<in> S . ?X x = y} * y) +
    (\<Sum> y \<in> ({0, 1} - ?X ` S) . prob {x \<in> S . ?X x = y} * y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ya\<in>(\<lambda>x. rind (T x) y) ` S. prob {x \<in> S. rind (T x) y = ya} * ya) = (\<Sum>ya\<in>(\<lambda>x. rind (T x) y) ` S. prob {x \<in> S. rind (T x) y = ya} * ya) + (\<Sum>ya\<in>{0, 1} - (\<lambda>x. rind (T x) y) ` S. prob {x \<in> S. rind (T x) y = ya} * ya)
[PROOF STEP]
using diff
[PROOF STATE]
proof (prove)
using this:
?y'12 \<in> {0, 1} - (\<lambda>x. rind (T x) y) ` S \<Longrightarrow> prob {x \<in> S. rind (T x) y = ?y'12} = 0

goal (1 subgoal):
 1. (\<Sum>ya\<in>(\<lambda>x. rind (T x) y) ` S. prob {x \<in> S. rind (T x) y = ya} * ya) = (\<Sum>ya\<in>(\<lambda>x. rind (T x) y) ` S. prob {x \<in> S. rind (T x) y = ya} * ya) + (\<Sum>ya\<in>{0, 1} - (\<lambda>x. rind (T x) y) ` S. prob {x \<in> S. rind (T x) y = ya} * ya)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>ya\<in>(\<lambda>x. rind (T x) y) ` S. prob {x \<in> S. rind (T x) y = ya} * ya) = (\<Sum>ya\<in>(\<lambda>x. rind (T x) y) ` S. prob {x \<in> S. rind (T x) y = ya} * ya) + (\<Sum>ya\<in>{0, 1} - (\<lambda>x. rind (T x) y) ` S. prob {x \<in> S. rind (T x) y = ya} * ya)

goal (1 subgoal):
 1. expectation (\<lambda>x. rind (T x) y) = prob {x \<in> S. indicator (T x) y = (1::'c)}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ya\<in>(\<lambda>x. rind (T x) y) ` S. prob {x \<in> S. rind (T x) y = ya} * ya) = (\<Sum>ya\<in>(\<lambda>x. rind (T x) y) ` S. prob {x \<in> S. rind (T x) y = ya} * ya) + (\<Sum>ya\<in>{0, 1} - (\<lambda>x. rind (T x) y) ` S. prob {x \<in> S. rind (T x) y = ya} * ya)

goal (1 subgoal):
 1. expectation (\<lambda>x. rind (T x) y) = prob {x \<in> S. indicator (T x) y = (1::'c)}
[PROOF STEP]
have "... = (\<Sum> y \<in> {0, 1} . prob {x \<in> S . ?X x = y} * y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ya\<in>(\<lambda>x. rind (T x) y) ` S. prob {x \<in> S. rind (T x) y = ya} * ya) + (\<Sum>ya\<in>{0, 1} - (\<lambda>x. rind (T x) y) ` S. prob {x \<in> S. rind (T x) y = ya} * ya) = (\<Sum>ya\<in>{0, 1}. prob {x \<in> S. rind (T x) y = ya} * ya)
[PROOF STEP]
using sum.subset_diff[of "?X ` S" "{0, 1}" "\<lambda> y. prob {x \<in> S . ?X x = y} * y"] ss
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>(\<lambda>x. rind (T x) y) ` S \<subseteq> {0, 1}; finite {0, 1}\<rbrakk> \<Longrightarrow> (\<Sum>ya\<in>{0, 1}. prob {x \<in> S. rind (T x) y = ya} * ya) = (\<Sum>ya\<in>{0, 1} - (\<lambda>x. rind (T x) y) ` S. prob {x \<in> S. rind (T x) y = ya} * ya) + (\<Sum>ya\<in>(\<lambda>x. rind (T x) y) ` S. prob {x \<in> S. rind (T x) y = ya} * ya)
(\<lambda>x. rind (T x) y) ` S \<subseteq> {0, 1}

goal (1 subgoal):
 1. (\<Sum>ya\<in>(\<lambda>x. rind (T x) y) ` S. prob {x \<in> S. rind (T x) y = ya} * ya) + (\<Sum>ya\<in>{0, 1} - (\<lambda>x. rind (T x) y) ` S. prob {x \<in> S. rind (T x) y = ya} * ya) = (\<Sum>ya\<in>{0, 1}. prob {x \<in> S. rind (T x) y = ya} * ya)
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
(\<Sum>ya\<in>(\<lambda>x. rind (T x) y) ` S. prob {x \<in> S. rind (T x) y = ya} * ya) + (\<Sum>ya\<in>{0, 1} - (\<lambda>x. rind (T x) y) ` S. prob {x \<in> S. rind (T x) y = ya} * ya) = (\<Sum>ya\<in>{0, 1}. prob {x \<in> S. rind (T x) y = ya} * ya)

goal (1 subgoal):
 1. expectation (\<lambda>x. rind (T x) y) = prob {x \<in> S. indicator (T x) y = (1::'c)}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>ya\<in>(\<lambda>x. rind (T x) y) ` S. prob {x \<in> S. rind (T x) y = ya} * ya) + (\<Sum>ya\<in>{0, 1} - (\<lambda>x. rind (T x) y) ` S. prob {x \<in> S. rind (T x) y = ya} * ya) = (\<Sum>ya\<in>{0, 1}. prob {x \<in> S. rind (T x) y = ya} * ya)

goal (1 subgoal):
 1. expectation (\<lambda>x. rind (T x) y) = prob {x \<in> S. indicator (T x) y = (1::'c)}
[PROOF STEP]
have "... = prob {x \<in> S . ?X x = 0} * 0 + prob {x \<in> S. ?X x = 1} * 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>ya\<in>{0, 1}. prob {x \<in> S. rind (T x) y = ya} * ya) = prob {x \<in> S. rind (T x) y = 0} * 0 + prob {x \<in> S. rind (T x) y = 1} * 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>ya\<in>{0, 1}. prob {x \<in> S. rind (T x) y = ya} * ya) = prob {x \<in> S. rind (T x) y = 0} * 0 + prob {x \<in> S. rind (T x) y = 1} * 1

goal (1 subgoal):
 1. expectation (\<lambda>x. rind (T x) y) = prob {x \<in> S. indicator (T x) y = (1::'c)}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
expectation (\<lambda>x. rind (T x) y) = prob {x \<in> S. rind (T x) y = 0} * 0 + prob {x \<in> S. rind (T x) y = 1} * 1
[PROOF STEP]
have "expectation ?X = prob {x \<in> S. ?X x = 1}*1"
[PROOF STATE]
proof (prove)
using this:
expectation (\<lambda>x. rind (T x) y) = prob {x \<in> S. rind (T x) y = 0} * 0 + prob {x \<in> S. rind (T x) y = 1} * 1

goal (1 subgoal):
 1. expectation (\<lambda>x. rind (T x) y) = prob {x \<in> S. rind (T x) y = 1} * 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
expectation (\<lambda>x. rind (T x) y) = prob {x \<in> S. rind (T x) y = 1} * 1

goal (1 subgoal):
 1. expectation (\<lambda>x. rind (T x) y) = prob {x \<in> S. indicator (T x) y = (1::'c)}
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
expectation (\<lambda>x. rind (T x) y) = prob {x \<in> S. rind (T x) y = 1} * 1

goal (1 subgoal):
 1. expectation (\<lambda>x. rind (T x) y) = prob {x \<in> S. indicator (T x) y = (1::'c)}
[PROOF STEP]
by (smt (verit) Collect_cong indicator_eq_1_iff)
[PROOF STATE]
proof (state)
this:
expectation (\<lambda>x. rind (T x) y) = prob {x \<in> S. indicator (T x) y = (1::'c)}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma iT_Div_mod_iprev_nth: "
  \<lbrakk> finite I; I \<noteq> {}; \<forall>x\<in>I. \<forall>y\<in>I. x mod k = y mod k \<rbrakk> \<Longrightarrow>
  (I \<oslash> k) \<leftarrow> n = (I \<leftarrow> n) div k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite I; I \<noteq> {}; \<forall>x\<in>I. \<forall>y\<in>I. x mod k = y mod k\<rbrakk> \<Longrightarrow> (I \<oslash> k) \<leftarrow> n = (I \<leftarrow> n) div k
[PROOF STEP]
apply (case_tac "k = 0")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>finite I; I \<noteq> {}; \<forall>x\<in>I. \<forall>y\<in>I. x mod k = y mod k; k = 0\<rbrakk> \<Longrightarrow> (I \<oslash> k) \<leftarrow> n = (I \<leftarrow> n) div k
 2. \<lbrakk>finite I; I \<noteq> {}; \<forall>x\<in>I. \<forall>y\<in>I. x mod k = y mod k; k \<noteq> 0\<rbrakk> \<Longrightarrow> (I \<oslash> k) \<leftarrow> n = (I \<leftarrow> n) div k
[PROOF STEP]
apply (simp add: iT_Div_0 iTILL_0 iprev_nth_singleton)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite I; I \<noteq> {}; \<forall>x\<in>I. \<forall>y\<in>I. x mod k = y mod k; k \<noteq> 0\<rbrakk> \<Longrightarrow> (I \<oslash> k) \<leftarrow> n = (I \<leftarrow> n) div k
[PROOF STEP]
apply (simp add: iT_Div_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite I; I \<noteq> {}; \<forall>x\<in>I. \<forall>y\<in>I. x mod k = y mod k; 0 < k\<rbrakk> \<Longrightarrow> ((\<lambda>n. n div k) ` I) \<leftarrow> n = (I \<leftarrow> n) div k
[PROOF STEP]
by (rule iprev_nth_image[OF _ _ mod_eq_div_right_strict_mono_on])


[STATEMENT]
lemma bigo_plus_self_subset [intro]:
  "O(f) + O(f) <= O(f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. O(f) + O(f) \<subseteq> O(f)
[PROOF STEP]
apply (auto simp add: bigo_alt_def set_plus_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a c b ca. \<lbrakk>(0::'b) < c; \<forall>x. \<bar>a x\<bar> \<le> c * \<bar>f x\<bar>; (0::'b) < ca; \<forall>x. \<bar>b x\<bar> \<le> ca * \<bar>f x\<bar>\<rbrakk> \<Longrightarrow> \<exists>c>0::'b. \<forall>x. \<bar>a x + b x\<bar> \<le> c * \<bar>f x\<bar>
[PROOF STEP]
apply (rule_tac x = "c + ca" in exI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a c b ca. \<lbrakk>(0::'b) < c; \<forall>x. \<bar>a x\<bar> \<le> c * \<bar>f x\<bar>; (0::'b) < ca; \<forall>x. \<bar>b x\<bar> \<le> ca * \<bar>f x\<bar>\<rbrakk> \<Longrightarrow> (0::'b) < c + ca \<and> (\<forall>x. \<bar>a x + b x\<bar> \<le> (c + ca) * \<bar>f x\<bar>)
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a c b ca x. \<lbrakk>(0::'b) < c; \<forall>x. \<bar>a x\<bar> \<le> c * \<bar>f x\<bar>; (0::'b) < ca; \<forall>x. \<bar>b x\<bar> \<le> ca * \<bar>f x\<bar>\<rbrakk> \<Longrightarrow> \<bar>a x + b x\<bar> \<le> (c + ca) * \<bar>f x\<bar>
[PROOF STEP]
apply (simp add: ring_distribs func_plus)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a c b ca x. \<lbrakk>(0::'b) < c; \<forall>x. \<bar>a x\<bar> \<le> c * \<bar>f x\<bar>; (0::'b) < ca; \<forall>x. \<bar>b x\<bar> \<le> ca * \<bar>f x\<bar>\<rbrakk> \<Longrightarrow> \<bar>a x + b x\<bar> \<le> c * \<bar>f x\<bar> + ca * \<bar>f x\<bar>
[PROOF STEP]
by (metis order_trans abs_triangle_ineq add_mono)


[STATEMENT]
lemma idx_pm_of_pm_minus: "idx_pm_of_pm xs (f - g) = idx_pm_of_pm xs f - idx_pm_of_pm xs g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. idx_pm_of_pm xs (f - g) = idx_pm_of_pm xs f - idx_pm_of_pm xs g
[PROOF STEP]
by (rule poly_mapping_eqI, simp add: lookup_idx_pm_of_pm lookup_minus when_def)


[STATEMENT]
lemma comp_surj_on: "
  \<lbrakk> surj_on f A B; surj_on g B C \<rbrakk> \<Longrightarrow> surj_on (g \<circ> f) A C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>surj_on f A B; surj_on g B C\<rbrakk> \<Longrightarrow> surj_on (g \<circ> f) A C
[PROOF STEP]
unfolding comp_def surj_on_image_conv
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>B \<subseteq> f ` A; C \<subseteq> g ` B\<rbrakk> \<Longrightarrow> C \<subseteq> (\<lambda>x. g (f x)) ` A
[PROOF STEP]
by blast


[STATEMENT]
lemma eventually_within_Un:
  "eventually P (at x within (s \<union> t)) \<longleftrightarrow>
    eventually P (at x within s) \<and> eventually P (at x within t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eventually P (at x within s \<union> t) = (eventually P (at x within s) \<and> eventually P (at x within t))
[PROOF STEP]
unfolding eventually_at_filter
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>\<^sub>F xa in nhds x. xa \<noteq> x \<longrightarrow> xa \<in> s \<union> t \<longrightarrow> P xa) = ((\<forall>\<^sub>F xa in nhds x. xa \<noteq> x \<longrightarrow> xa \<in> s \<longrightarrow> P xa) \<and> (\<forall>\<^sub>F xa in nhds x. xa \<noteq> x \<longrightarrow> xa \<in> t \<longrightarrow> P xa))
[PROOF STEP]
by (auto elim!: eventually_rev_mp)


[STATEMENT]
lemma index_Basis_list_axis1: "index Basis_list (axis i (1::real)) = index enum_class.enum i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. index Basis_list (axis i 1) = index enum_class.enum i
[PROOF STEP]
apply (auto simp: Basis_list_vec_def Basis_list_real_def )
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. index (map (\<lambda>n. axis n 1) enum_class.enum) (axis i 1) = index enum_class.enum i
[PROOF STEP]
apply (subst index_map_inj)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. inj (\<lambda>n. axis n 1)
 2. index enum_class.enum i = index enum_class.enum i
[PROOF STEP]
by (auto intro!: injI simp: axis_eq_axis)


[STATEMENT]
lemma sum_of_naturals: "2 * (\<Sum>i=0..n. i) = n * Suc n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * \<Sum> {0..n} = n * Suc n
[PROOF STEP]
by (induct n) auto


[STATEMENT]
lemma arcsin: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> - (pi/2) \<le> arcsin y \<and> arcsin y \<le> pi/2 \<and> sin (arcsin y) = y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>- 1 \<le> y; y \<le> 1\<rbrakk> \<Longrightarrow> - (pi / 2) \<le> arcsin y \<and> arcsin y \<le> pi / 2 \<and> sin (arcsin y) = y
[PROOF STEP]
unfolding arcsin_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>- 1 \<le> y; y \<le> 1\<rbrakk> \<Longrightarrow> - (pi / 2) \<le> (THE x. - (pi / 2) \<le> x \<and> x \<le> pi / 2 \<and> sin x = y) \<and> (THE x. - (pi / 2) \<le> x \<and> x \<le> pi / 2 \<and> sin x = y) \<le> pi / 2 \<and> sin (THE x. - (pi / 2) \<le> x \<and> x \<le> pi / 2 \<and> sin x = y) = y
[PROOF STEP]
by (rule theI' [OF sin_total])


[STATEMENT]
lemma divide_poly_main_field:
  fixes d :: "'a::field poly"
  assumes d: "d \<noteq> 0"
  defines lc: "lc \<equiv> coeff d (degree d)"
  shows "divide_poly_main lc q r d dr n =
    fst (pseudo_divmod_main lc (smult ((1 / lc)^n) q) (smult ((1 / lc)^n) r) d dr n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. divide_poly_main lc q r d dr n = fst (pseudo_divmod_main lc (smult (((1::'a) / lc) ^ n) q) (smult (((1::'a) / lc) ^ n) r) d dr n)
[PROOF STEP]
unfolding lc
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. divide_poly_main (lead_coeff d) q r d dr n = fst (pseudo_divmod_main (lead_coeff d) (smult (((1::'a) / lead_coeff d) ^ n) q) (smult (((1::'a) / lead_coeff d) ^ n) r) d dr n)
[PROOF STEP]
by (subst fst_pseudo_divmod_main_as_divide_poly_main) (auto simp: d power_one_over)


[STATEMENT]
lemma set_integral_norm_bound:
  fixes f :: "_ \<Rightarrow> 'a :: {banach, second_countable_topology}"
  shows "set_integrable M k f \<Longrightarrow> norm (LINT x:k|M. f x) \<le> LINT x:k|M. norm (f x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set_integrable M k f \<Longrightarrow> norm (set_lebesgue_integral M k f) \<le> \<integral>x\<in>k. norm (f x)\<partial>M
[PROOF STEP]
using integral_norm_bound[of M "\<lambda>x. indicator k x *\<^sub>R f x"]
[PROOF STATE]
proof (prove)
using this:
norm (LINT x|M. indicat_real k x *\<^sub>R f x) \<le> LINT x|M. norm (indicat_real k x *\<^sub>R f x)

goal (1 subgoal):
 1. set_integrable M k f \<Longrightarrow> norm (set_lebesgue_integral M k f) \<le> \<integral>x\<in>k. norm (f x)\<partial>M
[PROOF STEP]
by (simp add: set_lebesgue_integral_def)


[STATEMENT]
lemma cross7_components:
  "(x \<times>\<^sub>7 y)$1 = x$2 * y$4 - x$4 * y$2 + x$3 * y$7 -  x$7 * y$3 +  x$5 * y$6 -  x$6 * y$5  "
  "(x \<times>\<^sub>7 y)$2 = x$4 * y$1 - x$1 * y$4 + x$3 * y$5 -  x$5 * y$3 +  x$6 * y$7 -  x$7 * y$6  "
  "(x \<times>\<^sub>7 y)$3 = x$5 * y$2 - x$2 * y$5 + x$4 * y$6 -  x$6 * y$4 +  x$7 * y$1 -  x$1 * y$7  "
  "(x \<times>\<^sub>7 y)$4 = x$1 * y$2 - x$2 * y$1 + x$6 * y$3 -  x$3 * y$6 +  x$5 * y$7 -  x$7 * y$5  "
  "(x \<times>\<^sub>7 y)$5 = x$6 * y$1 - x$1 * y$6 + x$2 * y$3 -  x$3 * y$2 +  x$7 * y$4 -  x$4 * y$7  "
  "(x \<times>\<^sub>7 y)$6 = x$1 * y$5 - x$5 * y$1 + x$7 * y$2 -  x$2 * y$7 +  x$3 * y$4 -  x$4 * y$3  "
  "(x \<times>\<^sub>7 y)$7 = x$1 * y$3 - x$3 * y$1 + x$4 * y$5 -  x$5 * y$4 +  x$2 * y$6 -  x$6 * y$2  "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((x \<times>\<^sub>7 y) $ 1 = x $ 2 * y $ 4 - x $ 4 * y $ 2 + x $ 3 * y $ 7 - x $ 7 * y $ 3 + x $ 5 * y $ 6 - x $ 6 * y $ 5 &&& (x \<times>\<^sub>7 y) $ 2 = x $ 4 * y $ 1 - x $ 1 * y $ 4 + x $ 3 * y $ 5 - x $ 5 * y $ 3 + x $ 6 * y $ 7 - x $ 7 * y $ 6 &&& (x \<times>\<^sub>7 y) $ 3 = x $ 5 * y $ 2 - x $ 2 * y $ 5 + x $ 4 * y $ 6 - x $ 6 * y $ 4 + x $ 7 * y $ 1 - x $ 1 * y $ 7) &&& ((x \<times>\<^sub>7 y) $ 4 = x $ 1 * y $ 2 - x $ 2 * y $ 1 + x $ 6 * y $ 3 - x $ 3 * y $ 6 + x $ 5 * y $ 7 - x $ 7 * y $ 5 &&& (x \<times>\<^sub>7 y) $ 5 = x $ 6 * y $ 1 - x $ 1 * y $ 6 + x $ 2 * y $ 3 - x $ 3 * y $ 2 + x $ 7 * y $ 4 - x $ 4 * y $ 7) &&& (x \<times>\<^sub>7 y) $ 6 = x $ 1 * y $ 5 - x $ 5 * y $ 1 + x $ 7 * y $ 2 - x $ 2 * y $ 7 + x $ 3 * y $ 4 - x $ 4 * y $ 3 &&& (x \<times>\<^sub>7 y) $ 7 = x $ 1 * y $ 3 - x $ 3 * y $ 1 + x $ 4 * y $ 5 - x $ 5 * y $ 4 + x $ 2 * y $ 6 - x $ 6 * y $ 2
[PROOF STEP]
by (simp_all add: cross7_def inner_vec_def sum_7 vec_eq_iff algebra_simps)


[STATEMENT]
lemma evimage_inter_cong: "(\<And> w. w \<in> S \<Longrightarrow> f w = g w) \<Longrightarrow> f \<inverse>\<^bsub>n\<^esub> y \<inter> S = g \<inverse>\<^bsub>n\<^esub> y \<inter> S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>w. w \<in> S \<Longrightarrow> f w = g w) \<Longrightarrow> f \<inverse>\<^bsub>n\<^esub> y \<inter> S = g \<inverse>\<^bsub>n\<^esub> y \<inter> S
[PROOF STEP]
unfolding evimage_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>w. w \<in> S \<Longrightarrow> f w = g w) \<Longrightarrow> f -` y \<inter> carrier (R\<^bsup>n\<^esup>) \<inter> S = g -` y \<inter> carrier (R\<^bsup>n\<^esup>) \<inter> S
[PROOF STEP]
by (smt Int_assoc Int_commute vimage_inter_cong)


[STATEMENT]
lemma sum_mono2:
  assumes fin: "finite B"
    and sub: "A \<subseteq> B"
    and nn: "\<And>b. b \<in> B-A \<Longrightarrow> 0 \<le> f b"
  shows "sum_0 f A \<le> sum_0 f B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_0 f A \<le> sum_0 f B
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. sum_0 f A \<le> sum_0 f B
[PROOF STEP]
have "sum_0 f A \<le> sum_0 f A + sum_0 f (B-A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_0 f A \<le> sum_0 f A + sum_0 f (B - A)
[PROOF STEP]
by (metis add_left_mono sum_0.F_one nn sum_nonneg)
[PROOF STATE]
proof (state)
this:
sum_0 f A \<le> sum_0 f A + sum_0 f (B - A)

goal (1 subgoal):
 1. sum_0 f A \<le> sum_0 f B
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum_0 f A \<le> sum_0 f A + sum_0 f (B - A)

goal (1 subgoal):
 1. sum_0 f A \<le> sum_0 f B
[PROOF STEP]
from fin finite_subset[OF sub fin]
[PROOF STATE]
proof (chain)
picking this:
finite B
finite A
[PROOF STEP]
have "\<dots> = sum_0 f (A \<union> (B-A))"
[PROOF STATE]
proof (prove)
using this:
finite B
finite A

goal (1 subgoal):
 1. sum_0 f A + sum_0 f (B - A) = sum_0 f (A \<union> (B - A))
[PROOF STEP]
by (simp add: sum_0.union_disjoint del: Un_Diff_cancel)
[PROOF STATE]
proof (state)
this:
sum_0 f A + sum_0 f (B - A) = sum_0 f (A \<union> (B - A))

goal (1 subgoal):
 1. sum_0 f A \<le> sum_0 f B
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum_0 f A + sum_0 f (B - A) = sum_0 f (A \<union> (B - A))

goal (1 subgoal):
 1. sum_0 f A \<le> sum_0 f B
[PROOF STEP]
from sub
[PROOF STATE]
proof (chain)
picking this:
A \<subseteq> B
[PROOF STEP]
have "A \<union> (B-A) = B"
[PROOF STATE]
proof (prove)
using this:
A \<subseteq> B

goal (1 subgoal):
 1. A \<union> (B - A) = B
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
A \<union> (B - A) = B

goal (1 subgoal):
 1. sum_0 f A \<le> sum_0 f B
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sum_0 f A \<le> sum_0 f B
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
sum_0 f A \<le> sum_0 f B

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem dual_Join [intro?]: "dual (\<Squnion>A) = \<Sqinter>(dual ` A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dual (\<Squnion>A) = \<Sqinter>dual ` A
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. dual (\<Squnion>A) = \<Sqinter>dual ` A
[PROOF STEP]
from is_Sup_Join
[PROOF STATE]
proof (chain)
picking this:
is_Sup ?A (\<Squnion>?A)
[PROOF STEP]
have "is_Inf (dual ` A) (dual (\<Squnion>A))"
[PROOF STATE]
proof (prove)
using this:
is_Sup ?A (\<Squnion>?A)

goal (1 subgoal):
 1. is_Inf (dual ` A) (dual (\<Squnion>A))
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
is_Inf (dual ` A) (dual (\<Squnion>A))

goal (1 subgoal):
 1. dual (\<Squnion>A) = \<Sqinter>dual ` A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
is_Inf (dual ` A) (dual (\<Squnion>A))
[PROOF STEP]
have "\<Sqinter>(dual ` A) = dual (\<Squnion>A)"
[PROOF STATE]
proof (prove)
using this:
is_Inf (dual ` A) (dual (\<Squnion>A))

goal (1 subgoal):
 1. \<Sqinter>dual ` A = dual (\<Squnion>A)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
\<Sqinter>dual ` A = dual (\<Squnion>A)

goal (1 subgoal):
 1. dual (\<Squnion>A) = \<Sqinter>dual ` A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<Sqinter>dual ` A = dual (\<Squnion>A)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<Sqinter>dual ` A = dual (\<Squnion>A)

goal (1 subgoal):
 1. dual (\<Squnion>A) = \<Sqinter>dual ` A
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
dual (\<Squnion>A) = \<Sqinter>dual ` A

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma diag_elems_real:
  fixes B::"complex Matrix.mat"
  assumes "\<forall>i < dim_row B. B$$(i,i) \<in> Reals"
  shows "diag_elems B \<subseteq> Reals"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diag_elems B \<subseteq> \<real>
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> diag_elems B \<Longrightarrow> x \<in> \<real>
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> diag_elems B \<Longrightarrow> x \<in> \<real>
[PROOF STEP]
assume "x\<in> diag_elems B"
[PROOF STATE]
proof (state)
this:
x \<in> diag_elems B

goal (1 subgoal):
 1. \<And>x. x \<in> diag_elems B \<Longrightarrow> x \<in> \<real>
[PROOF STEP]
hence "\<exists>i < dim_row B. x = B $$(i,i)"
[PROOF STATE]
proof (prove)
using this:
x \<in> diag_elems B

goal (1 subgoal):
 1. \<exists>i<dim_row B. x = B $$ (i, i)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
x \<in> diag_elems B
\<forall>i<dim_row B. B $$ (i, i) \<in> \<real>

goal (1 subgoal):
 1. \<exists>i<dim_row B. x = B $$ (i, i)
[PROOF STEP]
unfolding diag_elems_def
[PROOF STATE]
proof (prove)
using this:
x \<in> {B $$ (i, i) |i. i < dim_row B}
\<forall>i<dim_row B. B $$ (i, i) \<in> \<real>

goal (1 subgoal):
 1. \<exists>i<dim_row B. x = B $$ (i, i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>i<dim_row B. x = B $$ (i, i)

goal (1 subgoal):
 1. \<And>x. x \<in> diag_elems B \<Longrightarrow> x \<in> \<real>
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
\<exists>i<dim_row B. x = B $$ (i, i)
[PROOF STEP]
obtain i where "i < dim_row B" "x = B $$ (i,i)"
[PROOF STATE]
proof (prove)
using this:
\<exists>i<dim_row B. x = B $$ (i, i)

goal (1 subgoal):
 1. (\<And>i. \<lbrakk>i < dim_row B; x = B $$ (i, i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i < dim_row B
x = B $$ (i, i)

goal (1 subgoal):
 1. \<And>x. x \<in> diag_elems B \<Longrightarrow> x \<in> \<real>
[PROOF STEP]
thus "x \<in> Reals"
[PROOF STATE]
proof (prove)
using this:
i < dim_row B
x = B $$ (i, i)

goal (1 subgoal):
 1. x \<in> \<real>
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
i < dim_row B
x = B $$ (i, i)
\<forall>i<dim_row B. B $$ (i, i) \<in> \<real>

goal (1 subgoal):
 1. x \<in> \<real>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
x \<in> \<real>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma finite_ball_avoid:
  fixes S :: "'a :: euclidean_space set"
  assumes "open S" "finite X" "p \<in> S"
  shows "\<exists>e>0. \<forall>w\<in>ball p e. w\<in>S \<and> (w\<noteq>p \<longrightarrow> w\<notin>X)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>e>0. \<forall>w\<in>ball p e. w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>e>0. \<forall>w\<in>ball p e. w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)
[PROOF STEP]
obtain e1 where "0 < e1" and e1_b:"ball p e1 \<subseteq> S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>e1. \<lbrakk>0 < e1; ball p e1 \<subseteq> S\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using open_contains_ball_eq[OF \<open>open S\<close>] assms
[PROOF STATE]
proof (prove)
using this:
(?x \<in> S) = (\<exists>e>0. ball ?x e \<subseteq> S)
open S
finite X
p \<in> S

goal (1 subgoal):
 1. (\<And>e1. \<lbrakk>0 < e1; ball p e1 \<subseteq> S\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < e1
ball p e1 \<subseteq> S

goal (1 subgoal):
 1. \<exists>e>0. \<forall>w\<in>ball p e. w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)
[PROOF STEP]
obtain e2 where "0 < e2" and "\<forall>x\<in>X. x \<noteq> p \<longrightarrow> e2 \<le> dist p x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>e2. \<lbrakk>0 < e2; \<forall>x\<in>X. x \<noteq> p \<longrightarrow> e2 \<le> dist p x\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using finite_set_avoid[OF \<open>finite X\<close>,of p]
[PROOF STATE]
proof (prove)
using this:
\<exists>d>0. \<forall>x\<in>X. x \<noteq> p \<longrightarrow> d \<le> dist p x

goal (1 subgoal):
 1. (\<And>e2. \<lbrakk>0 < e2; \<forall>x\<in>X. x \<noteq> p \<longrightarrow> e2 \<le> dist p x\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < e2
\<forall>x\<in>X. x \<noteq> p \<longrightarrow> e2 \<le> dist p x

goal (1 subgoal):
 1. \<exists>e>0. \<forall>w\<in>ball p e. w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)
[PROOF STEP]
hence "\<forall>w\<in>ball p (min e1 e2). w\<in>S \<and> (w\<noteq>p \<longrightarrow> w\<notin>X)"
[PROOF STATE]
proof (prove)
using this:
0 < e2
\<forall>x\<in>X. x \<noteq> p \<longrightarrow> e2 \<le> dist p x

goal (1 subgoal):
 1. \<forall>w\<in>ball p (min e1 e2). w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)
[PROOF STEP]
using e1_b
[PROOF STATE]
proof (prove)
using this:
0 < e2
\<forall>x\<in>X. x \<noteq> p \<longrightarrow> e2 \<le> dist p x
ball p e1 \<subseteq> S

goal (1 subgoal):
 1. \<forall>w\<in>ball p (min e1 e2). w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>w\<in>ball p (min e1 e2). w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)

goal (1 subgoal):
 1. \<exists>e>0. \<forall>w\<in>ball p e. w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)
[PROOF STEP]
thus "\<exists>e>0. \<forall>w\<in>ball p e. w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)"
[PROOF STATE]
proof (prove)
using this:
\<forall>w\<in>ball p (min e1 e2). w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)

goal (1 subgoal):
 1. \<exists>e>0. \<forall>w\<in>ball p e. w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)
[PROOF STEP]
using \<open>e2>0\<close> \<open>e1>0\<close>
[PROOF STATE]
proof (prove)
using this:
\<forall>w\<in>ball p (min e1 e2). w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)
0 < e2
0 < e1

goal (1 subgoal):
 1. \<exists>e>0. \<forall>w\<in>ball p e. w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)
[PROOF STEP]
apply (rule_tac x="min e1 e2" in exI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>w\<in>ball p (min e1 e2). w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X); 0 < e2; 0 < e1\<rbrakk> \<Longrightarrow> 0 < min e1 e2 \<and> (\<forall>w\<in>ball p (min e1 e2). w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>e>0. \<forall>w\<in>ball p e. w \<in> S \<and> (w \<noteq> p \<longrightarrow> w \<notin> X)

goal:
No subgoals!
[PROOF STEP]
qed