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

[Merged by Bors] - refactor(analysis/asymptotics): make is_o irreducible #2416

Closed
wants to merge 2 commits into from

Conversation

sgouezel
Copy link
Collaborator

is_o is currently not irreducible. Since it is a complicated type, Lean can have trouble checking if two types with is_o are defeq or not, leading to timeouts as described in https://leanprover.zulipchat.com/#narrow/stream/217875-Is-there.20code.20for.20X.3F/topic/undergraduate.20calculus/near/193776607
This PR makes is_o irreducible.

TO CONTRIBUTORS:

Please include a summary of the changes made in this PR above "TO CONTRIBUTORS:", as that text will become the commit message. You are also encouraged to append the following co-authorship template if you'd like to acknowledge suggestions / commits made by other users:

Co-authored-by: name name@example.com

Make sure you have:

If this PR is related to a discussion on Zulip, please include a link in the discussion.

For reviewers: code review check list

If you're confused by comments on your PR like bors r+ or bors d+, please see our notes on bors for information on our merging workflow.

@rwbarton
Copy link
Collaborator

This looks simple enough, but given that is_o is a Prop (and not a function, say), another, "less magical" approach could be to turn it into a structure instead of a def; have you considered this?

@sgouezel
Copy link
Collaborator Author

I don't see the advantage of the structure over the irreducibility. In some situations, Lean might want to see into the structure to see if two is_o things are equal, and then it would face the same problem as before, so it seems to me that irreducibility is safer.

Copy link
Collaborator

@semorrison semorrison left a comment

Choose a reason for hiding this comment

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

LGTM

@PatrickMassot
Copy link
Member

@avigad I think you wrote that definition, do you have any comment?

@avigad
Copy link
Collaborator

avigad commented Apr 14, 2020

It looks good to me. Lean shouldn't be unfolding is_o: everything should depend on the interface for reasoning with it, not the internal definition. So I see no harm in sealing it off.

Copy link
Member

@jcommelin jcommelin left a comment

Choose a reason for hiding this comment

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

LGTM

@gebner
Copy link
Member

gebner commented Apr 14, 2020

In some situations, Lean might want to see into the structure to see if two is_o things are equal, [...]

This is not the case. If is_o is a structure then Lean can't unfold is_o .... at all. This is exactly the same situation as with irreducible.

@sgouezel
Copy link
Collaborator Author

OK, thanks for the clarification. Is there any advantage of a structure over the irreducible attribute, or are they really equivalent? The advantage I can see in not having a structure is that in the whole file developing asymptotics we use a lot the definition of is_o, and we only turn on the attribute at the end of the file.

@rwbarton
Copy link
Collaborator

structure just seems conceptually simpler--for example it means the elaborator and the kernel agree on what things are definitionally equal. Using irreducible seems like more of a hack. I don't have any concrete advantages, though.

@urkud
Copy link
Member

urkud commented Apr 15, 2020

I have two comments.

  1. You make is_O_with and is_o irreducible but is_O is still reducible. Is it intentional?
  2. Could you please add lemmas like is_o.def to unfold definitions without rw? Probably with main versions returning eventually and primed versions returning is_O_with.

@sgouezel
Copy link
Collaborator Author

1 - Yes, it was intentional to leave is_O reducible, as I am under the impression that sigma types create less difficulty for Lean than pi types. Still, as I don't like inconsistencies, I have also made it irreducible.

2 - I have added a few lemmas in the direction you are indicating. Maybe these are not exactly the statements you would like -- I would say this can be changed later, when you play with is_o and is_O and get a feel for what is missing.

@sgouezel sgouezel added the awaiting-review The author would like community review of the PR label Apr 15, 2020
Copy link
Member

@jcommelin jcommelin left a comment

Choose a reason for hiding this comment

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

I agree. Let's just try this out.

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 Apr 16, 2020
bors bot pushed a commit that referenced this pull request Apr 16, 2020
`is_o` is currently not irreducible. Since it is a complicated type, Lean can have trouble checking if two types with `is_o` are defeq or not, leading to timeouts as described in https://leanprover.zulipchat.com/#narrow/stream/217875-Is-there.20code.20for.20X.3F/topic/undergraduate.20calculus/near/193776607
This PR makes `is_o` irreducible.
@bors
Copy link

bors bot commented Apr 16, 2020

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title refactor(analysis/asymptotics): make is_o irreducible [Merged by Bors] - refactor(analysis/asymptotics): make is_o irreducible Apr 16, 2020
@bors bors bot closed this Apr 16, 2020
@bors bors bot deleted the is_o_irreducible branch April 16, 2020 12:26
anrddh pushed a commit to anrddh/mathlib that referenced this pull request May 15, 2020
…munity#2416)

`is_o` is currently not irreducible. Since it is a complicated type, Lean can have trouble checking if two types with `is_o` are defeq or not, leading to timeouts as described in https://leanprover.zulipchat.com/#narrow/stream/217875-Is-there.20code.20for.20X.3F/topic/undergraduate.20calculus/near/193776607
This PR makes `is_o` irreducible.
anrddh pushed a commit to anrddh/mathlib that referenced this pull request May 16, 2020
…munity#2416)

`is_o` is currently not irreducible. Since it is a complicated type, Lean can have trouble checking if two types with `is_o` are defeq or not, leading to timeouts as described in https://leanprover.zulipchat.com/#narrow/stream/217875-Is-there.20code.20for.20X.3F/topic/undergraduate.20calculus/near/193776607
This PR makes `is_o` irreducible.
cipher1024 pushed a commit to cipher1024/mathlib that referenced this pull request Mar 15, 2022
…munity#2416)

`is_o` is currently not irreducible. Since it is a complicated type, Lean can have trouble checking if two types with `is_o` are defeq or not, leading to timeouts as described in https://leanprover.zulipchat.com/#narrow/stream/217875-Is-there.20code.20for.20X.3F/topic/undergraduate.20calculus/near/193776607
This PR makes `is_o` irreducible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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

8 participants