Skip to content

Commit e3d45dc

Browse files
authored
Merge pull request #6 from LeanMachineLearning/lint
Lint and test
2 parents 1dd783e + 19d549e commit e3d45dc

6 files changed

Lines changed: 13 additions & 10 deletions

File tree

‎RandomDo/Measurable.lean‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ def Vector.measurableEquivTuple {n : ℕ} : Vector α n ≃ᵐ (Fin n → α) wh
117117
ext
118118
simp
119119

120-
instance : MeasurableSpace (Option α) := MeasurableSpace.map some inferInstance
120+
instance instMeasurableSpaceOption : MeasurableSpace (Option α) :=
121+
MeasurableSpace.map some inferInstance
121122

122123
theorem measurableSet_option_iff {s : Set (Option α)} :
123124
MeasurableSet s ↔ MeasurableSet (some ⁻¹' s) := Iff.rfl

‎RandomDo/Monad/ForInInstances.lean‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ section MeasurableSpace
2020

2121
variable {α : Type*} [MeasurableSpace α]
2222

23-
instance : MeasurableSpace (List α) :=
23+
instance instMeasurableSpaceList : MeasurableSpace (List α) :=
2424
MeasurableSpace.comap List.equivSigmaTuple inferInstance
2525

26-
instance : MeasurableSpace (Array α) :=
26+
instance instMeasurableSpaceArray : MeasurableSpace (Array α) :=
2727
MeasurableSpace.comap Array.toList inferInstance
2828

29-
instance {n : ℕ} : MeasurableSpace (Vector α n) :=
29+
instance instMeasurableSpaceVector {n : ℕ} : MeasurableSpace (Vector α n) :=
3030
MeasurableSpace.comap Vector.toArray inferInstance
3131

3232
@[fun_prop]
@@ -52,7 +52,7 @@ section Array
5252
{β : Type u} [mβ : MeasurableSpace β]
5353
(as : Array α) (b : β) (f : (a : α) → a ∈ as → β → m (ForInStep β)) : m β :=
5454
let sz := as.usize
55-
let rec @[specialize] loop (i : USize) (b : β) : m β := rdo
55+
let rec @[specialize, nolint docBlame] loop (i : USize) (b : β) : m β := rdo
5656
if i < sz then
5757
let a := as.uget i lcProof
5858
match (← f a lcProof b) with
@@ -67,7 +67,7 @@ section Array
6767
protected def Array.measurableSpaceForIn' [MeasurableSpaceMonad m]
6868
{β : Type u} [mβ : MeasurableSpace β]
6969
(as : Array α) (b : β) (f : (a : α) → a ∈ as → β → m (ForInStep β)) : m β :=
70-
let rec loop (i : Nat) (h : i ≤ as.size) (b : β) : m β := rdo
70+
let rec @[nolint docBlame] loop (i : Nat) (h : i ≤ as.size) (b : β) : m β := rdo
7171
match i, h with
7272
| 0, _ => mPure b
7373
| i+1, h =>
@@ -97,7 +97,7 @@ variable {α β : Type*} [MeasurableSpace α] [MeasurableSpace β] [Ring α]
9797
protected def List.measurableSpaceForIn' [MeasurableSpaceMonad m]
9898
{β : Type u} [mβ : MeasurableSpace β] (as : @& List α) (init : β)
9999
(f : (a : α) → a ∈ as → β → m (ForInStep β)) : m β :=
100-
let rec @[specialize]
100+
let rec @[specialize, nolint docBlame]
101101
loop : (as' : @& List α) → (b : β) → Exists (fun bs => bs ++ as' = as) → m β
102102
| [], b, _ => mPure b
103103
| a::as', b, h => rdo

‎RandomDo/Monad/Instances.lean‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ open Function
5757
/-- A monad for random number generation. -/
5858
structure RandomM (Ω : Type w) [MeasurableSpace Ω] (P : Measure Ω)
5959
(α : Type u) [MeasurableSpace α] where
60+
/-- Draws a value from a state of the source of randomness, and hands back the state left for the
61+
next draw. -/
6062
sample : Ω → α × Ω
6163
measurePreserving : MeasurePreserving sample P ((Measure.map (Prod.fst ∘ sample) P).prod P)
6264

‎RandomDo/Monad/MeasurableSpace.lean‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,6 @@ variable {f : (α : Type u) → [MeasurableSpace α] → Type v} [MeasurableSpac
142142
g₁ <$>ₘ g₀ <$>ₘ x = (fun a => g₁ (g₀ a)) <$>ₘ x :=
143143
(comp_mMap x hg₀ hg₁).symm
144144

145-
@[simp] theorem mMap_unit {a : f PUnit} : (fun _ => PUnit.unit) <$>ₘ a = a := by simp
146-
147145
open MeasurableSpaceBind MeasurableSpacePure MeasurableSpaceFunctor
148146

149147
/-- A `MeasurableSpaceMonad` satisfies the measurable space monad laws. -/

‎Test/Common.lean‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module
22

33
public import RandomDo
4+
public import Mathlib.Probability.Distributions.Bernoulli
45

56
set_option linter.style.header false
67

‎lakefile.toml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name = "RandomDo"
2-
defaultTargets = ["RandomDo", "Test"]
2+
defaultTargets = ["RandomDo"]
33
lintDriver = "batteries/runLinter"
4+
testDriver = "Test"
45

56
[leanOptions]
67
pp.unicode.fun = true

0 commit comments

Comments
 (0)