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
.
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.
Equations
- Nonneg.inhabited = { default := ⟨a, ⋯⟩ }
Equations
- Nonneg.zero = { zero := ⟨0, ⋯⟩ }
Equations
- Nonneg.add = { add := fun (x y : { x : α // 0 ≤ x }) => ⟨↑x + ↑y, ⋯⟩ }
Equations
- Nonneg.nsmul = { smul := fun (n : ℕ) (x : { x : α // 0 ≤ x }) => ⟨n • ↑x, ⋯⟩ }
Equations
- Nonneg.one = { one := ⟨1, ⋯⟩ }
Equations
- Nonneg.mul = { mul := fun (x y : { x : α // 0 ≤ x }) => ⟨↑x * ↑y, ⋯⟩ }
Equations
- Nonneg.addMonoid = Function.Injective.addMonoid (fun (a : { x : α // 0 ≤ x }) => ↑a) ⋯ ⋯ ⋯ ⋯
Coercion {x : α // 0 ≤ x} → α
as an AddMonoidHom
.
Equations
- Nonneg.coeAddMonoidHom = { toFun := Subtype.val, map_zero' := ⋯, map_add' := ⋯ }
Instances For
Equations
- Nonneg.addCommMonoid = Function.Injective.addCommMonoid (fun (a : { x : α // 0 ≤ x }) => ↑a) ⋯ ⋯ ⋯ ⋯
Equations
- Nonneg.natCast = { natCast := fun (n : ℕ) => ⟨↑n, ⋯⟩ }
Alias of Nonneg.coe_natCast
.
Alias of Nonneg.mk_natCast
.
Equations
Equations
- Nonneg.pow = { pow := fun (x : { x : α // 0 ≤ x }) (n : ℕ) => ⟨↑x ^ n, ⋯⟩ }
Equations
- Nonneg.semiring = Function.Injective.semiring (fun (a : { x : α // 0 ≤ x }) => ↑a) ⋯ ⋯ ⋯ ⋯ ⋯ ⋯ ⋯ ⋯
Equations
Coercion {x : α // 0 ≤ x} → α
as a RingHom
.
Equations
- Nonneg.coeRingHom = { toFun := Subtype.val, map_one' := ⋯, map_mul' := ⋯, map_zero' := ⋯, map_add' := ⋯ }
Instances For
Equations
- Nonneg.commSemiring = Function.Injective.commSemiring (fun (a : { x : α // 0 ≤ x }) => ↑a) ⋯ ⋯ ⋯ ⋯ ⋯ ⋯ ⋯ ⋯
Equations
The function a ↦ max a 0
of type α → {x : α // 0 ≤ x}
.
Equations
- Nonneg.toNonneg a = ⟨a ⊔ 0, ⋯⟩
Instances For
Equations
- Nonneg.sub = { sub := fun (x y : { x : α // 0 ≤ x }) => Nonneg.toNonneg (↑x - ↑y) }