Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: CanonicallyOrderedAddCancelCommMonoid #9307

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions Mathlib/Algebra/Order/Monoid/Canonical/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ theorem le_iff_forall_one_lt_lt_mul' : a ≤ b ↔ ∀ ε, 1 < ε → a < b * ε
end ExistsMulOfLE


/-- A canonically ordered additive monoid is an ordered commutative additive monoid
/-- A canonically ordered additive commutative monoid is an ordered commutative additive monoid
in which the ordering coincides with the subtractibility relation,
which is to say, `a ≤ b` iff there exists `c` with `b = a + c`.
This is satisfied by the natural numbers, for example, but not
Expand All @@ -108,7 +108,7 @@ class CanonicallyOrderedAddCommMonoid (α : Type*) extends OrderedAddCommMonoid
-- see Note [lower instance priority]
attribute [instance 100] CanonicallyOrderedAddCommMonoid.toOrderBot

/-- A canonically ordered monoid is an ordered commutative monoid
/-- A canonically ordered commutative monoid is an ordered commutative monoid
in which the ordering coincides with the divisibility relation,
which is to say, `a ≤ b` iff there exists `c` with `b = a * c`.
Examples seem rare; it seems more likely that the `OrderDual`
Expand Down Expand Up @@ -320,13 +320,24 @@ instance bit0 {M} [CanonicallyOrderedAddCommMonoid M] {x : M} [NeZero x] : NeZer

end NeZero

/-- A canonically linear-ordered additive monoid is a canonically ordered additive monoid
whose ordering is a linear order. -/
/-- A canonically ordered additive cancellative commutative monoid is
a canonically ordered additive commutative monoid in which addition is cancellative. -/
class CanonicallyOrderedAddCancelCommMonoid (α : Type*)
extends CanonicallyOrderedAddCommMonoid α, OrderedCancelAddCommMonoid α

/-- A canonically ordered cancellative commutative monoid is
a canonically ordered commutative monoid in which multiplication is cancellative. -/
@[to_additive]
class CanonicallyOrderedCancelCommMonoid (α : Type*)
extends CanonicallyOrderedCommMonoid α, OrderedCancelCommMonoid α

/-- A canonically linear-ordered additive commutative monoid is
a canonically ordered additive commutative monoid whose ordering is a linear order. -/
class CanonicallyLinearOrderedAddCommMonoid (α : Type*)
extends CanonicallyOrderedAddCommMonoid α, LinearOrderedAddCommMonoid α
#align canonically_linear_ordered_add_monoid CanonicallyLinearOrderedAddCommMonoid

/-- A canonically linear-ordered monoid is a canonically ordered monoid
/-- A canonically linear-ordered commutative monoid is a canonically ordered commutative monoid
whose ordering is a linear order. -/
@[to_additive]
class CanonicallyLinearOrderedCommMonoid (α : Type*)
Expand Down
3 changes: 3 additions & 0 deletions Mathlib/Data/Nat/Order/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ instance canonicallyOrderedCommSemiring : CanonicallyOrderedCommSemiring ℕ :=
instance canonicallyLinearOrderedAddCommMonoid : CanonicallyLinearOrderedAddCommMonoid ℕ :=
{ (inferInstance : CanonicallyOrderedAddCommMonoid ℕ), Nat.linearOrder with }

instance canonicallyOrderedAddCancelCommMonoid : CanonicallyOrderedAddCancelCommMonoid ℕ :=
{ (inferInstance : CanonicallyOrderedAddCommMonoid ℕ), Nat.linearOrderedCommSemiring with }

variable {m n k l : ℕ}

/-! ### Equalities and inequalities involving zero and one -/
Expand Down
4 changes: 4 additions & 0 deletions Mathlib/Data/Rat/NNRat.lean
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ instance [AddCommMonoid α] [DistribMulAction ℚ α] : DistribMulAction ℚ≥0
instance [AddCommMonoid α] [Module ℚ α] : Module ℚ≥0 α :=
Module.compHom α coeHom

instance canonicallyOrderedAddCancelCommMonoid : CanonicallyOrderedAddCancelCommMonoid ℚ≥0 :=
{ (inferInstance : CanonicallyOrderedAddCommMonoid ℚ≥0),
(inferInstance : OrderedCancelAddCommMonoid ℚ≥0) with }

@[simp]
theorem coe_coeHom : ⇑coeHom = ((↑) : ℚ≥0 → ℚ) :=
rfl
Expand Down
4 changes: 4 additions & 0 deletions Mathlib/Data/Real/NNReal.lean
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,10 @@ instance contravariant_add : ContravariantClass ℝ≥0 ℝ≥0 (· + ·) (· <
instance covariant_mul : CovariantClass ℝ≥0 ℝ≥0 (· * ·) (· ≤ ·) := inferInstance
#align nnreal.covariant_mul NNReal.covariant_mul

instance canonicallyOrderedAddCancelCommMonoid : CanonicallyOrderedAddCancelCommMonoid ℝ≥0 :=
{ (inferInstance : CanonicallyOrderedAddCommMonoid ℝ≥0),
(inferInstance : OrderedCancelAddCommMonoid ℝ≥0) with }

-- porting note: TODO: delete?
nonrec theorem le_of_forall_pos_le_add {a b : ℝ≥0} (h : ∀ ε, 0 < ε → a ≤ b + ε) : a ≤ b :=
le_of_forall_pos_le_add h
Expand Down