@@ -5,8 +5,8 @@ Authors: David Ledvinka
55-/
66module
77
8- public import Mathlib.Control.Random
9- public import Mathlib.MeasureTheory.Measure.GiryMonad
8+ public import Mathlib.MeasureTheory.MeasurableSpace.Constructions
9+ public import Mathlib.Tactic.FunProp
1010
1111/-!
1212# Measurable space monads
@@ -26,12 +26,10 @@ instance.
2626 `MeasurableSpaceFunctor` satisfies the laws of a functor on measurable spaces.
2727* `LawfulMeasurableSpaceMonad`: A `Prop`-valued typeclass which states that a given
2828 `MeasurableSpaceMonad` satisfies the laws of a monad on measurable spaces.
29- * `MeasurableSpaceForIn`: **TODO**
30- * `MeasurableSpaceForIn'`: **TODO**
3129
3230## Notation
3331
34- The following notation is available:
32+ The following notation is available in the `MeasureTheory` scope :
3533
3634* `f <$>ₘ x`: `MeasurableSpaceFunctor.mMap f x`.
3735* `x >>=ₘ f`: `MeasurableSpaceBind.mBind x f`.
@@ -55,9 +53,9 @@ see R. J. Aumann, [*Borel structures for function spaces*](https://doi.org/10.12
5553
5654@[expose] public section
5755
58- open Function
56+ namespace MeasureTheory
5957
60- section
58+ open Function
6159
6260universe u v
6361
@@ -97,7 +95,7 @@ class MeasurableSpaceFunctor (f : (α : Type u) → [MeasurableSpace α] → Typ
9795 mMapConst {α β : Type u} [MeasurableSpace α] [MeasurableSpace β] : α → f β → f α :=
9896 mMap ∘ (const _)
9997
100- @[inherit_doc] infixr :100 " <$>ₘ " => MeasurableSpaceFunctor.mMap
98+ @[inherit_doc] scoped infixr :100 " <$>ₘ " => MeasurableSpaceFunctor.mMap
10199
102100/--
103101The `mPure` function is overloaded via `MeasurableSpacePure` instances.
@@ -123,7 +121,7 @@ class MeasurableSpaceBind (m : (α : Type u) → [MeasurableSpace α] → Type v
123121 -/
124122 mBind {α β : Type u} [MeasurableSpace α] [MeasurableSpace β] : m α → (α → m β) → m β
125123
126- @[inherit_doc] infixl :55 " >>=ₘ " => MeasurableSpaceBind.mBind
124+ @[inherit_doc] scoped infixl :55 " >>=ₘ " => MeasurableSpaceBind.mBind
127125
128126/--
129127A monad on types with a `MeasurableSpace` instance.
@@ -232,8 +230,8 @@ class LawfulMeasurableSpaceMonad
232230open LawfulMeasurableSpaceMonad
233231
234232attribute [fun_prop] measurable_mPure measurable_mBind
235- attribute [simp] pure_bind bind_assoc bind_pure_comp
236- attribute [grind <=] pure_bind
233+ attribute [simp] mPure_mBind mBind_assoc mBind_mPure_comp
234+ attribute [grind <=] mPure_mBind
237235
238236variable {m : (α : Type u) → [MeasurableSpace α] → Type v} [MeasurableSpaceMonad m]
239237 [∀ α, [MeasurableSpace α] → MeasurableSpace (m α)] [LawfulMeasurableSpaceMonad m]
@@ -263,50 +261,8 @@ theorem mBind_mPure_unit {x : m PUnit} : (x >>=ₘ fun _ => mPure ⟨⟩) = x :=
263261 {g : β → m γ} (hg : Measurable g) :
264262 ((f <$>ₘ x) >>=ₘ fun b => g b) = (x >>=ₘ fun a => g (f a)) := by
265263 rw [← mBind_mPure_comp hf]
266- simp (disch := fun_prop) [mBind_assoc, mPure_mBind]
264+ simp (disch := fun_prop) only [mBind_assoc, mPure_mBind]
267265
268266end Lawful
269267
270- end
271-
272- section MeasurableSpaceFor
273-
274- universe uρ uα u v
275-
276- variable {α : Type u} [mα : MeasurableSpace α] (m : (α : Type u) → [MeasurableSpace α] → Type v)
277- {m' : (α : Type u) → Type v}
278-
279- instance instMeasurableSpace {β : Type u} [mβ : MeasurableSpace β] :
280- MeasurableSpace (ForInStep β) := mβ.map ForInStep.yield ⊓ mβ.map ForInStep.done
281-
282- /--
283- Monadic iteration in `rdo`-blocks, using the `for x in xs` notation.
284- -/
285- class MeasurableSpaceForIn (ρ : Type uρ) (α : outParam (Type uα)) where
286- /--
287- Monadically iterates over the contents of a collection `xs`, with a local state `b` and the
288- possibility of early termination.
289- -/
290- forIn {β : Type u} [MeasurableSpace β] (xs : ρ) (b : β)
291- (f : α → β → m (ForInStep β)) : m β
292-
293- /--
294- Monadic iteration in `rdo`-blocks with a membership proof, using the `for h : x in xs` notation.
295- -/
296- class MeasurableSpaceForIn' (ρ : Type uρ) (α : outParam (Type uα))
297- (d : outParam (Membership α ρ)) where
298- /--
299- Monadically iterates over the contents of a collection `xs`, with a local state `b` and the
300- possibility of early termination. At each iteration, the body of the loop is provided with a proof
301- that the current element is in the collection.
302- -/
303- forIn' {β : Type u} [MeasurableSpace β] (xs : ρ) (b : β)
304- (f : (a : α) → a ∈ xs → β → m (ForInStep β)) : m β
305-
306- @[simps]
307- instance (priority := 500 ) instMeasurableSpaceForInOfForIn'
308- {ρ : Type uρ} {α : Type uα} {d : Membership α ρ} [MeasurableSpaceForIn' m ρ α d] :
309- MeasurableSpaceForIn m ρ α where
310- forIn x b f := MeasurableSpaceForIn'.forIn' x b fun a _ s => f a s
311-
312- end MeasurableSpaceFor
268+ end MeasureTheory
0 commit comments