src/HOL/Analysis/Nonnegative_Lebesgue_Integration.thy
changeset 73253 f6bb31879698
parent 71633 07bec530f02e
child 73536 5131c388a9b0
equal deleted inserted replaced
73252:b4552595b04e 73253:f6bb31879698
  1172     using bnd supp by (subst nn_integral_cmult) (auto simp: ennreal_mult_less_top)
  1172     using bnd supp by (subst nn_integral_cmult) (auto simp: ennreal_mult_less_top)
  1173   finally show ?thesis .
  1173   finally show ?thesis .
  1174 qed
  1174 qed
  1175 
  1175 
  1176 theorem nn_integral_Markov_inequality:
  1176 theorem nn_integral_Markov_inequality:
  1177   assumes u: "u \<in> borel_measurable M" and "A \<in> sets M"
  1177   assumes u: "(\<lambda>x. u x * indicator A x) \<in> borel_measurable M" and "A \<in> sets M"
  1178   shows "(emeasure M) ({x\<in>space M. 1 \<le> c * u x} \<inter> A) \<le> c * (\<integral>\<^sup>+ x. u x * indicator A x \<partial>M)"
  1178   shows "(emeasure M) ({x\<in>A. 1 \<le> c * u x}) \<le> c * (\<integral>\<^sup>+ x. u x * indicator A x \<partial>M)"
  1179     (is "(emeasure M) ?A \<le> _ * ?PI")
  1179     (is "(emeasure M) ?A \<le> _ * ?PI")
  1180 proof -
  1180 proof -
  1181   have "?A \<in> sets M"
  1181   define u' where "u' = (\<lambda>x. u x * indicator A x)"
  1182     using \<open>A \<in> sets M\<close> u by auto
  1182   have [measurable]: "u' \<in> borel_measurable M"
  1183   hence "(emeasure M) ?A = (\<integral>\<^sup>+ x. indicator ?A x \<partial>M)"
  1183     using u unfolding u'_def .
       
  1184   have "{x\<in>space M. c * u' x \<ge> 1} \<in> sets M"
       
  1185     by measurable
       
  1186   also have "{x\<in>space M. c * u' x \<ge> 1} = ?A"
       
  1187     using sets.sets_into_space[OF \<open>A \<in> sets M\<close>] by (auto simp: u'_def indicator_def)
       
  1188   finally have "(emeasure M) ?A = (\<integral>\<^sup>+ x. indicator ?A x \<partial>M)"
  1184     using nn_integral_indicator by simp
  1189     using nn_integral_indicator by simp
  1185   also have "\<dots> \<le> (\<integral>\<^sup>+ x. c * (u x * indicator A x) \<partial>M)"
  1190   also have "\<dots> \<le> (\<integral>\<^sup>+ x. c * (u x * indicator A x) \<partial>M)"
  1186     using u by (auto intro!: nn_integral_mono_AE simp: indicator_def)
  1191     using u by (auto intro!: nn_integral_mono_AE simp: indicator_def)
  1187   also have "\<dots> = c * (\<integral>\<^sup>+ x. u x * indicator A x \<partial>M)"
  1192   also have "\<dots> = c * (\<integral>\<^sup>+ x. u x * indicator A x \<partial>M)"
  1188     using assms by (auto intro!: nn_integral_cmult)
  1193     using assms by (auto intro!: nn_integral_cmult)
  1189   finally show ?thesis .
  1194   finally show ?thesis .
  1190 qed
  1195 qed
       
  1196 
       
  1197 lemma Chernoff_ineq_nn_integral_ge:
       
  1198   assumes s: "s > 0" and [measurable]: "A \<in> sets M"
       
  1199   assumes [measurable]: "(\<lambda>x. f x * indicator A x) \<in> borel_measurable M"
       
  1200   shows   "emeasure M {x\<in>A. f x \<ge> a} \<le>
       
  1201            ennreal (exp (-s * a)) * nn_integral M (\<lambda>x. ennreal (exp (s * f x)) * indicator A x)"
       
  1202 proof -
       
  1203   define f' where "f' = (\<lambda>x. f x * indicator A x)"
       
  1204   have [measurable]: "f' \<in> borel_measurable M"
       
  1205     using assms(3) unfolding f'_def by assumption
       
  1206   have "(\<lambda>x. ennreal (exp (s * f' x)) * indicator A x) \<in> borel_measurable M"
       
  1207     by simp
       
  1208   also have "(\<lambda>x. ennreal (exp (s * f' x)) * indicator A x) =
       
  1209              (\<lambda>x. ennreal (exp (s * f x)) * indicator A x)"
       
  1210     by (auto simp: f'_def indicator_def fun_eq_iff)
       
  1211   finally have meas: "\<dots> \<in> borel_measurable M" .
       
  1212 
       
  1213   have "{x\<in>A. f x \<ge> a} = {x\<in>A. ennreal (exp (-s * a)) * ennreal (exp (s * f x)) \<ge> 1}"
       
  1214     using s by (auto simp: exp_minus field_simps simp flip: ennreal_mult)
       
  1215   also have "emeasure M \<dots> \<le> ennreal (exp (-s * a)) *
       
  1216                (\<integral>\<^sup>+x. ennreal (exp (s * f x)) * indicator A x \<partial>M)"
       
  1217     by (intro order.trans[OF nn_integral_Markov_inequality] meas) auto
       
  1218   finally show ?thesis .
       
  1219 qed
       
  1220 
       
  1221 lemma Chernoff_ineq_nn_integral_le:
       
  1222   assumes s: "s > 0" and [measurable]: "A \<in> sets M"
       
  1223   assumes [measurable]: "f \<in> borel_measurable M"
       
  1224   shows   "emeasure M {x\<in>A. f x \<le> a} \<le>
       
  1225            ennreal (exp (s * a)) * nn_integral M (\<lambda>x. ennreal (exp (-s * f x)) * indicator A x)"
       
  1226   using Chernoff_ineq_nn_integral_ge[of s A M "\<lambda>x. -f x" "-a"] assms by simp
  1191 
  1227 
  1192 lemma nn_integral_noteq_infinite:
  1228 lemma nn_integral_noteq_infinite:
  1193   assumes g: "g \<in> borel_measurable M" and "integral\<^sup>N M g \<noteq> \<infinity>"
  1229   assumes g: "g \<in> borel_measurable M" and "integral\<^sup>N M g \<noteq> \<infinity>"
  1194   shows "AE x in M. g x \<noteq> \<infinity>"
  1230   shows "AE x in M. g x \<noteq> \<infinity>"
  1195 proof (rule ccontr)
  1231 proof (rule ccontr)
  1430   qed
  1466   qed
  1431   then show ?thesis by simp
  1467   then show ?thesis by simp
  1432 qed
  1468 qed
  1433 
  1469 
  1434 lemma nn_integral_0_iff:
  1470 lemma nn_integral_0_iff:
  1435   assumes u: "u \<in> borel_measurable M"
  1471   assumes u [measurable]: "u \<in> borel_measurable M"
  1436   shows "integral\<^sup>N M u = 0 \<longleftrightarrow> emeasure M {x\<in>space M. u x \<noteq> 0} = 0"
  1472   shows "integral\<^sup>N M u = 0 \<longleftrightarrow> emeasure M {x\<in>space M. u x \<noteq> 0} = 0"
  1437     (is "_ \<longleftrightarrow> (emeasure M) ?A = 0")
  1473     (is "_ \<longleftrightarrow> (emeasure M) ?A = 0")
  1438 proof -
  1474 proof -
  1439   have u_eq: "(\<integral>\<^sup>+ x. u x * indicator ?A x \<partial>M) = integral\<^sup>N M u"
  1475   have u_eq: "(\<integral>\<^sup>+ x. u x * indicator ?A x \<partial>M) = integral\<^sup>N M u"
  1440     by (auto intro!: nn_integral_cong simp: indicator_def)
  1476     by (auto intro!: nn_integral_cong simp: indicator_def)
  1447     assume *: "integral\<^sup>N M u = 0"
  1483     assume *: "integral\<^sup>N M u = 0"
  1448     let ?M = "\<lambda>n. {x \<in> space M. 1 \<le> real (n::nat) * u x}"
  1484     let ?M = "\<lambda>n. {x \<in> space M. 1 \<le> real (n::nat) * u x}"
  1449     have "0 = (SUP n. (emeasure M) (?M n \<inter> ?A))"
  1485     have "0 = (SUP n. (emeasure M) (?M n \<inter> ?A))"
  1450     proof -
  1486     proof -
  1451       { fix n :: nat
  1487       { fix n :: nat
  1452         from nn_integral_Markov_inequality[OF u, of ?A "of_nat n"] u
  1488         have "emeasure M {x \<in> ?A. 1 \<le> of_nat n * u x} \<le>
  1453         have "(emeasure M) (?M n \<inter> ?A) \<le> 0"
  1489                 of_nat n * \<integral>\<^sup>+ x. u x * indicator ?A x \<partial>M"
  1454           by (simp add: ennreal_of_nat_eq_real_of_nat u_eq *)
  1490           by (intro nn_integral_Markov_inequality) auto
       
  1491         also have "{x \<in> ?A. 1 \<le> of_nat n * u x} = (?M n \<inter> ?A)"
       
  1492           by (auto simp: ennreal_of_nat_eq_real_of_nat u_eq * )
       
  1493         finally have "emeasure M (?M n \<inter> ?A) \<le> 0"
       
  1494           by (simp add: ennreal_of_nat_eq_real_of_nat u_eq * )
  1455         moreover have "0 \<le> (emeasure M) (?M n \<inter> ?A)" using u by auto
  1495         moreover have "0 \<le> (emeasure M) (?M n \<inter> ?A)" using u by auto
  1456         ultimately have "(emeasure M) (?M n \<inter> ?A) = 0" by auto }
  1496         ultimately have "(emeasure M) (?M n \<inter> ?A) = 0" by auto }
  1457       thus ?thesis by simp
  1497       thus ?thesis by simp
  1458     qed
  1498     qed
  1459     also have "\<dots> = (emeasure M) (\<Union>n. ?M n \<inter> ?A)"
  1499     also have "\<dots> = (emeasure M) (\<Union>n. ?M n \<inter> ?A)"
  1614 next
  1654 next
  1615   show "\<And>x. x \<in> borel_measurable N \<and> (\<forall>s. integral\<^sup>N (M s) x < \<infinity>) \<Longrightarrow>
  1655   show "\<And>x. x \<in> borel_measurable N \<and> (\<forall>s. integral\<^sup>N (M s) x < \<infinity>) \<Longrightarrow>
  1616          (\<lambda>s. integral\<^sup>N (M s) (f x)) = g (\<lambda>s. integral\<^sup>N (M s) x)"
  1656          (\<lambda>s. integral\<^sup>N (M s) (f x)) = g (\<lambda>s. integral\<^sup>N (M s) x)"
  1617     by (subst step) auto
  1657     by (subst step) auto
  1618 qed (insert bound, auto simp add: le_fun_def INF_apply[abs_def] top_fun_def intro!: meas f g)
  1658 qed (insert bound, auto simp add: le_fun_def INF_apply[abs_def] top_fun_def intro!: meas f g)
       
  1659 
       
  1660 
       
  1661 text \<open>Cauchy--Schwarz inequality for \<^const>\<open>nn_integral\<close>\<close>
       
  1662 
       
  1663 lemma sum_of_squares_ge_ennreal:
       
  1664   fixes a b :: ennreal
       
  1665   shows "2 * a * b \<le> a\<^sup>2 + b\<^sup>2"
       
  1666 proof (cases a; cases b)
       
  1667   fix x y
       
  1668   assume xy: "x \<ge> 0" "y \<ge> 0" and [simp]: "a = ennreal x" "b = ennreal y"
       
  1669   have "0 \<le> (x - y)\<^sup>2"
       
  1670     by simp
       
  1671   also have "\<dots> = x\<^sup>2 + y\<^sup>2 - 2 * x * y"
       
  1672     by (simp add: algebra_simps power2_eq_square)
       
  1673   finally have "2 * x * y \<le> x\<^sup>2 + y\<^sup>2"
       
  1674     by simp
       
  1675   hence "ennreal (2 * x * y) \<le> ennreal (x\<^sup>2 + y\<^sup>2)"
       
  1676     by (intro ennreal_leI)
       
  1677   thus ?thesis using xy
       
  1678     by (simp add: ennreal_mult ennreal_power)
       
  1679 qed auto
       
  1680 
       
  1681 lemma Cauchy_Schwarz_nn_integral:
       
  1682   assumes [measurable]: "f \<in> borel_measurable M" "g \<in> borel_measurable M"
       
  1683   shows "(\<integral>\<^sup>+x. f x * g x \<partial>M)\<^sup>2 \<le> (\<integral>\<^sup>+x. f x ^ 2 \<partial>M) * (\<integral>\<^sup>+x. g x ^ 2 \<partial>M)"
       
  1684 proof (cases "(\<integral>\<^sup>+x. f x * g x \<partial>M) = 0")
       
  1685   case False
       
  1686   define F where "F = nn_integral M (\<lambda>x. f x ^ 2)"
       
  1687   define G where "G = nn_integral M (\<lambda>x. g x ^ 2)"
       
  1688   from False have "\<not>(AE x in M. f x = 0 \<or> g x = 0)"
       
  1689     by (auto simp: nn_integral_0_iff_AE)
       
  1690   hence "\<not>(AE x in M. f x = 0)" and "\<not>(AE x in M. g x = 0)"
       
  1691     by (auto intro: AE_disjI1 AE_disjI2)
       
  1692   hence nz: "F \<noteq> 0" "G \<noteq> 0"
       
  1693     by (auto simp: nn_integral_0_iff_AE F_def G_def)
       
  1694 
       
  1695   show ?thesis
       
  1696   proof (cases "F = \<infinity> \<or> G = \<infinity>")
       
  1697     case True
       
  1698     thus ?thesis using nz
       
  1699       by (auto simp: F_def G_def)
       
  1700   next
       
  1701     case False
       
  1702     define F' where "F' = ennreal (sqrt (enn2real F))"
       
  1703     define G' where "G' = ennreal (sqrt (enn2real G))"
       
  1704     from False have fin: "F < top" "G < top"
       
  1705       by (simp_all add: top.not_eq_extremum)
       
  1706     have F'_sqr: "F'\<^sup>2 = F"
       
  1707       using False by (cases F) (auto simp: F'_def ennreal_power)
       
  1708     have G'_sqr: "G'\<^sup>2 = G"
       
  1709       using False by (cases G) (auto simp: G'_def ennreal_power)
       
  1710     have nz': "F' \<noteq> 0" "G' \<noteq> 0" and fin': "F' \<noteq> \<infinity>" "G' \<noteq> \<infinity>"
       
  1711       using F'_sqr G'_sqr nz fin by auto
       
  1712     from fin' have fin'': "F' < top" "G' < top"
       
  1713       by (auto simp: top.not_eq_extremum)
       
  1714 
       
  1715     have "2 * (F' / F') * (G' / G') * (\<integral>\<^sup>+x. f x * g x \<partial>M) =
       
  1716           F' * G' * (\<integral>\<^sup>+x. 2 * (f x / F') * (g x / G') \<partial>M)"
       
  1717       using nz' fin''
       
  1718       by (simp add: divide_ennreal_def algebra_simps ennreal_inverse_mult flip: nn_integral_cmult)
       
  1719     also have "F'/ F' = 1"
       
  1720       using nz' fin'' by simp
       
  1721     also have "G'/ G' = 1"
       
  1722       using nz' fin'' by simp
       
  1723     also have "2 * 1 * 1 = (2 :: ennreal)" by simp
       
  1724     also have "F' * G' * (\<integral>\<^sup>+ x. 2 * (f x / F') * (g x / G') \<partial>M) \<le>
       
  1725                F' * G' * (\<integral>\<^sup>+x. (f x / F')\<^sup>2 + (g x / G')\<^sup>2 \<partial>M)"
       
  1726       by (intro mult_left_mono nn_integral_mono sum_of_squares_ge_ennreal) auto
       
  1727     also have "\<dots> = F' * G' * (F / F'\<^sup>2 + G / G'\<^sup>2)" using nz
       
  1728       by (auto simp: nn_integral_add algebra_simps nn_integral_divide F_def G_def)
       
  1729     also have "F / F'\<^sup>2 = 1"
       
  1730       using nz F'_sqr fin by simp
       
  1731     also have "G / G'\<^sup>2 = 1"
       
  1732       using nz G'_sqr fin by simp
       
  1733     also have "F' * G' * (1 + 1) = 2 * (F' * G')"
       
  1734       by (simp add: mult_ac)
       
  1735     finally have "(\<integral>\<^sup>+x. f x * g x \<partial>M) \<le> F' * G'"
       
  1736       by (subst (asm) ennreal_mult_le_mult_iff) auto
       
  1737     hence "(\<integral>\<^sup>+x. f x * g x \<partial>M)\<^sup>2 \<le> (F' * G')\<^sup>2"
       
  1738       by (intro power_mono_ennreal)
       
  1739     also have "\<dots> = F * G"
       
  1740       by (simp add: algebra_simps F'_sqr G'_sqr)
       
  1741     finally show ?thesis
       
  1742       by (simp add: F_def G_def)
       
  1743   qed
       
  1744 qed auto
       
  1745 
  1619 
  1746 
  1620 (* TODO: rename? *)
  1747 (* TODO: rename? *)
  1621 subsection \<open>Integral under concrete measures\<close>
  1748 subsection \<open>Integral under concrete measures\<close>
  1622 
  1749 
  1623 lemma nn_integral_mono_measure:
  1750 lemma nn_integral_mono_measure: