Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

[Merged by Bors] - refactor(algebra/ordered_group): multiplicative versions of ordered monoids/groups #2844

Closed
wants to merge 9 commits into from

Conversation

jcommelin
Copy link
Member

This PR defines multiplicative versions of ordered monoids and groups. It also lints the file.

@bryangingechen bryangingechen added the awaiting-review The author would like community review of the PR label May 28, 2020
@bryangingechen bryangingechen changed the title refactor(algebra/ordered_group): multiplicate versions of ordered monoids/groups refactor(algebra/ordered_group): multiplicative versions of ordered monoids/groups May 28, 2020
@semorrison
Copy link
Collaborator

Could you explain what's going on that prevents making the number of primes match up between the additive and multiplicative statements?

@jcommelin
Copy link
Member Author

The reason for the different number of primes for the multiplicative and additive versions is that I didn't want to change any of the existing names in mathlib. So there would be a statement add_le_add for ordered additive monoids, and mul_le_mul for ordered semirings. Now that I've multiplificied ordered additive monoids, the corresponding lemma has to be called something like mul_le_mul'.
See also this thread: https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/mul_le_mul/near/198876550

@jcommelin
Copy link
Member Author

I've also fixed conflicts (hopefully).

Copy link
Member

@kbuzzard kbuzzard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought a bit about balancing 's but maybe it can be done in a second PR? They're easy to spot, it's just everything which is tagged @[to_additive X] rather than @[to_additive]

have a + b ≥ a + 0, from add_le_add_left' h,
by rwa add_zero at this
@[to_additive le_add_of_nonneg_right']
lemma le_mul_of_one_le_right'' (h : 1 ≤ b) : a ≤ a * b :=
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So am I right in thinking that (a) there is no lemma at all called le_mul_of_one_le_right anywhere and (b) there is a lemma called le_mul_of_one_le_right', which is defined in mathlib and used precisely 3 times? So naively one might say that we could rename current le_mul_of_one_le_right' to le_mul_of_one_le_right and then rename this to le_mul_of_one_le_right'?

But actually current le_mul_of_one_le_right'is a lemma about semirings and should arguably be called le_mul_of_nonneg_of_one_le_right.

Edit: I see now I've looked at the rest of the PR that there seem to be too many unbalanced ' issues here for it to be worth fixing them all at once.

have 0 + a ≤ b + a, from add_le_add_right' h,
by rwa zero_add at this
@[to_additive le_add_of_nonneg_left']
lemma le_mul_of_one_le_left'' (h : 1 ≤ b) : a ≤ b * a :=
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no le_mul_of_one_le_left, and the lemma le_mul_of_one_le_left' is defined in src/algebra and then never used at all! Again it's about semirings and could be renamed le_mul_of_nonneg_of_one_le_left. (did we decide that "left" meant "the left one is not the duplicated one"?

(Edit: maybe just don't bother)

lemma add_nonneg' (ha : 0 ≤ a) (hb : 0 ≤ b) : 0 ≤ a + b :=
le_add_of_nonneg_of_le' ha hb
@[to_additive add_nonneg']
lemma one_le_mul' (ha : 1 ≤ a) (hb : 1 ≤ b) : 1 ≤ a * b :=
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't like mul_one_le'?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, I don't (-;

lemma add_pos_of_pos_of_nonneg' (ha : 0 < a) (hb : 0 ≤ b) : 0 < a + b :=
lt_of_lt_of_le ha $ le_add_of_nonneg_right' hb
@[to_additive]
lemma mul_one_lt_of_one_lt_of_one_le' (ha : 1 < a) (hb : 1 ≤ b) : 1 < a * b :=
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're happy with this name (and why not?) then maybe le_mul_of_nonneg_of_one_le_right is OK (above)?

lemma monotone.add (hf : monotone f) (hg : monotone g) : monotone (λ x, f x + g x) :=
λ x y h, add_le_add' (hf h) (hg h)
@[to_additive monotone.add]
lemma monotone.mul' (hf : monotone f) (hg : monotone g) : monotone (λ x, f x * g x) :=
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

monotone.mul is defined and then never used, and could be monotone.mul_of_nonneg

left_cancel_monoid α := { ..‹ordered_cancel_comm_monoid α› }

@[to_additive add_le_add_left]
lemma mul_le_mul_left'' : ∀ {a b : α} (h : a ≤ b) (c : α), c * a ≤ c * b :=
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I am beginning to tire of this :-( I can see the problem now. add_le_add_left is used all over the place, and is a theorem about add comm monoids, and mul_le_mul_left is a theorem about semirings. I'm not sure it's possible to keep the primes matched up without a major amount of hassle for what is basically a small gain.


@[to_additive]
lemma mul_le_mul_three {a b c d e f : α} (h₁ : a ≤ d) (h₂ : b ≤ e) (h₃ : c ≤ f) :
a * b * c ≤ d * e * f :=
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought they liked

le_trans (mul_le_mul'' (mul_le_mul'' h₁ h₂) h₃) $ le_refl _

better?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait -- whatever is le_trans even doing there? mul_le_mul'' (mul_le_mul'' h₁ h₂) h₃?

TODO:
The `add_lt_add_left` field of `ordered_add_comm_group` is redundant,
and it is no longer in core so we can remove it now.
This alternative constructor is the best we could do.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surely ... "is a workaround until someone fixes this"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess change "best we can do" to "best we could do" is not very strong wording (-;

@semorrison
Copy link
Collaborator

@jcommelin, I propose we don't worry about the inconsistent primes, as this is still a step in the right direction, and merge (after resolving conflicts), as is.

@semorrison
Copy link
Collaborator

bors d+

@bors
Copy link

bors bot commented Jun 9, 2020

✌️ jcommelin can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@jcommelin
Copy link
Member Author

bors merge

@github-actions github-actions bot added ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) and removed awaiting-review The author would like community review of the PR labels Jun 9, 2020
bors bot pushed a commit that referenced this pull request Jun 9, 2020
…onoids/groups (#2844)

This PR defines multiplicative versions of ordered monoids and groups. It also lints the file.
@bors
Copy link

bors bot commented Jun 9, 2020

Build failed:

@bryangingechen bryangingechen removed the ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) label Jun 9, 2020
@jcommelin
Copy link
Member Author

sudo

bors merge

@github-actions github-actions bot added the ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) label Jun 9, 2020
bors bot pushed a commit that referenced this pull request Jun 9, 2020
…onoids/groups (#2844)

This PR defines multiplicative versions of ordered monoids and groups. It also lints the file.
@bors
Copy link

bors bot commented Jun 9, 2020

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title refactor(algebra/ordered_group): multiplicative versions of ordered monoids/groups [Merged by Bors] - refactor(algebra/ordered_group): multiplicative versions of ordered monoids/groups Jun 9, 2020
@bors bors bot closed this Jun 9, 2020
@bors bors bot deleted the ordered-monoid branch June 9, 2020 19:04
cipher1024 pushed a commit to cipher1024/mathlib that referenced this pull request Mar 15, 2022
…onoids/groups (leanprover-community#2844)

This PR defines multiplicative versions of ordered monoids and groups. It also lints the file.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants