src/HOL/Probability/ex/Koepf_Duermuth_Countermeasure.thy
changeset 61609 77b453bd616f
parent 61284 2314c2f62eb1
child 61649 268d88ec9087
equal deleted inserted replaced
61553:933eb9e6a1cc 61609:77b453bd616f
   372     have "\<P>(t\<circ>OB ; fst) {(t obs, k)} = (\<Sum>obs'\<in>?S obs. \<P>(OB ; fst) {(obs', k)})"
   372     have "\<P>(t\<circ>OB ; fst) {(t obs, k)} = (\<Sum>obs'\<in>?S obs. \<P>(OB ; fst) {(obs', k)})"
   373       unfolding comp_def
   373       unfolding comp_def
   374       using finite_measure_finite_Union[OF _ df]
   374       using finite_measure_finite_Union[OF _ df]
   375       by (auto simp add: * intro!: setsum_nonneg)
   375       by (auto simp add: * intro!: setsum_nonneg)
   376     also have "(\<Sum>obs'\<in>?S obs. \<P>(OB ; fst) {(obs', k)}) = real (card (?S obs)) * \<P>(OB ; fst) {(obs, k)}"
   376     also have "(\<Sum>obs'\<in>?S obs. \<P>(OB ; fst) {(obs', k)}) = real (card (?S obs)) * \<P>(OB ; fst) {(obs, k)}"
   377       by (simp add: t_eq_imp[OF `k \<in> keys` `K k \<noteq> 0` obs] real_eq_of_nat)
   377       by (simp add: t_eq_imp[OF `k \<in> keys` `K k \<noteq> 0` obs])
   378     finally have "\<P>(t\<circ>OB ; fst) {(t obs, k)} = real (card (?S obs)) * \<P>(OB ; fst) {(obs, k)}" .}
   378     finally have "\<P>(t\<circ>OB ; fst) {(t obs, k)} = real (card (?S obs)) * \<P>(OB ; fst) {(obs, k)}" .}
   379   note P_t_eq_P_OB = this
   379   note P_t_eq_P_OB = this
   380 
   380 
   381   { fix k obs assume "k \<in> keys" and obs: "obs \<in> OB`msgs"
   381   { fix k obs assume "k \<in> keys" and obs: "obs \<in> OB`msgs"
   382     have "\<P>(t\<circ>OB | fst) {(t obs, k)} =
   382     have "\<P>(t\<circ>OB | fst) {(t obs, k)} =
   469     using conditional_entropy_nonneg[of "t\<circ>OB" fst] by simp
   469     using conditional_entropy_nonneg[of "t\<circ>OB" fst] by simp
   470   also have "\<dots> \<le> log b (real (card ((t\<circ>OB)`msgs)))"
   470   also have "\<dots> \<le> log b (real (card ((t\<circ>OB)`msgs)))"
   471     using entropy_le_card[of "t\<circ>OB", OF simple_distributedI[OF simple_function_finite refl]] by simp
   471     using entropy_le_card[of "t\<circ>OB", OF simple_distributedI[OF simple_function_finite refl]] by simp
   472   also have "\<dots> \<le> log b (real (n + 1)^card observations)"
   472   also have "\<dots> \<le> log b (real (n + 1)^card observations)"
   473     using card_T_bound not_empty
   473     using card_T_bound not_empty
   474     by (auto intro!: log_le simp: card_gt_0_iff power_real_of_nat simp del: real_of_nat_power real_of_nat_Suc)
   474     by (auto intro!: log_le simp: card_gt_0_iff power_real_of_nat simp del: of_nat_power of_nat_Suc)
   475   also have "\<dots> = real (card observations) * log b (real n + 1)"
   475   also have "\<dots> = real (card observations) * log b (real n + 1)"
   476     by (simp add: log_nat_power real_of_nat_Suc)
   476     by (simp add: log_nat_power add.commute)
   477   finally show ?thesis  .
   477   finally show ?thesis  .
   478 qed
   478 qed
   479 
   479 
   480 end
   480 end
   481 
   481