The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V01. The language of Mathlib

Mathlib.Logic.Equiv.Option

43 declarations and 4 deprecated aliases. Mathlib docs · Source

Equivalences for Option α

We define

  • Equiv.optionCongr: the Option α ≃ Option β constructed from e : α ≃ β by sending none to none, and applying e elsewhere.
  • Equiv.removeNone: the α ≃ β constructed from Option α ≃ Option β by removing none from both sides.

def Equiv.optionCongr E1 #

{α : Type u_1} → {β : Type u_2} → α ≃ β → Option α ≃ Option β

A universe-polymorphic version of EquivFunctor.mapEquiv Option e.

theorem Equiv.optionCongr_apply E0 #

∀ {α : Type u_1} {β : Type u_2} (e : α ≃ β) (a : Option α), e.optionCongr a = Option.map (⇑e) a

theorem Equiv.optionCongr_refl E0 #

∀ {α : Type u_1}, (Equiv.refl α).optionCongr = Equiv.refl (Option α)

theorem Equiv.optionCongr_symm E0 #

∀ {α : Type u_1} {β : Type u_2} (e : α ≃ β), e.symm.optionCongr = e.optionCongr.symm

theorem Equiv.optionCongr_trans E0 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} (e₁ : α ≃ β) (e₂ : β ≃ γ),
  (e₁.trans e₂).optionCongr = e₁.optionCongr.trans e₂.optionCongr

theorem Equiv.optionCongr_eq_equivFunctor_mapEquiv E1 #

∀ {α β : Type u} (e : α ≃ β), e.optionCongr = EquivFunctor.mapEquiv Option e

When α and β are in the same universe, this is the same as the result of EquivFunctor.mapEquiv.

def Equiv.removeNoneAux E0 #

{α : Type u_1} → {β : Type u_2} → Option α ≃ Option β → α → β

If we have a value on one side of an Equiv of Option we also have a value on the other side of the equivalence

theorem Equiv.removeNoneAux_some E1 #

∀ {α : Type u_1} {β : Type u_2} (e : Option α ≃ Option β) {x : α},
  (∃ x', e (some x) = some x') → some (e.removeNoneAux x) = e (some x)

theorem Equiv.removeNoneAux_none E1 #

∀ {α : Type u_1} {β : Type u_2} (e : Option α ≃ Option β) {x : α}, e (some x) = none → some (e.removeNoneAux x) = e none

theorem Equiv.removeNoneAux_inv E1 #

∀ {α : Type u_1} {β : Type u_2} (e : Option α ≃ Option β) (x : α), e.symm.removeNoneAux (e.removeNoneAux x) = x

def Equiv.removeNone E1 #

{α : Type u_1} → {β : Type u_2} → Option α ≃ Option β → α ≃ β

Given an equivalence between two Option types, eliminate none from that equivalence by mapping e.symm none to e none.

theorem Equiv.removeNone_symm E0 #

∀ {α : Type u_1} {β : Type u_2} (e : Option α ≃ Option β), e.removeNone.symm = e.symm.removeNone

theorem Equiv.removeNone_some E1 #

∀ {α : Type u_1} {β : Type u_2} (e : Option α ≃ Option β) {x : α},
  (∃ x', e (some x) = some x') → some (e.removeNone x) = e (some x)

theorem Equiv.removeNone_none E1 #

∀ {α : Type u_1} {β : Type u_2} (e : Option α ≃ Option β) {x : α}, e (some x) = none → some (e.removeNone x) = e none

theorem Equiv.option_symm_apply_none_iff E0 #

∀ {α : Type u_1} {β : Type u_2} (e : Option α ≃ Option β), e.symm none = none ↔ e none = none

theorem Equiv.some_removeNone_iff E0 #

∀ {α : Type u_1} {β : Type u_2} (e : Option α ≃ Option β) {x : α}, some (e.removeNone x) = e none ↔ e.symm none = some x

theorem Equiv.removeNone_optionCongr E0 #

∀ {α : Type u_1} {β : Type u_2} (e : α ≃ β), e.optionCongr.removeNone = e

theorem Equiv.optionCongr_injective E1 #

∀ {α : Type u_1} {β : Type u_2}, Function.Injective Equiv.optionCongr

def Equiv.optionSubtype E1 #

{α : Type u_1} → {β : Type u_2} → [DecidableEq β] → (x : β) → { e // e none = x } ≃ (α ≃ { y // y ≠ x })

Equivalences between Option α and β that send none to x are equivalent to equivalences between α and {y : β // y ≠ x}.

theorem Equiv.optionSubtype_apply_apply E0 #

∀ {α : Type u_1} {β : Type u_2} [inst : DecidableEq β] (x : β) (e : { e // e none = x }) (a : α) (h : ↑e (some a) ≠ x),
  ((Equiv.optionSubtype x) e) a = ⟨↑e (some a), h⟩

theorem Equiv.coe_optionSubtype_apply_apply E0 #

∀ {α : Type u_1} {β : Type u_2} [inst : DecidableEq β] (x : β) (e : { e // e none = x }) (a : α),
  ↑(((Equiv.optionSubtype x) e) a) = ↑e (some a)

theorem Equiv.optionSubtype_apply_symm_apply E0 #

∀ {α : Type u_1} {β : Type u_2} [inst : DecidableEq β] (x : β) (e : { e // e none = x }) (b : { y // y ≠ x }),
  some (((Equiv.optionSubtype x) e).symm b) = (↑e).symm ↑b

theorem Equiv.optionSubtype_symm_apply_apply_coe E0 #

∀ {α : Type u_1} {β : Type u_2} [inst : DecidableEq β] (x : β) (e : α ≃ { y // y ≠ x }) (a : α),
  ↑((Equiv.optionSubtype x).symm e) (some a) = ↑(e a)

theorem Equiv.optionSubtype_symm_apply_apply_some E0 #

∀ {α : Type u_1} {β : Type u_2} [inst : DecidableEq β] (x : β) (e : α ≃ { y // y ≠ x }) (a : α),
  ↑((Equiv.optionSubtype x).symm e) (some a) = ↑(e a)

theorem Equiv.optionSubtype_symm_apply_apply_none E0 #

∀ {α : Type u_1} {β : Type u_2} [inst : DecidableEq β] (x : β) (e : α ≃ { y // y ≠ x }),
  ↑((Equiv.optionSubtype x).symm e) none = x

theorem Equiv.optionSubtype_symm_apply_symm_apply E0 #

∀ {α : Type u_1} {β : Type u_2} [inst : DecidableEq β] (x : β) (e : α ≃ { y // y ≠ x }) (b : { y // y ≠ x }),
  (↑((Equiv.optionSubtype x).symm e)).symm ↑b = some (e.symm b)

def Equiv.optionSubtypeNe E1 #

{α : Type u_1} → [DecidableEq α] → (a : α) → Option { b // b ≠ a } ≃ α

Any type with a distinguished element is equivalent to an Option type on the subtype excluding that element.

theorem Equiv.optionSubtypeNe_symm_apply E0 #

∀ {α : Type u_1} [inst : DecidableEq α] (a b : α),
  (Equiv.optionSubtypeNe a).symm b = if h : b = a then none else some ⟨b, h⟩

theorem Equiv.optionSubtypeNe_apply E0 #

∀ {α : Type u_1} [inst : DecidableEq α] (a : α) (a_1 : Option { y // y ≠ a }),
  (Equiv.optionSubtypeNe a) a_1 = a_1.casesOn' a Subtype.val

theorem Equiv.optionSubtypeNe_symm_self E1 #

∀ {α : Type u_1} [inst : DecidableEq α] (a : α), (Equiv.optionSubtypeNe a).symm a = none

theorem Equiv.optionSubtypeNe_symm_of_ne E1 #

∀ {α : Type u_1} [inst : DecidableEq α] {a b : α} (hba : b ≠ a), (Equiv.optionSubtypeNe a).symm b = some ⟨b, hba⟩

theorem Equiv.optionSubtypeNe_none E0 #

∀ {α : Type u_1} [inst : DecidableEq α] (a : α), (Equiv.optionSubtypeNe a) none = a

theorem Equiv.optionSubtypeNe_some E0 #

∀ {α : Type u_1} [inst : DecidableEq α] (a : α) (b : { b // b ≠ a }), (Equiv.optionSubtypeNe a) (some b) = ↑b

def Equiv.optionEquivSumPUnit E1 #

(α : Type w) → Option α ≃ α ⊕ PUnit.{v + 1}

Option α is equivalent to α ⊕ PUnit

theorem Equiv.optionEquivSumPUnit_none E0 #

∀ {α : Type u_4}, (Equiv.optionEquivSumPUnit α) none = Sum.inr PUnit.unit

theorem Equiv.optionEquivSumPUnit_some E0 #

∀ {α : Type u_4} (a : α), (Equiv.optionEquivSumPUnit α) (some a) = Sum.inl a

theorem Equiv.optionEquivSumPUnit_coe E0 #

∀ {α : Type u_4} (a : α), (Equiv.optionEquivSumPUnit α) (some a) = Sum.inl a

theorem Equiv.optionEquivSumPUnit_symm_inl E0 #

∀ {α : Type u_4} (a : α), (Equiv.optionEquivSumPUnit α).symm (Sum.inl a) = some a

theorem Equiv.optionEquivSumPUnit_symm_inr E0 #

∀ {α : Type u_4} (a : PUnit.{u_5 + 1}), (Equiv.optionEquivSumPUnit α).symm (Sum.inr a) = none

def Equiv.optionIsSomeEquiv E1 #

(α : Type u_4) → { x // x.isSome = true } ≃ α

The set of x : Option α such that isSome x is equivalent to α.

theorem Equiv.optionIsSomeEquiv_symm_apply_coe E0 #

∀ (α : Type u_4) (x : α), ↑((Equiv.optionIsSomeEquiv α).symm x) = some x

theorem Equiv.optionIsSomeEquiv_apply E0 #

∀ (α : Type u_4) (o : { x // x.isSome = true }), (Equiv.optionIsSomeEquiv α) o = (↑o).get ⋯

abbrev Equiv.subtypeNeSumPUnit E1 #

{α : Type u_1} → [DecidableEq α] → (i₀ : α) → { i // i ≠ i₀ } ⊕ PUnit.{u + 1} ≃ α

The bijection { i // i ≠ i₀ } ⊕ PUnit ≃ α for any i₀ : α.

Deprecated aliases

NameNew nameSince
Equiv.removeNone_auxEquiv.removeNoneAux2026-06-06
Equiv.removeNone_aux_invEquiv.removeNoneAux_inv2026-06-06
Equiv.removeNone_aux_noneEquiv.removeNoneAux_none2026-06-06
Equiv.removeNone_aux_someEquiv.removeNoneAux_some2026-06-06