Skip to content

Commit 0642ba5

Browse files
authored
Merge pull request #5 from LeanMachineLearning/CI
Lint and test
2 parents 5a93e91 + 77907e4 commit 0642ba5

5 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎RandomDo/Measurable.lean‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ open MeasureTheory Set
3131

3232
variable {α : Type*} [MeasurableSpace α]
3333

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

106+
/-- Vectors are equivalent to tuples of a given length. -/
105107
def Vector.measurableEquivTuple {n : ℕ} : Vector α n ≃ᵐ (Fin n → α) where
106108
toFun v := fun i ↦ v[i]
107109
invFun := .ofFn

‎RandomDo/Monad/Instances.lean‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ universe u v w
2121

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

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

5555
open Function
5656

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

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

‎RandomDo/Monad/MeasurableSpace.lean‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ The `mPure` function is overloaded via `MeasurableSpacePure` instances.
6565
`MeasurableSpacePure` is typically accessed via `MeasurableSpaceMonad` instances, which extend it.
6666
-/
6767
class MeasurableSpacePure (f : (α : Type u) → [MeasurableSpace α] → Type v) where
68+
/-- Given `a : α` where `α` has a `MeasurableSpace` instance, `mPure a : f α` represents an
69+
action that does nothing and returns a -/
6870
mPure {α : Type u} [MeasurableSpace α] : α → f α
6971

7072
/--

‎RandomDo/Monad/Notation.lean‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def randOps : DoOps := { DoOps.default with
6363
return mkApp2 m α σ
6464
}
6565

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

6869
/-- Define `rdo` notation elaborator. -/

‎RandomDo/Tactic/Examples.lean‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,8 @@ attribute[fun_prop] ProbabilityTheory.Kernel.measurable_coe
155155
example : Measurable fun a => κ a s := by
156156
fun_prop (disch := measurability)
157157

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

0 commit comments

Comments
 (0)