src/HOL/Probability/Nonnegative_Lebesgue_Integration.thy
changeset 56994 8d5e5ec1cac3
parent 56993 e5366291d6aa
child 56996 891e992e510f
equal deleted inserted replaced
56993:e5366291d6aa 56994:8d5e5ec1cac3
    11 
    11 
    12 lemma indicator_less_ereal[simp]:
    12 lemma indicator_less_ereal[simp]:
    13   "indicator A x \<le> (indicator B x::ereal) \<longleftrightarrow> (x \<in> A \<longrightarrow> x \<in> B)"
    13   "indicator A x \<le> (indicator B x::ereal) \<longleftrightarrow> (x \<in> A \<longrightarrow> x \<in> B)"
    14   by (simp add: indicator_def not_le)
    14   by (simp add: indicator_def not_le)
    15 
    15 
    16 section "Simple function"
    16 subsection "Simple function"
    17 
    17 
    18 text {*
    18 text {*
    19 
    19 
    20 Our simple functions are not restricted to positive real numbers. Instead
    20 Our simple functions are not restricted to positive real numbers. Instead
    21 they are just functions with a finite range and are measurable when singleton
    21 they are just functions with a finite range and are measurable when singleton
   499   also have "T -` (f -` {i} \<inter> space M') \<inter> space M = (\<lambda>x. f (T x)) -` {i} \<inter> space M"
   499   also have "T -` (f -` {i} \<inter> space M') \<inter> space M = (\<lambda>x. f (T x)) -` {i} \<inter> space M"
   500     using T unfolding measurable_def by auto
   500     using T unfolding measurable_def by auto
   501   finally show "(\<lambda>x. f (T x)) -` {i} \<inter> space M \<in> sets M" .
   501   finally show "(\<lambda>x. f (T x)) -` {i} \<inter> space M \<in> sets M" .
   502 qed
   502 qed
   503 
   503 
   504 section "Simple integral"
   504 subsection "Simple integral"
   505 
   505 
   506 definition simple_integral :: "'a measure \<Rightarrow> ('a \<Rightarrow> ereal) \<Rightarrow> ereal" ("integral\<^sup>S") where
   506 definition simple_integral :: "'a measure \<Rightarrow> ('a \<Rightarrow> ereal) \<Rightarrow> ereal" ("integral\<^sup>S") where
   507   "integral\<^sup>S M f = (\<Sum>x \<in> f ` space M. x * emeasure M (f -` {x} \<inter> space M))"
   507   "integral\<^sup>S M f = (\<Sum>x \<in> f ` space M. x * emeasure M (f -` {x} \<inter> space M))"
   508 
   508 
   509 syntax
   509 syntax
   732   have "integral\<^sup>S M (\<lambda>x. 0) \<le> integral\<^sup>S M f"
   732   have "integral\<^sup>S M (\<lambda>x. 0) \<le> integral\<^sup>S M f"
   733     using simple_integral_mono_AE[OF _ f ae] by auto
   733     using simple_integral_mono_AE[OF _ f ae] by auto
   734   then show ?thesis by simp
   734   then show ?thesis by simp
   735 qed
   735 qed
   736 
   736 
   737 section "Continuous positive integration"
   737 subsection {* Integral on nonnegative functions *}
   738 
   738 
   739 definition positive_integral :: "'a measure \<Rightarrow> ('a \<Rightarrow> ereal) \<Rightarrow> ereal" ("integral\<^sup>P") where
   739 definition positive_integral :: "'a measure \<Rightarrow> ('a \<Rightarrow> ereal) \<Rightarrow> ereal" ("integral\<^sup>P") where
   740   "integral\<^sup>P M f = (SUP g : {g. simple_function M g \<and> g \<le> max 0 \<circ> f}. integral\<^sup>S M g)"
   740   "integral\<^sup>P M f = (SUP g : {g. simple_function M g \<and> g \<le> max 0 \<circ> f}. integral\<^sup>S M g)"
   741 
   741 
   742 syntax
   742 syntax
  1554     by (simp add: positive_integral_suminf)
  1554     by (simp add: positive_integral_suminf)
  1555   finally show ?thesis
  1555   finally show ?thesis
  1556     by (simp add: F_def)
  1556     by (simp add: F_def)
  1557 qed
  1557 qed
  1558 
  1558 
  1559 section {* Distributions *}
  1559 subsection {* Integral under concrete measures *}
       
  1560 
       
  1561 subsubsection {* Distributions *}
  1560 
  1562 
  1561 lemma positive_integral_distr':
  1563 lemma positive_integral_distr':
  1562   assumes T: "T \<in> measurable M M'"
  1564   assumes T: "T \<in> measurable M M'"
  1563   and f: "f \<in> borel_measurable (distr M M' T)" "\<And>x. 0 \<le> f x"
  1565   and f: "f \<in> borel_measurable (distr M M' T)" "\<And>x. 0 \<le> f x"
  1564   shows "integral\<^sup>P (distr M M' T) f = (\<integral>\<^sup>+ x. f (T x) \<partial>M)"
  1566   shows "integral\<^sup>P (distr M M' T) f = (\<integral>\<^sup>+ x. f (T x) \<partial>M)"
  1585 lemma positive_integral_distr:
  1587 lemma positive_integral_distr:
  1586   "T \<in> measurable M M' \<Longrightarrow> f \<in> borel_measurable M' \<Longrightarrow> integral\<^sup>P (distr M M' T) f = (\<integral>\<^sup>+ x. f (T x) \<partial>M)"
  1588   "T \<in> measurable M M' \<Longrightarrow> f \<in> borel_measurable M' \<Longrightarrow> integral\<^sup>P (distr M M' T) f = (\<integral>\<^sup>+ x. f (T x) \<partial>M)"
  1587   by (subst (1 2) positive_integral_max_0[symmetric])
  1589   by (subst (1 2) positive_integral_max_0[symmetric])
  1588      (simp add: positive_integral_distr')
  1590      (simp add: positive_integral_distr')
  1589 
  1591 
  1590 section {* Lebesgue integration on @{const count_space} *}
  1592 subsubsection {* Counting space *}
  1591 
  1593 
  1592 lemma simple_function_count_space[simp]:
  1594 lemma simple_function_count_space[simp]:
  1593   "simple_function (count_space A) f \<longleftrightarrow> finite (f ` A)"
  1595   "simple_function (count_space A) f \<longleftrightarrow> finite (f ` A)"
  1594   unfolding simple_function_def by simp
  1596   unfolding simple_function_def by simp
  1595 
  1597 
  1664     finally show "(\<Sum>i. emeasure M (X x) * indicator {from_nat_into I i} x) = emeasure M (X x)" .
  1666     finally show "(\<Sum>i. emeasure M (X x) * indicator {from_nat_into I i} x) = emeasure M (X x)" .
  1665   qed
  1667   qed
  1666   finally show ?thesis .
  1668   finally show ?thesis .
  1667 qed
  1669 qed
  1668 
  1670 
  1669 section {* Measures with Restricted Space *}
  1671 subsubsection {* Measures with Restricted Space *}
  1670 
  1672 
  1671 lemma positive_integral_restrict_space:
  1673 lemma positive_integral_restrict_space:
  1672   assumes \<Omega>: "\<Omega> \<in> sets M" and f: "f \<in> borel_measurable M" "\<And>x. 0 \<le> f x" "\<And>x. x \<in> space M - \<Omega> \<Longrightarrow> f x = 0"
  1674   assumes \<Omega>: "\<Omega> \<in> sets M" and f: "f \<in> borel_measurable M" "\<And>x. 0 \<le> f x" "\<And>x. x \<in> space M - \<Omega> \<Longrightarrow> f x = 0"
  1673   shows "positive_integral (restrict_space M \<Omega>) f = positive_integral M f"
  1675   shows "positive_integral (restrict_space M \<Omega>) f = positive_integral M f"
  1674 using f proof (induct rule: borel_measurable_induct)
  1676 using f proof (induct rule: borel_measurable_induct)
  1694 next
  1696 next
  1695   case (seq F) then show ?case
  1697   case (seq F) then show ?case
  1696     by (auto simp add: SUP_eq_iff measurable_restrict_space1 \<Omega> positive_integral_monotone_convergence_SUP)
  1698     by (auto simp add: SUP_eq_iff measurable_restrict_space1 \<Omega> positive_integral_monotone_convergence_SUP)
  1697 qed
  1699 qed
  1698 
  1700 
  1699 section {* Measure spaces with an associated density *}
  1701 subsubsection {* Measure spaces with an associated density *}
  1700 
  1702 
  1701 definition density :: "'a measure \<Rightarrow> ('a \<Rightarrow> ereal) \<Rightarrow> 'a measure" where
  1703 definition density :: "'a measure \<Rightarrow> ('a \<Rightarrow> ereal) \<Rightarrow> 'a measure" where
  1702   "density M f = measure_of (space M) (sets M) (\<lambda>A. \<integral>\<^sup>+ x. f x * indicator A x \<partial>M)"
  1704   "density M f = measure_of (space M) (sets M) (\<lambda>A. \<integral>\<^sup>+ x. f x * indicator A x \<partial>M)"
  1703 
  1705 
  1704 lemma 
  1706 lemma 
  1916     using f g ac by (auto intro!: density_cong measurable_If)
  1918     using f g ac by (auto intro!: density_cong measurable_If)
  1917   then show ?thesis
  1919   then show ?thesis
  1918     using f g by (subst density_density_eq) auto
  1920     using f g by (subst density_density_eq) auto
  1919 qed
  1921 qed
  1920 
  1922 
  1921 section {* Point measure *}
  1923 subsubsection {* Point measure *}
  1922 
  1924 
  1923 definition point_measure :: "'a set \<Rightarrow> ('a \<Rightarrow> ereal) \<Rightarrow> 'a measure" where
  1925 definition point_measure :: "'a set \<Rightarrow> ('a \<Rightarrow> ereal) \<Rightarrow> 'a measure" where
  1924   "point_measure A f = density (count_space A) f"
  1926   "point_measure A f = density (count_space A) f"
  1925 
  1927 
  1926 lemma
  1928 lemma
  1989 lemma positive_integral_point_measure_finite:
  1991 lemma positive_integral_point_measure_finite:
  1990   "finite A \<Longrightarrow> (\<And>a. a \<in> A \<Longrightarrow> 0 \<le> f a) \<Longrightarrow> (\<And>a. a \<in> A \<Longrightarrow> 0 \<le> g a) \<Longrightarrow>
  1992   "finite A \<Longrightarrow> (\<And>a. a \<in> A \<Longrightarrow> 0 \<le> f a) \<Longrightarrow> (\<And>a. a \<in> A \<Longrightarrow> 0 \<le> g a) \<Longrightarrow>
  1991     integral\<^sup>P (point_measure A f) g = (\<Sum>a\<in>A. f a * g a)"
  1993     integral\<^sup>P (point_measure A f) g = (\<Sum>a\<in>A. f a * g a)"
  1992   by (subst positive_integral_point_measure) (auto intro!: setsum_mono_zero_left simp: less_le)
  1994   by (subst positive_integral_point_measure) (auto intro!: setsum_mono_zero_left simp: less_le)
  1993 
  1995 
  1994 section {* Uniform measure *}
  1996 subsubsection {* Uniform measure *}
  1995 
  1997 
  1996 definition "uniform_measure M A = density M (\<lambda>x. indicator A x / emeasure M A)"
  1998 definition "uniform_measure M A = density M (\<lambda>x. indicator A x / emeasure M A)"
  1997 
  1999 
  1998 lemma
  2000 lemma
  1999   shows sets_uniform_measure[simp]: "sets (uniform_measure M A) = sets M"
  2001   shows sets_uniform_measure[simp]: "sets (uniform_measure M A) = sets M"
  2017   assumes A: "emeasure M A \<noteq> 0" "emeasure M A \<noteq> \<infinity>" and B: "B \<in> sets M"
  2019   assumes A: "emeasure M A \<noteq> 0" "emeasure M A \<noteq> \<infinity>" and B: "B \<in> sets M"
  2018   shows "measure (uniform_measure M A) B = measure M (A \<inter> B) / measure M A"
  2020   shows "measure (uniform_measure M A) B = measure M (A \<inter> B) / measure M A"
  2019   using emeasure_uniform_measure[OF emeasure_neq_0_sets[OF A(1)] B] A
  2021   using emeasure_uniform_measure[OF emeasure_neq_0_sets[OF A(1)] B] A
  2020   by (cases "emeasure M A" "emeasure M (A \<inter> B)" rule: ereal2_cases) (simp_all add: measure_def)
  2022   by (cases "emeasure M A" "emeasure M (A \<inter> B)" rule: ereal2_cases) (simp_all add: measure_def)
  2021 
  2023 
  2022 section {* Uniform count measure *}
  2024 subsubsection {* Uniform count measure *}
  2023 
  2025 
  2024 definition "uniform_count_measure A = point_measure A (\<lambda>x. 1 / card A)"
  2026 definition "uniform_count_measure A = point_measure A (\<lambda>x. 1 / card A)"
  2025  
  2027  
  2026 lemma 
  2028 lemma 
  2027   shows space_uniform_count_measure: "space (uniform_count_measure A) = A"
  2029   shows space_uniform_count_measure: "space (uniform_count_measure A) = A"