--- a/src/HOL/Probability/Information.thy Tue Apr 20 17:58:34 2010 +0200
+++ b/src/HOL/Probability/Information.thy Mon May 03 14:35:10 2010 +0200
@@ -1,5 +1,5 @@
theory Information
-imports Probability_Space Product_Measure
+imports Probability_Space Product_Measure "../Multivariate_Analysis/Convex"
begin
lemma pos_neg_part_abs:
@@ -699,338 +699,6 @@
qed
(* --------------- upper bound on entropy for a rv ------------------------- *)
-definition convex_set :: "real set \<Rightarrow> bool"
-where
- "convex_set C \<equiv> (\<forall> x y \<mu>. x \<in> C \<and> y \<in> C \<and> 0 \<le> \<mu> \<and> \<mu> \<le> 1 \<longrightarrow> \<mu> * x + (1 - \<mu>) * y \<in> C)"
-
-lemma pos_is_convex:
- shows "convex_set {0 <..}"
-unfolding convex_set_def
-proof safe
- fix x y \<mu> :: real
- assume asms: "\<mu> \<ge> 0" "\<mu> \<le> 1" "x > 0" "y > 0"
- { assume "\<mu> = 0"
- hence "\<mu> * x + (1 - \<mu>) * y = y" by simp
- hence "\<mu> * x + (1 - \<mu>) * y > 0" using asms by simp }
- moreover
- { assume "\<mu> = 1"
- hence "\<mu> * x + (1 - \<mu>) * y > 0" using asms by simp }
- moreover
- { assume "\<mu> \<noteq> 1" "\<mu> \<noteq> 0"
- hence "\<mu> > 0" "(1 - \<mu>) > 0" using asms by auto
- hence "\<mu> * x + (1 - \<mu>) * y > 0" using asms
- apply (subst add_nonneg_pos[of "\<mu> * x" "(1 - \<mu>) * y"])
- using real_mult_order by auto fastsimp }
- ultimately show "\<mu> * x + (1 - \<mu>) * y > 0" using assms by blast
-qed
-
-definition convex_fun :: "(real \<Rightarrow> real) \<Rightarrow> real set \<Rightarrow> bool"
-where
- "convex_fun f C \<equiv> (\<forall> x y \<mu>. convex_set C \<and> (x \<in> C \<and> y \<in> C \<and> 0 \<le> \<mu> \<and> \<mu> \<le> 1
- \<longrightarrow> f (\<mu> * x + (1 - \<mu>) * y) \<le> \<mu> * f x + (1 - \<mu>) * f y))"
-
-lemma pos_convex_function:
- fixes f :: "real \<Rightarrow> real"
- assumes "convex_set C"
- assumes leq: "\<And> x y. \<lbrakk>x \<in> C ; y \<in> C\<rbrakk> \<Longrightarrow> f' x * (y - x) \<le> f y - f x"
- shows "convex_fun f C"
-unfolding convex_fun_def
-using assms
-proof safe
- fix x y \<mu> :: real
- let ?x = "\<mu> * x + (1 - \<mu>) * y"
- assume asm: "convex_set C" "x \<in> C" "y \<in> C" "\<mu> \<ge> 0" "\<mu> \<le> 1"
- hence "1 - \<mu> \<ge> 0" by auto
- hence xpos: "?x \<in> C" using asm unfolding convex_set_def by auto
- have geq: "\<mu> * (f x - f ?x) + (1 - \<mu>) * (f y - f ?x)
- \<ge> \<mu> * f' ?x * (x - ?x) + (1 - \<mu>) * f' ?x * (y - ?x)"
- using add_mono[OF mult_mono1[OF leq[OF xpos asm(2)] `\<mu> \<ge> 0`]
- mult_mono1[OF leq[OF xpos asm(3)] `1 - \<mu> \<ge> 0`]] by auto
- hence "\<mu> * f x + (1 - \<mu>) * f y - f ?x \<ge> 0"
- by (auto simp add:field_simps)
- thus "\<mu> * f x + (1 - \<mu>) * f y \<ge> f ?x" by simp
-qed
-
-lemma atMostAtLeast_subset_convex:
- assumes "convex_set C"
- assumes "x \<in> C" "y \<in> C" "x < y"
- shows "{x .. y} \<subseteq> C"
-proof safe
- fix z assume zasm: "z \<in> {x .. y}"
- { assume asm: "x < z" "z < y"
- let "?\<mu>" = "(y - z) / (y - x)"
- have "0 \<le> ?\<mu>" "?\<mu> \<le> 1" using assms asm by (auto simp add:field_simps)
- hence comb: "?\<mu> * x + (1 - ?\<mu>) * y \<in> C"
- using assms[unfolded convex_set_def] by blast
- have "?\<mu> * x + (1 - ?\<mu>) * y = (y - z) * x / (y - x) + (1 - (y - z) / (y - x)) * y"
- by (auto simp add:field_simps)
- also have "\<dots> = ((y - z) * x + (y - x - (y - z)) * y) / (y - x)"
- using assms unfolding add_divide_distrib by (auto simp:field_simps)
- also have "\<dots> = z"
- using assms by (auto simp:field_simps)
- finally have "z \<in> C"
- using comb by auto } note less = this
- show "z \<in> C" using zasm less assms
- unfolding atLeastAtMost_iff le_less by auto
-qed
-
-lemma f''_imp_f':
- fixes f :: "real \<Rightarrow> real"
- assumes "convex_set C"
- assumes f': "\<And> x. x \<in> C \<Longrightarrow> DERIV f x :> (f' x)"
- assumes f'': "\<And> x. x \<in> C \<Longrightarrow> DERIV f' x :> (f'' x)"
- assumes pos: "\<And> x. x \<in> C \<Longrightarrow> f'' x \<ge> 0"
- assumes "x \<in> C" "y \<in> C"
- shows "f' x * (y - x) \<le> f y - f x"
-using assms
-proof -
- { fix x y :: real assume asm: "x \<in> C" "y \<in> C" "y > x"
- hence ge: "y - x > 0" "y - x \<ge> 0" by auto
- from asm have le: "x - y < 0" "x - y \<le> 0" by auto
- then obtain z1 where z1: "z1 > x" "z1 < y" "f y - f x = (y - x) * f' z1"
- using subsetD[OF atMostAtLeast_subset_convex[OF `convex_set C` `x \<in> C` `y \<in> C` `x < y`],
- THEN f', THEN MVT2[OF `x < y`, rule_format, unfolded atLeastAtMost_iff[symmetric]]]
- by auto
- hence "z1 \<in> C" using atMostAtLeast_subset_convex
- `convex_set C` `x \<in> C` `y \<in> C` `x < y` by fastsimp
- from z1 have z1': "f x - f y = (x - y) * f' z1"
- by (simp add:field_simps)
- obtain z2 where z2: "z2 > x" "z2 < z1" "f' z1 - f' x = (z1 - x) * f'' z2"
- using subsetD[OF atMostAtLeast_subset_convex[OF `convex_set C` `x \<in> C` `z1 \<in> C` `x < z1`],
- THEN f'', THEN MVT2[OF `x < z1`, rule_format, unfolded atLeastAtMost_iff[symmetric]]] z1
- by auto
- obtain z3 where z3: "z3 > z1" "z3 < y" "f' y - f' z1 = (y - z1) * f'' z3"
- using subsetD[OF atMostAtLeast_subset_convex[OF `convex_set C` `z1 \<in> C` `y \<in> C` `z1 < y`],
- THEN f'', THEN MVT2[OF `z1 < y`, rule_format, unfolded atLeastAtMost_iff[symmetric]]] z1
- by auto
- have "f' y - (f x - f y) / (x - y) = f' y - f' z1"
- using asm z1' by auto
- also have "\<dots> = (y - z1) * f'' z3" using z3 by auto
- finally have cool': "f' y - (f x - f y) / (x - y) = (y - z1) * f'' z3" by simp
- have A': "y - z1 \<ge> 0" using z1 by auto
- have "z3 \<in> C" using z3 asm atMostAtLeast_subset_convex
- `convex_set C` `x \<in> C` `z1 \<in> C` `x < z1` by fastsimp
- hence B': "f'' z3 \<ge> 0" using assms by auto
- from A' B' have "(y - z1) * f'' z3 \<ge> 0" using mult_nonneg_nonneg by auto
- from cool' this have "f' y - (f x - f y) / (x - y) \<ge> 0" by auto
- from mult_right_mono_neg[OF this le(2)]
- have "f' y * (x - y) - (f x - f y) / (x - y) * (x - y) \<le> 0 * (x - y)"
- unfolding diff_def using real_add_mult_distrib by auto
- hence "f' y * (x - y) - (f x - f y) \<le> 0" using le by auto
- hence res: "f' y * (x - y) \<le> f x - f y" by auto
- have "(f y - f x) / (y - x) - f' x = f' z1 - f' x"
- using asm z1 by auto
- also have "\<dots> = (z1 - x) * f'' z2" using z2 by auto
- finally have cool: "(f y - f x) / (y - x) - f' x = (z1 - x) * f'' z2" by simp
- have A: "z1 - x \<ge> 0" using z1 by auto
- have "z2 \<in> C" using z2 z1 asm atMostAtLeast_subset_convex
- `convex_set C` `z1 \<in> C` `y \<in> C` `z1 < y` by fastsimp
- hence B: "f'' z2 \<ge> 0" using assms by auto
- from A B have "(z1 - x) * f'' z2 \<ge> 0" using mult_nonneg_nonneg by auto
- from cool this have "(f y - f x) / (y - x) - f' x \<ge> 0" by auto
- from mult_right_mono[OF this ge(2)]
- have "(f y - f x) / (y - x) * (y - x) - f' x * (y - x) \<ge> 0 * (y - x)"
- unfolding diff_def using real_add_mult_distrib by auto
- hence "f y - f x - f' x * (y - x) \<ge> 0" using ge by auto
- hence "f y - f x \<ge> f' x * (y - x)" "f' y * (x - y) \<le> f x - f y"
- using res by auto } note less_imp = this
- { fix x y :: real assume "x \<in> C" "y \<in> C" "x \<noteq> y"
- hence"f y - f x \<ge> f' x * (y - x)"
- unfolding neq_iff apply safe
- using less_imp by auto } note neq_imp = this
- moreover
- { fix x y :: real assume asm: "x \<in> C" "y \<in> C" "x = y"
- hence "f y - f x \<ge> f' x * (y - x)" by auto }
- ultimately show ?thesis using assms by blast
-qed
-
-lemma f''_ge0_imp_convex:
- fixes f :: "real \<Rightarrow> real"
- assumes conv: "convex_set C"
- assumes f': "\<And> x. x \<in> C \<Longrightarrow> DERIV f x :> (f' x)"
- assumes f'': "\<And> x. x \<in> C \<Longrightarrow> DERIV f' x :> (f'' x)"
- assumes pos: "\<And> x. x \<in> C \<Longrightarrow> f'' x \<ge> 0"
- shows "convex_fun f C"
-using f''_imp_f'[OF conv f' f'' pos] assms pos_convex_function by fastsimp
-
-lemma minus_log_convex:
- fixes b :: real
- assumes "b > 1"
- shows "convex_fun (\<lambda> x. - log b x) {0 <..}"
-proof -
- have "\<And> z. z > 0 \<Longrightarrow> DERIV (log b) z :> 1 / (ln b * z)" using DERIV_log by auto
- hence f': "\<And> z. z > 0 \<Longrightarrow> DERIV (\<lambda> z. - log b z) z :> - 1 / (ln b * z)"
- using DERIV_minus by auto
- have "\<And> z :: real. z > 0 \<Longrightarrow> DERIV inverse z :> - (inverse z ^ Suc (Suc 0))"
- using less_imp_neq[THEN not_sym, THEN DERIV_inverse] by auto
- from this[THEN DERIV_cmult, of _ "- 1 / ln b"]
- have "\<And> z :: real. z > 0 \<Longrightarrow> DERIV (\<lambda> z. (- 1 / ln b) * inverse z) z :> (- 1 / ln b) * (- (inverse z ^ Suc (Suc 0)))"
- by auto
- hence f''0: "\<And> z :: real. z > 0 \<Longrightarrow> DERIV (\<lambda> z. - 1 / (ln b * z)) z :> 1 / (ln b * z * z)"
- unfolding inverse_eq_divide by (auto simp add:real_mult_assoc)
- have f''_ge0: "\<And> z :: real. z > 0 \<Longrightarrow> 1 / (ln b * z * z) \<ge> 0"
- using `b > 1` by (auto intro!:less_imp_le simp add:divide_pos_pos[of 1] real_mult_order)
- from f''_ge0_imp_convex[OF pos_is_convex,
- unfolded greaterThan_iff, OF f' f''0 f''_ge0]
- show ?thesis by auto
-qed
-
-lemma setsum_nonneg_0:
- fixes f :: "'a \<Rightarrow> real"
- assumes "finite s"
- assumes "\<And> i. i \<in> s \<Longrightarrow> f i \<ge> 0"
- assumes "(\<Sum> i \<in> s. f i) = 0"
- assumes "i \<in> s"
- shows "f i = 0"
-proof -
- { assume asm: "f i > 0"
- from assms have "\<forall> j \<in> s - {i}. f j \<ge> 0" by auto
- from setsum_nonneg[of "s - {i}" f, OF this]
- have "(\<Sum> j \<in> s - {i}. f j) \<ge> 0" by simp
- hence "(\<Sum> j \<in> s - {i}. f j) + f i > 0" using asm by auto
- from this setsum.remove[of s i f, OF `finite s` `i \<in> s`]
- have "(\<Sum> j \<in> s. f j) > 0" by auto
- hence "False" using assms by auto }
- thus ?thesis using assms by fastsimp
-qed
-
-lemma setsum_nonneg_leq_1:
- fixes f :: "'a \<Rightarrow> real"
- assumes "finite s"
- assumes "\<And> i. i \<in> s \<Longrightarrow> f i \<ge> 0"
- assumes "(\<Sum> i \<in> s. f i) = 1"
- assumes "i \<in> s"
- shows "f i \<le> 1"
-proof -
- { assume asm: "f i > 1"
- from assms have "\<forall> j \<in> s - {i}. f j \<ge> 0" by auto
- from setsum_nonneg[of "s - {i}" f, OF this]
- have "(\<Sum> j \<in> s - {i}. f j) \<ge> 0" by simp
- hence "(\<Sum> j \<in> s - {i}. f j) + f i > 1" using asm by auto
- from this setsum.remove[of s i f, OF `finite s` `i \<in> s`]
- have "(\<Sum> j \<in> s. f j) > 1" by auto
- hence "False" using assms by auto }
- thus ?thesis using assms by fastsimp
-qed
-
-lemma convex_set_setsum:
- assumes "finite s" "s \<noteq> {}"
- assumes "convex_set C"
- assumes "(\<Sum> i \<in> s. a i) = 1"
- assumes "\<And> i. i \<in> s \<Longrightarrow> a i \<ge> 0"
- assumes "\<And> i. i \<in> s \<Longrightarrow> y i \<in> C"
- shows "(\<Sum> j \<in> s. a j * y j) \<in> C"
-using assms
-proof (induct s arbitrary:a rule:finite_ne_induct)
- case (singleton i) note asms = this
- hence "a i = 1" by auto
- thus ?case using asms by auto
-next
- case (insert i s) note asms = this
- { assume "a i = 1"
- hence "(\<Sum> j \<in> s. a j) = 0"
- using asms by auto
- hence "\<And> j. j \<in> s \<Longrightarrow> a j = 0"
- using setsum_nonneg_0 asms by fastsimp
- hence ?case using asms by auto }
- moreover
- { assume asm: "a i \<noteq> 1"
- from asms have yai: "y i \<in> C" "a i \<ge> 0" by auto
- have fis: "finite (insert i s)" using asms by auto
- hence ai1: "a i \<le> 1" using setsum_nonneg_leq_1[of "insert i s" a] asms by simp
- hence "a i < 1" using asm by auto
- hence i0: "1 - a i > 0" by auto
- let "?a j" = "a j / (1 - a i)"
- { fix j assume "j \<in> s"
- hence "?a j \<ge> 0"
- using i0 asms divide_nonneg_pos
- by fastsimp } note a_nonneg = this
- have "(\<Sum> j \<in> insert i s. a j) = 1" using asms by auto
- hence "(\<Sum> j \<in> s. a j) = 1 - a i" using setsum.insert asms by fastsimp
- hence "(\<Sum> j \<in> s. a j) / (1 - a i) = 1" using i0 by auto
- hence a1: "(\<Sum> j \<in> s. ?a j) = 1" unfolding divide.setsum by simp
- from this asms
- have "(\<Sum>j\<in>s. ?a j * y j) \<in> C" using a_nonneg by fastsimp
- hence "a i * y i + (1 - a i) * (\<Sum> j \<in> s. ?a j * y j) \<in> C"
- using asms[unfolded convex_set_def, rule_format] yai ai1 by auto
- hence "a i * y i + (\<Sum> j \<in> s. (1 - a i) * (?a j * y j)) \<in> C"
- using mult_right.setsum[of "(1 - a i)" "\<lambda> j. ?a j * y j" s] by auto
- hence "a i * y i + (\<Sum> j \<in> s. a j * y j) \<in> C" using i0 by auto
- hence ?case using setsum.insert asms by auto }
- ultimately show ?case by auto
-qed
-
-lemma convex_fun_setsum:
- fixes a :: "'a \<Rightarrow> real"
- assumes "finite s" "s \<noteq> {}"
- assumes "convex_fun f C"
- assumes "(\<Sum> i \<in> s. a i) = 1"
- assumes "\<And> i. i \<in> s \<Longrightarrow> a i \<ge> 0"
- assumes "\<And> i. i \<in> s \<Longrightarrow> y i \<in> C"
- shows "f (\<Sum> i \<in> s. a i * y i) \<le> (\<Sum> i \<in> s. a i * f (y i))"
-using assms
-proof (induct s arbitrary:a rule:finite_ne_induct)
- case (singleton i)
- hence ai: "a i = 1" by auto
- thus ?case by auto
-next
- case (insert i s) note asms = this
- hence "convex_fun f C" by simp
- from this[unfolded convex_fun_def, rule_format]
- have conv: "\<And> x y \<mu>. \<lbrakk>x \<in> C; y \<in> C; 0 \<le> \<mu>; \<mu> \<le> 1\<rbrakk>
- \<Longrightarrow> f (\<mu> * x + (1 - \<mu>) * y) \<le> \<mu> * f x + (1 - \<mu>) * f y"
- by simp
- { assume "a i = 1"
- hence "(\<Sum> j \<in> s. a j) = 0"
- using asms by auto
- hence "\<And> j. j \<in> s \<Longrightarrow> a j = 0"
- using setsum_nonneg_0 asms by fastsimp
- hence ?case using asms by auto }
- moreover
- { assume asm: "a i \<noteq> 1"
- from asms have yai: "y i \<in> C" "a i \<ge> 0" by auto
- have fis: "finite (insert i s)" using asms by auto
- hence ai1: "a i \<le> 1" using setsum_nonneg_leq_1[of "insert i s" a] asms by simp
- hence "a i < 1" using asm by auto
- hence i0: "1 - a i > 0" by auto
- let "?a j" = "a j / (1 - a i)"
- { fix j assume "j \<in> s"
- hence "?a j \<ge> 0"
- using i0 asms divide_nonneg_pos
- by fastsimp } note a_nonneg = this
- have "(\<Sum> j \<in> insert i s. a j) = 1" using asms by auto
- hence "(\<Sum> j \<in> s. a j) = 1 - a i" using setsum.insert asms by fastsimp
- hence "(\<Sum> j \<in> s. a j) / (1 - a i) = 1" using i0 by auto
- hence a1: "(\<Sum> j \<in> s. ?a j) = 1" unfolding divide.setsum by simp
- have "convex_set C" using asms unfolding convex_fun_def by auto
- hence asum: "(\<Sum> j \<in> s. ?a j * y j) \<in> C"
- using asms convex_set_setsum[OF `finite s` `s \<noteq> {}`
- `convex_set C` a1 a_nonneg] by auto
- have asum_le: "f (\<Sum> j \<in> s. ?a j * y j) \<le> (\<Sum> j \<in> s. ?a j * f (y j))"
- using a_nonneg a1 asms by blast
- have "f (\<Sum> j \<in> insert i s. a j * y j) = f ((\<Sum> j \<in> s. a j * y j) + a i * y i)"
- using setsum.insert[of s i "\<lambda> j. a j * y j", OF `finite s` `i \<notin> s`] asms
- by (auto simp only:add_commute)
- also have "\<dots> = f ((1 - a i) * (\<Sum> j \<in> s. a j * y j) / (1 - a i) + a i * y i)"
- using i0 by auto
- also have "\<dots> = f ((1 - a i) * (\<Sum> j \<in> s. a j * y j / (1 - a i)) + a i * y i)"
- unfolding divide.setsum[of "\<lambda> j. a j * y j" s "1 - a i", symmetric] by auto
- also have "\<dots> = f ((1 - a i) * (\<Sum> j \<in> s. ?a j * y j) + a i * y i)" by auto
- also have "\<dots> \<le> (1 - a i) * f ((\<Sum> j \<in> s. ?a j * y j)) + a i * f (y i)"
- using conv[of "y i" "(\<Sum> j \<in> s. ?a j * y j)" "a i", OF yai(1) asum yai(2) ai1]
- by (auto simp only:add_commute)
- also have "\<dots> \<le> (1 - a i) * (\<Sum> j \<in> s. ?a j * f (y j)) + a i * f (y i)"
- using add_right_mono[OF mult_left_mono[of _ _ "1 - a i",
- OF asum_le less_imp_le[OF i0]], of "a i * f (y i)"] by simp
- also have "\<dots> = (\<Sum> j \<in> s. (1 - a i) * ?a j * f (y j)) + a i * f (y i)"
- unfolding mult_right.setsum[of "1 - a i" "\<lambda> j. ?a j * f (y j)"] using i0 by auto
- also have "\<dots> = (\<Sum> j \<in> s. a j * f (y j)) + a i * f (y i)" using i0 by auto
- also have "\<dots> = (\<Sum> j \<in> insert i s. a j * f (y j))" using asms by auto
- finally have "f (\<Sum> j \<in> insert i s. a j * y j) \<le> (\<Sum> j \<in> insert i s. a j * f (y j))"
- by simp }
- ultimately show ?case by auto
-qed
-
lemma log_setsum:
assumes "finite s" "s \<noteq> {}"
assumes "b > 1"
@@ -1039,10 +707,10 @@
assumes "\<And> i. i \<in> s \<Longrightarrow> y i \<in> {0 <..}"
shows "log b (\<Sum> i \<in> s. a i * y i) \<ge> (\<Sum> i \<in> s. a i * log b (y i))"
proof -
- have "convex_fun (\<lambda> x. - log b x) {0 <..}"
+ have "convex_on {0 <..} (\<lambda> x. - log b x)"
by (rule minus_log_convex[OF `b > 1`])
hence "- log b (\<Sum> i \<in> s. a i * y i) \<le> (\<Sum> i \<in> s. a i * - log b (y i))"
- using convex_fun_setsum assms by blast
+ using convex_on_setsum[of _ _ "\<lambda> x. - log b x"] assms pos_is_convex by fastsimp
thus ?thesis by (auto simp add:setsum_negf le_imp_neg_le)
qed