mathlib documentation

algebra.order.nonneg

The type of nonnegative elements #

This file defines instances and prove some properties about the nonnegative elements {x : α // 0 ≤ x} of an arbitrary type α.

Currently we only state instances and states some simp/norm_cast lemmas.

When α is , this will give us some properties about ℝ≥0.

Main declarations #

Implementation Notes #

Instead of {x : α // 0 ≤ x} we could also use set.Ici (0 : α), which is definitionally equal. However, using the explicit subtype has a big advantage: when writing and element explicitly with a proof of nonnegativity as ⟨x, hx⟩, the hx is expected to have type 0 ≤ x. If we would use Ici 0, then the type is expected to be x ∈ Ici 0. Although these types are definitionally equal, this often confuses the elaborator. Similar problems arise when doing cases on an element.

The disadvantage is that we have to duplicate some instances about set.Ici to this subtype.

@[protected, instance]
def nonneg.order_bot {α : Type u_1} [preorder α] {a : α} :
order_bot {x // a x}

This instance uses data fields from subtype.partial_order to help type-class inference. The set.Ici data fields are definitionally equal, but that requires unfolding semireducible definitions, so type-class inference won't see this.

Equations
theorem nonneg.bot_eq {α : Type u_1} [preorder α] {a : α} :
= a, _⟩
@[protected, instance]
def nonneg.no_max_order {α : Type u_1} [partial_order α] [no_max_order α] {a : α} :
no_max_order {x // a x}
@[protected, instance]
def nonneg.semilattice_inf {α : Type u_1} [semilattice_inf α] {a : α} :
semilattice_inf {x // a x}
Equations
@[protected, instance]
def nonneg.densely_ordered {α : Type u_1} [preorder α] [densely_ordered α] {a : α} :
densely_ordered {x // a x}
@[protected]

If Sup ∅ ≤ a then {x : α // a ≤ x} is a conditionally_complete_linear_order.

Equations
@[protected]

If Sup ∅ ≤ a then {x : α // a ≤ x} is a conditionally_complete_linear_order_bot.

This instance uses data fields from subtype.linear_order to help type-class inference. The set.Ici data fields are definitionally equal, but that requires unfolding semireducible definitions, so type-class inference won't see this.

Equations
@[protected, instance]
def nonneg.inhabited {α : Type u_1} [preorder α] {a : α} :
inhabited {x // a x}
Equations
@[protected, instance]
def nonneg.has_zero {α : Type u_1} [has_zero α] [preorder α] :
has_zero {x // 0 x}
Equations
@[protected, simp, norm_cast]
theorem nonneg.coe_zero {α : Type u_1} [has_zero α] [preorder α] :
0 = 0
@[simp]
theorem nonneg.mk_eq_zero {α : Type u_1} [has_zero α] [preorder α] {x : α} (hx : 0 x) :
x, hx⟩ = 0 x = 0
@[protected, instance]
def nonneg.has_add {α : Type u_1} [add_zero_class α] [preorder α] [covariant_class α α has_add.add has_le.le] :
has_add {x // 0 x}
Equations
@[simp]
theorem nonneg.mk_add_mk {α : Type u_1} [add_zero_class α] [preorder α] [covariant_class α α has_add.add has_le.le] {x y : α} (hx : 0 x) (hy : 0 y) :
x, hx⟩ + y, hy⟩ = x + y, _⟩
@[protected, simp, norm_cast]
theorem nonneg.coe_add {α : Type u_1} [add_zero_class α] [preorder α] [covariant_class α α has_add.add has_le.le] (a b : {x // 0 x}) :
(a + b) = a + b
@[protected, instance]
def nonneg.has_nsmul {α : Type u_1} [add_monoid α] [preorder α] [covariant_class α α has_add.add has_le.le] :
has_scalar {x // 0 x}
Equations
@[simp]
theorem nonneg.nsmul_mk {α : Type u_1} [add_monoid α] [preorder α] [covariant_class α α has_add.add has_le.le] (n : ) {x : α} (hx : 0 x) :
n x, hx⟩ = n x, _⟩
@[protected, simp, norm_cast]
theorem nonneg.coe_nsmul {α : Type u_1} [add_monoid α] [preorder α] [covariant_class α α has_add.add has_le.le] (n : ) (a : {x // 0 x}) :
(n a) = n a
@[protected, instance]
Equations
@[protected, instance]
Equations
@[protected, instance]
Equations
@[protected, instance]
Equations
def nonneg.coe_add_monoid_hom {α : Type u_1} [ordered_add_comm_monoid α] :
{x // 0 x} →+ α

Coercion {x : α // 0 ≤ x} → α as a add_monoid_hom.

Equations
@[norm_cast]
theorem nonneg.nsmul_coe {α : Type u_1} [ordered_add_comm_monoid α] (n : ) (r : {x // 0 x}) :
(n r) = n r
@[protected, instance]
def nonneg.archimedean {α : Type u_1} [ordered_add_comm_monoid α] [archimedean α] :
archimedean {x // 0 x}
@[protected, instance]
def nonneg.has_one {α : Type u_1} [ordered_semiring α] :
has_one {x // 0 x}
Equations
@[protected, simp, norm_cast]
theorem nonneg.coe_one {α : Type u_1} [ordered_semiring α] :
1 = 1
@[simp]
theorem nonneg.mk_eq_one {α : Type u_1} [ordered_semiring α] {x : α} (hx : 0 x) :
x, hx⟩ = 1 x = 1
@[protected, instance]
def nonneg.has_mul {α : Type u_1} [ordered_semiring α] :
has_mul {x // 0 x}
Equations
@[protected, simp, norm_cast]
theorem nonneg.coe_mul {α : Type u_1} [ordered_semiring α] (a b : {x // 0 x}) :
a * b = (a) * b
@[simp]
theorem nonneg.mk_mul_mk {α : Type u_1} [ordered_semiring α] {x y : α} (hx : 0 x) (hy : 0 y) :
x, hx⟩ * y, hy⟩ = x * y, _⟩
@[protected, instance]
def nonneg.has_pow {α : Type u_1} [ordered_semiring α] :
has_pow {x // 0 x}
Equations
@[protected, simp, norm_cast]
theorem nonneg.coe_pow {α : Type u_1} [ordered_semiring α] (a : {x // 0 x}) (n : ) :
(a ^ n) = a ^ n
@[simp]
theorem nonneg.mk_pow {α : Type u_1} [ordered_semiring α] {x : α} (hx : 0 x) (n : ) :
x, hx⟩ ^ n = x ^ n, _⟩
@[protected, instance]
def nonneg.ordered_semiring {α : Type u_1} [ordered_semiring α] :
Equations
@[protected, instance]
Equations
@[protected, instance]
def nonneg.monoid_with_zero {α : Type u_1} [ordered_semiring α] :
Equations
@[protected, instance]
def nonneg.nontrivial {α : Type u_1} [linear_ordered_semiring α] :
nontrivial {x // 0 x}
@[protected, instance]
Equations
def nonneg.coe_ring_hom {α : Type u_1} [ordered_semiring α] :
{x // 0 x} →+* α

Coercion {x : α // 0 ≤ x} → α as a ring_hom.

Equations
@[protected, simp, norm_cast]
theorem nonneg.coe_nat_cast {α : Type u_1} [ordered_semiring α] (n : ) :
@[protected, instance]
def nonneg.has_inv {α : Type u_1} [linear_ordered_field α] :
has_inv {x // 0 x}
Equations
@[protected, simp, norm_cast]
theorem nonneg.coe_inv {α : Type u_1} [linear_ordered_field α] (a : {x // 0 x}) :
@[simp]
theorem nonneg.inv_mk {α : Type u_1} [linear_ordered_field α] {x : α} (hx : 0 x) :
x, hx⟩⁻¹ = x⁻¹, _⟩
@[protected, instance]
Equations
@[protected, instance]
def nonneg.has_div {α : Type u_1} [linear_ordered_field α] :
has_div {x // 0 x}
Equations
@[protected, simp, norm_cast]
theorem nonneg.coe_div {α : Type u_1} [linear_ordered_field α] (a b : {x // 0 x}) :
(a / b) = a / b
@[simp]
theorem nonneg.mk_div_mk {α : Type u_1} [linear_ordered_field α] {x y : α} (hx : 0 x) (hy : 0 y) :
x, hx⟩ / y, hy⟩ = x / y, _⟩
@[protected, instance]
def nonneg.floor_semiring {α : Type u_1} [ordered_semiring α] [floor_semiring α] :
floor_semiring {r // 0 r}
Equations
@[norm_cast]
theorem nonneg.nat_floor_coe {α : Type u_1} [ordered_semiring α] [floor_semiring α] (a : {r // 0 r}) :
@[norm_cast]
theorem nonneg.nat_ceil_coe {α : Type u_1} [ordered_semiring α] [floor_semiring α] (a : {r // 0 r}) :
def nonneg.to_nonneg {α : Type u_1} [has_zero α] [linear_order α] (a : α) :
{x // 0 x}

The function a ↦ max a 0 of type α → {x : α // 0 ≤ x}.

Equations
@[simp]
theorem nonneg.coe_to_nonneg {α : Type u_1} [has_zero α] [linear_order α] {a : α} :
@[simp]
theorem nonneg.to_nonneg_of_nonneg {α : Type u_1} [has_zero α] [linear_order α] {a : α} (h : 0 a) :
@[simp]
theorem nonneg.to_nonneg_coe {α : Type u_1} [has_zero α] [linear_order α] {a : {x // 0 x}} :
@[simp]
theorem nonneg.to_nonneg_le {α : Type u_1} [has_zero α] [linear_order α] {a : α} {b : {x // 0 x}} :
@[simp]
theorem nonneg.to_nonneg_lt {α : Type u_1} [has_zero α] [linear_order α] {a : {x // 0 x}} {b : α} :
@[protected, instance]
def nonneg.has_sub {α : Type u_1} [has_zero α] [linear_order α] [has_sub α] :
has_sub {x // 0 x}
Equations
@[simp]
theorem nonneg.mk_sub_mk {α : Type u_1} [has_zero α] [linear_order α] [has_sub α] {x y : α} (hx : 0 x) (hy : 0 y) :
x, hx⟩ - y, hy⟩ = nonneg.to_nonneg (x - y)
@[protected, instance]
def nonneg.has_ordered_sub {α : Type u_1} [linear_ordered_ring α] :
has_ordered_sub {x // 0 x}
Equations