File: Mathlib/Data/Option/Basic.lean

full_name: Option.coe_def
code: theorem coe_def : (fun a ↦ ↑a : α → Option α) = some 
goal: (fun a => some a) = some

full_name: Option.mem_map
code: theorem mem_map {f : α → β} {y : β} {o : Option α} : y ∈ o.map f ↔ ∃ x ∈ o, f x = y 
goal: y ∈ Option.map f o ↔ ∃ x, x ∈ o ∧ f x = y

full_name: Option.mem_map_of_injective
code: @[simp 1100, nolint simpNF]
theorem mem_map_of_injective {f : α → β} (H : Function.Injective f) {a : α} {o : Option α} :
    f a ∈ o.map f ↔ a ∈ o 
goal: f a ∈ Option.map f o ↔ a ∈ o

full_name: Option.forall_mem_map
code: theorem forall_mem_map {f : α → β} {o : Option α} {p : β → Prop} :
    (∀ y ∈ o.map f, p y) ↔ ∀ x ∈ o, p (f x) 
goal: (∀ (y : β), y ∈ Option.map f o → p y) ↔ ∀ (x : α), x ∈ o → p (f x)

full_name: Option.exists_mem_map
code: theorem exists_mem_map {f : α → β} {o : Option α} {p : β → Prop} :
    (∃ y ∈ o.map f, p y) ↔ ∃ x ∈ o, p (f x) 
goal: (∃ y, y ∈ Option.map f o ∧ p y) ↔ ∃ x, x ∈ o ∧ p (f x)

full_name: Option.coe_get
code: theorem coe_get {o : Option α} (h : o.isSome) : ((Option.get _ h : α) : Option α) = o 
goal: some (o.get h) = o

full_name: Option.eq_of_mem_of_mem
code: theorem eq_of_mem_of_mem {a : α} {o1 o2 : Option α} (h1 : a ∈ o1) (h2 : a ∈ o2) : o1 = o2 
goal: o1 = o2

full_name: Option.Mem.leftUnique
code: theorem Mem.leftUnique : Relator.LeftUnique ((· ∈ ·) : α → Option α → Prop) 
goal: Relator.LeftUnique fun x x_1 => x ∈ x_1

full_name: Option.some_injective
code: theorem some_injective (α : Type*) : Function.Injective (@some α) 
goal: Function.Injective some

full_name: Option.map_injective
code: /-- `Option.map f` is injective if `f` is injective. -/
theorem map_injective {f : α → β} (Hf : Function.Injective f) : Function.Injective (Option.map f)
  
goal: Function.Injective (Option.map f)

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

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.bind_eq_some'
code: theorem bind_eq_some' {x : Option α} {f : α → Option β} {b : β} :
    x.bind f = some b ↔ ∃ a, x = some a ∧ f a = some b 
goal: x.bind f = some b ↔ ∃ a, x = some a ∧ f a = some b

full_name: Option.bind_congr
code: theorem bind_congr {f g : α → Option β} {x : Option α}
    (h : ∀ a ∈ x, f a = g a) : x.bind f = x.bind g 
goal: x.bind f = x.bind g

full_name: Option.bind_congr'
code: @[congr]
theorem bind_congr' {f g : α → Option β} {x y : Option α} (hx : x = y)
    (hf : ∀ a ∈ y, f a = g a) : x.bind f = y.bind g 
goal: x.bind f = y.bind g

full_name: Option.joinM_eq_join
code: theorem joinM_eq_join : joinM = @join α 
goal: joinM = Option.join

full_name: Option.bind_eq_bind'
code: theorem bind_eq_bind' {α β : Type u} {f : α → Option β} {x : Option α} : x >>= f = x.bind f 
goal: x >>= f = x.bind f

full_name: Option.map_coe
code: theorem map_coe {α β} {a : α} {f : α → β} : f <$> (a : Option α) = ↑(f a) 
goal: f <$> some a = some (f a)

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

full_name: Option.map_injective'
code: /-- `Option.map` as a function between functions is injective. -/
theorem map_injective' : Function.Injective (@Option.map α β) 
goal: Function.Injective Option.map

full_name: Option.map_inj
code: @[simp]
theorem map_inj {f g : α → β} : Option.map f = Option.map g ↔ f = g 
goal: Option.map f = Option.map g ↔ f = g

full_name: Option.map_eq_id
code: @[simp]
theorem map_eq_id {f : α → α} : Option.map f = id ↔ f = id 
goal: Option.map f = id ↔ f = id

full_name: Option.map_comm
code: theorem map_comm {f₁ : α → β} {f₂ : α → γ} {g₁ : β → δ} {g₂ : γ → δ} (h : g₁ ∘ f₁ = g₂ ∘ f₂)
    (a : α) :
    (Option.map f₁ a).map g₁ = (Option.map f₂ a).map g₂ 
goal: Option.map g₁ (Option.map f₁ (some a)) = Option.map g₂ (Option.map f₂ (some a))

full_name: Option.pbind_eq_bind
code: theorem pbind_eq_bind (f : α → Option β) (x : Option α) : (x.pbind fun a _ ↦ f a) = x.bind f 
goal: (x.pbind fun a x => f a) = x.bind f

full_name: Option.map_bind
code: theorem map_bind {α β γ} (f : β → γ) (x : Option α) (g : α → Option β) :
    Option.map f (x >>= g) = x >>= fun a ↦ Option.map f (g a) 
goal: Option.map f (x >>= g) = do
  let a ← x
  Option.map f (g a)

full_name: Option.map_bind'
code: theorem map_bind' (f : β → γ) (x : Option α) (g : α → Option β) :
    Option.map f (x.bind g) = x.bind fun a ↦ Option.map f (g a) 
goal: Option.map f (x.bind g) = x.bind fun a => Option.map f (g a)

full_name: Option.map_pbind
code: theorem map_pbind (f : β → γ) (x : Option α) (g : ∀ a, a ∈ x → Option β) :
    Option.map f (x.pbind g) = x.pbind fun a H ↦ Option.map f (g a H) 
goal: Option.map f (x.pbind g) = x.pbind fun a H => Option.map f (g a H)

full_name: Option.pbind_map
code: theorem pbind_map (f : α → β) (x : Option α) (g : ∀ b : β, b ∈ x.map f → Option γ) :
    pbind (Option.map f x) g = x.pbind fun a h ↦ g (f a) (mem_map_of_mem _ h) 
goal: (Option.map f x).pbind g = x.pbind fun a h => g (f a) ⋯

full_name: Option.pmap_none
code: @[simp]
theorem pmap_none (f : ∀ a : α, p a → β) {H} : pmap f (@none α) H = none 
goal: Option.pmap f none H = none

full_name: Option.pmap_some
code: @[simp]
theorem pmap_some (f : ∀ a : α, p a → β) {x : α} (h : p x) :
    pmap f (some x) = fun _ ↦ some (f x h) 
goal: Option.pmap f (some x) = fun x_1 => some (f x h)

full_name: Option.mem_pmem
code: theorem mem_pmem {a : α} (h : ∀ a ∈ x, p a) (ha : a ∈ x) : f a (h a ha) ∈ pmap f x h 
goal: f a ⋯ ∈ Option.pmap f x h

full_name: Option.pmap_map
code: theorem pmap_map (g : γ → α) (x : Option γ) (H) :
    pmap f (x.map g) H = pmap (fun a h ↦ f (g a) h) x fun a h ↦ H _ (mem_map_of_mem _ h) 
goal: Option.pmap f (Option.map g x) H = Option.pmap (fun a h => f (g a) h) x ⋯

full_name: Option.map_pmap
code: theorem map_pmap (g : β → γ) (f : ∀ a, p a → β) (x H) :
    Option.map g (pmap f x H) = pmap (fun a h ↦ g (f a h)) x H 
goal: Option.map g (Option.pmap f x H) = Option.pmap (fun a h => g (f a h)) x H

full_name: Option.pmap_eq_map
code: theorem pmap_eq_map (p : α → Prop) (f : α → β) (x H) :
    @pmap _ _ p (fun a _ ↦ f a) x H = Option.map f x 
goal: Option.pmap (fun a x => f a) x H = Option.map f x

full_name: Option.pmap_bind
code: theorem pmap_bind {α β γ} {x : Option α} {g : α → Option β} {p : β → Prop} {f : ∀ b, p b → γ} (H)
    (H' : ∀ (a : α), ∀ b ∈ g a, b ∈ x >>= g) :
    pmap f (x >>= g) H = x >>= fun a ↦ pmap f (g a) fun b h ↦ H _ (H' a _ h) 
goal: Option.pmap f (x >>= g) H = do
  let a ← x
  Option.pmap f (g a) ⋯

full_name: Option.bind_pmap
code: theorem bind_pmap {α β γ} {p : α → Prop} (f : ∀ a, p a → β) (x : Option α) (g : β → Option γ) (H) :
    pmap f x H >>= g = x.pbind fun a h ↦ g (f a (H _ h)) 
goal: Option.pmap f x H >>= g = x.pbind fun a h => g (f a ⋯)

full_name: Option.pbind_eq_none
code: theorem pbind_eq_none {f : ∀ a : α, a ∈ x → Option β}
    (h' : ∀ a (H : a ∈ x), f a H = none → x = none) : x.pbind f = none ↔ x = none 
goal: x.pbind f = none ↔ x = none

full_name: Option.pbind_eq_some
code: theorem pbind_eq_some {f : ∀ a : α, a ∈ x → Option β} {y : β} :
    x.pbind f = some y ↔ ∃ (z : α) (H : z ∈ x), f z H = some y 
goal: x.pbind f = some y ↔ ∃ z H, f z H = some y

full_name: Option.pmap_eq_none_iff
code: theorem pmap_eq_none_iff {h} : pmap f x h = none ↔ x = none 
goal: Option.pmap f x h = none ↔ x = none

full_name: Option.pmap_eq_some_iff
code: theorem pmap_eq_some_iff {hf} {y : β} :
    pmap f x hf = some y ↔ ∃ (a : α) (H : x = some a), f a (hf a H) = y 
goal: Option.pmap f x hf = some y ↔ ∃ a H, f a ⋯ = y

full_name: Option.join_pmap_eq_pmap_join
code: theorem join_pmap_eq_pmap_join {f : ∀ a, p a → β} {x : Option (Option α)} (H) :
    (pmap (pmap f) x H).join = pmap f x.join fun a h ↦ H (some a) (mem_of_mem_join h) _ rfl 
goal: (Option.pmap (Option.pmap f) x H).join = Option.pmap f x.join ⋯

full_name: Option.seq_some
code: @[simp]
theorem seq_some {α β} {a : α} {f : α → β} : some f <*> some a = some (f a) 
goal: (Seq.seq (some f) fun x => some a) = some (f a)

full_name: Option.some_orElse'
code: @[simp]
theorem some_orElse' (a : α) (x : Option α) : (some a).orElse (fun _ ↦ x) = some a 
goal: ((some a).orElse fun x_1 => x) = some a

full_name: Option.none_orElse'
code: @[simp]
theorem none_orElse' (x : Option α) : none.orElse (fun _ ↦ x) = x 
goal: (none.orElse fun x_1 => x) = x

full_name: Option.orElse_none'
code: @[simp]
theorem orElse_none' (x : Option α) : x.orElse (fun _ ↦ none) = x 
goal: (x.orElse fun x => none) = x

full_name: Option.exists_ne_none
code: theorem exists_ne_none {p : Option α → Prop} : (∃ x ≠ none, p x) ↔ (∃ x : α, p x) 
goal: (∃ x, x ≠ none ∧ p x) ↔ ∃ x, p (some x)

full_name: Option.isSome_map
code: @[simp]
theorem isSome_map (f : α → β) (o : Option α) : isSome (o.map f) = isSome o 
goal: (Option.map f o).isSome = o.isSome

full_name: Option.get_map
code: @[simp]
theorem get_map (f : α → β) {o : Option α} (h : isSome (o.map f)) :
    (o.map f).get h = f (o.get (by rwa [← isSome_map])) 
goal: (Option.map f o).get h = f (o.get ⋯)

full_name: Option.iget_mem
code: theorem iget_mem [Inhabited α] : ∀ {o : Option α}, isSome o → o.iget ∈ o
  
goal: o.isSome = true → o.iget ∈ o

full_name: Option.iget_of_mem
code: theorem iget_of_mem [Inhabited α] {a : α} : ∀ {o : Option α}, a ∈ o → o.iget = a
  
goal: a ∈ o → o.iget = a

full_name: Option.getD_default_eq_iget
code: theorem getD_default_eq_iget [Inhabited α] (o : Option α) :
    o.getD default = o.iget 
goal: o.getD default = o.iget

full_name: Option.guard_eq_some'
code: @[simp]
theorem guard_eq_some' {p : Prop} [Decidable p] (u) : _root_.guard p = some u ↔ p 
goal: guard p = some u ↔ p

full_name: Option.liftOrGet_choice
code: theorem liftOrGet_choice {f : α → α → α} (h : ∀ a b, f a b = a ∨ f a b = b) :
    ∀ o₁ o₂, liftOrGet f o₁ o₂ = o₁ ∨ liftOrGet f o₁ o₂ = o₂
  
goal: Option.liftOrGet f o₁ o₂ = o₁ ∨ Option.liftOrGet f o₁ o₂ = o₂

full_name: Option.casesOn'
code: /-- Given an element of `a : Option α`, a default element `b : β` and a function `α → β`, apply this
function to `a` if it comes from `α`, and return `b` otherwise. -/
def casesOn' : Option α → β → (α → β) → β
  
goal: Option α → β → (α → β) → β

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

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

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

full_name: Option.casesOn'_none_coe
code: theorem casesOn'_none_coe (f : Option α → β) (o : Option α) :
    casesOn' o (f none) (f ∘ (fun a ↦ ↑a)) = f o 
goal: o.casesOn' (f none) (f ∘ fun a => some a) = f o

full_name: Option.casesOn'_eq_elim
code: lemma casesOn'_eq_elim (b : β) (f : α → β) (a : Option α) :
    Option.casesOn' a b f = Option.elim a b f 
goal: a.casesOn' b f = a.elim b f

full_name: Option.orElse_eq_some
code: theorem orElse_eq_some (o o' : Option α) (x : α) :
    (o <|> o') = some x ↔ o = some x ∨ o = none ∧ o' = some x 
goal: (HOrElse.hOrElse o fun x => o') = some x ↔ o = some x ∨ o = none ∧ o' = some x

full_name: Option.orElse_eq_some'
code: theorem orElse_eq_some' (o o' : Option α) (x : α) :
    o.orElse (fun _ ↦ o') = some x ↔ o = some x ∨ o = none ∧ o' = some x 
goal: (o.orElse fun x => o') = some x ↔ o = some x ∨ o = none ∧ o' = some x

full_name: Option.orElse_eq_none
code: @[simp]
theorem orElse_eq_none (o o' : Option α) : (o <|> o') = none ↔ o = none ∧ o' = none 
goal: (HOrElse.hOrElse o fun x => o') = none ↔ o = none ∧ o' = none

full_name: Option.orElse_eq_none'
code: @[simp]
theorem orElse_eq_none' (o o' : Option α) : o.orElse (fun _ ↦ o') = none ↔ o = none ∧ o' = none 
goal: (o.orElse fun x => o') = none ↔ o = none ∧ o' = none

full_name: Option.choice_eq_none
code: theorem choice_eq_none (α : Type*) [IsEmpty α] : choice α = none 
goal: Option.choice α = none

full_name: Option.elim_none_some
code: theorem elim_none_some (f : Option α → β) : (fun x ↦ Option.elim x (f none) (f ∘ some)) = f 
goal: (fun x => x.elim (f none) (f ∘ some)) = f

full_name: Option.elim_comp
code: theorem elim_comp (h : α → β) {f : γ → α} {x : α} {i : Option γ} :
    (i.elim (h x) fun j => h (f j)) = h (i.elim x f) 
goal: (i.elim (h x) fun j => h (f j)) = h (i.elim x f)

full_name: Option.elim_comp₂
code: theorem elim_comp₂ (h : α → β → γ) {f : γ → α} {x : α} {g : γ → β} {y : β}
    {i : Option γ} : (i.elim (h x y) fun j => h (f j) (g j)) = h (i.elim x f) (i.elim y g) 
goal: (i.elim (h x y) fun j => h (f j) (g j)) = h (i.elim x f) (i.elim y g)

full_name: Option.elim_apply
code: theorem elim_apply {f : γ → α → β} {x : α → β} {i : Option γ} {y : α} :
    i.elim x f y = i.elim (x y) fun j => f j y 
goal: i.elim x f y = i.elim (x y) fun j => f j y

full_name: Option.get!_some
code: @[simp]
theorem get!_some [Inhabited α] (a : α) : (some a).get! = a 
goal: (some a).get! = a

full_name: Option.get!_none
code: @[simp]
theorem get!_none [Inhabited α] : (none : Option α).get! = default 
goal: none.get! = default

full_name: Option.bnot_isSome
code: @[simp]
lemma bnot_isSome (a : Option α) : (! a.isSome) = a.isNone 
goal: (!a.isSome) = a.isNone

full_name: Option.bnot_comp_isSome
code: @[simp]
lemma bnot_comp_isSome : (! ·) ∘ @Option.isSome α = Option.isNone 
goal: (fun x => !x) ∘ Option.isSome = Option.isNone

full_name: Option.bnot_isNone
code: @[simp]
lemma bnot_isNone (a : Option α) : (! a.isNone) = a.isSome 
goal: (!a.isNone) = a.isSome

full_name: Option.bnot_comp_isNone
code: @[simp]
lemma bnot_comp_isNone : (! ·) ∘ @Option.isNone α = Option.isSome 
goal: (fun x => !x) ∘ Option.isNone = Option.isSome

full_name: Option.isNone_eq_false_iff
code: @[simp]
lemma isNone_eq_false_iff (a : Option α) : Option.isNone a = false ↔ Option.isSome a 
goal: a.isNone = false ↔ a.isSome = true

full_name: Option.eq_none_or_eq_some
code: lemma eq_none_or_eq_some (a : Option α) : a = none ∨ ∃ x, a = some x 
goal: a = none ∨ ∃ x, a = some x

full_name: Option.forall_some_ne_iff_eq_none
code: lemma forall_some_ne_iff_eq_none {o : Option α} : (∀ (x : α), some x ≠ o) ↔ o = none 
goal: (∀ (x : α), some x ≠ o) ↔ o = none