Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions RandomDo/Measurable.lean
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ open MeasureTheory Set

variable {α : Type*} [MeasurableSpace α]

/-- Lists are measurably equivalent to the sigma type of tuples of a given length. -/
def List.measurableEquivSigmaTuple : List α ≃ᵐ Σ n, Fin n → α where
toFun := List.equivSigmaTuple
invFun := List.equivSigmaTuple.symm
Expand Down Expand Up @@ -102,6 +103,7 @@ lemma Vector.measurableSpace_eq_comap {n : ℕ} :
(MeasurableSpace.comap List.ofFn inferInstance) := MeasurableSpace.comap_comp.symm
_ = _ := by rw [(measurableEmbedding_ofFn n).comap_eq]

/-- Vectors are equivalent to tuples of a given length. -/
def Vector.measurableEquivTuple {n : ℕ} : Vector α n ≃ᵐ (Fin n → α) where
toFun v := fun i ↦ v[i]
invFun := .ofFn
Expand Down
4 changes: 3 additions & 1 deletion RandomDo/Monad/Instances.lean
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ universe u v w

/-- A (core) monad automatically defines a (not necessarily lawful) measurable space monad by
forgetting the measurable space argument. -/
def Monad.toMeasurableSpaceMonad (m : Type u → Type v) [Monad m] (α : Type u) [MeasurableSpace α] :
def Monad.toMeasurableSpaceMonad (m : Type u → Type v) (α : Type u) [_mα : MeasurableSpace α] :
Type v := m α

instance {m : Type u → Type v} [Monad m] :
Expand Down Expand Up @@ -54,11 +54,13 @@ section RandomM

open Function

/-- A monad for random number generation. -/
structure RandomM (Ω : Type w) [MeasurableSpace Ω] (P : Measure Ω)
(α : Type u) [MeasurableSpace α] where
sample : Ω → α × Ω
measurePreserving : MeasurePreserving sample P ((Measure.map (Prod.fst ∘ sample) P).prod P)

/-- TODO -/
abbrev SampleM (Ω : Type w) [MeasurableSpace Ω] (P : Measure Ω) :=
RandomM (ℕ → Ω) (Measure.infinitePi fun _ : ℕ ↦ P)

Expand Down
2 changes: 2 additions & 0 deletions RandomDo/Monad/MeasurableSpace.lean
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ The `mPure` function is overloaded via `MeasurableSpacePure` instances.
`MeasurableSpacePure` is typically accessed via `MeasurableSpaceMonad` instances, which extend it.
-/
class MeasurableSpacePure (f : (α : Type u) → [MeasurableSpace α] → Type v) where
/-- Given `a : α` where `α` has a `MeasurableSpace` instance, `mPure a : f α` represents an
action that does nothing and returns a -/
mPure {α : Type u} [MeasurableSpace α] : α → f α

/--
Expand Down
1 change: 1 addition & 0 deletions RandomDo/Monad/Notation.lean
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def randOps : DoOps := { DoOps.default with
return mkApp2 m α σ
}

/-- The `do` notation for writing monadic programs depending on a `MeasurableSpace` instance. -/
syntax (name := randKind) "rdo" doSeq : term

/-- Define `rdo` notation elaborator. -/
Expand Down
4 changes: 4 additions & 0 deletions RandomDo/Tactic/Examples.lean
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,8 @@ attribute[fun_prop] ProbabilityTheory.Kernel.measurable_coe
example : Measurable fun a => κ a s := by
fun_prop (disch := measurability)

/- The programs above are examples of what `rdo` and `is_markov` do, not an API: `docBlame` is
told not to ask them for documentation. -/
attribute [nolint docBlame] test1 test2 test3 test4 test5 thompson Vector.v_equiv

end
Loading