# Documentation

Mathlib.Logic.Nontrivial

# Nontrivial types #

A type is nontrivial if it contains at least two elements. This is useful in particular for rings (where it is equivalent to the fact that zero is different from one) and for vector spaces (where it is equivalent to the fact that the dimension is positive).

We introduce a typeclass Nontrivial formalizing this property.

class Nontrivial (α : Type u_1) :
• In a nontrivial type, there exists a pair of distinct terms.

exists_pair_ne : x y, x y

Predicate typeclass for expressing that a type is not reduced to a single element. In rings, this is equivalent to 0 ≠ 1≠ 1. In vector spaces, this is equivalent to positive dimension.

Instances
theorem nontrivial_iff {α : Type u_1} :
x y, x y
theorem exists_pair_ne (α : Type u_1) [inst : ] :
x y, x y
theorem Decidable.exists_ne {α : Type u_1} [inst : ] [inst : ] (x : α) :
y, y x
theorem exists_ne {α : Type u_1} [inst : ] (x : α) :
y, y x
theorem nontrivial_of_ne {α : Type u_1} (x : α) (y : α) (h : x y) :
theorem nontrivial_of_lt {α : Type u_1} [inst : ] (x : α) (y : α) (h : x < y) :
theorem exists_pair_lt (α : Type u_1) [inst : ] [inst : ] :
x y, x < y
theorem nontrivial_iff_lt {α : Type u_1} [inst : ] :
x y, x < y
theorem nontrivial_iff_exists_ne {α : Type u_1} (x : α) :
y, y x
theorem Subtype.nontrivial_iff_exists_ne {α : Type u_1} (p : αProp) (x : ) :
y x, y x
Equations
instance Nontrivial.to_nonempty {α : Type u_1} [inst : ] :

See Note [lower instance priority]

Note that since this and nonempty_of_inhabited are the most "obvious" way to find a nonempty instance if no direct instance can be found, we give this a higher priority than the usual 100.

Equations
noncomputable def nontrivialPSumUnique (α : Type u_1) [inst : ] :

An inhabited type is either nontrivial, or has a unique element.

Equations
• = if h : then else PSum.inr { toInhabited := { default := default }, uniq := (_ : ∀ (x : α), x = default) }
theorem subsingleton_iff {α : Type u_1} :
∀ (x y : α), x = y
theorem not_nontrivial (α : Type u_1) [inst : ] :
theorem not_subsingleton (α : Type u_1) [inst : ] :
theorem subsingleton_or_nontrivial (α : Type u_1) :

A type is either a subsingleton or nontrivial.

theorem false_of_nontrivial_of_subsingleton (α : Type u_1) [inst : ] [inst : ] :
instance Option.nontrivial {α : Type u_1} [inst : ] :
Equations
theorem Function.Injective.nontrivial {α : Type u_1} {β : Type u_2} [inst : ] {f : αβ} (hf : ) :

Pushforward a nontrivial instance along an injective function.

theorem Function.Surjective.nontrivial {α : Type u_2} {β : Type u_1} [inst : ] {f : αβ} (hf : ) :

Pullback a nontrivial instance along a surjective function.

theorem Function.Injective.exists_ne {α : Type u_1} {β : Type u_2} [inst : ] {f : αβ} (hf : ) (y : β) :
x, f x y

An injective function from a nontrivial type has an argument at which it does not take a given value.

instance nontrivial_prod_right {α : Type u_1} {β : Type u_2} [inst : ] [inst : ] :
Nontrivial (α × β)
Equations
instance nontrivial_prod_left {α : Type u_1} {β : Type u_2} [inst : ] [inst : ] :
Nontrivial (α × β)
Equations
theorem Pi.nontrivial_at {I : Type u_2} {f : IType u_1} (i' : I) [inst : ∀ (i : I), Nonempty (f i)] [inst : Nontrivial (f i')] :
Nontrivial ((i : I) → f i)

A pi type is nontrivial if it's nonempty everywhere and nontrivial somewhere.

instance Pi.nontrivial {I : Type u_1} {f : IType u_2} [inst : ] [inst : ∀ (i : I), Nonempty (f i)] [inst : Nontrivial (f default)] :
Nontrivial ((i : I) → f i)

As a convenience, provide an instance automatically if (f default) is nontrivial.

If a different index has the non-trivial type, then use haveI := nontrivial_at that_index.

Equations
instance Function.nontrivial {α : Type u_1} {β : Type u_2} [h : ] [inst : ] :
Nontrivial (αβ)
Equations
theorem Subsingleton.le {α : Type u_1} [inst : ] [inst : ] (x : α) (y : α) :
x y