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 acanonically_linear_ordered_add_monoid
ifα
is alinear_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.
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
- nonneg.order_bot = {bot := order_bot.bot set.Ici.order_bot, bot_le := _}
Equations
Equations
Equations
If Sup ∅ ≤ a
then {x : α // a ≤ x}
is a conditionally_complete_linear_order
.
Equations
- nonneg.conditionally_complete_linear_order = {sup := conditionally_complete_linear_order.sup (ord_connected_subset_conditionally_complete_linear_order (set.Ici a)), le := conditionally_complete_linear_order.le (ord_connected_subset_conditionally_complete_linear_order (set.Ici a)), lt := conditionally_complete_linear_order.lt (ord_connected_subset_conditionally_complete_linear_order (set.Ici a)), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := conditionally_complete_linear_order.inf (ord_connected_subset_conditionally_complete_linear_order (set.Ici a)), inf_le_left := _, inf_le_right := _, le_inf := _, Sup := conditionally_complete_linear_order.Sup (ord_connected_subset_conditionally_complete_linear_order (set.Ici a)), Inf := conditionally_complete_linear_order.Inf (ord_connected_subset_conditionally_complete_linear_order (set.Ici a)), le_cSup := _, cSup_le := _, cInf_le := _, le_cInf := _, le_total := _, decidable_le := conditionally_complete_linear_order.decidable_le (ord_connected_subset_conditionally_complete_linear_order (set.Ici a)), decidable_eq := conditionally_complete_linear_order.decidable_eq (ord_connected_subset_conditionally_complete_linear_order (set.Ici a)), decidable_lt := conditionally_complete_linear_order.decidable_lt (ord_connected_subset_conditionally_complete_linear_order (set.Ici a)), max_def := _, min_def := _}
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
- nonneg.conditionally_complete_linear_order_bot h = {sup := conditionally_complete_linear_order.sup nonneg.conditionally_complete_linear_order, le := conditionally_complete_linear_order.le nonneg.conditionally_complete_linear_order, lt := conditionally_complete_linear_order.lt nonneg.conditionally_complete_linear_order, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := conditionally_complete_linear_order.inf nonneg.conditionally_complete_linear_order, inf_le_left := _, inf_le_right := _, le_inf := _, Sup := conditionally_complete_linear_order.Sup nonneg.conditionally_complete_linear_order, Inf := conditionally_complete_linear_order.Inf nonneg.conditionally_complete_linear_order, le_cSup := _, cSup_le := _, cInf_le := _, le_cInf := _, le_total := _, decidable_le := conditionally_complete_linear_order.decidable_le nonneg.conditionally_complete_linear_order, decidable_eq := conditionally_complete_linear_order.decidable_eq nonneg.conditionally_complete_linear_order, decidable_lt := conditionally_complete_linear_order.decidable_lt nonneg.conditionally_complete_linear_order, max_def := _, min_def := _, bot := order_bot.bot nonneg.order_bot, bot_le := _, cSup_empty := _}
Equations
- nonneg.ordered_add_comm_monoid = function.injective.ordered_add_comm_monoid coe nonneg.ordered_add_comm_monoid._proof_1 nonneg.ordered_add_comm_monoid._proof_2 nonneg.ordered_add_comm_monoid._proof_3 nonneg.ordered_add_comm_monoid._proof_4
Equations
- nonneg.linear_ordered_add_comm_monoid = function.injective.linear_ordered_add_comm_monoid coe nonneg.linear_ordered_add_comm_monoid._proof_3 nonneg.linear_ordered_add_comm_monoid._proof_4 nonneg.linear_ordered_add_comm_monoid._proof_5 nonneg.linear_ordered_add_comm_monoid._proof_6 nonneg.linear_ordered_add_comm_monoid._proof_7 nonneg.linear_ordered_add_comm_monoid._proof_8
Equations
- nonneg.ordered_cancel_add_comm_monoid = function.injective.ordered_cancel_add_comm_monoid coe nonneg.ordered_cancel_add_comm_monoid._proof_3 nonneg.ordered_cancel_add_comm_monoid._proof_4 nonneg.ordered_cancel_add_comm_monoid._proof_5 nonneg.ordered_cancel_add_comm_monoid._proof_6
Equations
- nonneg.linear_ordered_cancel_add_comm_monoid = function.injective.linear_ordered_cancel_add_comm_monoid coe nonneg.linear_ordered_cancel_add_comm_monoid._proof_3 nonneg.linear_ordered_cancel_add_comm_monoid._proof_4 nonneg.linear_ordered_cancel_add_comm_monoid._proof_5 nonneg.linear_ordered_cancel_add_comm_monoid._proof_6 nonneg.linear_ordered_cancel_add_comm_monoid._proof_7 nonneg.linear_ordered_cancel_add_comm_monoid._proof_8
Coercion {x : α // 0 ≤ x} → α
as a add_monoid_hom
.
Equations
- nonneg.coe_add_monoid_hom = {to_fun := coe coe_to_lift, map_zero' := _, map_add' := _}
Equations
- nonneg.has_one = {one := ⟨1, _⟩}
Equations
- nonneg.add_monoid_with_one = {nat_cast := λ (n : ℕ), ⟨↑n, _⟩, add := ordered_add_comm_monoid.add nonneg.ordered_add_comm_monoid, add_assoc := _, zero := ordered_add_comm_monoid.zero nonneg.ordered_add_comm_monoid, zero_add := _, add_zero := _, nsmul := ordered_add_comm_monoid.nsmul nonneg.ordered_add_comm_monoid, nsmul_zero' := _, nsmul_succ' := _, one := 1, nat_cast_zero := _, nat_cast_succ := _}
Equations
- nonneg.ordered_semiring = function.injective.ordered_semiring coe 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
Equations
- nonneg.strict_ordered_semiring = function.injective.strict_ordered_semiring coe 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
Equations
- nonneg.ordered_comm_semiring = function.injective.ordered_comm_semiring coe 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
Equations
- nonneg.strict_ordered_comm_semiring = function.injective.strict_ordered_comm_semiring coe 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
Equations
- nonneg.monoid_with_zero = semiring.to_monoid_with_zero {x // 0 ≤ x}
Equations
Equations
Equations
- nonneg.linear_ordered_semiring = function.injective.linear_ordered_semiring coe 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
Equations
- nonneg.linear_ordered_comm_monoid_with_zero = {le := linear_ordered_semiring.le nonneg.linear_ordered_semiring, lt := linear_ordered_semiring.lt nonneg.linear_ordered_semiring, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_total := _, decidable_le := linear_ordered_semiring.decidable_le nonneg.linear_ordered_semiring, decidable_eq := linear_ordered_semiring.decidable_eq nonneg.linear_ordered_semiring, decidable_lt := linear_ordered_semiring.decidable_lt nonneg.linear_ordered_semiring, max := linear_ordered_semiring.max nonneg.linear_ordered_semiring, max_def := _, min := linear_ordered_semiring.min nonneg.linear_ordered_semiring, min_def := _, mul := linear_ordered_semiring.mul nonneg.linear_ordered_semiring, mul_assoc := _, one := linear_ordered_semiring.one nonneg.linear_ordered_semiring, one_mul := _, mul_one := _, npow := linear_ordered_semiring.npow nonneg.linear_ordered_semiring, npow_zero' := _, npow_succ' := _, mul_comm := _, mul_le_mul_left := _, zero := linear_ordered_semiring.zero nonneg.linear_ordered_semiring, zero_mul := _, mul_zero := _, zero_le_one := _}
Equations
- nonneg.canonically_ordered_add_monoid = {add := ordered_add_comm_monoid.add nonneg.ordered_add_comm_monoid, add_assoc := _, zero := ordered_add_comm_monoid.zero nonneg.ordered_add_comm_monoid, zero_add := _, add_zero := _, nsmul := ordered_add_comm_monoid.nsmul nonneg.ordered_add_comm_monoid, nsmul_zero' := _, nsmul_succ' := _, add_comm := _, le := ordered_add_comm_monoid.le nonneg.ordered_add_comm_monoid, lt := ordered_add_comm_monoid.lt nonneg.ordered_add_comm_monoid, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, add_le_add_left := _, bot := order_bot.bot nonneg.order_bot, bot_le := _, exists_add_of_le := _, le_self_add := _}
Equations
- nonneg.canonically_ordered_comm_semiring = {add := canonically_ordered_add_monoid.add nonneg.canonically_ordered_add_monoid, add_assoc := _, zero := canonically_ordered_add_monoid.zero nonneg.canonically_ordered_add_monoid, zero_add := _, add_zero := _, nsmul := canonically_ordered_add_monoid.nsmul nonneg.canonically_ordered_add_monoid, nsmul_zero' := _, nsmul_succ' := _, add_comm := _, le := canonically_ordered_add_monoid.le nonneg.canonically_ordered_add_monoid, lt := canonically_ordered_add_monoid.lt nonneg.canonically_ordered_add_monoid, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, add_le_add_left := _, bot := canonically_ordered_add_monoid.bot nonneg.canonically_ordered_add_monoid, bot_le := _, exists_add_of_le := _, le_self_add := _, mul := ordered_comm_semiring.mul nonneg.ordered_comm_semiring, left_distrib := _, right_distrib := _, zero_mul := _, mul_zero := _, mul_assoc := _, one := ordered_comm_semiring.one nonneg.ordered_comm_semiring, one_mul := _, mul_one := _, nat_cast := ordered_comm_semiring.nat_cast nonneg.ordered_comm_semiring, nat_cast_zero := _, nat_cast_succ := _, npow := ordered_comm_semiring.npow nonneg.ordered_comm_semiring, npow_zero' := _, npow_succ' := _, mul_comm := _, eq_zero_or_eq_zero_of_mul_eq_zero := _}
Equations
- nonneg.canonically_linear_ordered_add_monoid = {add := canonically_ordered_add_monoid.add nonneg.canonically_ordered_add_monoid, add_assoc := _, zero := canonically_ordered_add_monoid.zero nonneg.canonically_ordered_add_monoid, zero_add := _, add_zero := _, nsmul := canonically_ordered_add_monoid.nsmul nonneg.canonically_ordered_add_monoid, nsmul_zero' := _, nsmul_succ' := _, add_comm := _, le := linear_order.le (subtype.linear_order (λ (x : α), 0 ≤ x)), lt := linear_order.lt (subtype.linear_order (λ (x : α), 0 ≤ x)), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, add_le_add_left := _, bot := canonically_ordered_add_monoid.bot nonneg.canonically_ordered_add_monoid, bot_le := _, exists_add_of_le := _, le_self_add := _, le_total := _, decidable_le := linear_order.decidable_le (subtype.linear_order (λ (x : α), 0 ≤ x)), decidable_eq := linear_order.decidable_eq (subtype.linear_order (λ (x : α), 0 ≤ x)), decidable_lt := linear_order.decidable_lt (subtype.linear_order (λ (x : α), 0 ≤ x)), max := linear_order.max (subtype.linear_order (λ (x : α), 0 ≤ x)), max_def := _, min := linear_order.min (subtype.linear_order (λ (x : α), 0 ≤ x)), min_def := _}
The function a ↦ max a 0
of type α → {x : α // 0 ≤ x}
.
Equations
- nonneg.to_nonneg a = ⟨linear_order.max a 0, _⟩
Equations
- nonneg.has_sub = {sub := λ (x y : {x // 0 ≤ x}), nonneg.to_nonneg (↑x - ↑y)}