Documentation

Mathlib.Data.Option.Defs

Extra definitions on Option#

This file defines more operations involving Option α. Lemmas about them are located in other files under Mathlib.Data.Option. Other basic operations on Option are defined in the core library.

inductive Option.rel {α : Type u_1} {β : Type u_2} (r : αβProp) :
Prop
• If a ~ b, then some a ~ some b

some: ∀ {α : Type u_1} {β : Type u_2} {r : αβProp} {a : α} {b : β}, r a bOption.rel r (some a) (some b)
• none ~ none

none: ∀ {α : Type u_1} {β : Type u_2} {r : αβProp}, Option.rel r none none

Lifts a relation α → β → Prop→ β → Prop→ Prop to a relation Option α → Option β → Prop→ Option β → Prop→ Prop by just adding none ~ none.

Instances For
def Option.traverse {F : Type u → Type v} [inst : ] {α : Type u_1} {β : Type u} (f : αF β) :
F ()

Traverse an object of Option α with a function f : α → F β→ F β for an applicative F.

Equations
• = match x with | none => pure none | some x => some <$> f x def Option.maybe {m : Type u → Type v} [inst : ] {α : Type u} : Option (m α)m () If you maybe have a monadic computation in a [Monad m] which produces a term of type α, then there is a naturally associated way to always perform a computation in m which maybe produces a result. Equations • = match x with | none => pure none | some fn => some <$> fn
def Option.getDM' {m : Type u_1 → Type u_2} {α : Type u_1} [inst : ] (x : m ()) (y : m α) :
m α
Equations
def Option.elim' {α : Type u_1} {β : Type u_2} (b : β) (f : αβ) :
β

An elimination principle for Option. It is a nondependent version of Option.rec.

Equations
theorem Option.mem_some_iff {α : Type u_1} {a : α} {b : α} :
a some b b = a
@[inline]
def Option.decidableEqNone {α : Type u_1} {o : } :
Decidable (o = none)

o = none is decidable even if the wrapped type does not have decidable equality. This is not an instance because it is not definitionally equal to Option.decidableEq. Try to use o.isNone or o.isSome instead.

Equations
instance Option.decidableForallMem {α : Type u_1} {p : αProp} [inst : ] (o : ) :
Decidable ((a : α) → a op a)
Equations
• One or more equations did not get rendered due to their size.
instance Option.decidableExistsMem {α : Type u_1} {p : αProp} [inst : ] (o : ) :
Decidable (a, a o p a)
Equations
• One or more equations did not get rendered due to their size.
def Option.iget {α : Type u_1} [inst : ] :
α

Inhabited get function. Returns a if the input is some a, otherwise returns default.

Equations
• = match x with | some x => x | none => default
theorem Option.iget_some {α : Type u_1} [inst : ] {a : α} :
@[simp]
theorem Option.mem_toList {α : Type u_1} {a : α} {o : } :
a o
instance Option.liftOrGet_isCommutative {α : Type u_1} (f : ααα) [inst : ] :
Equations
instance Option.liftOrGet_isAssociative {α : Type u_1} (f : ααα) [inst : ] :
Equations
instance Option.liftOrGet_isIdempotent {α : Type u_1} (f : ααα) [inst : ] :
Equations
instance Option.liftOrGet_isLeftId {α : Type u_1} (f : ααα) :
IsLeftId () () none
Equations
instance Option.liftOrGet_isRightId {α : Type u_1} (f : ααα) :
IsRightId () () none
Equations