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) :
Option αOption βProp

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

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

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

    Equations
    Instances For
      def Option.maybe {m : Type u → Type v} [Monad m] {α : Type u} :
      Option (m α)m (Option α)

      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
      Instances For
        @[deprecated Option.getDM]
        def Option.getDM' {m : Type u_1 → Type u_2} {α : Type u_1} [Monad m] (x : m (Option α)) (y : m α) :
        m α
        Equations
        Instances For
          def Option.elim' {α : Type u_1} {β : Type u_2} (b : β) (f : αβ) :
          Option αβ

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

          Equations
          Instances For
            @[simp]
            theorem Option.elim'_none {α : Type u_1} {β : Type u_2} (b : β) (f : αβ) :
            Option.elim' b f none = b
            @[simp]
            theorem Option.elim'_some {α : Type u_1} {β : Type u_2} {a : α} (b : β) (f : αβ) :
            Option.elim' b f (some a) = f a
            theorem Option.elim'_eq_elim {α : Type u_3} {β : Type u_4} (b : β) (f : αβ) (a : Option α) :
            theorem Option.mem_some_iff {α : Type u_3} {a : α} {b : α} :
            a some b b = a
            @[inline]
            def Option.decidableEqNone {α : Type u_1} {o : Option α} :
            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
            Instances For
              instance Option.decidableForallMem {α : Type u_1} {p : αProp} [DecidablePred p] (o : Option α) :
              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} [DecidablePred p] (o : Option α) :
              Decidable (a, a o p a)
              Equations
              • One or more equations did not get rendered due to their size.
              @[reducible]
              def Option.iget {α : Type u_1} [Inhabited α] :
              Option αα

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

              Equations
              Instances For
                theorem Option.iget_some {α : Type u_1} [Inhabited α] {a : α} :
                @[simp]
                theorem Option.mem_toList {α : Type u_1} {a : α} {o : Option α} :
                def Lean.LOption.toOption {α : Type u_3} :

                Convert undef to none to make an LOption into an Option.

                Equations
                Instances For