Skip to content

Commit

Permalink
doc(algebra/invertible): implementation notes about invertible inst…
Browse files Browse the repository at this point in the history
…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`.
  • Loading branch information
Vierkantor committed Jul 27, 2021
1 parent 2ea73d1 commit a052dd6
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/algebra/invertible.lean
Expand Up @@ -33,6 +33,23 @@ If multiplication is associative, `invertible` is a subsingleton anyway.
The `simp` normal form tries to normalize `⅟a` to `a ⁻¹`. Otherwise, it pushes
`⅟` inside the expression as much as possible.
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
```
## Tags
invertible, inverse element, inv_of, a half, one half, a third, one third, ½, ⅓
Expand Down

0 comments on commit a052dd6

Please sign in to comment.