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 acanonically_linear_ordered_add_monoid
ifα
is alinear_ordered_ring
.{x : α // 0 ≤ x}
is alinear_ordered_comm_group_with_zero
ifα
is alinear_ordered_field
.
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
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 := conditionally_complete_linear_order.max (ord_connected_subset_conditionally_complete_linear_order (set.Ici a)), max_def := _, min := conditionally_complete_linear_order.min (ord_connected_subset_conditionally_complete_linear_order (set.Ici a)), 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 := conditionally_complete_linear_order.max nonneg.conditionally_complete_linear_order, max_def := _, min := conditionally_complete_linear_order.min nonneg.conditionally_complete_linear_order, min_def := _, bot := order_bot.bot nonneg.order_bot, bot_le := _, cSup_empty := _}
Equations
- nonneg.inhabited = {default := ⟨a, _⟩}
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
Equations
- nonneg.linear_ordered_add_comm_monoid = function.injective.linear_ordered_add_comm_monoid coe nonneg.linear_ordered_add_comm_monoid._proof_2 nonneg.linear_ordered_add_comm_monoid._proof_3 nonneg.linear_ordered_add_comm_monoid._proof_4
Equations
- nonneg.ordered_cancel_add_comm_monoid = function.injective.ordered_cancel_add_comm_monoid coe nonneg.ordered_cancel_add_comm_monoid._proof_2 nonneg.ordered_cancel_add_comm_monoid._proof_3 nonneg.ordered_cancel_add_comm_monoid._proof_4
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_2 nonneg.linear_ordered_cancel_add_comm_monoid._proof_3 nonneg.linear_ordered_cancel_add_comm_monoid._proof_4
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.ordered_semiring = function.injective.ordered_semiring coe nonneg.ordered_semiring._proof_2 nonneg.ordered_semiring._proof_3 nonneg.ordered_semiring._proof_4 nonneg.ordered_semiring._proof_5 nonneg.ordered_semiring._proof_6
Equations
- nonneg.ordered_comm_semiring = function.injective.ordered_comm_semiring coe nonneg.ordered_comm_semiring._proof_2 nonneg.ordered_comm_semiring._proof_3 nonneg.ordered_comm_semiring._proof_4 nonneg.ordered_comm_semiring._proof_5 nonneg.ordered_comm_semiring._proof_6
Equations
- nonneg.monoid_with_zero = semiring.to_monoid_with_zero {x // 0 ≤ x}
Equations
- nonneg.linear_ordered_semiring = function.injective.linear_ordered_semiring coe nonneg.linear_ordered_semiring._proof_2 nonneg.linear_ordered_semiring._proof_3 nonneg.linear_ordered_semiring._proof_4 nonneg.linear_ordered_semiring._proof_5 nonneg.linear_ordered_semiring._proof_6
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.linear_ordered_comm_group_with_zero = {le := linear_ordered_comm_monoid_with_zero.le nonneg.linear_ordered_comm_monoid_with_zero, lt := linear_ordered_comm_monoid_with_zero.lt nonneg.linear_ordered_comm_monoid_with_zero, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_total := _, decidable_le := linear_ordered_comm_monoid_with_zero.decidable_le nonneg.linear_ordered_comm_monoid_with_zero, decidable_eq := linear_ordered_comm_monoid_with_zero.decidable_eq nonneg.linear_ordered_comm_monoid_with_zero, decidable_lt := linear_ordered_comm_monoid_with_zero.decidable_lt nonneg.linear_ordered_comm_monoid_with_zero, max := linear_ordered_comm_monoid_with_zero.max nonneg.linear_ordered_comm_monoid_with_zero, max_def := _, min := linear_ordered_comm_monoid_with_zero.min nonneg.linear_ordered_comm_monoid_with_zero, min_def := _, mul := linear_ordered_comm_monoid_with_zero.mul nonneg.linear_ordered_comm_monoid_with_zero, mul_assoc := _, one := linear_ordered_comm_monoid_with_zero.one nonneg.linear_ordered_comm_monoid_with_zero, one_mul := _, mul_one := _, npow := linear_ordered_comm_monoid_with_zero.npow nonneg.linear_ordered_comm_monoid_with_zero, npow_zero' := _, npow_succ' := _, mul_comm := _, mul_le_mul_left := _, zero := linear_ordered_comm_monoid_with_zero.zero nonneg.linear_ordered_comm_monoid_with_zero, zero_mul := _, mul_zero := _, zero_le_one := _, inv := has_inv.inv nonneg.has_inv, div := comm_group_with_zero.div._default linear_ordered_comm_monoid_with_zero.mul nonneg.linear_ordered_comm_group_with_zero._proof_18 linear_ordered_comm_monoid_with_zero.one nonneg.linear_ordered_comm_group_with_zero._proof_19 nonneg.linear_ordered_comm_group_with_zero._proof_20 linear_ordered_comm_monoid_with_zero.npow nonneg.linear_ordered_comm_group_with_zero._proof_21 nonneg.linear_ordered_comm_group_with_zero._proof_22 has_inv.inv, div_eq_mul_inv := _, zpow := comm_group_with_zero.zpow._default linear_ordered_comm_monoid_with_zero.mul nonneg.linear_ordered_comm_group_with_zero._proof_24 linear_ordered_comm_monoid_with_zero.one nonneg.linear_ordered_comm_group_with_zero._proof_25 nonneg.linear_ordered_comm_group_with_zero._proof_26 linear_ordered_comm_monoid_with_zero.npow nonneg.linear_ordered_comm_group_with_zero._proof_27 nonneg.linear_ordered_comm_group_with_zero._proof_28 has_inv.inv, zpow_zero' := _, zpow_succ' := _, zpow_neg' := _, exists_pair_ne := _, inv_zero := _, mul_inv_cancel := _}
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 := _, le_iff_exists_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 := _, le_iff_exists_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 := _, 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 := _, le_iff_exists_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 := max (subtype.linear_order (λ (x : α), 0 ≤ x)), max_def := _, min := 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 = ⟨max a 0, _⟩
Equations
- nonneg.has_sub = {sub := λ (x y : {x // 0 ≤ x}), nonneg.to_nonneg (↑x - ↑y)}