File: .lake/packages/lean4/src/lean/Init/Data/Option/Basic.lean

full_name: Option.«instBEq_.lake»
code: BEq
goal: {α : Type u_1} → [inst : BEq α] → BEq (Option α)

full_name: Option.getM
code: /-- Lifts an optional value to any `Alternative`, sending `none` to `failure`. -/
def getM [Alternative m] : Option α → m α
  
goal: Option α → m α

full_name: Option.toMonad
code: @[deprecated getM (since := "2024-04-17")]
def toMonad [Monad m] [Alternative m] : Option α → m α 
goal: Option α → m α

full_name: Option.isSome
code: /-- Returns `true` on `some x` and `false` on `none`. -/
@[inline] def isSome : Option α → Bool
  
goal: Option α → Bool

full_name: Option.toBool
code: @[deprecated isSome, inline] def toBool : Option α → Bool 
goal: Option α → Bool

full_name: Option.isNone
code: /-- Returns `true` on `none` and `false` on `some x`. -/
@[inline] def isNone : Option α → Bool
  
goal: Option α → Bool

full_name: Option.isEqSome
code: /--
`x?.isEqSome y` is equivalent to `x? == some y`, but avoids an allocation.
-/
@[inline] def isEqSome [BEq α] : Option α → α → Bool
  
goal: Option α → α → Bool

full_name: Option.bind
code: @[inline] protected def bind : Option α → (α → Option β) → Option β
  
goal: Option α → (α → Option β) → Option β

full_name: Option.bindM
code: /-- Runs `f` on `o`'s value, if any, and returns its result, or else returns `none`.  -/
@[inline] protected def bindM [Monad m] (f : α → m (Option β)) (o : Option α) : m (Option β) 
goal: m (Option β)

full_name: Option.mapM
code: /--
Runs a monadic function `f` on an optional value.
If the optional value is `none` the function is not called.
-/
@[inline] protected def mapM [Monad m] (f : α → m β) (o : Option α) : m (Option β) 
goal: m (Option β)

full_name: Option.map_id
code: theorem map_id : (Option.map id : Option α → Option α) = id 
goal: Option.map id = id

full_name: Option.filter
code: /-- Keeps an optional value only if it satisfies the predicate `p`. -/
@[always_inline, inline] protected def filter (p : α → Bool) : Option α → Option α
  
goal: Option α → Option α

full_name: Option.all
code: /-- Checks that an optional value satisfies a predicate `p` or is `none`. -/
@[always_inline, inline] protected def all (p : α → Bool) : Option α → Bool
  
goal: Option α → Bool

full_name: Option.any
code: /-- Checks that an optional value is not `none` and the value satisfies a predicate `p`. -/
@[always_inline, inline] protected def any (p : α → Bool) : Option α → Bool
  
goal: Option α → Bool

full_name: Option.orElse
code: /--
Implementation of `OrElse`'s `<|>` syntax for `Option`.
-/
@[always_inline, macro_inline] protected def orElse : Option α → (Unit → Option α) → Option α
  
goal: Option α → (Unit → Option α) → Option α

full_name: Option.«instOrElse_.lake»
code: instance : OrElse (Option α) 
goal: OrElse (Option α)

full_name: Option.lt
code: @[inline] protected def lt (r : α → α → Prop) : Option α → Option α → Prop
  
goal: Option α → Option α → Prop

full_name: Option.instDecidableRelLt
code: instance (r : α → α → Prop) [s : DecidableRel r] : DecidableRel (Option.lt r)
  
goal: DecidableRel (Option.lt r)

full_name: Option.merge
code: /-- Take a pair of options and if they are both `some`, apply the given fn to produce an output.
Otherwise act like `orElse`. -/
def merge (fn : α → α → α) : Option α → Option α → Option α
  
goal: Option α → Option α → Option α

full_name: Option.getD_none
code: @[simp] theorem getD_none : getD none a = a 
goal: ∀ {α : Type u_1} {a : α}, none.getD a = a

full_name: Option.getD_some
code: @[simp] theorem getD_some : getD (some a) b = a 
goal: ∀ {α : Type u_1} {a b : α}, (some a).getD b = a

full_name: Option.map_none'
code: @[simp] theorem map_none' (f : α → β) : none.map f = none 
goal: Option.map f none = none

full_name: Option.map_some'
code: @[simp] theorem map_some' (a) (f : α → β) : (some a).map f = some (f a) 
goal: Option.map f (some a) = some (f a)

full_name: Option.none_bind
code: @[simp] theorem none_bind (f : α → Option β) : none.bind f = none 
goal: none.bind f = none

full_name: Option.some_bind
code: @[simp] theorem some_bind (a) (f : α → Option β) : (some a).bind f = f a 
goal: (some a).bind f = f a

full_name: Option.elim
code: /-- An elimination principle for `Option`. It is a nondependent version of `Option.recOn`. -/
@[inline] protected def elim : Option α → β → (α → β) → β
  
goal: Option α → β → (α → β) → β

full_name: Option.get
code: /-- Extracts the value `a` from an option that is known to be `some a` for some `a`. -/
@[inline] def get {α : Type u} : (o : Option α) → isSome o → α
  
goal: o.isSome = true → α

full_name: Option.guard
code: /-- `guard p a` returns `some a` if `p a` holds, otherwise `none`. -/
@[inline] def guard (p : α → Prop) [DecidablePred p] (a : α) : Option α 
goal: Option α

full_name: Option.toList
code: /--
Cast of `Option` to `List`. Returns `[a]` if the input is `some a`, and `[]` if it is `none`.
-/
@[inline] def toList : Option α → List α
  
goal: Option α → List α

full_name: Option.toArray
code: /--
Cast of `Option` to `Array`. Returns `#[a]` if the input is `some a`, and `#[]` if it is `none`.
-/
@[inline] def toArray : Option α → Array α
  
goal: Option α → Array α

full_name: Option.liftOrGet
code: /--
Two arguments failsafe function. Returns `f a b` if the inputs are `some a` and `some b`, and
"does nothing" otherwise.
-/
def liftOrGet (f : α → α → α) : Option α → Option α → Option α
  
goal: Option α → Option α → Option α

full_name: Option.Rel
code: /-- Lifts a relation `α → β → Prop` to a relation `Option α → Option β → Prop` by just adding
`none ~ none`. -/
inductive Rel (r : α → β → Prop) : Option α → Option β → Prop
  /-- If `a ~ b`, then `some a ~ some b` -/
  | some {a b} : r a b → Rel r (some a) (some b)
  /-- `none ~ none` -/
  | none : Rel r none none
goal: Option α → Option β → Prop

full_name: Option.Rel.none
code: /-- Lifts a relation `α → β → Prop` to a relation `Option α → Option β → Prop` by just adding
`none ~ none`. -/
inductive Rel (r : α → β → Prop) : Option α → Option β → Prop
  /-- If `a ~ b`, then `some a ~ some b` -/
  | some {a b} : r a b → Rel r (some a) (some b)
  /-- `none ~ none` -/
  | none : Rel r none none
goal: Option.Rel r none none

full_name: Option.Rel.some
code: /-- Lifts a relation `α → β → Prop` to a relation `Option α → Option β → Prop` by just adding
`none ~ none`. -/
inductive Rel (r : α → β → Prop) : Option α → Option β → Prop
  /-- If `a ~ b`, then `some a ~ some b` -/
  | some {a b} : r a b → Rel r (some a) (some b)
  /-- `none ~ none` -/
  | none : Rel r none none
goal: r a b → Option.Rel r (some a) (some b)

full_name: Option.join
code: /-- Flatten an `Option` of `Option`, a specialization of `joinM`. -/
@[simp, inline] def join (x : Option (Option α)) : Option α 
goal: Option α

full_name: Option.mapA
code: /-- Like `Option.mapM` but for applicative functors. -/
@[inline] protected def mapA [Applicative m] {α β} (f : α → m β) : Option α → m (Option β)
  
goal: Option α → m (Option β)

full_name: Option.sequence
code: /--
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.
-/
@[inline] def sequence [Monad m] {α : Type u} : Option (m α) → m (Option α)
  
goal: Option (m α) → m (Option α)

full_name: Option.elimM
code: /-- A monadic analogue of `Option.elim`. -/
@[inline] def elimM [Monad m] (x : m (Option α)) (y : m β) (z : α → m β) : m β 
goal: m β

full_name: Option.getDM
code: /-- A monadic analogue of `Option.getD`. -/
@[inline] def getDM [Monad m] (x : Option α) (y : m α) : m α 
goal: m α

full_name: Option.«instLawfulBEq_.lake»
code: instance (α) [BEq α] [LawfulBEq α] : LawfulBEq (Option α) 
goal: LawfulBEq (Option α)

full_name: Option.all_none
code: @[simp] theorem all_none : Option.all p none = true 
goal: ∀ {α : Type u_1} {p : α → Bool}, Option.all p none = true

full_name: Option.all_some
code: @[simp] theorem all_some : Option.all p (some x) = p x 
goal: ∀ {α : Type u_1} {p : α → Bool} {x : α}, Option.all p (some x) = p x

full_name: Option.min
code: /-- The minimum of two optional values. -/
protected def min [Min α] : Option α → Option α → Option α
  
goal: Option α → Option α → Option α

full_name: Option.«instMin_.lake»
code: instance [Min α] : Min (Option α) 
goal: Min (Option α)

full_name: Option.min_some_some
code: @[simp] theorem min_some_some [Min α] {a b : α} : min (some a) (some b) = some (min a b) 
goal: min (some a) (some b) = some (min a b)

full_name: Option.min_some_none
code: @[simp] theorem min_some_none [Min α] {a : α} : min (some a) none = some a 
goal: min (some a) none = some a

full_name: Option.min_none_some
code: @[simp] theorem min_none_some [Min α] {b : α} : min none (some b) = some b 
goal: min none (some b) = some b

full_name: Option.min_none_none
code: @[simp] theorem min_none_none [Min α] : min (none : Option α) none = none 
goal: min none none = none

full_name: Option.max
code: /-- The maximum of two optional values. -/
protected def max [Max α] : Option α → Option α → Option α
  
goal: Option α → Option α → Option α

full_name: Option.«instMax_.lake»
code: instance [Max α] : Max (Option α) 
goal: Max (Option α)

full_name: Option.max_some_some
code: @[simp] theorem max_some_some [Max α] {a b : α} : max (some a) (some b) = some (max a b) 
goal: max (some a) (some b) = some (max a b)

full_name: Option.max_some_none
code: @[simp] theorem max_some_none [Max α] {a : α} : max (some a) none = some a 
goal: max (some a) none = some a

full_name: Option.max_none_some
code: @[simp] theorem max_none_some [Max α] {b : α} : max none (some b) = some b 
goal: max none (some b) = some b

full_name: Option.max_none_none
code: @[simp] theorem max_none_none [Max α] : max (none : Option α) none = none 
goal: max none none = none

full_name: «instLTOption_.lake»
code: instance [LT α] : LT (Option α) 
goal: LT (Option α)

full_name: «instFunctorOption_.lake»
code: @[always_inline]
instance : Functor Option 
goal: Functor Option

full_name: «instMonadOption_.lake»
code: @[always_inline]
instance : Monad Option 
goal: Monad Option

full_name: «instAlternativeOption_.lake»
code: @[always_inline]
instance : Alternative Option 
goal: Alternative Option

full_name: liftOption
code: def liftOption [Alternative m] : Option α → m α
  
goal: Option α → m α

full_name: Option.tryCatch
code: @[always_inline, inline] protected def Option.tryCatch (x : Option α) (handle : Unit → Option α) : Option α 
goal: Option α

full_name: «instMonadExceptOfUnitOption_.lake»
code: instance : MonadExceptOf Unit Option 
goal: MonadExceptOf Unit Option