mathlib icon indicating copy to clipboard operation
mathlib copied to clipboard

refactor(algebra/order/floor): Relax lemmas to remove `linear_order` requirement

Open linesthatinterlace opened this issue 3 years ago • 13 comments

There is a TODO in algebra/order/floor.lean which notes that many lemmas do not require the linearly ordered part of their hypothesis and these could be relaxed. This commit actions this TODO.


Reviewers should make sure:

  • No lemmas have disappeared in this refactor.
  • There are no lemmas that could be loosened, but haven't been.

Open in Gitpod

linesthatinterlace avatar Sep 02 '22 13:09 linesthatinterlace

Note that I haven't changed any proofs unless strictly necessary - in one place (floor_mono') I have added a lemma where there was an obvious loosening of both conclusion and hypothesis. There may be others like this. There may also be lemmas which are true under looser hypotheses, but whose proofs currently use stronger lemmas than necessary. These are difficult to find, and important to spot if we can find any: I cannot.

linesthatinterlace avatar Sep 02 '22 13:09 linesthatinterlace

Cool - I wonder if some sort of poll is appropriate to get a sense of community opinion on this? I can see both cases.

linesthatinterlace avatar Sep 05 '22 07:09 linesthatinterlace

In my opinion, the work is done, let's merge it, but let's remove the todo so that extra work isn't done. (I'm still not convinced that the work is unnecesary, but anyways...). Generalising always is a benefit when formalising, in my experience, regardless of the mathematicality and the usefulness of it. You can do a poll in the zulip.

ericrbg avatar Sep 05 '22 12:09 ericrbg

This PR actually does remove the TODO already, @ericrbg!

linesthatinterlace avatar Sep 05 '22 12:09 linesthatinterlace

@YaelDillies Do I understand correctly from Zulip that you are no long opposed to this PR?

jcommelin avatar Sep 19 '22 10:09 jcommelin

My understanding is that @YaelDillies wants to actually see the example that was cited - but there's no reason it has to be Yael who gives the OK here; that's why I asked for a vote. I thought the outcome of that was that people were happy to see it added.

linesthatinterlace avatar Sep 19 '22 11:09 linesthatinterlace

I am not opposed anymore, but I still want to see that prod.floor_ring instance, be it on this PR or on a branch depending on #16172. I just want to make sure the example actually works.

YaelDillies avatar Sep 19 '22 11:09 YaelDillies

I will note that we only have one instance of floor_semiring currently, which feels... off.

linesthatinterlace avatar Oct 11 '22 13:10 linesthatinterlace

nnrat was added recently and it is a floor_semiring (even though I forgot to prove it). But even without that the docs say we have four instances.

YaelDillies avatar Oct 11 '22 13:10 YaelDillies

Oh yes, sorry. I wasn't counting the two in the floor.lean file itself because I'd already fixed them! nnrat is derivable like nnreal from the nonneg instance so I'll just slip that in while I'm here.

linesthatinterlace avatar Oct 11 '22 13:10 linesthatinterlace

If you think that's best.

On Wed, 12 Oct 2022, 07:04 Yaël Dillies, @.***> wrote:

@.**** commented on this pull request.

In counterexamples/map_floor.lean https://github.com/leanprover-community/mathlib/pull/16352#discussion_r993029923 :

  • rw [←neg_lt_neg_iff, ←map_neg, ←cast_neg, ←floor_neg_eq_neg_ceil, ←floor_neg_eq_neg_ceil,
  • ←map_neg, neg_add', ←cast_neg],

Can you rename your floor_neg/floor_neg' to floor_neg_iff and revert that name change?

— Reply to this email directly, view it on GitHub https://github.com/leanprover-community/mathlib/pull/16352#discussion_r993029923, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIDTA6CQCWTS4DMHAIUDI7LWCZIGXANCNFSM6AAAAAAQDJJPAQ . You are receiving this because you authored the thread.Message ID: @.***>

linesthatinterlace avatar Oct 12 '22 06:10 linesthatinterlace

Can you think of a better name for floor_of_not_nonneg?

linesthatinterlace avatar Oct 12 '22 08:10 linesthatinterlace

Added some more generalisations. I feel like ceil_add_nat should be able to be proved without the linearity, but I cannot see how.

linesthatinterlace avatar Oct 12 '22 09:10 linesthatinterlace

Sorry, I've not had the time to work on this as much. Mistake I think.

On Wed, 19 Oct 2022, 16:44 Yaël Dillies, @.***> wrote:

@.**** commented on this pull request.

In counterexamples/map_floor.lean https://github.com/leanprover-community/mathlib/pull/16352#discussion_r999643033 :

  • rw [←neg_lt_neg_iff, ←map_neg, ←cast_neg, ←floor_neg_eq_neg_ceil, ←floor_neg_eq_neg_ceil,
  • ←map_neg, neg_add', ←cast_neg],

It still hasn't disappeared from the diff.

— Reply to this email directly, view it on GitHub https://github.com/leanprover-community/mathlib/pull/16352#discussion_r999643033, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIDTA6AEQKLQ2OO534SHTDTWEAJOPANCNFSM6AAAAAAQDJJPAQ . You are receiving this because you authored the thread.Message ID: @.***>

linesthatinterlace avatar Oct 19 '22 15:10 linesthatinterlace

I have a bunch of improvements to this PR that rely on char_zero lemmas being available for strict_ordered_semirings, so I will change strict_ordered_semiring to extend nontrivial to turn strict_ordered_semiring.to_char_zero into an instance.

YaelDillies avatar Nov 02 '22 17:11 YaelDillies

This PR/issue depends on:

This PR/issue depends on:

  • ~~leanprover-community/mathlib#17394~~ By Dependent Issues (🤖). Happy coding!

Shall I abandon this?

linesthatinterlace avatar Apr 13 '23 14:04 linesthatinterlace

It is sadly way under the tide, so I think it'd be better to wait after the port, especially given that nothing urgently depends on it.

YaelDillies avatar Apr 13 '23 20:04 YaelDillies

I don't see any reason to keep this open now.

linesthatinterlace avatar Aug 27 '23 03:08 linesthatinterlace