Skip to content

chore: add some doc-strings, so Mathlib is happy #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 4, 2024
Merged
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
4 changes: 4 additions & 0 deletions Plausible/Random.lean
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class BoundedRandom (m) (α : Type u) [LE α] where
-/
randomR {g : Type} (lo hi : α) (h : lo ≤ hi) [RandomGen g] : RandGT g m {a // lo ≤ a ∧ a ≤ hi}

/-- Given a random generator for `α`, we can convert it to a random generator for `ULift α`. -/
@[inline]
protected def RandT.up {α : Type u} {m : Type u → Type w} {m' : Type (max u v) → Type w'}
{g : Type} [RandomGen g] [Monad m] [Monad m']
Expand All @@ -71,6 +72,7 @@ protected def RandT.up {α : Type u} {m : Type u → Type w} {m' : Type (max u v
set <| ULift.up gen.down
return ⟨val⟩

/-- Given a random generator for `ULift α`, we can convert it to a random generator for `α`. -/
@[inline]
protected def RandT.down {α : Type u} {m : Type (max u v) → Type w} {m' : Type u → Type w'}
{g : Type} [RandomGen g] [Monad m] [Monad m']
Expand Down Expand Up @@ -103,11 +105,13 @@ def range {g : Type} [RandomGen g] [Monad m] : RandGT g m (Nat × Nat) := do
let rng := (← get).down
return RandomGen.range rng

/-- Given a random generator for `α`, we can convert it to a random generator for `ULift α`. -/
@[inline]
protected def up {α : Type u} {g : Type} [RandomGen g] (x : RandG g α) :
RandG g (ULift.{v} α) := do
RandT.up (fun x => pure ⟨Id.run x⟩) x

/-- Given a random generator for `ULift α`, we can convert it to a random generator for `α`. -/
@[inline]
protected def down {α : Type u} {g : Type} [RandomGen g] (x : RandG g (ULift.{v} α)) :
RandG g α :=
Expand Down