Documentation

Mathlib.Algebra.Order.Nonneg.Ring

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 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} [Preorder α] {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
theorem Nonneg.bot_eq {α : Type u_1} [Preorder α] {a : α} :
= { val := a, property := (_ : a a) }
instance Nonneg.semilatticeSup {α : Type u_1} [SemilatticeSup α] {a : α} :
SemilatticeSup { x // a x }
Equations
  • Nonneg.semilatticeSup = Set.Ici.semilatticeSup
instance Nonneg.semilatticeInf {α : Type u_1} [SemilatticeInf α] {a : α} :
SemilatticeInf { x // a x }
Equations
  • Nonneg.semilatticeInf = Set.Ici.semilatticeInf
instance Nonneg.distribLattice {α : Type u_1} [DistribLattice α] {a : α} :
DistribLattice { x // a x }
Equations
  • Nonneg.distribLattice = Set.Ici.distribLattice
@[reducible]

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]

    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
    • One or more equations did not get rendered due to their size.
    Instances For
      instance Nonneg.inhabited {α : Type u_1} [Preorder α] {a : α} :
      Inhabited { x // a x }
      Equations
      • Nonneg.inhabited = { default := { val := a, property := (_ : a a) } }
      instance Nonneg.zero {α : Type u_1} [Zero α] [Preorder α] :
      Zero { x // 0 x }
      Equations
      • Nonneg.zero = { zero := { val := 0, property := (_ : 0 0) } }
      @[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) :
      { val := x, property := hx } = 0 x = 0
      instance Nonneg.add {α : Type u_1} [AddZeroClass α] [Preorder α] [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 => { val := x + y, property := (_ : 0 x + y) } }
      @[simp]
      theorem Nonneg.mk_add_mk {α : Type u_1} [AddZeroClass α] [Preorder α] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] {x : α} {y : α} (hx : 0 x) (hy : 0 y) :
      { val := x, property := hx } + { val := y, property := hy } = { val := x + y, property := (_ : 0 x + y) }
      @[simp]
      theorem Nonneg.coe_add {α : Type u_1} [AddZeroClass α] [Preorder α] [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} [AddMonoid α] [Preorder α] [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 => { val := n x, property := (_ : 0 n x) } }
      @[simp]
      theorem Nonneg.nsmul_mk {α : Type u_1} [AddMonoid α] [Preorder α] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] (n : ) {x : α} (hx : 0 x) :
      n { val := x, property := hx } = { val := n x, property := (_ : 0 n x) }
      @[simp]
      theorem Nonneg.coe_nsmul {α : Type u_1} [AddMonoid α] [Preorder α] [CovariantClass α α (fun x x_1 => x + x_1) fun x x_1 => x x_1] (n : ) (a : { x // 0 x }) :
      ↑(n a) = n a
      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.
      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.coeAddMonoidHom {α : Type u_1} [OrderedAddCommMonoid α] :
      { x // 0 x } →+ α

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

      Equations
      • Nonneg.coeAddMonoidHom = { toZeroHom := { toFun := Subtype.val, map_zero' := (_ : 0 = 0) }, map_add' := (_ : ∀ (a b : { x // 0 x }), ↑(a + b) = a + b) }
      Instances For
        theorem Nonneg.nsmul_coe {α : Type u_1} [OrderedAddCommMonoid α] (n : ) (r : { x // 0 x }) :
        ↑(n r) = n r
        instance Nonneg.one {α : Type u_1} [OrderedSemiring α] :
        One { x // 0 x }
        Equations
        • Nonneg.one = { one := { val := 1, property := (_ : 0 1) } }
        @[simp]
        theorem Nonneg.coe_one {α : Type u_1} [OrderedSemiring α] :
        1 = 1
        @[simp]
        theorem Nonneg.mk_eq_one {α : Type u_1} [OrderedSemiring α] {x : α} (hx : 0 x) :
        { val := x, property := hx } = 1 x = 1
        instance Nonneg.mul {α : Type u_1} [OrderedSemiring α] :
        Mul { x // 0 x }
        Equations
        • Nonneg.mul = { mul := fun x y => { val := x * y, property := (_ : 0 x * y) } }
        @[simp]
        theorem Nonneg.coe_mul {α : Type u_1} [OrderedSemiring α] (a : { x // 0 x }) (b : { x // 0 x }) :
        ↑(a * b) = a * b
        @[simp]
        theorem Nonneg.mk_mul_mk {α : Type u_1} [OrderedSemiring α] {x : α} {y : α} (hx : 0 x) (hy : 0 y) :
        { val := x, property := hx } * { val := y, property := hy } = { val := x * y, property := (_ : 0 x * y) }
        instance Nonneg.addMonoidWithOne {α : Type u_1} [OrderedSemiring α] :
        AddMonoidWithOne { x // 0 x }
        Equations
        • Nonneg.addMonoidWithOne = let src := Nonneg.one; let src_1 := Nonneg.orderedAddCommMonoid; AddMonoidWithOne.mk
        @[simp]
        theorem Nonneg.coe_nat_cast {α : Type u_1} [OrderedSemiring α] (n : ) :
        n = n
        @[simp]
        theorem Nonneg.mk_nat_cast {α : Type u_1} [OrderedSemiring α] (n : ) :
        { val := n, property := (_ : 0 n) } = n
        instance Nonneg.pow {α : Type u_1} [OrderedSemiring α] :
        Pow { x // 0 x }
        Equations
        • Nonneg.pow = { pow := fun x n => { val := x ^ n, property := (_ : 0 x ^ n) } }
        @[simp]
        theorem Nonneg.coe_pow {α : Type u_1} [OrderedSemiring α] (a : { x // 0 x }) (n : ) :
        ↑(a ^ n) = a ^ n
        @[simp]
        theorem Nonneg.mk_pow {α : Type u_1} [OrderedSemiring α] {x : α} (hx : 0 x) (n : ) :
        { val := x, property := hx } ^ n = { val := x ^ n, property := (_ : 0 x ^ n) }
        instance Nonneg.orderedSemiring {α : Type u_1} [OrderedSemiring α] :
        OrderedSemiring { x // 0 x }
        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.
        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.
        instance Nonneg.monoidWithZero {α : Type u_1} [OrderedSemiring α] :
        MonoidWithZero { x // 0 x }
        Equations
        • Nonneg.monoidWithZero = inferInstance
        Equations
        • Nonneg.commMonoidWithZero = inferInstance
        instance Nonneg.semiring {α : Type u_1} [OrderedSemiring α] :
        Semiring { x // 0 x }
        Equations
        • Nonneg.semiring = inferInstance
        instance Nonneg.commSemiring {α : Type u_1} [OrderedCommSemiring α] :
        CommSemiring { x // 0 x }
        Equations
        • Nonneg.commSemiring = inferInstance
        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.coeRingHom {α : Type u_1} [OrderedSemiring α] :
        { x // 0 x } →+* α

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

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          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.
          Equations
          • One or more equations did not get rendered due to their size.
          def Nonneg.toNonneg {α : Type u_1} [Zero α] [LinearOrder α] (a : α) :
          { x // 0 x }

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

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