src/HOL/Library/Indicator_Function.thy
author haftmann
Sat, 28 Jun 2014 21:09:17 +0200
changeset 57427 91f9e4148460
parent 57418 6ab1c7cb0b8d
child 57446 06e195515deb
permissions -rw-r--r--
proper trading of variables; more appropriate ML variable names
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37665
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
     1
(*  Title:      HOL/Library/Indicator_Function.thy
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
     2
    Author:     Johannes Hoelzl (TU Muenchen)
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
     3
*)
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
     4
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
     5
header {* Indicator Function *}
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
     6
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
     7
theory Indicator_Function
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 54408
diff changeset
     8
imports Complex_Main
37665
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
     9
begin
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    10
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    11
definition "indicator S x = (if x \<in> S then 1 else 0)"
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    12
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    13
lemma indicator_simps[simp]:
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    14
  "x \<in> S \<Longrightarrow> indicator S x = 1"
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    15
  "x \<notin> S \<Longrightarrow> indicator S x = 0"
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    16
  unfolding indicator_def by auto
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    17
45425
7fee7d7abf2f avoid inconsistent sort constraints;
wenzelm
parents: 37665
diff changeset
    18
lemma indicator_pos_le[intro, simp]: "(0::'a::linordered_semidom) \<le> indicator S x"
37665
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    19
  and indicator_le_1[intro, simp]: "indicator S x \<le> (1::'a::linordered_semidom)"
45425
7fee7d7abf2f avoid inconsistent sort constraints;
wenzelm
parents: 37665
diff changeset
    20
  unfolding indicator_def by auto
7fee7d7abf2f avoid inconsistent sort constraints;
wenzelm
parents: 37665
diff changeset
    21
7fee7d7abf2f avoid inconsistent sort constraints;
wenzelm
parents: 37665
diff changeset
    22
lemma indicator_abs_le_1: "\<bar>indicator S x\<bar> \<le> (1::'a::linordered_idom)"
37665
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    23
  unfolding indicator_def by auto
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    24
54408
67dec4ccaabd equation when indicator function equals 0 or 1
hoelzl
parents: 45425
diff changeset
    25
lemma indicator_eq_0_iff: "indicator A x = (0::_::zero_neq_one) \<longleftrightarrow> x \<notin> A"
67dec4ccaabd equation when indicator function equals 0 or 1
hoelzl
parents: 45425
diff changeset
    26
  by (auto simp: indicator_def)
67dec4ccaabd equation when indicator function equals 0 or 1
hoelzl
parents: 45425
diff changeset
    27
67dec4ccaabd equation when indicator function equals 0 or 1
hoelzl
parents: 45425
diff changeset
    28
lemma indicator_eq_1_iff: "indicator A x = (1::_::zero_neq_one) \<longleftrightarrow> x \<in> A"
67dec4ccaabd equation when indicator function equals 0 or 1
hoelzl
parents: 45425
diff changeset
    29
  by (auto simp: indicator_def)
67dec4ccaabd equation when indicator function equals 0 or 1
hoelzl
parents: 45425
diff changeset
    30
37665
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    31
lemma split_indicator:
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    32
  "P (indicator S x) \<longleftrightarrow> ((x \<in> S \<longrightarrow> P 1) \<and> (x \<notin> S \<longrightarrow> P 0))"
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    33
  unfolding indicator_def by auto
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    34
45425
7fee7d7abf2f avoid inconsistent sort constraints;
wenzelm
parents: 37665
diff changeset
    35
lemma indicator_inter_arith: "indicator (A \<inter> B) x = indicator A x * (indicator B x::'a::semiring_1)"
7fee7d7abf2f avoid inconsistent sort constraints;
wenzelm
parents: 37665
diff changeset
    36
  unfolding indicator_def by (auto simp: min_def max_def)
7fee7d7abf2f avoid inconsistent sort constraints;
wenzelm
parents: 37665
diff changeset
    37
7fee7d7abf2f avoid inconsistent sort constraints;
wenzelm
parents: 37665
diff changeset
    38
lemma indicator_union_arith: "indicator (A \<union> B) x =  indicator A x + indicator B x - indicator A x * (indicator B x::'a::ring_1)"
7fee7d7abf2f avoid inconsistent sort constraints;
wenzelm
parents: 37665
diff changeset
    39
  unfolding indicator_def by (auto simp: min_def max_def)
7fee7d7abf2f avoid inconsistent sort constraints;
wenzelm
parents: 37665
diff changeset
    40
7fee7d7abf2f avoid inconsistent sort constraints;
wenzelm
parents: 37665
diff changeset
    41
lemma indicator_inter_min: "indicator (A \<inter> B) x = min (indicator A x) (indicator B x::'a::linordered_semidom)"
37665
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    42
  and indicator_union_max: "indicator (A \<union> B) x = max (indicator A x) (indicator B x::'a::linordered_semidom)"
45425
7fee7d7abf2f avoid inconsistent sort constraints;
wenzelm
parents: 37665
diff changeset
    43
  unfolding indicator_def by (auto simp: min_def max_def)
7fee7d7abf2f avoid inconsistent sort constraints;
wenzelm
parents: 37665
diff changeset
    44
7fee7d7abf2f avoid inconsistent sort constraints;
wenzelm
parents: 37665
diff changeset
    45
lemma indicator_compl: "indicator (- A) x = 1 - (indicator A x::'a::ring_1)"
37665
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    46
  and indicator_diff: "indicator (A - B) x = indicator A x * (1 - indicator B x::'a::ring_1)"
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    47
  unfolding indicator_def by (auto simp: min_def max_def)
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    48
45425
7fee7d7abf2f avoid inconsistent sort constraints;
wenzelm
parents: 37665
diff changeset
    49
lemma indicator_times: "indicator (A \<times> B) x = indicator A (fst x) * (indicator B (snd x)::'a::semiring_1)"
37665
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    50
  unfolding indicator_def by (cases x) auto
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    51
45425
7fee7d7abf2f avoid inconsistent sort constraints;
wenzelm
parents: 37665
diff changeset
    52
lemma indicator_sum: "indicator (A <+> B) x = (case x of Inl x \<Rightarrow> indicator A x | Inr x \<Rightarrow> indicator B x)"
37665
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    53
  unfolding indicator_def by (cases x) auto
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    54
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    55
lemma
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    56
  fixes f :: "'a \<Rightarrow> 'b::semiring_1" assumes "finite A"
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    57
  shows setsum_mult_indicator[simp]: "(\<Sum>x \<in> A. f x * indicator B x) = (\<Sum>x \<in> A \<inter> B. f x)"
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    58
  and setsum_indicator_mult[simp]: "(\<Sum>x \<in> A. indicator B x * f x) = (\<Sum>x \<in> A \<inter> B. f x)"
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    59
  unfolding indicator_def
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56993
diff changeset
    60
  using assms by (auto intro!: setsum.mono_neutral_cong_right split: split_if_asm)
37665
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    61
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    62
lemma setsum_indicator_eq_card:
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    63
  assumes "finite A"
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    64
  shows "(SUM x : A. indicator B x) = card (A Int B)"
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    65
  using setsum_mult_indicator[OF assms, of "%x. 1::nat"]
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    66
  unfolding card_eq_setsum by simp
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    67
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 54408
diff changeset
    68
lemma setsum_indicator_scaleR[simp]:
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 54408
diff changeset
    69
  "finite A \<Longrightarrow>
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 54408
diff changeset
    70
    (\<Sum>x \<in> A. indicator (B x) (g x) *\<^sub>R f x) = (\<Sum>x \<in> {x\<in>A. g x \<in> B x}. f x::'a::real_vector)"
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 56993
diff changeset
    71
  using assms by (auto intro!: setsum.mono_neutral_cong_right split: split_if_asm simp: indicator_def)
56993
e5366291d6aa introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
hoelzl
parents: 54408
diff changeset
    72
37665
579258a77fec Add theory for indicator function.
hoelzl
parents:
diff changeset
    73
end