Skip to content

Commit

Permalink
feat(algebra/ordered_monoid): min_*_distrib (#6144)
Browse files Browse the repository at this point in the history
Also provide a `canonically_linear_ordered_add_monoid` instances for `nat`, `nnreal`, `cardinal` and `with_top`.



Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
  • Loading branch information
pechersky and eric-wieser committed Feb 10, 2021
1 parent 3cc398b commit 3fae96c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
20 changes: 20 additions & 0 deletions src/algebra/ordered_monoid.lean
Expand Up @@ -676,6 +676,26 @@ instance canonically_linear_ordered_monoid.semilattice_sup_bot
[canonically_linear_ordered_monoid α] : semilattice_sup_bot α :=
{ ..lattice_of_linear_order, ..canonically_ordered_monoid.to_order_bot α }

instance with_top.canonically_linear_ordered_add_monoid
(α : Type*) [canonically_linear_ordered_add_monoid α] :
canonically_linear_ordered_add_monoid (with_top α) :=
{ .. (infer_instance : canonically_ordered_add_monoid (with_top α)),
.. (infer_instance : linear_order (with_top α)) }

@[to_additive] lemma min_mul_distrib [canonically_linear_ordered_monoid α] (a b c : α) :
min a (b * c) = min a (min a b * min a c) :=
begin
cases le_total a b with hb hb,
{ simp [hb, le_mul_right] },
{ cases le_total a c with hc hc,
{ simp [hc, le_mul_left] },
{ simp [hb, hc] } }
end

@[to_additive] lemma min_mul_distrib' [canonically_linear_ordered_monoid α] (a b c : α) :
min (a * b) c = min (min a c * min b c) c :=
by simpa [min_comm _ c] using min_mul_distrib c a b

end canonically_linear_ordered_monoid

/-- An ordered cancellative additive commutative monoid
Expand Down
4 changes: 4 additions & 0 deletions src/data/nat/basic.lean
Expand Up @@ -94,6 +94,10 @@ instance : canonically_ordered_comm_semiring ℕ :=
.. (infer_instance : linear_ordered_semiring ℕ),
.. (infer_instance : comm_semiring ℕ) }

instance : canonically_linear_ordered_add_monoid ℕ :=
{ .. (infer_instance : canonically_ordered_add_monoid ℕ),
.. nat.linear_order }

instance nat.subtype.semilattice_sup_bot (s : set ℕ) [decidable_pred s] [h : nonempty s] :
semilattice_sup_bot s :=
{ bot := ⟨nat.find (nonempty_subtype.1 h), nat.find_spec (nonempty_subtype.1 h)⟩,
Expand Down
7 changes: 3 additions & 4 deletions src/data/real/nnreal.lean
Expand Up @@ -215,7 +215,7 @@ galois_insertion.monotone_intro nnreal.coe_mono nnreal.of_real_mono
instance : order_bot ℝ≥0 :=
{ bot := ⊥, bot_le := assume ⟨a, h⟩, h, .. nnreal.linear_order }

instance : canonically_ordered_add_monoid ℝ≥0 :=
instance : canonically_linear_ordered_add_monoid ℝ≥0 :=
{ add_le_add_left := assume a b h c, @add_le_add_left ℝ _ a b h c,
lt_of_add_lt_add_left := assume a b c, @lt_of_add_lt_add_left ℝ _ a b c,
le_iff_exists_add := assume ⟨a, ha⟩ ⟨b, hb⟩,
Expand Down Expand Up @@ -246,8 +246,7 @@ instance : linear_ordered_semiring ℝ≥0 :=
mul_lt_mul_of_pos_right := assume a b c, @mul_lt_mul_of_pos_right ℝ _ a b c,
zero_le_one := @zero_le_one ℝ _,
exists_pair_ne := ⟨0, 1, ne_of_lt (@zero_lt_one ℝ _ _)⟩,
.. nnreal.linear_order,
.. nnreal.canonically_ordered_add_monoid,
.. nnreal.canonically_linear_ordered_add_monoid,
.. nnreal.comm_semiring, }

instance : linear_ordered_comm_group_with_zero ℝ≥0 :=
Expand All @@ -257,7 +256,7 @@ instance : linear_ordered_comm_group_with_zero ℝ≥0 :=
.. nnreal.comm_group_with_zero }

instance : canonically_ordered_comm_semiring ℝ≥0 :=
{ .. nnreal.canonically_ordered_add_monoid,
{ .. nnreal.canonically_linear_ordered_add_monoid,
.. nnreal.comm_semiring,
.. (show no_zero_divisors ℝ≥0, by apply_instance),
.. nnreal.comm_group_with_zero }
Expand Down
4 changes: 4 additions & 0 deletions src/set_theory/cardinal.lean
Expand Up @@ -275,6 +275,10 @@ instance : canonically_ordered_comm_semiring cardinal.{u} :=
..cardinal.order_bot,
..cardinal.comm_semiring, ..cardinal.linear_order }

noncomputable instance : canonically_linear_ordered_add_monoid cardinal.{u} :=
{ .. (infer_instance : canonically_ordered_add_monoid cardinal.{u}),
.. cardinal.linear_order }

@[simp] theorem zero_lt_one : (0 : cardinal) < 1 :=
lt_of_le_of_ne (zero_le _) zero_ne_one

Expand Down

0 comments on commit 3fae96c

Please sign in to comment.