fact
stringlengths
6
3.84k
type
stringclasses
11 values
library
stringclasses
32 values
imports
listlengths
1
14
filename
stringlengths
20
95
symbolic_name
stringlengths
1
90
docstring
stringlengths
7
20k
hasFix [Fix <| (x : Sigma β) → γ x.1 x.2] : Fix ((x : _) → (y : β x) → γ x y) := ⟨fun f ↦ curry (fix <| uncurry ∘ f ∘ curry)⟩ variable [∀ x y, OmegaCompletePartialOrder <| γ x y]
instance
Control
[ "Mathlib.Data.Stream.Init", "Mathlib.Tactic.ApplyFun", "Mathlib.Control.Fix", "Mathlib.Order.OmegaCompletePartialOrder" ]
Mathlib/Control/LawfulFix.lean
hasFix
null
uncurry_curry_ωScottContinuous (hc : ωScottContinuous f) : ωScottContinuous <| (monotoneUncurry α β γ).comp <| (⟨f,hc.monotone⟩ : ((x : _) → (y : β x) → γ x y) →o (x : _) → (y : β x) → γ x y).comp <| monotoneCurry α β γ := (ωScottContinuous_uncurry _ _ _).comp (hc.comp (ωScottContinuous_curry _ _ _))
theorem
Control
[ "Mathlib.Data.Stream.Init", "Mathlib.Tactic.ApplyFun", "Mathlib.Control.Fix", "Mathlib.Order.OmegaCompletePartialOrder" ]
Mathlib/Control/LawfulFix.lean
uncurry_curry_ωScottContinuous
null
lawfulFix' [LawfulFix <| (x : Sigma β) → γ x.1 x.2] : LawfulFix ((x y : _) → γ x y) where fix_eq {_f} hc := by dsimp [fix] conv_lhs => erw [LawfulFix.fix_eq (uncurry_curry_ωScottContinuous hc)] rfl
instance
Control
[ "Mathlib.Data.Stream.Init", "Mathlib.Tactic.ApplyFun", "Mathlib.Control.Fix", "Mathlib.Order.OmegaCompletePartialOrder" ]
Mathlib/Control/LawfulFix.lean
lawfulFix'
null
RandGT (g : Type) := StateT (ULift g)
abbrev
Control
[ "Mathlib.Control.ULiftable", "Mathlib.Order.Fin.Basic" ]
Mathlib/Control/Random.lean
RandGT
A monad transformer to generate random objects using the generic generator type `g`
RandG (g : Type) := RandGT g Id
abbrev
Control
[ "Mathlib.Control.ULiftable", "Mathlib.Order.Fin.Basic" ]
Mathlib/Control/Random.lean
RandG
A monad to generate random objects using the generator type `g`.
RandT := RandGT StdGen
abbrev
Control
[ "Mathlib.Control.ULiftable", "Mathlib.Order.Fin.Basic" ]
Mathlib/Control/Random.lean
RandT
A monad transformer to generate random objects using the generator type `StdGen`. `RandT m α` should be thought of a random value in `m α`.
Rand := RandG StdGen
abbrev
Control
[ "Mathlib.Control.ULiftable", "Mathlib.Order.Fin.Basic" ]
Mathlib/Control/Random.lean
Rand
A monad to generate random objects using the generator type `StdGen`.
Random (m) (α : Type u) where /-- Sample an element of this type from the provided generator. -/ random [RandomGen g] : RandGT g m α
class
Control
[ "Mathlib.Control.ULiftable", "Mathlib.Order.Fin.Basic" ]
Mathlib/Control/Random.lean
Random
`Random m α` gives us machinery to generate values of type `α` in the monad `m`. Note that `m` is a parameter as some types may only be sampleable with access to a certain monad.
BoundedRandom (m) (α : Type u) [Preorder α] where /-- Sample a bounded element of this type from the provided generator. -/ randomR {g : Type} (lo hi : α) (h : lo ≤ hi) [RandomGen g] : RandGT g m {a // lo ≤ a ∧ a ≤ hi}
class
Control
[ "Mathlib.Control.ULiftable", "Mathlib.Order.Fin.Basic" ]
Mathlib/Control/Random.lean
BoundedRandom
`BoundedRandom m α` gives us machinery to generate values of type `α` between certain bounds in the monad `m`.
next [RandomGen g] [Monad m] : RandGT g m Nat := do let rng := (← get).down let (res, new) := RandomGen.next rng set (ULift.up new) pure res
def
Control
[ "Mathlib.Control.ULiftable", "Mathlib.Order.Fin.Basic" ]
Mathlib/Control/Random.lean
next
Generate a random `Nat`.
split {g : Type} [RandomGen g] [Monad m] : RandGT g m g := do let rng := (← get).down let (r1, r2) := RandomGen.split rng set (ULift.up r1) pure r2
def
Control
[ "Mathlib.Control.ULiftable", "Mathlib.Order.Fin.Basic" ]
Mathlib/Control/Random.lean
split
Create a new random number generator distinct from the one stored in the state.
range {g : Type} [RandomGen g] [Monad m] : RandGT g m (Nat × Nat) := do let rng := (← get).down pure <| RandomGen.range rng
def
Control
[ "Mathlib.Control.ULiftable", "Mathlib.Order.Fin.Basic" ]
Mathlib/Control/Random.lean
range
Get the range of `Nat` that can be generated by the generator `g`.
rand (α : Type u) [Random m α] [RandomGen g] : RandGT g m α := Random.random
def
Control
[ "Mathlib.Control.ULiftable", "Mathlib.Order.Fin.Basic" ]
Mathlib/Control/Random.lean
rand
Generate a random value of type `α`.
randBound (α : Type u) [Preorder α] [BoundedRandom m α] (lo hi : α) (h : lo ≤ hi) [RandomGen g] : RandGT g m {a // lo ≤ a ∧ a ≤ hi} := (BoundedRandom.randomR lo hi h : RandGT g _ _)
def
Control
[ "Mathlib.Control.ULiftable", "Mathlib.Order.Fin.Basic" ]
Mathlib/Control/Random.lean
randBound
Generate a random value of type `α` between `x` and `y` inclusive.
randFin {n : Nat} [NeZero n] [RandomGen g] : RandGT g m (Fin n) := fun ⟨g⟩ ↦ pure <| randNat g 0 (n - 1) |>.map (Fin.ofNat n) ULift.up
def
Control
[ "Mathlib.Control.ULiftable", "Mathlib.Order.Fin.Basic" ]
Mathlib/Control/Random.lean
randFin
Generate a random `Fin`.
randBool [RandomGen g] : RandGT g m Bool := return (← rand (Fin 2)) == 1
def
Control
[ "Mathlib.Control.ULiftable", "Mathlib.Order.Fin.Basic" ]
Mathlib/Control/Random.lean
randBool
Generate a random `Bool`.
runRand (cmd : RandT m α) : m α := do let stdGen ← ULiftable.up (stdGenRef.get : m₀ _) let (res, new) ← StateT.run cmd stdGen let _ ← ULiftable.up (stdGenRef.set new.down : m₀ _) pure res
def
Control
[ "Mathlib.Control.ULiftable", "Mathlib.Order.Fin.Basic" ]
Mathlib/Control/Random.lean
runRand
Execute `RandT m α` using the global `stdGenRef` as RNG. Note that: - `stdGenRef` is not necessarily properly seeded on program startup as of now and will therefore be deterministic. - `stdGenRef` is not thread local, hence two threads accessing it at the same time will get the exact same generator.
runRandWith (seed : Nat) (cmd : RandT m α) : m α := do pure <| (← cmd.run (ULift.up <| mkStdGen seed)).1
def
Control
[ "Mathlib.Control.ULiftable", "Mathlib.Order.Fin.Basic" ]
Mathlib/Control/Random.lean
runRandWith
Execute `RandT m α` using the global `stdGenRef` as RNG and the given `seed`.
protected map (f : α → β) (a : PLift α) : PLift β := PLift.up (f a.down) @[simp]
def
Control
[ "Mathlib.Init" ]
Mathlib/Control/ULift.lean
map
Functorial action.
map_up (f : α → β) (a : α) : (PLift.up a).map f = PLift.up (f a) := rfl
theorem
Control
[ "Mathlib.Init" ]
Mathlib/Control/ULift.lean
map_up
null
@[simp] protected pure : α → PLift α := up
def
Control
[ "Mathlib.Init" ]
Mathlib/Control/ULift.lean
pure
Embedding of pure values.
protected seq (f : PLift (α → β)) (x : Unit → PLift α) : PLift β := PLift.up (f.down (x ()).down) @[simp]
def
Control
[ "Mathlib.Init" ]
Mathlib/Control/ULift.lean
seq
Applicative sequencing.
seq_up (f : α → β) (x : α) : (PLift.up f).seq (fun _ => PLift.up x) = PLift.up (f x) := rfl
theorem
Control
[ "Mathlib.Init" ]
Mathlib/Control/ULift.lean
seq_up
null
protected bind (a : PLift α) (f : α → PLift β) : PLift β := f a.down @[simp]
def
Control
[ "Mathlib.Init" ]
Mathlib/Control/ULift.lean
bind
Monadic bind.
bind_up (a : α) (f : α → PLift β) : (PLift.up a).bind f = f a := rfl
theorem
Control
[ "Mathlib.Init" ]
Mathlib/Control/ULift.lean
bind_up
null
@[simp] rec.constant {α : Sort u} {β : Type v} (b : β) : (@PLift.rec α (fun _ => β) fun _ => b) = fun _ => b := rfl
theorem
Control
[ "Mathlib.Init" ]
Mathlib/Control/ULift.lean
rec.constant
null
protected map (f : α → β) (a : ULift.{u'} α) : ULift.{v'} β := ULift.up.{v'} (f a.down) @[simp]
def
Control
[ "Mathlib.Init" ]
Mathlib/Control/ULift.lean
map
Functorial action.
map_up (f : α → β) (a : α) : (ULift.up.{u'} a).map f = ULift.up.{v'} (f a) := rfl
theorem
Control
[ "Mathlib.Init" ]
Mathlib/Control/ULift.lean
map_up
null
@[simp] protected pure : α → ULift α := up
def
Control
[ "Mathlib.Init" ]
Mathlib/Control/ULift.lean
pure
Embedding of pure values.
protected seq {α β} (f : ULift (α → β)) (x : Unit → ULift α) : ULift β := ULift.up.{u} (f.down (x ()).down) @[simp]
def
Control
[ "Mathlib.Init" ]
Mathlib/Control/ULift.lean
seq
Applicative sequencing.
seq_up (f : α → β) (x : α) : (ULift.up f).seq (fun _ => ULift.up x) = ULift.up (f x) := rfl
theorem
Control
[ "Mathlib.Init" ]
Mathlib/Control/ULift.lean
seq_up
null
protected bind (a : ULift α) (f : α → ULift β) : ULift β := f a.down @[simp]
def
Control
[ "Mathlib.Init" ]
Mathlib/Control/ULift.lean
bind
Monadic bind.
bind_up (a : α) (f : α → ULift β) : (ULift.up a).bind f = f a := rfl
theorem
Control
[ "Mathlib.Init" ]
Mathlib/Control/ULift.lean
bind_up
null
@[simp] rec.constant {α : Type u} {β : Sort v} (b : β) : (@ULift.rec α (fun _ => β) fun _ => b) = fun _ => b := rfl
theorem
Control
[ "Mathlib.Init" ]
Mathlib/Control/ULift.lean
rec.constant
null
ULiftable (f : outParam (Type u₀ → Type u₁)) (g : Type v₀ → Type v₁) where congr {α β} : α ≃ β → f α ≃ g β
class
Control
[ "Mathlib.Control.Monad.Basic", "Mathlib.Control.Monad.Cont", "Mathlib.Control.Monad.Writer", "Mathlib.Logic.Equiv.Basic", "Mathlib.Logic.Equiv.Functor", "Mathlib.Control.Lawful" ]
Mathlib/Control/ULiftable.lean
ULiftable
Given a universe polymorphic type family `M.{u} : Type u₁ → Type u₂`, this class convert between instantiations, from `M.{u} : Type u₁ → Type u₂` to `M.{v} : Type v₁ → Type v₂` and back. `f` is an outParam, because `g` can almost always be inferred from the current monad. At any rate, the lift should be unique, as the intent is to only lift the same constants with different universe parameters.
symm (f : Type u₀ → Type u₁) (g : Type v₀ → Type v₁) [ULiftable f g] : ULiftable g f where congr e := (ULiftable.congr e.symm).symm
abbrev
Control
[ "Mathlib.Control.Monad.Basic", "Mathlib.Control.Monad.Cont", "Mathlib.Control.Monad.Writer", "Mathlib.Logic.Equiv.Basic", "Mathlib.Logic.Equiv.Functor", "Mathlib.Control.Lawful" ]
Mathlib/Control/ULiftable.lean
symm
Not an instance as it is incompatible with `outParam`. In practice it seems not to be needed anyway.
refl (f : Type u₀ → Type u₁) [Functor f] [LawfulFunctor f] : ULiftable f f where congr e := Functor.mapEquiv _ e
instance
Control
[ "Mathlib.Control.Monad.Basic", "Mathlib.Control.Monad.Cont", "Mathlib.Control.Monad.Writer", "Mathlib.Logic.Equiv.Basic", "Mathlib.Logic.Equiv.Functor", "Mathlib.Control.Lawful" ]
Mathlib/Control/ULiftable.lean
refl
null
up {f : Type u₀ → Type u₁} {g : Type max u₀ v → Type v₁} [ULiftable f g] {α} : f α → g (ULift.{v} α) := (ULiftable.congr Equiv.ulift.symm).toFun
abbrev
Control
[ "Mathlib.Control.Monad.Basic", "Mathlib.Control.Monad.Cont", "Mathlib.Control.Monad.Writer", "Mathlib.Logic.Equiv.Basic", "Mathlib.Logic.Equiv.Functor", "Mathlib.Control.Lawful" ]
Mathlib/Control/ULiftable.lean
up
The most common practical use `ULiftable` (together with `down`), the function `up.{v}` takes `x : M.{u} α` and lifts it to `M.{max u v} (ULift.{v} α)`
down {f : Type u₀ → Type u₁} {g : Type max u₀ v → Type v₁} [ULiftable f g] {α} : g (ULift.{v} α) → f α := (ULiftable.congr Equiv.ulift.symm).invFun
abbrev
Control
[ "Mathlib.Control.Monad.Basic", "Mathlib.Control.Monad.Cont", "Mathlib.Control.Monad.Writer", "Mathlib.Logic.Equiv.Basic", "Mathlib.Logic.Equiv.Functor", "Mathlib.Control.Lawful" ]
Mathlib/Control/ULiftable.lean
down
The most common practical use of `ULiftable` (together with `up`), the function `down.{v}` takes `x : M.{max u v} (ULift.{v} α)` and lowers it to `M.{u} α`
adaptUp (F : Type v₀ → Type v₁) (G : Type max v₀ u₀ → Type u₁) [ULiftable F G] [Monad G] {α β} (x : F α) (f : α → G β) : G β := up x >>= f ∘ ULift.down.{u₀}
def
Control
[ "Mathlib.Control.Monad.Basic", "Mathlib.Control.Monad.Cont", "Mathlib.Control.Monad.Writer", "Mathlib.Logic.Equiv.Basic", "Mathlib.Logic.Equiv.Functor", "Mathlib.Control.Lawful" ]
Mathlib/Control/ULiftable.lean
adaptUp
convenient shortcut to avoid manipulating `ULift`
adaptDown {F : Type max u₀ v₀ → Type u₁} {G : Type v₀ → Type v₁} [L : ULiftable G F] [Monad F] {α β} (x : F α) (f : α → G β) : G β := @down.{max u₀ v₀} G F L β <| x >>= @up.{max u₀ v₀} G F L β ∘ f
def
Control
[ "Mathlib.Control.Monad.Basic", "Mathlib.Control.Monad.Cont", "Mathlib.Control.Monad.Writer", "Mathlib.Logic.Equiv.Basic", "Mathlib.Logic.Equiv.Functor", "Mathlib.Control.Lawful" ]
Mathlib/Control/ULiftable.lean
adaptDown
convenient shortcut to avoid manipulating `ULift`
upMap {F : Type u₀ → Type u₁} {G : Type max u₀ v₀ → Type v₁} [ULiftable F G] [Functor G] {α β} (f : α → β) (x : F α) : G β := Functor.map (f ∘ ULift.down.{v₀}) (up x)
def
Control
[ "Mathlib.Control.Monad.Basic", "Mathlib.Control.Monad.Cont", "Mathlib.Control.Monad.Writer", "Mathlib.Logic.Equiv.Basic", "Mathlib.Logic.Equiv.Functor", "Mathlib.Control.Lawful" ]
Mathlib/Control/ULiftable.lean
upMap
map function that moves up universes
downMap {F : Type max u₀ v₀ → Type u₁} {G : Type u₀ → Type v₁} [ULiftable G F] [Functor F] {α β} (f : α → β) (x : F α) : G β := down (Functor.map (ULift.up.{v₀} ∘ f) x : F (ULift β))
def
Control
[ "Mathlib.Control.Monad.Basic", "Mathlib.Control.Monad.Cont", "Mathlib.Control.Monad.Writer", "Mathlib.Logic.Equiv.Basic", "Mathlib.Logic.Equiv.Functor", "Mathlib.Control.Lawful" ]
Mathlib/Control/ULiftable.lean
downMap
map function that moves down universes
up' {f : Type u₀ → Type u₁} {g : Type v₀ → Type v₁} [ULiftable f g] : f PUnit → g PUnit := ULiftable.congr Equiv.punitEquivPUnit
abbrev
Control
[ "Mathlib.Control.Monad.Basic", "Mathlib.Control.Monad.Cont", "Mathlib.Control.Monad.Writer", "Mathlib.Logic.Equiv.Basic", "Mathlib.Logic.Equiv.Functor", "Mathlib.Control.Lawful" ]
Mathlib/Control/ULiftable.lean
up'
A version of `up` for a `PUnit` return type.
down' {f : Type u₀ → Type u₁} {g : Type v₀ → Type v₁} [ULiftable f g] : g PUnit → f PUnit := (ULiftable.congr Equiv.punitEquivPUnit).symm
abbrev
Control
[ "Mathlib.Control.Monad.Basic", "Mathlib.Control.Monad.Cont", "Mathlib.Control.Monad.Writer", "Mathlib.Logic.Equiv.Basic", "Mathlib.Logic.Equiv.Functor", "Mathlib.Control.Lawful" ]
Mathlib/Control/ULiftable.lean
down'
A version of `down` for a `PUnit` return type.
up_down {f : Type u₀ → Type u₁} {g : Type max u₀ v₀ → Type v₁} [ULiftable f g] {α} (x : g (ULift.{v₀} α)) : up (down x : f α) = x := (ULiftable.congr Equiv.ulift.symm).right_inv _
theorem
Control
[ "Mathlib.Control.Monad.Basic", "Mathlib.Control.Monad.Cont", "Mathlib.Control.Monad.Writer", "Mathlib.Logic.Equiv.Basic", "Mathlib.Logic.Equiv.Functor", "Mathlib.Control.Lawful" ]
Mathlib/Control/ULiftable.lean
up_down
null
down_up {f : Type u₀ → Type u₁} {g : Type max u₀ v₀ → Type v₁} [ULiftable f g] {α} (x : f α) : down (up x : g (ULift.{v₀} α)) = x := (ULiftable.congr Equiv.ulift.symm).left_inv _
theorem
Control
[ "Mathlib.Control.Monad.Basic", "Mathlib.Control.Monad.Cont", "Mathlib.Control.Monad.Writer", "Mathlib.Logic.Equiv.Basic", "Mathlib.Logic.Equiv.Functor", "Mathlib.Control.Lawful" ]
Mathlib/Control/ULiftable.lean
down_up
null
instULiftableId : ULiftable Id Id where congr F := F
instance
Control
[ "Mathlib.Control.Monad.Basic", "Mathlib.Control.Monad.Cont", "Mathlib.Control.Monad.Writer", "Mathlib.Logic.Equiv.Basic", "Mathlib.Logic.Equiv.Functor", "Mathlib.Control.Lawful" ]
Mathlib/Control/ULiftable.lean
instULiftableId
null
StateT.uliftable' {m : Type u₀ → Type v₀} {m' : Type u₁ → Type v₁} [ULiftable m m'] (F : s ≃ s') : ULiftable (StateT s m) (StateT s' m') where congr G := StateT.equiv <| Equiv.piCongr F fun _ => ULiftable.congr <| Equiv.prodCongr G F
def
Control
[ "Mathlib.Control.Monad.Basic", "Mathlib.Control.Monad.Cont", "Mathlib.Control.Monad.Writer", "Mathlib.Logic.Equiv.Basic", "Mathlib.Logic.Equiv.Functor", "Mathlib.Control.Lawful" ]
Mathlib/Control/ULiftable.lean
StateT.uliftable'
for specific state types, this function helps to create a uliftable instance
StateT.instULiftableULiftULift {m m'} [ULiftable m m'] : ULiftable (StateT (ULift.{max v₀ u₀} s) m) (StateT (ULift.{max v₁ u₀} s) m') := StateT.uliftable' <| Equiv.ulift.trans Equiv.ulift.symm
instance
Control
[ "Mathlib.Control.Monad.Basic", "Mathlib.Control.Monad.Cont", "Mathlib.Control.Monad.Writer", "Mathlib.Logic.Equiv.Basic", "Mathlib.Logic.Equiv.Functor", "Mathlib.Control.Lawful" ]
Mathlib/Control/ULiftable.lean
StateT.instULiftableULiftULift
null
ReaderT.uliftable' {m m'} [ULiftable m m'] (F : s ≃ s') : ULiftable (ReaderT s m) (ReaderT s' m') where congr G := ReaderT.equiv <| Equiv.piCongr F fun _ => ULiftable.congr G
def
Control
[ "Mathlib.Control.Monad.Basic", "Mathlib.Control.Monad.Cont", "Mathlib.Control.Monad.Writer", "Mathlib.Logic.Equiv.Basic", "Mathlib.Logic.Equiv.Functor", "Mathlib.Control.Lawful" ]
Mathlib/Control/ULiftable.lean
ReaderT.uliftable'
for specific reader monads, this function helps to create a uliftable instance
ReaderT.instULiftableULiftULift {m m'} [ULiftable m m'] : ULiftable (ReaderT (ULift.{max v₀ u₀} s) m) (ReaderT (ULift.{max v₁ u₀} s) m') := ReaderT.uliftable' <| Equiv.ulift.trans Equiv.ulift.symm
instance
Control
[ "Mathlib.Control.Monad.Basic", "Mathlib.Control.Monad.Cont", "Mathlib.Control.Monad.Writer", "Mathlib.Logic.Equiv.Basic", "Mathlib.Logic.Equiv.Functor", "Mathlib.Control.Lawful" ]
Mathlib/Control/ULiftable.lean
ReaderT.instULiftableULiftULift
null
ContT.uliftable' {m m'} [ULiftable m m'] (F : r ≃ r') : ULiftable (ContT r m) (ContT r' m') where congr := ContT.equiv (ULiftable.congr F)
def
Control
[ "Mathlib.Control.Monad.Basic", "Mathlib.Control.Monad.Cont", "Mathlib.Control.Monad.Writer", "Mathlib.Logic.Equiv.Basic", "Mathlib.Logic.Equiv.Functor", "Mathlib.Control.Lawful" ]
Mathlib/Control/ULiftable.lean
ContT.uliftable'
for specific continuation passing monads, this function helps to create a uliftable instance
ContT.instULiftableULiftULift {m m'} [ULiftable m m'] : ULiftable (ContT (ULift.{max v₀ u₀} s) m) (ContT (ULift.{max v₁ u₀} s) m') := ContT.uliftable' <| Equiv.ulift.trans Equiv.ulift.symm
instance
Control
[ "Mathlib.Control.Monad.Basic", "Mathlib.Control.Monad.Cont", "Mathlib.Control.Monad.Writer", "Mathlib.Logic.Equiv.Basic", "Mathlib.Logic.Equiv.Functor", "Mathlib.Control.Lawful" ]
Mathlib/Control/ULiftable.lean
ContT.instULiftableULiftULift
null
WriterT.uliftable' {m m'} [ULiftable m m'] (F : w ≃ w') : ULiftable (WriterT w m) (WriterT w' m') where congr G := WriterT.equiv <| ULiftable.congr <| Equiv.prodCongr G F
def
Control
[ "Mathlib.Control.Monad.Basic", "Mathlib.Control.Monad.Cont", "Mathlib.Control.Monad.Writer", "Mathlib.Logic.Equiv.Basic", "Mathlib.Logic.Equiv.Functor", "Mathlib.Control.Lawful" ]
Mathlib/Control/ULiftable.lean
WriterT.uliftable'
for specific writer monads, this function helps to create a uliftable instance
WriterT.instULiftableULiftULift {m m'} [ULiftable m m'] : ULiftable (WriterT (ULift.{max v₀ u₀} s) m) (WriterT (ULift.{max v₁ u₀} s) m') := WriterT.uliftable' <| Equiv.ulift.trans Equiv.ulift.symm
instance
Control
[ "Mathlib.Control.Monad.Basic", "Mathlib.Control.Monad.Cont", "Mathlib.Control.Monad.Writer", "Mathlib.Logic.Equiv.Basic", "Mathlib.Logic.Equiv.Functor", "Mathlib.Control.Lawful" ]
Mathlib/Control/ULiftable.lean
WriterT.instULiftableULiftULift
null
Except.instULiftable {ε : Type u₀} : ULiftable (Except.{u₀,v₁} ε) (Except.{u₀,v₂} ε) where congr e := { toFun := Except.map e invFun := Except.map e.symm left_inv := fun f => by cases f <;> simp [Except.map] right_inv := fun f => by cases f <;> simp [Except.map] }
instance
Control
[ "Mathlib.Control.Monad.Basic", "Mathlib.Control.Monad.Cont", "Mathlib.Control.Monad.Writer", "Mathlib.Logic.Equiv.Basic", "Mathlib.Logic.Equiv.Functor", "Mathlib.Control.Lawful" ]
Mathlib/Control/ULiftable.lean
Except.instULiftable
null
Option.instULiftable : ULiftable Option.{u₀} Option.{u₁} where congr e := { toFun := Option.map e invFun := Option.map e.symm left_inv := fun f => by cases f <;> simp right_inv := fun f => by cases f <;> simp }
instance
Control
[ "Mathlib.Control.Monad.Basic", "Mathlib.Control.Monad.Cont", "Mathlib.Control.Monad.Writer", "Mathlib.Logic.Equiv.Basic", "Mathlib.Logic.Equiv.Functor", "Mathlib.Control.Lawful" ]
Mathlib/Control/ULiftable.lean
Option.instULiftable
null
ofFin_intCast (z : ℤ) : ofFin (z : Fin (2^w)) = ↑z := by cases w case zero => simp only [eq_nil] case succ w => apply BitVec.eq_of_toInt_eq rw [toInt_ofFin, Fin.val_intCast, Int.natCast_pow, Nat.cast_ofNat, Int.ofNat_toNat, toInt_intCast] rw [Int.max_eq_left] · have h : (2 ^ (w + 1) : Int) = (2 ^ (w + 1) : Nat) := by simp rw [h, Int.emod_bmod] · omega open Fin.CommRing in @[simp] theorem toFin_intCast (z : ℤ) : (z : BitVec w).toFin = ↑z := by rw [← ofFin_intCast] /-!
theorem
Data
[ "Mathlib.Algebra.Ring.InjSurj", "Mathlib.Algebra.Ring.Equiv", "Mathlib.Data.ZMod.Defs", "Mathlib.Data.Int.Cast.Lemmas" ]
Mathlib/Data/BitVec.lean
ofFin_intCast
null
toNat_injective {n : Nat} : Function.Injective (BitVec.toNat : BitVec n → _) | ⟨_, _⟩, ⟨_, _⟩, rfl => rfl
theorem
Data
[ "Mathlib.Algebra.Ring.InjSurj", "Mathlib.Algebra.Ring.Equiv", "Mathlib.Data.ZMod.Defs", "Mathlib.Data.Int.Cast.Lemmas" ]
Mathlib/Data/BitVec.lean
toNat_injective
null
toFin_injective {n : Nat} : Function.Injective (toFin : BitVec n → _) | ⟨_, _⟩, ⟨_, _⟩, rfl => rfl /-!
theorem
Data
[ "Mathlib.Algebra.Ring.InjSurj", "Mathlib.Algebra.Ring.Equiv", "Mathlib.Data.ZMod.Defs", "Mathlib.Data.Int.Cast.Lemmas" ]
Mathlib/Data/BitVec.lean
toFin_injective
null
toFin_nsmul (n : ℕ) (x : BitVec w) : toFin (n • x) = n • x.toFin := toFin_mul _ _ |>.trans <| by open scoped Fin.CommRing in simp only [natCast_eq_ofNat, toFin_ofNat, Fin.ofNat_eq_cast, nsmul_eq_mul]
lemma
Data
[ "Mathlib.Algebra.Ring.InjSurj", "Mathlib.Algebra.Ring.Equiv", "Mathlib.Data.ZMod.Defs", "Mathlib.Data.Int.Cast.Lemmas" ]
Mathlib/Data/BitVec.lean
toFin_nsmul
null
toFin_zsmul (z : ℤ) (x : BitVec w) : toFin (z • x) = z • x.toFin := toFin_mul _ _ |>.trans <| by open scoped Fin.CommRing in simp only [zsmul_eq_mul, toFin_intCast]
lemma
Data
[ "Mathlib.Algebra.Ring.InjSurj", "Mathlib.Algebra.Ring.Equiv", "Mathlib.Data.ZMod.Defs", "Mathlib.Data.Int.Cast.Lemmas" ]
Mathlib/Data/BitVec.lean
toFin_zsmul
null
toFin_pow (x : BitVec w) (n : ℕ) : toFin (x ^ n) = x.toFin ^ n := by induction n with | zero => simp | succ n ih => simp [ih, BitVec.pow_succ, pow_succ] /-!
lemma
Data
[ "Mathlib.Algebra.Ring.InjSurj", "Mathlib.Algebra.Ring.Equiv", "Mathlib.Data.ZMod.Defs", "Mathlib.Data.Int.Cast.Lemmas" ]
Mathlib/Data/BitVec.lean
toFin_pow
null
@[simps] equivFin {m : ℕ} : BitVec m ≃+* Fin (2 ^ m) where toFun a := a.toFin invFun a := ofFin a map_mul' := toFin_mul map_add' := toFin_add
def
Data
[ "Mathlib.Algebra.Ring.InjSurj", "Mathlib.Algebra.Ring.Equiv", "Mathlib.Data.ZMod.Defs", "Mathlib.Data.Int.Cast.Lemmas" ]
Mathlib/Data/BitVec.lean
equivFin
The ring `BitVec m` is isomorphic to `Fin (2 ^ m)`.
Bracket (L M : Type*) where /-- `⁅x, y⁆` is the result of a bracket operation on elements `x` and `y`. It is supported by the `Bracket` typeclass. -/ bracket : L → M → M @[inherit_doc] notation "⁅" x ", " y "⁆" => Bracket.bracket x y
class
Data
[ "Mathlib.Tactic.TypeStar" ]
Mathlib/Data/Bracket.lean
Bracket
The `Bracket` class has three intended uses: 1. for certain binary operations on structures, like the product `⁅x, y⁆` of two elements `x`, `y` in a Lie algebra or the commutator of two elements `x` and `y` in a group. 2. for certain actions of one structure on another, like the action `⁅x, m⁆` of an element `x` of a Lie algebra on an element `m` in one of its modules (analogous to `SMul` in the associative setting). 3. for binary operations on substructures, like the commutator `⁅H, K⁆` of two subgroups `H` and `K` of a group.
@[ext] TotalSpace (F : Type*) (E : B → Type*) where /-- `Bundle.TotalSpace.proj` is the canonical projection `Bundle.TotalSpace F E → B` from the total space to the base space. -/ proj : B snd : E proj
structure
Data
[ "Mathlib.Data.Set.Basic" ]
Mathlib/Data/Bundle.lean
TotalSpace
`Bundle.TotalSpace F E` is the total space of the bundle. It consists of pairs `(proj : B, snd : E proj)`.
TotalSpace.mk' (F : Type*) (x : B) (y : E x) : TotalSpace F E := ⟨x, y⟩
abbrev
Data
[ "Mathlib.Data.Set.Basic" ]
Mathlib/Data/Bundle.lean
TotalSpace.mk'
null
TotalSpace.mk_cast {x x' : B} (h : x = x') (b : E x) : .mk' F x' (cast (congr_arg E h) b) = TotalSpace.mk x b := by subst h; rfl @[simp 1001, mfld_simps 1001]
theorem
Data
[ "Mathlib.Data.Set.Basic" ]
Mathlib/Data/Bundle.lean
TotalSpace.mk_cast
null
TotalSpace.mk_inj {b : B} {y y' : E b} : mk' F b y = mk' F b y' ↔ y = y' := by simp [TotalSpace.ext_iff]
theorem
Data
[ "Mathlib.Data.Set.Basic" ]
Mathlib/Data/Bundle.lean
TotalSpace.mk_inj
null
TotalSpace.mk_injective (b : B) : Injective (mk b : E b → TotalSpace F E) := fun _ _ ↦ mk_inj.1
theorem
Data
[ "Mathlib.Data.Set.Basic" ]
Mathlib/Data/Bundle.lean
TotalSpace.mk_injective
null
TotalSpace.eta (z : TotalSpace F E) : TotalSpace.mk z.proj z.2 = z := rfl @[simp]
theorem
Data
[ "Mathlib.Data.Set.Basic" ]
Mathlib/Data/Bundle.lean
TotalSpace.eta
null
TotalSpace.exists {p : TotalSpace F E → Prop} : (∃ x, p x) ↔ ∃ b y, p ⟨b, y⟩ := ⟨fun ⟨x, hx⟩ ↦ ⟨x.1, x.2, hx⟩, fun ⟨b, y, h⟩ ↦ ⟨⟨b, y⟩, h⟩⟩ @[simp]
theorem
Data
[ "Mathlib.Data.Set.Basic" ]
Mathlib/Data/Bundle.lean
TotalSpace.exists
null
TotalSpace.range_mk (b : B) : range ((↑) : E b → TotalSpace F E) = π F E ⁻¹' {b} := by apply Subset.antisymm · rintro _ ⟨x, rfl⟩ rfl · rintro ⟨_, x⟩ rfl exact ⟨x, rfl⟩
theorem
Data
[ "Mathlib.Data.Set.Basic" ]
Mathlib/Data/Bundle.lean
TotalSpace.range_mk
null
@[reducible, nolint unusedArguments] Trivial (B : Type*) (F : Type*) : B → Type _ := fun _ => F
def
Data
[ "Mathlib.Data.Set.Basic" ]
Mathlib/Data/Bundle.lean
Trivial
Notation for the direct sum of two bundles over the same base. -/ notation:100 E₁ " ×ᵇ " E₂ => fun x => E₁ x × E₂ x /-- `Bundle.Trivial B F` is the trivial bundle over `B` of fiber `F`.
TotalSpace.trivialSnd (B : Type*) (F : Type*) : TotalSpace F (Bundle.Trivial B F) → F := TotalSpace.snd
def
Data
[ "Mathlib.Data.Set.Basic" ]
Mathlib/Data/Bundle.lean
TotalSpace.trivialSnd
The trivial bundle, unlike other bundles, has a canonical projection on the fiber.
@[simps (attr := mfld_simps)] TotalSpace.toProd (B F : Type*) : (TotalSpace F fun _ : B => F) ≃ B × F where toFun x := (x.1, x.2) invFun x := ⟨x.1, x.2⟩
def
Data
[ "Mathlib.Data.Set.Basic" ]
Mathlib/Data/Bundle.lean
TotalSpace.toProd
A trivial bundle is equivalent to the product `B × F`.
Pullback (f : B' → B) (E : B → Type*) : B' → Type _ := fun x => E (f x) @[inherit_doc] notation f " *ᵖ " E:arg => Pullback f E
def
Data
[ "Mathlib.Data.Set.Basic" ]
Mathlib/Data/Bundle.lean
Pullback
The pullback of a bundle `E` over a base `B` under a map `f : B' → B`, denoted by `Bundle.Pullback f E` or `f *ᵖ E`, is the bundle over `B'` whose fiber over `b'` is `E (f b')`.
@[simp] pullbackTotalSpaceEmbedding (f : B' → B) : TotalSpace F (f *ᵖ E) → B' × TotalSpace F E := fun z => (z.proj, TotalSpace.mk (f z.proj) z.2)
def
Data
[ "Mathlib.Data.Set.Basic" ]
Mathlib/Data/Bundle.lean
pullbackTotalSpaceEmbedding
Natural embedding of the total space of `f *ᵖ E` into `B' × TotalSpace F E`.
@[simps (attr := mfld_simps)] Pullback.lift (f : B' → B) : TotalSpace F (f *ᵖ E) → TotalSpace F E := fun z => ⟨f z.proj, z.2⟩ @[simp, mfld_simps]
def
Data
[ "Mathlib.Data.Set.Basic" ]
Mathlib/Data/Bundle.lean
Pullback.lift
The base map `f : B' → B` lifts to a canonical map on the total spaces.
Pullback.lift_mk (f : B' → B) (x : B') (y : E (f x)) : Pullback.lift f (.mk' F x y) = ⟨f x, y⟩ := rfl
theorem
Data
[ "Mathlib.Data.Set.Basic" ]
Mathlib/Data/Bundle.lean
Pullback.lift_mk
null
Erased (α : Sort u) : Sort max 1 u := { s : α → Prop // ∃ a, (a = ·) = s }
def
Data
[ "Mathlib.Logic.Equiv.Defs" ]
Mathlib/Data/Erased.lean
Erased
`Erased α` is the same as `α`, except that the elements of `Erased α` are erased in the VM in the same way as types and proofs. This can be used to track data without storing it literally.
@[inline] mk {α} (a : α) : Erased α := ⟨fun b => a = b, a, rfl⟩
def
Data
[ "Mathlib.Logic.Equiv.Defs" ]
Mathlib/Data/Erased.lean
mk
Erase a value.
noncomputable out {α} : Erased α → α | ⟨_, h⟩ => Classical.choose h
def
Data
[ "Mathlib.Logic.Equiv.Defs" ]
Mathlib/Data/Erased.lean
out
Extracts the erased value, noncomputably.
OutType (a : Erased (Sort u)) : Sort u := out a
abbrev
Data
[ "Mathlib.Logic.Equiv.Defs" ]
Mathlib/Data/Erased.lean
OutType
Extracts the erased value, if it is a type. Note: `(mk a).OutType` is not definitionally equal to `a`.
out_proof {p : Prop} (a : Erased p) : p := out a @[simp]
theorem
Data
[ "Mathlib.Logic.Equiv.Defs" ]
Mathlib/Data/Erased.lean
out_proof
Extracts the erased value, if it is a proof.
out_mk {α} (a : α) : (mk a).out = a := by let h := (mk a).2; change Classical.choose h = a have := Classical.choose_spec h exact cast (congr_fun this a).symm rfl @[simp]
theorem
Data
[ "Mathlib.Logic.Equiv.Defs" ]
Mathlib/Data/Erased.lean
out_mk
null
mk_out {α} : ∀ a : Erased α, mk (out a) = a | ⟨s, h⟩ => by simp only [mk]; congr; exact Classical.choose_spec h @[ext]
theorem
Data
[ "Mathlib.Logic.Equiv.Defs" ]
Mathlib/Data/Erased.lean
mk_out
null
out_inj {α} (a b : Erased α) (h : a.out = b.out) : a = b := by simpa using congr_arg mk h
theorem
Data
[ "Mathlib.Logic.Equiv.Defs" ]
Mathlib/Data/Erased.lean
out_inj
null
noncomputable equiv (α) : Erased α ≃ α := ⟨out, mk, mk_out, out_mk⟩
def
Data
[ "Mathlib.Logic.Equiv.Defs" ]
Mathlib/Data/Erased.lean
equiv
Equivalence between `Erased α` and `α`.
choice {α} (h : Nonempty α) : Erased α := mk (Classical.choice h) @[simp]
def
Data
[ "Mathlib.Logic.Equiv.Defs" ]
Mathlib/Data/Erased.lean
choice
Computably produce an erased value from a proof of nonemptiness.
nonempty_iff {α} : Nonempty (Erased α) ↔ Nonempty α := ⟨fun ⟨a⟩ => ⟨a.out⟩, fun ⟨a⟩ => ⟨mk a⟩⟩
theorem
Data
[ "Mathlib.Logic.Equiv.Defs" ]
Mathlib/Data/Erased.lean
nonempty_iff
null
bind {α β} (a : Erased α) (f : α → Erased β) : Erased β := ⟨fun b => (f a.out).1 b, (f a.out).2⟩ @[simp]
def
Data
[ "Mathlib.Logic.Equiv.Defs" ]
Mathlib/Data/Erased.lean
bind
`(>>=)` operation on `Erased`. This is a separate definition because `α` and `β` can live in different universes (the universe is fixed in `Monad`).
bind_eq_out {α β} (a f) : @bind α β a f = f a.out := rfl
theorem
Data
[ "Mathlib.Logic.Equiv.Defs" ]
Mathlib/Data/Erased.lean
bind_eq_out
null
join {α} (a : Erased (Erased α)) : Erased α := bind a id @[simp]
def
Data
[ "Mathlib.Logic.Equiv.Defs" ]
Mathlib/Data/Erased.lean
join
Collapses two levels of erasure.
join_eq_out {α} (a) : @join α a = a.out := rfl
theorem
Data
[ "Mathlib.Logic.Equiv.Defs" ]
Mathlib/Data/Erased.lean
join_eq_out
null
map {α β} (f : α → β) (a : Erased α) : Erased β := bind a (mk ∘ f) @[simp]
def
Data
[ "Mathlib.Logic.Equiv.Defs" ]
Mathlib/Data/Erased.lean
map
`(<$>)` operation on `Erased`. This is a separate definition because `α` and `β` can live in different universes (the universe is fixed in `Functor`).
map_out {α β} {f : α → β} (a : Erased α) : (a.map f).out = f a.out := by simp [map]
theorem
Data
[ "Mathlib.Logic.Equiv.Defs" ]
Mathlib/Data/Erased.lean
map_out
null
protected Monad : Monad Erased where pure := @mk bind := @bind map := @map @[simp]
instance
Data
[ "Mathlib.Logic.Equiv.Defs" ]
Mathlib/Data/Erased.lean
Monad
null
pure_def {α} : (pure : α → Erased α) = @mk _ := rfl @[simp]
theorem
Data
[ "Mathlib.Logic.Equiv.Defs" ]
Mathlib/Data/Erased.lean
pure_def
null