This PR adds the new transparency setting `@[instance_reducible]`. We
used to check whether a declaration had `instance` reducibility by using
the `isInstance` predicate. However, this was not a robust solution
because:
- We have scoped instances, and `isInstance` returns `true` only if the
scope is active.
- We have auxiliary declarations used to construct instances manually,
such as:
```lean
def lt_wfRel : WellFoundedRelation Nat
```
`isInstance` also returns `false` for this kind of declaration.
In both cases, the declaration may be (or may have been) used to
construct an instance, but `isInstance`
returns `false`. Thus, we claim it is a mistake to check the
reducibility status using `isInstance`.
`isInstance` indicates whether a declaration is available for the type
class resolution mechanism,
not its transparency status.
**We are decoupling whether a declaration is available for type class
resolution from its transparency status.**
**Remak**: We need a update stage0 to complete this feature.
---------
Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
31 lines
2 KiB
Text
31 lines
2 KiB
Text
CommMonoid.mk.{u} {α : Type u} [toMonoid : Monoid.{u} α]
|
||
(mul_comm :
|
||
∀ (a b : α),
|
||
@Eq.{u + 1} α
|
||
(@HMul.hMul.{u, u, u} α α α (@instHMul.{u} α (@Semigroup.toMul.{u} α (@Monoid.toSemigroup.{u} α toMonoid))) a b)
|
||
(@HMul.hMul.{u, u, u} α α α (@instHMul.{u} α (@Semigroup.toMul.{u} α (@Monoid.toSemigroup.{u} α toMonoid))) b
|
||
a)) :
|
||
CommMonoid.{u} α
|
||
@[instance_reducible] def CommMonoid.toCommSemigroup.{u} : {α : Type u} →
|
||
[self : CommMonoid.{u} α] → CommSemigroup.{u} α :=
|
||
fun (α : Type u) (self : CommMonoid.{u} α) =>
|
||
@CommSemigroup.mk.{u} α (@Monoid.toSemigroup.{u} α (@CommMonoid.toMonoid.{u} α self))
|
||
(@CommMonoid.mul_comm.{u} α self)
|
||
CommGroup.mk.{u} {α : Type u} [toGroup : Group.{u} α]
|
||
(mul_comm :
|
||
∀ (a b : α),
|
||
@Eq.{u + 1} α
|
||
(@HMul.hMul.{u, u, u} α α α
|
||
(@instHMul.{u} α (@Semigroup.toMul.{u} α (@Monoid.toSemigroup.{u} α (@Group.toMonoid.{u} α toGroup)))) a b)
|
||
(@HMul.hMul.{u, u, u} α α α
|
||
(@instHMul.{u} α (@Semigroup.toMul.{u} α (@Monoid.toSemigroup.{u} α (@Group.toMonoid.{u} α toGroup)))) b a)) :
|
||
CommGroup.{u} α
|
||
@[instance_reducible] def CommGroup.toCommMonoid.{u} : {α : Type u} → [self : CommGroup.{u} α] → CommMonoid.{u} α :=
|
||
fun (α : Type u) (self : CommGroup.{u} α) =>
|
||
@CommMonoid.mk.{u} α (@Group.toMonoid.{u} α (@CommGroup.toGroup.{u} α self)) (@CommGroup.mul_comm.{u} α self)
|
||
Field.mk.{u} {α : Type u} [toDivisionRing : DivisionRing α] (mul_comm : ∀ (a b : α), a * b = b * a) : Field α
|
||
@[instance_reducible] def Field.toDivisionRing.{u} : {α : Type u} → [self : Field.{u} α] → DivisionRing.{u} α :=
|
||
fun (α : Type u) [self : Field.{u} α] => self.1
|
||
@[instance_reducible] def Field.toCommRing.{u} : {α : Type u} → [self : Field.{u} α] → CommRing.{u} α :=
|
||
fun (α : Type u) (self : Field.{u} α) =>
|
||
@CommRing.mk.{u} α (@DivisionRing.toRing.{u} α (@Field.toDivisionRing.{u} α self)) (@Field.mul_comm.{u} α self)
|