Documentation

Mathlib.Algebra.Order.Nonneg.Basic

The type of nonnegative elements #

This file defines instances and prove some properties about the nonnegative elements Nonneg α 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.

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.

@[reducible, inline]
abbrev Nonneg (α : Type u_2) [Zero α] [LE α] :
Type u_2

The subtype of nonnegative elements.

TODO: Nonneg could be converted to a one-field or two-field structure, as discussed on Zulip: https://leanprover.zulipchat.com/#narrow/channel/113488-general/topic/backward.2EisDefEq.2ErespectTransparency/near/585745328

Equations
Instances For
    @[instance_reducible]
    instance Nonneg.inhabited {α : Type u_1} [Preorder α] {a : α} :
    Inhabited { x : α // a x }
    Equations
    @[instance_reducible]
    instance Nonneg.zero {α : Type u_1} [Zero α] [Preorder α] :
    Equations
    @[simp]
    theorem Nonneg.coe_zero {α : Type u_1} [Zero α] [Preorder α] :
    0 = 0
    @[simp]
    theorem Nonneg.mk_eq_zero {α : Type u_1} [Zero α] [Preorder α] {x : α} (hx : 0 x) :
    x, hx = 0 x = 0
    @[instance_reducible]
    instance Nonneg.add {α : Type u_1} [AddZeroClass α] [Preorder α] [AddLeftMono α] :
    Add (Nonneg α)
    Equations
    @[simp]
    theorem Nonneg.mk_add_mk {α : Type u_1} [AddZeroClass α] [Preorder α] [AddLeftMono α] {x y : α} (hx : 0 x) (hy : 0 y) :
    x, hx + y, hy = x + y,
    @[simp]
    theorem Nonneg.coe_add {α : Type u_1} [AddZeroClass α] [Preorder α] [AddLeftMono α] (a b : Nonneg α) :
    ↑(a + b) = a + b
    @[instance_reducible]
    instance Nonneg.nsmul {α : Type u_1} [AddMonoid α] [Preorder α] [AddLeftMono α] :
    Equations
    @[simp]
    theorem Nonneg.nsmul_mk {α : Type u_1} [AddMonoid α] [Preorder α] [AddLeftMono α] (n : ) {x : α} (hx : 0 x) :
    n x, hx = n x,
    @[simp]
    theorem Nonneg.coe_nsmul {α : Type u_1} [AddMonoid α] [Preorder α] [AddLeftMono α] (n : ) (a : Nonneg α) :
    ↑(n a) = n a
    @[instance_reducible]
    instance Nonneg.one {α : Type u_1} [Zero α] [One α] [LE α] [ZeroLEOneClass α] :
    One (Nonneg α)
    Equations
    @[simp]
    theorem Nonneg.coe_one {α : Type u_1} [Zero α] [One α] [LE α] [ZeroLEOneClass α] :
    1 = 1
    @[simp]
    theorem Nonneg.mk_eq_one {α : Type u_1} [Zero α] [One α] [LE α] [ZeroLEOneClass α] {x : α} (hx : 0 x) :
    x, hx = 1 x = 1
    @[instance_reducible]
    instance Nonneg.mul {α : Type u_1} [MulZeroClass α] [Preorder α] [PosMulMono α] :
    Mul (Nonneg α)
    Equations
    @[simp]
    theorem Nonneg.coe_mul {α : Type u_1} [MulZeroClass α] [Preorder α] [PosMulMono α] (a b : Nonneg α) :
    ↑(a * b) = a * b
    @[simp]
    theorem Nonneg.mk_mul_mk {α : Type u_1} [MulZeroClass α] [Preorder α] [PosMulMono α] {x y : α} (hx : 0 x) (hy : 0 y) :
    x, hx * y, hy = x * y,
    @[instance_reducible]
    instance Nonneg.addMonoid {α : Type u_1} [AddMonoid α] [Preorder α] [AddLeftMono α] :
    Equations
    def Nonneg.coeAddMonoidHom {α : Type u_1} [AddMonoid α] [Preorder α] [AddLeftMono α] :
    Nonneg α →+ α

    Coercion Nonneg α → α as an AddMonoidHom.

    Equations
    Instances For
      @[simp]
      theorem Nonneg.coeAddMonoidHom_apply {α : Type u_1} [AddMonoid α] [Preorder α] [AddLeftMono α] (self : { x : α // 0 x }) :
      coeAddMonoidHom self = self
      theorem Nonneg.nsmul_coe {α : Type u_1} [AddMonoid α] [Preorder α] [AddLeftMono α] (n : ) (r : Nonneg α) :
      ↑(n r) = n r
      @[instance_reducible]
      Equations
      @[instance_reducible]
      Equations
      @[instance_reducible]
      Equations
      @[simp]
      theorem Nonneg.coe_natCast {α : Type u_1} [AddMonoidWithOne α] [PartialOrder α] [AddLeftMono α] [ZeroLEOneClass α] (n : ) :
      n = n
      @[simp]
      theorem Nonneg.mk_natCast {α : Type u_1} [AddMonoidWithOne α] [PartialOrder α] [AddLeftMono α] [ZeroLEOneClass α] (n : ) :
      n, = n
      @[instance_reducible]
      Equations
      @[instance_reducible]
      instance Nonneg.pow {α : Type u_1} [MonoidWithZero α] [Preorder α] [ZeroLEOneClass α] [PosMulMono α] :
      Equations
      @[simp]
      theorem Nonneg.coe_pow {α : Type u_1} [MonoidWithZero α] [Preorder α] [ZeroLEOneClass α] [PosMulMono α] (a : Nonneg α) (n : ) :
      ↑(a ^ n) = a ^ n
      @[simp]
      theorem Nonneg.mk_pow {α : Type u_1} [MonoidWithZero α] [Preorder α] [ZeroLEOneClass α] [PosMulMono α] {x : α} (hx : 0 x) (n : ) :
      x, hx ^ n = x ^ n,
      @[instance_reducible]
      instance Nonneg.semiring {α : Type u_1} [Semiring α] [PartialOrder α] [ZeroLEOneClass α] [AddLeftMono α] [PosMulMono α] :
      Equations
      • One or more equations did not get rendered due to their size.

      Coercion Nonneg α → α as a RingHom.

      Equations
      Instances For
        @[instance_reducible]
        Equations
        def Nonneg.toNonneg {α : Type u_1} [Zero α] [SemilatticeSup α] (a : α) :

        The function a ↦ max a 0 of type α → Nonneg α.

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