# HG changeset patch # User hoelzl # Date 1421402355 -3600 # Node ID 854fe701c9843dbd4052a5fb882c4f377fe6d678 # Parent eb3d8e7b4b219bf8fdc429636706de5cf7dabc9e tuned measurability proofs diff -r eb3d8e7b4b21 -r 854fe701c984 src/HOL/Probability/Borel_Space.thy --- a/src/HOL/Probability/Borel_Space.thy Mon Jan 19 21:54:56 2015 +0100 +++ b/src/HOL/Probability/Borel_Space.thy Fri Jan 16 10:59:15 2015 +0100 @@ -218,11 +218,10 @@ by (drule borel_measurable_continuous_on_restrict) simp lemma borel_measurable_continuous_on_if: - assumes [measurable]: "A \ sets borel" and f: "continuous_on A f" and g: "continuous_on (- A) g" - shows "(\x. if x \ A then f x else g x) \ borel_measurable borel" - by (rule measurable_piecewise_restrict[where - X="\b. if b then A else - A" and I=UNIV and f="\b x. if b then f x else g x"]) - (auto intro: f g borel_measurable_continuous_on_restrict) + "A \ sets borel \ continuous_on A f \ continuous_on (- A) g \ + (\x. if x \ A then f x else g x) \ borel_measurable borel" + by (auto simp add: measurable_If_restrict_space_iff Collect_neg_eq + intro!: borel_measurable_continuous_on_restrict) lemma borel_measurable_continuous_countable_exceptions: fixes f :: "'a::t1_space \ 'b::topological_space" @@ -241,26 +240,11 @@ shows "(\x. f (g x)) \ borel_measurable M" using measurable_comp[OF g borel_measurable_continuous_on1[OF f]] by (simp add: comp_def) -lemma borel_measurable_continuous_on_open': - "continuous_on A f \ open A \ - (\x. if x \ A then f x else c) \ borel_measurable borel" - using borel_measurable_continuous_on_if[of A f "\_. c"] by (auto intro: continuous_on_const) - -lemma borel_measurable_continuous_on_open: - fixes f :: "'a::topological_space \ 'b::t1_space" - assumes cont: "continuous_on A f" "open A" - assumes g: "g \ borel_measurable M" - shows "(\x. if g x \ A then f (g x) else c) \ borel_measurable M" - using measurable_comp[OF g borel_measurable_continuous_on_open'[OF cont], of c] - by (simp add: comp_def) - lemma borel_measurable_continuous_on_indicator: fixes f g :: "'a::topological_space \ 'b::real_normed_vector" - assumes A: "A \ sets borel" and f: "continuous_on A f" - shows "(\x. indicator A x *\<^sub>R f x) \ borel_measurable borel" - using borel_measurable_continuous_on_if[OF assms, of "\_. 0"] - by (simp add: indicator_def if_distrib[where f="\x. x *\<^sub>R a" for a] continuous_on_const - cong del: if_cong) + shows "A \ sets borel \ continuous_on A f \ (\x. indicator A x *\<^sub>R f x) \ borel_measurable borel" + by (subst borel_measurable_restrict_space_iff[symmetric]) + (auto intro: borel_measurable_continuous_on_restrict) lemma borel_eq_countable_basis: fixes B::"'a::topological_space set set" @@ -1046,21 +1030,11 @@ by (simp add: cart_eq_inner_axis) lemma convex_measurable: - fixes A :: "'a :: ordered_euclidean_space set" - assumes X: "X \ borel_measurable M" "X ` space M \ A" "open A" - assumes q: "convex_on A q" - shows "(\x. q (X x)) \ borel_measurable M" -proof - - have "(\x. if X x \ A then q (X x) else 0) \ borel_measurable M" (is "?qX") - proof (rule borel_measurable_continuous_on_open[OF _ _ X(1)]) - show "open A" by fact - from this q show "continuous_on A q" - by (rule convex_on_continuous) - qed - also have "?qX \ (\x. q (X x)) \ borel_measurable M" - using X by (intro measurable_cong) auto - finally show ?thesis . -qed + fixes A :: "'a :: euclidean_space set" + shows "X \ borel_measurable M \ X ` space M \ A \ open A \ convex_on A q \ + (\x. q (X x)) \ borel_measurable M" + by (rule measurable_compose[where f=X and N="restrict_space borel A"]) + (auto intro!: borel_measurable_continuous_on_restrict convex_on_continuous measurable_restrict_space2) lemma borel_measurable_ln[measurable (raw)]: assumes f: "f \ borel_measurable M" @@ -1102,17 +1076,17 @@ "f \ borel_measurable M \ (\x. real (natfloor (f x))) \ borel_measurable M" by simp -lemma borel_measurable_root [measurable]: "(root n) \ borel_measurable borel" +lemma borel_measurable_root [measurable]: "root n \ borel_measurable borel" by (intro borel_measurable_continuous_on1 continuous_intros) lemma borel_measurable_sqrt [measurable]: "sqrt \ borel_measurable borel" by (intro borel_measurable_continuous_on1 continuous_intros) lemma borel_measurable_power [measurable (raw)]: - fixes f :: "_ \ 'b::{power,real_normed_algebra}" - assumes f: "f \ borel_measurable M" - shows "(\x. (f x) ^ n) \ borel_measurable M" - by (intro borel_measurable_continuous_on [OF _ f] continuous_intros) + fixes f :: "_ \ 'b::{power,real_normed_algebra}" + assumes f: "f \ borel_measurable M" + shows "(\x. (f x) ^ n) \ borel_measurable M" + by (intro borel_measurable_continuous_on [OF _ f] continuous_intros) lemma borel_measurable_Re [measurable]: "Re \ borel_measurable borel" by (intro borel_measurable_continuous_on1 continuous_intros) @@ -1490,7 +1464,7 @@ have **: "\e y. open {x. dist x y < e}" using open_ball by (simp_all add: ball_def dist_commute) - have "{x\space borel. isCont f x } \ sets borel" + have "{x\space borel. isCont f x} \ sets borel" unfolding * apply (intro sets.sets_Collect_countable_All sets.sets_Collect_countable_Ex) apply (simp add: Collect_all_eq) diff -r eb3d8e7b4b21 -r 854fe701c984 src/HOL/Probability/Sigma_Algebra.thy --- a/src/HOL/Probability/Sigma_Algebra.thy Mon Jan 19 21:54:56 2015 +0100 +++ b/src/HOL/Probability/Sigma_Algebra.thy Fri Jan 16 10:59:15 2015 +0100 @@ -1858,6 +1858,11 @@ definition measurable :: "'a measure \ 'b measure \ ('a \ 'b) set" where "measurable A B = {f \ space A -> space B. \y \ sets B. f -` y \ space A \ sets A}" +lemma measurableI: + "(\x. x \ space M \ f x \ space N) \ (\A. A \ sets N \ f -` A \ space M \ sets M) \ + f \ measurable M N" + by (auto simp: measurable_def) + lemma measurable_space: "f \ measurable M A \ x \ space M \ f x \ space A" unfolding measurable_def by auto @@ -1926,11 +1931,17 @@ using sets[THEN sets_eq_imp_space_eq] sets by (simp add: measurable_def) lemma measurable_cong: - assumes "\ w. w \ space M \ f w = g w" + assumes "\w. w \ space M \ f w = g w" shows "f \ measurable M M' \ g \ measurable M M'" unfolding measurable_def using assms by (simp cong: vimage_inter_cong Pi_cong) +lemma measurable_cong': + assumes "\w. w \ space M =simp=> f w = g w" + shows "f \ measurable M M' \ g \ measurable M M'" + unfolding measurable_def using assms + by (simp cong: vimage_inter_cong Pi_cong add: simp_implies_def) + lemma measurable_cong_strong: "M = N \ M' = N' \ (\w. w \ space M \ f w = g w) \ f \ measurable M M' \ g \ measurable N N'" @@ -1955,35 +1966,6 @@ "c \ space M' \ (\x. c) \ measurable M M'" by (auto simp add: measurable_def) -lemma measurable_If: - assumes measure: "f \ measurable M M'" "g \ measurable M M'" - assumes P: "{x\space M. P x} \ sets M" - shows "(\x. if P x then f x else g x) \ measurable M M'" - unfolding measurable_def -proof safe - fix x assume "x \ space M" - thus "(if P x then f x else g x) \ space M'" - using measure unfolding measurable_def by auto -next - fix A assume "A \ sets M'" - hence *: "(\x. if P x then f x else g x) -` A \ space M = - ((f -` A \ space M) \ {x\space M. P x}) \ - ((g -` A \ space M) \ (space M - {x\space M. P x}))" - using measure unfolding measurable_def by (auto split: split_if_asm) - show "(\x. if P x then f x else g x) -` A \ space M \ sets M" - using `A \ sets M'` measure P unfolding * measurable_def - by (auto intro!: sets.Un) -qed - -lemma measurable_If_set: - assumes measure: "f \ measurable M M'" "g \ measurable M M'" - assumes P: "A \ space M \ sets M" - shows "(\x. if x \ A then f x else g x) \ measurable M M'" -proof (rule measurable_If[OF measure]) - have "{x \ space M. x \ A} = A \ space M" by auto - thus "{x \ space M. x \ A} \ sets M" using `A \ space M \ sets M` by auto -qed - lemma measurable_ident: "id \ measurable M M" by (auto simp add: measurable_def) @@ -2028,46 +2010,6 @@ ultimately show ?thesis by auto qed -lemma measurable_strong: - fixes f :: "'a \ 'b" and g :: "'b \ 'c" - assumes f: "f \ measurable a b" and g: "g \ space b \ space c" - and t: "f ` (space a) \ t" - and cb: "\s. s \ sets c \ (g -` s) \ t \ sets b" - shows "(g o f) \ measurable a c" -proof - - have fab: "f \ (space a -> space b)" - and ba: "\y. y \ sets b \ (f -` y) \ (space a) \ sets a" using f - by (auto simp add: measurable_def) - have eq: "\y. (g \ f) -` y \ space a = f -` (g -` y \ t) \ space a" using t - by force - show ?thesis - apply (auto simp add: measurable_def vimage_comp) - apply (metis funcset_mem fab g) - apply (subst eq) - apply (metis ba cb) - done -qed - -lemma measurable_discrete_difference: - assumes f: "f \ measurable M N" - assumes X: "countable X" - assumes sets: "\x. x \ X \ {x} \ sets M" - assumes space: "\x. x \ X \ g x \ space N" - assumes eq: "\x. x \ space M \ x \ X \ f x = g x" - shows "g \ measurable M N" - unfolding measurable_def -proof safe - fix x assume "x \ space M" then show "g x \ space N" - using measurable_space[OF f, of x] eq[of x] space[of x] by (cases "x \ X") auto -next - fix S assume S: "S \ sets N" - have "g -` S \ space M = (f -` S \ space M) - (\x\X. {x}) \ (\x\{x\X. g x \ S}. {x})" - using sets.sets_into_space[OF sets] eq by auto - also have "\ \ sets M" - by (safe intro!: sets.Diff sets.Un measurable_sets[OF f] S sets.countable_UN' X countable_Collect sets) - finally show "g -` S \ space M \ sets M" . -qed - lemma measurable_mono1: "M' \ Pow \ \ M \ M' \ measurable (measure_of \ M \) N \ measurable (measure_of \ M' \') N" @@ -2088,35 +2030,6 @@ "f \ measurable (count_space A) M \ f \ A \ space M" unfolding measurable_def by simp -lemma measurable_count_space_eq2: - assumes "finite A" - shows "f \ measurable M (count_space A) \ (f \ space M \ A \ (\a\A. f -` {a} \ space M \ sets M))" -proof - - { fix X assume "X \ A" "f \ space M \ A" - with `finite A` have "f -` X \ space M = (\a\X. f -` {a} \ space M)" "finite X" - by (auto dest: finite_subset) - moreover assume "\a\A. f -` {a} \ space M \ sets M" - ultimately have "f -` X \ space M \ sets M" - using `X \ A` by (auto intro!: sets.finite_UN simp del: UN_simps) } - then show ?thesis - unfolding measurable_def by auto -qed - -lemma measurable_count_space_eq2_countable: - fixes f :: "'a => 'c::countable" - shows "f \ measurable M (count_space A) \ (f \ space M \ A \ (\a\A. f -` {a} \ space M \ sets M))" -proof - - { fix X assume "X \ A" "f \ space M \ A" - assume *: "\a. a\A \ f -` {a} \ space M \ sets M" - have "f -` X \ space M = (\a\X. f -` {a} \ space M)" - by auto - also have "\ \ sets M" - using * `X \ A` by (intro sets.countable_UN) auto - finally have "f -` X \ space M \ sets M" . } - then show ?thesis - unfolding measurable_def by auto -qed - lemma measurable_compose_countable': assumes f: "\i. i \ I \ (\x. f i x) \ measurable M N" and g: "g \ measurable M (count_space I)" and I: "countable I" @@ -2129,31 +2042,12 @@ fix A assume A: "A \ sets N" have "(\x. f (g x) x) -` A \ space M = (\i\I. (g -` {i} \ space M) \ (f i -` A \ space M))" using measurable_space[OF g] by auto - also have "\ \ sets M" using f[THEN measurable_sets, OF _ A] g[THEN measurable_sets] - apply (auto intro!: sets.countable_UN' measurable_sets I) - apply (rule sets.Int) - apply auto - done + also have "\ \ sets M" + using f[THEN measurable_sets, OF _ A] g[THEN measurable_sets] + by (auto intro!: sets.countable_UN' I intro: sets.Int[OF measurable_sets measurable_sets]) finally show "(\x. f (g x) x) -` A \ space M \ sets M" . qed -lemma measurable_compose_countable: - assumes f: "\i::'i::countable. (\x. f i x) \ measurable M N" and g: "g \ measurable M (count_space UNIV)" - shows "(\x. f (g x) x) \ measurable M N" - by (rule measurable_compose_countable'[OF assms]) auto -lemma measurable_count_space_const: - "(\x. c) \ measurable M (count_space UNIV)" - by (simp add: measurable_const) - -lemma measurable_count_space: - "f \ measurable (count_space A) (count_space UNIV)" - by simp - -lemma measurable_compose_rev: - assumes f: "f \ measurable L N" and g: "g \ measurable M L" - shows "(\x. f (g x)) \ measurable M N" - using measurable_compose[OF g f] . - lemma measurable_count_space_eq_countable: assumes "countable A" shows "f \ measurable M (count_space A) \ (f \ space M \ A \ (\a\A. f -` {a} \ space M \ sets M))" @@ -2168,6 +2062,33 @@ unfolding measurable_def by auto qed +lemma measurable_count_space_eq2: + "finite A \ f \ measurable M (count_space A) \ (f \ space M \ A \ (\a\A. f -` {a} \ space M \ sets M))" + by (intro measurable_count_space_eq_countable countable_finite) + +lemma measurable_count_space_eq2_countable: + fixes f :: "'a => 'c::countable" + shows "f \ measurable M (count_space A) \ (f \ space M \ A \ (\a\A. f -` {a} \ space M \ sets M))" + by (intro measurable_count_space_eq_countable countableI_type) + +lemma measurable_compose_countable: + assumes f: "\i::'i::countable. (\x. f i x) \ measurable M N" and g: "g \ measurable M (count_space UNIV)" + shows "(\x. f (g x) x) \ measurable M N" + by (rule measurable_compose_countable'[OF assms]) auto + +lemma measurable_count_space_const: + "(\x. c) \ measurable M (count_space UNIV)" + by (simp add: measurable_const) + +lemma measurable_count_space: + "f \ measurable (count_space A) (count_space UNIV)" + by simp + +lemma measurable_compose_rev: + assumes f: "f \ measurable L N" and g: "g \ measurable M L" + shows "(\x. f (g x)) \ measurable M N" + using measurable_compose[OF g f] . + lemma measurable_empty_iff: "space N = {} \ f \ measurable M N \ space M = {}" by (auto simp add: measurable_def Pi_iff) @@ -2443,6 +2364,10 @@ lemma sets_restrict_UNIV[simp]: "sets (restrict_space M UNIV) = sets M" by (auto simp add: sets_restrict_space) +lemma sets_restrict_restrict_space: + "sets (restrict_space (restrict_space M A) B) = sets (restrict_space M (A \ B))" + unfolding sets_restrict_space image_comp by (intro image_cong) auto + lemma sets_restrict_space_iff: "\ \ space M \ sets M \ A \ sets (restrict_space M \) \ (A \ \ \ A \ sets M)" proof (subst sets_restrict_space, safe) @@ -2477,91 +2402,110 @@ qed lemma measurable_restrict_space1: - assumes \: "\ \ space M \ sets M" and f: "f \ measurable M N" + assumes f: "f \ measurable M N" shows "f \ measurable (restrict_space M \) N" unfolding measurable_def proof (intro CollectI conjI ballI) show sp: "f \ space (restrict_space M \) \ space N" - using measurable_space[OF f] sets.sets_into_space[OF \] by (auto simp: space_restrict_space) + using measurable_space[OF f] by (auto simp: space_restrict_space) fix A assume "A \ sets N" have "f -` A \ space (restrict_space M \) = (f -` A \ space M) \ (\ \ space M)" - using sets.sets_into_space[OF \] by (auto simp: space_restrict_space) + by (auto simp: space_restrict_space) also have "\ \ sets (restrict_space M \)" - unfolding sets_restrict_space_iff[OF \] - using measurable_sets[OF f `A \ sets N`] \ by blast + unfolding sets_restrict_space + using measurable_sets[OF f `A \ sets N`] by blast finally show "f -` A \ space (restrict_space M \) \ sets (restrict_space M \)" . qed +lemma measurable_restrict_space2_iff: + "f \ measurable M (restrict_space N \) \ (f \ measurable M N \ f \ space M \ \)" +proof - + have "\A. f \ space M \ \ \ f -` \ \ f -` A \ space M = f -` A \ space M" + by auto + then show ?thesis + by (auto simp: measurable_def space_restrict_space Pi_Int[symmetric] sets_restrict_space) +qed + lemma measurable_restrict_space2: - "\ \ space N \ sets N \ f \ space M \ \ \ f \ measurable M N \ - f \ measurable M (restrict_space N \)" - by (simp add: measurable_def space_restrict_space sets_restrict_space_iff Pi_Int[symmetric]) + "f \ space M \ \ \ f \ measurable M N \ f \ measurable M (restrict_space N \)" + by (simp add: measurable_restrict_space2_iff) -lemma measurable_restrict_space_iff: - assumes \[simp, intro]: "\ \ space M \ sets M" "c \ space N" - shows "f \ measurable (restrict_space M \) N \ - (\x. if x \ \ then f x else c) \ measurable M N" (is "f \ measurable ?R N \ ?f \ measurable M N") - unfolding measurable_def -proof safe - fix x assume "f \ space ?R \ space N" "x \ space M" then show "?f x \ space N" - using `c\space N` by (auto simp: space_restrict_space) -next - fix x assume "?f \ space M \ space N" "x \ space ?R" then show "f x \ space N" - using `c\space N` by (auto simp: space_restrict_space Pi_iff) +lemma measurable_piecewise_restrict: + assumes I: "countable C" + and X: "\\. \ \ C \ \ \ space M \ sets M" "space M \ \C" + and f: "\\. \ \ C \ f \ measurable (restrict_space M \) N" + shows "f \ measurable M N" +proof (rule measurableI) + fix x assume "x \ space M" + with X obtain \ where "\ \ C" "x \ \" "x \ space M" by auto + then show "f x \ space N" + by (auto simp: space_restrict_space intro: f measurable_space) next - fix X assume X: "X \ sets N" - assume *[THEN bspec]: "\y\sets N. f -` y \ space ?R \ sets ?R" - have "?f -` X \ space M = (f -` X \ (\ \ space M)) \ (if c \ X then (space M - (\ \ space M)) else {})" - by (auto split: split_if_asm) + fix A assume A: "A \ sets N" + have "f -` A \ space M = (\\\C. (f -` A \ (\ \ space M)))" + using X by (auto simp: subset_eq) also have "\ \ sets M" - using *[OF X] by (auto simp add: space_restrict_space sets_restrict_space_iff) - finally show "?f -` X \ space M \ sets M" . -next - assume *[THEN bspec]: "\y\sets N. ?f -` y \ space M \ sets M" - fix X :: "'b set" assume X: "X \ sets N" - have "f -` X \ (\ \ space M) = (?f -` X \ space M) \ (\ \ space M)" - by (auto simp: space_restrict_space) - also have "\ \ sets M" - using *[OF X] by auto - finally show "f -` X \ space ?R \ sets ?R" - by (auto simp add: sets_restrict_space_iff space_restrict_space) + using measurable_sets[OF f A] X I + by (intro sets.countable_UN') (auto simp: sets_restrict_space_iff space_restrict_space) + finally show "f -` A \ space M \ sets M" . qed -lemma measurableI: - "(\x. x \ space M \ f x \ space N) \ - (\A. A \ sets N \ f -` A \ space M \ sets M) \ - f \ measurable M N" - by (auto simp: measurable_def) +lemma measurable_piecewise_restrict_iff: + "countable C \ (\\. \ \ C \ \ \ space M \ sets M) \ space M \ (\C) \ + f \ measurable M N \ (\\\C. f \ measurable (restrict_space M \) N)" + by (auto intro: measurable_piecewise_restrict measurable_restrict_space1) + +lemma measurable_If_restrict_space_iff: + "{x\space M. P x} \ sets M \ + (\x. if P x then f x else g x) \ measurable M N \ + (f \ measurable (restrict_space M {x. P x}) N \ g \ measurable (restrict_space M {x. \ P x}) N)" + by (subst measurable_piecewise_restrict_iff[where C="{{x. P x}, {x. \ P x}}"]) + (auto simp: Int_def sets.sets_Collect_neg space_restrict_space conj_commute[of _ "x \ space M" for x] + cong: measurable_cong') + +lemma measurable_If: + "f \ measurable M M' \ g \ measurable M M' \ {x\space M. P x} \ sets M \ + (\x. if P x then f x else g x) \ measurable M M'" + unfolding measurable_If_restrict_space_iff by (auto intro: measurable_restrict_space1) + +lemma measurable_If_set: + assumes measure: "f \ measurable M M'" "g \ measurable M M'" + assumes P: "A \ space M \ sets M" + shows "(\x. if x \ A then f x else g x) \ measurable M M'" +proof (rule measurable_If[OF measure]) + have "{x \ space M. x \ A} = A \ space M" by auto + thus "{x \ space M. x \ A} \ sets M" using `A \ space M \ sets M` by auto +qed -lemma measurable_piecewise_restrict: - assumes I: "countable I" and X: "\i. i \ I \ X i \ sets M" "(\i\I. X i) = space M" - and meas: "\i. i \ I \ f i \ measurable (restrict_space M (X i)) N" - and eq: "\i x. i \ I \ x \ X i \ f i x = f' x" - shows "f' \ measurable M N" -proof (rule measurableI) - fix x assume "x \ space M" - then obtain i where "i \ I" "x \ X i" - using X by auto - then show "f' x \ space N" - using eq[of i x] meas[THEN measurable_space, of i x] `x \ space M` - by (auto simp: space_restrict_space) -next - fix A assume A: "A \ sets N" - have "f' -` A \ space M = {x \ space M. \i\I. x \ X i \ f i x \ A}" - by (auto simp: eq X(2)[symmetric]) - also have "\ \ sets M" - proof (intro sets.sets_Collect_countable_All'[OF _ I]) - fix i assume "i \ I" - then have "(f i -` A \ X i) \ (space M - X i) \ sets M" - using meas[THEN measurable_sets, OF `i \ I` A] X(1) - by (subst (asm) sets_restrict_space_iff) (auto simp: space_restrict_space) - also have "(f i -` A \ X i) \ (space M - X i) = {x \ space M. x \ X i \ f i x \ A}" - using `i \ I` by (auto simp: X(2)[symmetric]) - finally show "{x \ space M. x \ X i \ f i x \ A} \ sets M" . - qed - finally show "f' -` A \ space M \ sets M" . -qed +lemma measurable_restrict_space_iff: + "\ \ space M \ sets M \ c \ space N \ + f \ measurable (restrict_space M \) N \ (\x. if x \ \ then f x else c) \ measurable M N" + by (subst measurable_If_restrict_space_iff) + (simp_all add: Int_def conj_commute measurable_const) + +lemma restrict_space_singleton: "{x} \ sets M \ sets (restrict_space M {x}) = sets (count_space {x})" + using sets_restrict_space_iff[of "{x}" M] + by (auto simp add: sets_restrict_space_iff dest!: subset_singletonD) + +lemma measurable_restrict_countable: + assumes X[intro]: "countable X" + assumes sets[simp]: "\x. x \ X \ {x} \ sets M" + assumes space[simp]: "\x. x \ X \ f x \ space N" + assumes f: "f \ measurable (restrict_space M (- X)) N" + shows "f \ measurable M N" + using f sets.countable[OF sets X] + by (intro measurable_piecewise_restrict[where M=M and C="{- X} \ ((\x. {x}) ` X)"]) + (auto simp: Diff_Int_distrib2 Compl_eq_Diff_UNIV Int_insert_left sets.Diff restrict_space_singleton + simp del: sets_count_space cong: measurable_cong_sets) + +lemma measurable_discrete_difference: + assumes f: "f \ measurable M N" + assumes X: "countable X" "\x. x \ X \ {x} \ sets M" "\x. x \ X \ g x \ space N" + assumes eq: "\x. x \ space M \ x \ X \ f x = g x" + shows "g \ measurable M N" + by (rule measurable_restrict_countable[OF X]) + (auto simp: eq[symmetric] space_restrict_space cong: measurable_cong' intro: f measurable_restrict_space1) end