# mathlib3documentation

algebra.order.nonneg.ring

# The type of nonnegative elements #

THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.

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 #

• {x : α // 0 ≤ x} is a canonically_linear_ordered_add_monoid if α is a linear_ordered_ring.

## 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} [no_max_order α] {a : α} :
no_max_order {x // a x}
@[protected, instance]
def nonneg.semilattice_sup {α : Type u_1} {a : α} :
semilattice_sup {x // a x}
Equations
@[protected, instance]
def nonneg.semilattice_inf {α : Type u_1} {a : α} :
semilattice_inf {x // a x}
Equations
@[protected, instance]
def nonneg.distrib_lattice {α : Type u_1} {a : α} :
distrib_lattice {x // a x}
Equations
@[protected, instance]
def nonneg.densely_ordered {α : Type u_1} [preorder α] {a : α} :
densely_ordered {x // a x}
@[protected, reducible]
noncomputable def nonneg.conditionally_complete_linear_order {α : Type u_1} {a : α} :

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

Equations
@[protected, reducible]
noncomputable def nonneg.conditionally_complete_linear_order_bot {α : Type u_1} {a : α} (h : a) :

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} [preorder α]  :
Equations
@[simp]
theorem nonneg.mk_add_mk {α : Type u_1} [preorder α] {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} [preorder α] (a b : {x // 0 x}) :
(a + b) = a + b
@[protected, instance]
def nonneg.has_nsmul {α : Type u_1} [add_monoid α] [preorder α]  :
{x // 0 x}
Equations
@[simp]
theorem nonneg.nsmul_mk {α : Type u_1} [add_monoid α] [preorder α] (n : ) {x : α} (hx : 0 x) :
n x, hx⟩ = n x, _⟩
@[protected, simp, norm_cast]
theorem nonneg.coe_nsmul {α : Type u_1} [add_monoid α] [preorder α] (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}  :
{x // 0 x} →+ α

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

Equations
@[norm_cast]
theorem nonneg.nsmul_coe {α : Type u_1} (n : ) (r : {x // 0 x}) :
(n r) = n r
@[protected, instance]
def nonneg.has_one {α : Type u_1}  :
has_one {x // 0 x}
Equations
@[protected, simp, norm_cast]
theorem nonneg.coe_one {α : Type u_1}  :
1 = 1
@[simp]
theorem nonneg.mk_eq_one {α : Type u_1} {x : α} (hx : 0 x) :
x, hx⟩ = 1 x = 1
@[protected, instance]
def nonneg.has_mul {α : Type u_1}  :
has_mul {x // 0 x}
Equations
@[protected, simp, norm_cast]
theorem nonneg.coe_mul {α : Type u_1} (a b : {x // 0 x}) :
(a * b) = a * b
@[simp]
theorem nonneg.mk_mul_mk {α : Type u_1} {x y : α} (hx : 0 x) (hy : 0 y) :
x, hx⟩ * y, hy⟩ = x * y, _⟩
@[protected, instance]
def nonneg.add_monoid_with_one {α : Type u_1}  :
Equations
@[protected, simp, norm_cast]
theorem nonneg.coe_nat_cast {α : Type u_1} (n : ) :
@[simp]
theorem nonneg.mk_nat_cast {α : Type u_1} (n : ) :
n, _⟩ = n
@[protected, instance]
def nonneg.has_pow {α : Type u_1}  :
has_pow {x // 0 x}
Equations
@[protected, simp, norm_cast]
theorem nonneg.coe_pow {α : Type u_1} (a : {x // 0 x}) (n : ) :
(a ^ n) = a ^ n
@[simp]
theorem nonneg.mk_pow {α : Type u_1} {x : α} (hx : 0 x) (n : ) :
x, hx⟩ ^ n = x ^ n, _⟩
@[protected, instance]
def nonneg.ordered_semiring {α : Type u_1}  :
Equations
• nonneg.ordered_semiring = nonneg.ordered_semiring._proof_3 nonneg.ordered_semiring._proof_4 nonneg.ordered_semiring._proof_5 nonneg.ordered_semiring._proof_6 nonneg.ordered_semiring._proof_7 nonneg.ordered_semiring._proof_8 nonneg.ordered_semiring._proof_9 nonneg.ordered_semiring._proof_10
@[protected, instance]
Equations
• nonneg.strict_ordered_semiring = nonneg.strict_ordered_semiring._proof_3 nonneg.strict_ordered_semiring._proof_4 nonneg.strict_ordered_semiring._proof_5 nonneg.strict_ordered_semiring._proof_6 nonneg.strict_ordered_semiring._proof_7 nonneg.strict_ordered_semiring._proof_8 nonneg.strict_ordered_semiring._proof_9 nonneg.strict_ordered_semiring._proof_10
@[protected, instance]
Equations
• nonneg.ordered_comm_semiring = nonneg.ordered_comm_semiring._proof_3 nonneg.ordered_comm_semiring._proof_4 nonneg.ordered_comm_semiring._proof_5 nonneg.ordered_comm_semiring._proof_6 nonneg.ordered_comm_semiring._proof_7 nonneg.ordered_comm_semiring._proof_8 nonneg.ordered_comm_semiring._proof_9 nonneg.ordered_comm_semiring._proof_10
@[protected, instance]
Equations
• nonneg.strict_ordered_comm_semiring = nonneg.strict_ordered_comm_semiring._proof_3 nonneg.strict_ordered_comm_semiring._proof_4 nonneg.strict_ordered_comm_semiring._proof_5 nonneg.strict_ordered_comm_semiring._proof_6 nonneg.strict_ordered_comm_semiring._proof_7 nonneg.strict_ordered_comm_semiring._proof_8 nonneg.strict_ordered_comm_semiring._proof_9 nonneg.strict_ordered_comm_semiring._proof_10
@[protected, instance]
def nonneg.monoid_with_zero {α : Type u_1}  :
Equations
@[protected, instance]
Equations
@[protected, instance]
def nonneg.semiring {α : Type u_1}  :
semiring {x // 0 x}
Equations
@[protected, instance]
def nonneg.comm_semiring {α : Type u_1}  :
comm_semiring {x // 0 x}
Equations
@[protected, instance]
def nonneg.nontrivial {α : Type u_1}  :
nontrivial {x // 0 x}
@[protected, instance]
Equations
• nonneg.linear_ordered_semiring = nonneg.linear_ordered_semiring._proof_3 nonneg.linear_ordered_semiring._proof_4 nonneg.linear_ordered_semiring._proof_5 nonneg.linear_ordered_semiring._proof_6 nonneg.linear_ordered_semiring._proof_7 nonneg.linear_ordered_semiring._proof_8 nonneg.linear_ordered_semiring._proof_9 nonneg.linear_ordered_semiring._proof_10 nonneg.linear_ordered_semiring._proof_11 nonneg.linear_ordered_semiring._proof_12
@[protected, instance]
Equations
def nonneg.coe_ring_hom {α : Type u_1}  :
{x // 0 x} →+* α

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

Equations
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) :
= a, h⟩
@[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}} :
a b
@[simp]
theorem nonneg.to_nonneg_lt {α : Type u_1} [has_zero α] [linear_order α] {a : {x // 0 x}} {b : α} :
a < 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}  :
has_ordered_sub {x // 0 x}