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>
14 lines
424 B
Text
14 lines
424 B
Text
[4, 5, 6]
|
|
defInst.lean:8:26-8:32: error(lean.synthInstanceFailed): failed to synthesize instance of type class
|
|
BEq Foo
|
|
|
|
Hint: Adding the command `deriving instance BEq for Foo` may allow Lean to derive the missing instance.
|
|
fun x y => sorry : (x y : Foo) → ?m x y
|
|
[4, 5, 6]
|
|
fun x y => x == y : Foo → Foo → Bool
|
|
[("hello", "hello")]
|
|
false
|
|
true
|
|
true
|
|
@[instance_reducible] def instMonadM : Monad M :=
|
|
ReaderT.instMonad
|