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>
41 lines
1.2 KiB
Text
41 lines
1.2 KiB
Text
opaque q : Nat → Nat
|
|
def f (x : Nat) : Nat :=
|
|
match x with
|
|
| 0 => 1
|
|
| x+1 => q (f x)
|
|
|
|
theorem f_eq : f (x + 1) = q (f x) := rfl
|
|
|
|
/--
|
|
trace: [diag] Diagnostics
|
|
[reduction] unfolded declarations (max: 15, num: 4):
|
|
[reduction] Nat.rec ↦ 15
|
|
[reduction] Add.add ↦ 10
|
|
[reduction] HAdd.hAdd ↦ 10
|
|
[reduction] Nat.add ↦ 10
|
|
[reduction] unfolded reducible declarations (max: 15, num: 1):
|
|
[reduction] Nat.casesOn ↦ 15
|
|
use `set_option diagnostics.threshold <num>` to control threshold for reporting counters
|
|
-/
|
|
#guard_msgs in
|
|
example : f (x + 5) = q (q (q (q (q (f x))))) :=
|
|
set_option diagnostics.threshold 5 in
|
|
set_option diagnostics true in
|
|
rfl
|
|
|
|
/--
|
|
trace: [diag] Diagnostics
|
|
[reduction] unfolded declarations (max: 15, num: 4):
|
|
[reduction] Nat.rec ↦ 15
|
|
[reduction] Add.add ↦ 10
|
|
[reduction] HAdd.hAdd ↦ 10
|
|
[reduction] Nat.add ↦ 10
|
|
[reduction] unfolded reducible declarations (max: 15, num: 1):
|
|
[reduction] Nat.casesOn ↦ 15
|
|
use `set_option diagnostics.threshold <num>` to control threshold for reporting counters
|
|
-/
|
|
#guard_msgs in
|
|
example : f (x + 5) = q (q (q (q (q (f x))))) := by
|
|
set_option diagnostics.threshold 5 in
|
|
set_option diagnostics true in
|
|
rfl
|