Nonempty types #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
This file proves a few extra facts about nonempty
, which is defined in core Lean.
Main declarations #
nonempty.some
: Extracts a witness of nonemptiness using choice. Takesnonempty α
explicitly.classical.arbitrary
: Extracts a witness of nonemptiness using choice. Takesnonempty α
as an instance.
@[simp]
Using classical.choice
, lifts a (Prop
-valued) nonempty
instance to a (Type
-valued)
inhabited
instance. classical.inhabited_of_nonempty
already exists, in
core/init/classical.lean
, but the assumption is not a type class argument,
which makes it unsuitable for some applications.
Equations
@[protected, reducible]
Using classical.choice
, extracts a term from a nonempty
type.
Equations
- h.some = classical.choice h
@[protected]
@[protected]
theorem
nonempty.elim_to_inhabited
{α : Sort u_1}
[h : nonempty α]
{p : Prop}
(f : inhabited α → p) :
p
@[protected, instance]
def
pi.nonempty
{ι : Sort u_1}
{α : ι → Sort u_2}
[∀ (i : ι), nonempty (α i)] :
nonempty (Π (i : ι), α i)
theorem
function.surjective.nonempty
{α : Sort u_1}
{β : Sort u_2}
[h : nonempty β]
{f : α → β}
(hf : function.surjective f) :
nonempty α