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] - chore(algebra/invertible): units coerced to their monoid are invertible #8195

Closed
wants to merge 2 commits into from

Conversation

eric-wieser
Copy link
Member

@eric-wieser eric-wieser commented Jul 5, 2021


Open in Gitpod

@eric-wieser eric-wieser added the awaiting-review The author would like community review of the PR label Jul 5, 2021
Comment on lines 108 to 109
instance units.invertible [monoid α] (u : units α) : invertible (u : α) :=
{ inv_of := ↑(u⁻¹), inv_of_mul_self := u.inv_mul, mul_inv_of_self := u.mul_inv }
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm also a bit wary about coherence issues between this instance and others, especially invertible_of_group. Probably this one + invertible_one are fine since there is a cast in the conclusion. So e.g. we won't see the typeclass system reduce ↑(1 : units ℤ) to 1 : ℤ, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's play it safe, I'll just back out the instances for now

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's put a warning in the "implementation notes" above, so the next people to come across the file will know. I can't make a suggestion there, but how about something like:

Since `invertible a` is not a `Prop` (but it is a `subsingleton`), we have to be careful about coherence issues:
we should avoid having multiple non-defeq instances for `invertible a` in the same context.
This file plays it safe and uses `def` rather than `instance` for most definitions,
users can choose which instances to use at the point of use.

For example, here's how you can use an `invertible 1` instance:
```lean
variables {α : Type*} [monoid α]

def something_that_needs_inverses (x : α) [invertible x] := sorry

section
local attribute [instance] invertible_one
def something_one := something_that_needs_inverses 1
end
```

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 don't fully buy that argument (and looking at the Zulip thread nor really did @digama0), so would prefer not to be responsible for PRing it.

Can you make a new PR adding that text?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Created #8197 👍

Vierkantor added a commit that referenced this pull request Jul 5, 2021
…ances

In the discussion on #8195, I suggested to add these implementation notes.
Creating a new PR should allow for a bit more direct discussion on the use and
plans for `invertible.`
@Vierkantor
Copy link
Collaborator

LGTM!

bors d+

@bors
Copy link

bors bot commented Jul 5, 2021

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

@github-actions github-actions bot added delegated The PR author may merge after reviewing final suggestions. and removed awaiting-review The author would like community review of the PR labels Jul 5, 2021
@eric-wieser
Copy link
Member Author

bors r+

@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 Jul 5, 2021
bors bot pushed a commit that referenced this pull request Jul 5, 2021
@bors
Copy link

bors bot commented Jul 5, 2021

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title chore(algebra/invertible): units coerced to their monoid are invertible [Merged by Bors] - chore(algebra/invertible): units coerced to their monoid are invertible Jul 5, 2021
@bors bors bot closed this Jul 5, 2021
@bors bors bot deleted the eric-wieser/tidy-nonsingular-inverse branch July 5, 2021 13:27
bors bot pushed a commit that referenced this pull request Jul 27, 2021
…ances (#8197)

In the discussion on #8195, I suggested to add these implementation notes. Creating a new PR should allow for a bit more direct discussion on the use of and plans for `invertible`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
delegated The PR author may merge after reviewing final suggestions. 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

2 participants