# 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 #

• {x : α // 0 ≤ x} is a CanonicallyLinearOrderedAddCommMonoid if α is a LinearOrderedRing.

## 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 an 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.

instance Nonneg.orderBot {α : Type u_1} [] {a : α} :
OrderBot { x : α // a x }

This instance uses data fields from Subtype.partialOrder 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
• Nonneg.orderBot = let __src := Set.Ici.orderBot;
theorem Nonneg.bot_eq {α : Type u_1} [] {a : α} :
= a,
instance Nonneg.noMaxOrder {α : Type u_1} [] [] {a : α} :
NoMaxOrder { x : α // a x }
Equations
• =
instance Nonneg.semilatticeSup {α : Type u_1} [] {a : α} :
SemilatticeSup { x : α // a x }
Equations
• Nonneg.semilatticeSup = Set.Ici.semilatticeSup
instance Nonneg.semilatticeInf {α : Type u_1} [] {a : α} :
SemilatticeInf { x : α // a x }
Equations
• Nonneg.semilatticeInf = Set.Ici.semilatticeInf
instance Nonneg.distribLattice {α : Type u_1} [] {a : α} :
DistribLattice { x : α // a x }
Equations
• Nonneg.distribLattice = Set.Ici.distribLattice
instance Nonneg.instDenselyOrdered {α : Type u_1} [] [] {a : α} :
DenselyOrdered { x : α // a x }
Equations
• =
@[reducible, inline]
noncomputable abbrev Nonneg.conditionallyCompleteLinearOrder {α : Type u_1} {a : α} :

If sSup ∅ ≤ a then {x : α // a ≤ x} is a ConditionallyCompleteLinearOrder.

Equations
• One or more equations did not get rendered due to their size.
Instances For
@[reducible, inline]
noncomputable abbrev Nonneg.conditionallyCompleteLinearOrderBot {α : Type u_1} (a : α) :

If sSup ∅ ≤ a then {x : α // a ≤ x} is a ConditionallyCompleteLinearOrderBot.

This instance uses data fields from Subtype.linearOrder 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
• = let __src := Nonneg.orderBot; let __src_1 := Nonneg.conditionallyCompleteLinearOrder;
Instances For
instance Nonneg.inhabited {α : Type u_1} [] {a : α} :
Inhabited { x : α // a x }
Equations
• Nonneg.inhabited = { default := a, }
instance Nonneg.zero {α : Type u_1} [Zero α] [] :
Zero { x : α // 0 x }
Equations
• Nonneg.zero = { zero := 0, }
@[simp]
theorem Nonneg.coe_zero {α : Type u_1} [Zero α] [] :
0 = 0
@[simp]
theorem Nonneg.mk_eq_zero {α : Type u_1} [Zero α] [] {x : α} (hx : 0 x) :
x, hx = 0 x = 0
instance Nonneg.add {α : Type u_1} [] [] [CovariantClass α α (fun (x x_1 : α) => x + x_1) fun (x x_1 : α) => x x_1] :
Add { x : α // 0 x }
Equations
• Nonneg.add = { add := fun (x y : { x : α // 0 x }) => x + y, }
@[simp]
theorem Nonneg.mk_add_mk {α : Type u_1} [] [] [CovariantClass α α (fun (x x_1 : α) => x + x_1) fun (x x_1 : α) => x x_1] {x : α} {y : α} (hx : 0 x) (hy : 0 y) :
x, hx + y, hy = x + y,
@[simp]
theorem Nonneg.coe_add {α : Type u_1} [] [] [CovariantClass α α (fun (x x_1 : α) => x + x_1) fun (x x_1 : α) => x x_1] (a : { x : α // 0 x }) (b : { x : α // 0 x }) :
(a + b) = a + b
instance Nonneg.nsmul {α : Type u_1} [] [] [CovariantClass α α (fun (x x_1 : α) => x + x_1) fun (x x_1 : α) => x x_1] :
SMul { x : α // 0 x }
Equations
• Nonneg.nsmul = { smul := fun (n : ) (x : { x : α // 0 x }) => n x, }
@[simp]
theorem Nonneg.nsmul_mk {α : Type u_1} [] [] [CovariantClass α α (fun (x x_1 : α) => x + x_1) fun (x x_1 : α) => x x_1] (n : ) {x : α} (hx : 0 x) :
n x, hx = n x,
@[simp]
theorem Nonneg.coe_nsmul {α : Type u_1} [] [] [CovariantClass α α (fun (x x_1 : α) => x + x_1) fun (x x_1 : α) => x x_1] (n : ) (a : { x : α // 0 x }) :
(n a) = n a
instance Nonneg.orderedAddCommMonoid {α : Type u_1} :
OrderedAddCommMonoid { x : α // 0 x }
Equations
Equations
Equations
Equations
def Nonneg.coeAddMonoidHom {α : Type u_1} :
{ x : α // 0 x } →+ α

Coercion {x : α // 0 ≤ x} → α as an AddMonoidHom.

Equations
• Nonneg.coeAddMonoidHom = { toFun := Subtype.val, map_zero' := , map_add' := }
Instances For
theorem Nonneg.nsmul_coe {α : Type u_1} (n : ) (r : { x : α // 0 x }) :
(n r) = n r
instance Nonneg.one {α : Type u_1} [] :
One { x : α // 0 x }
Equations
• Nonneg.one = { one := 1, }
@[simp]
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
instance Nonneg.mul {α : Type u_1} [] :
Mul { x : α // 0 x }
Equations
• Nonneg.mul = { mul := fun (x y : { x : α // 0 x }) => x * y, }
@[simp]
theorem Nonneg.coe_mul {α : Type u_1} [] (a : { x : α // 0 x }) (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,
instance Nonneg.addMonoidWithOne {α : Type u_1} [] :
AddMonoidWithOne { x : α // 0 x }
Equations
@[simp]
theorem Nonneg.coe_natCast {α : Type u_1} [] (n : ) :
n = n
@[deprecated Nonneg.coe_natCast]
theorem Nonneg.coe_nat_cast {α : Type u_1} [] (n : ) :
n = n

Alias of Nonneg.coe_natCast.

@[simp]
theorem Nonneg.mk_natCast {α : Type u_1} [] (n : ) :
n, = n
@[deprecated Nonneg.mk_natCast]
theorem Nonneg.mk_nat_cast {α : Type u_1} [] (n : ) :
n, = n

Alias of Nonneg.mk_natCast.

instance Nonneg.pow {α : Type u_1} [] :
Pow { x : α // 0 x }
Equations
• Nonneg.pow = { pow := fun (x : { x : α // 0 x }) (n : ) => x ^ n, }
@[simp]
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,
instance Nonneg.orderedSemiring {α : Type u_1} [] :
OrderedSemiring { x : α // 0 x }
Equations
instance Nonneg.strictOrderedSemiring {α : Type u_1} :
StrictOrderedSemiring { x : α // 0 x }
Equations
instance Nonneg.orderedCommSemiring {α : Type u_1} :
OrderedCommSemiring { x : α // 0 x }
Equations
Equations
instance Nonneg.monoidWithZero {α : Type u_1} [] :
MonoidWithZero { x : α // 0 x }
Equations
• Nonneg.monoidWithZero = inferInstance
instance Nonneg.commMonoidWithZero {α : Type u_1} :
CommMonoidWithZero { x : α // 0 x }
Equations
• Nonneg.commMonoidWithZero = inferInstance
instance Nonneg.semiring {α : Type u_1} [] :
Semiring { x : α // 0 x }
Equations
• Nonneg.semiring = inferInstance
instance Nonneg.commSemiring {α : Type u_1} :
CommSemiring { x : α // 0 x }
Equations
• Nonneg.commSemiring = inferInstance
instance Nonneg.nontrivial {α : Type u_1} :
Nontrivial { x : α // 0 x }
Equations
• =
instance Nonneg.linearOrderedSemiring {α : Type u_1} :
LinearOrderedSemiring { x : α // 0 x }
Equations
Equations
• Nonneg.linearOrderedCommMonoidWithZero = let __src := Nonneg.linearOrderedSemiring; let __src_1 := Nonneg.orderedCommSemiring;
def Nonneg.coeRingHom {α : Type u_1} [] :
{ x : α // 0 x } →+* α

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

Equations
• Nonneg.coeRingHom = { toFun := Subtype.val, map_one' := , map_mul' := , map_zero' := , map_add' := }
Instances For
Equations
Equations
• One or more equations did not get rendered due to their size.
Equations
• One or more equations did not get rendered due to their size.
def Nonneg.toNonneg {α : Type u_1} [Zero α] [] (a : α) :
{ x : α // 0 x }

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

Equations
• = max a 0,
Instances For
@[simp]
theorem Nonneg.coe_toNonneg {α : Type u_1} [Zero α] [] {a : α} :
() = max a 0
@[simp]
theorem Nonneg.toNonneg_of_nonneg {α : Type u_1} [Zero α] [] {a : α} (h : 0 a) :
= a, h
@[simp]
theorem Nonneg.toNonneg_coe {α : Type u_1} [Zero α] [] {a : { x : α // 0 x }} :
= a
@[simp]
theorem Nonneg.toNonneg_le {α : Type u_1} [Zero α] [] {a : α} {b : { x : α // 0 x }} :
a b
@[simp]
theorem Nonneg.toNonneg_lt {α : Type u_1} [Zero α] [] {a : { x : α // 0 x }} {b : α} :
a < b
instance Nonneg.sub {α : Type u_1} [Zero α] [] [Sub α] :
Sub { x : α // 0 x }
Equations
@[simp]
theorem Nonneg.mk_sub_mk {α : Type u_1} [Zero α] [] [Sub α] {x : α} {y : α} (hx : 0 x) (hy : 0 y) :
x, hx - y, hy = Nonneg.toNonneg (x - y)
instance Nonneg.orderedSub {α : Type u_1} :
OrderedSub { x : α // 0 x }
Equations
• =